1 /* 2 * Copyright (C) 2018 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package android.telephony; 18 19 import android.annotation.IntDef; 20 import android.annotation.NonNull; 21 import android.annotation.Nullable; 22 import android.annotation.SystemApi; 23 import android.os.Parcel; 24 import android.telephony.AccessNetworkConstants.AccessNetworkType; 25 26 import java.lang.annotation.Retention; 27 import java.lang.annotation.RetentionPolicy; 28 import java.util.Objects; 29 30 /** 31 * Class stores information related to LTE network VoPS support 32 * @hide 33 */ 34 @SystemApi 35 public final class LteVopsSupportInfo extends VopsSupportInfo { 36 37 /**@hide*/ 38 @Retention(RetentionPolicy.SOURCE) 39 @IntDef( 40 value = {LTE_STATUS_NOT_AVAILABLE, LTE_STATUS_SUPPORTED, 41 LTE_STATUS_NOT_SUPPORTED}, prefix = "LTE_STATUS_") 42 public @interface LteVopsStatus {} 43 /** 44 * Indicates information not available from modem. 45 * 46 * @deprecated as no instance will be created in this case 47 */ 48 @Deprecated 49 public static final int LTE_STATUS_NOT_AVAILABLE = 1; 50 51 /** 52 * Indicates network support the feature. 53 */ 54 public static final int LTE_STATUS_SUPPORTED = 2; 55 56 /** 57 * Indicates network does not support the feature. 58 */ 59 public static final int LTE_STATUS_NOT_SUPPORTED = 3; 60 61 @LteVopsStatus 62 private final int mVopsSupport; 63 @LteVopsStatus 64 private final int mEmcBearerSupport; 65 LteVopsSupportInfo(@teVopsStatus int vops, @LteVopsStatus int emergency)66 public LteVopsSupportInfo(@LteVopsStatus int vops, @LteVopsStatus int emergency) { 67 mVopsSupport = vops; 68 mEmcBearerSupport = emergency; 69 } 70 71 /** 72 * Provides the LTE VoPS support capability as described in: 73 * 3GPP 24.301 EPS network feature support -> IMS VoPS 74 */ getVopsSupport()75 public @LteVopsStatus int getVopsSupport() { 76 return mVopsSupport; 77 } 78 79 /** 80 * Provides the LTE Emergency bearer support capability as described in: 81 * 3GPP 24.301 EPS network feature support -> EMC BS 82 * 25.331 LTE RRC SIB1 : ims-EmergencySupport-r9 83 */ getEmcBearerSupport()84 public @LteVopsStatus int getEmcBearerSupport() { 85 return mEmcBearerSupport; 86 } 87 88 /** 89 * Returns whether VoPS is supported by the network 90 */ 91 @Override isVopsSupported()92 public boolean isVopsSupported() { 93 return mVopsSupport == LTE_STATUS_SUPPORTED; 94 } 95 96 /** 97 * Returns whether emergency service is supported by the network 98 */ 99 @Override isEmergencyServiceSupported()100 public boolean isEmergencyServiceSupported() { 101 return mEmcBearerSupport == LTE_STATUS_SUPPORTED; 102 } 103 104 /** 105 * Returns whether emergency service fallback is supported by the network 106 */ 107 @Override isEmergencyServiceFallbackSupported()108 public boolean isEmergencyServiceFallbackSupported() { 109 return false; 110 } 111 112 @Override describeContents()113 public int describeContents() { 114 return 0; 115 } 116 117 @Override writeToParcel(@onNull Parcel out, int flags)118 public void writeToParcel(@NonNull Parcel out, int flags) { 119 super.writeToParcel(out, flags, AccessNetworkType.EUTRAN); 120 out.writeInt(mVopsSupport); 121 out.writeInt(mEmcBearerSupport); 122 } 123 124 @Override equals(@ullable Object o)125 public boolean equals(@Nullable Object o) { 126 if (o == null || !(o instanceof LteVopsSupportInfo)) { 127 return false; 128 } 129 if (this == o) return true; 130 LteVopsSupportInfo other = (LteVopsSupportInfo) o; 131 return mVopsSupport == other.mVopsSupport 132 && mEmcBearerSupport == other.mEmcBearerSupport; 133 } 134 135 @Override hashCode()136 public int hashCode() { 137 return Objects.hash(mVopsSupport, mEmcBearerSupport); 138 } 139 140 /** 141 * @return string representation. 142 */ 143 @NonNull 144 @Override toString()145 public String toString() { 146 return ("LteVopsSupportInfo : " 147 + " mVopsSupport = " + mVopsSupport 148 + " mEmcBearerSupport = " + mEmcBearerSupport); 149 } 150 151 public static final @android.annotation.NonNull Creator<LteVopsSupportInfo> CREATOR = 152 new Creator<LteVopsSupportInfo>() { 153 @Override 154 public LteVopsSupportInfo createFromParcel(Parcel in) { 155 // Skip the type info. 156 in.readInt(); 157 return new LteVopsSupportInfo(in); 158 } 159 160 @Override 161 public LteVopsSupportInfo[] newArray(int size) { 162 return new LteVopsSupportInfo[size]; 163 } 164 }; 165 166 /** @hide */ createFromParcelBody(Parcel in)167 protected static LteVopsSupportInfo createFromParcelBody(Parcel in) { 168 return new LteVopsSupportInfo(in); 169 } 170 LteVopsSupportInfo(Parcel in)171 private LteVopsSupportInfo(Parcel in) { 172 mVopsSupport = in.readInt(); 173 mEmcBearerSupport = in.readInt(); 174 } 175 } 176