1 /* 2 * Copyright (C) 2021 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 NR network VoPS support 32 * @hide 33 */ 34 @SystemApi 35 public final class NrVopsSupportInfo extends VopsSupportInfo { 36 37 /** 38 * Indicates network does not support vops 39 */ 40 public static final int NR_STATUS_VOPS_NOT_SUPPORTED = 0; 41 42 /** 43 * Indicates network supports vops over 3gpp access. 44 */ 45 public static final int NR_STATUS_VOPS_3GPP_SUPPORTED = 1; 46 47 /** 48 * Indicates network supports vops over non 3gpp access 49 */ 50 public static final int NR_STATUS_VOPS_NON_3GPP_SUPPORTED = 2; 51 52 /**@hide*/ 53 @Retention(RetentionPolicy.SOURCE) 54 @IntDef( 55 prefix = {"NR_STATUS_VOPS_"}, 56 value = { 57 NR_STATUS_VOPS_NOT_SUPPORTED, 58 NR_STATUS_VOPS_3GPP_SUPPORTED, 59 NR_STATUS_VOPS_NON_3GPP_SUPPORTED 60 }) 61 public @interface NrVopsStatus {} 62 63 /** 64 * Indicates network does not support emergency service 65 */ 66 public static final int NR_STATUS_EMC_NOT_SUPPORTED = 0; 67 68 /** 69 * Indicates network supports emergency service in NR connected to 5GCN only 70 */ 71 public static final int NR_STATUS_EMC_5GCN_ONLY = 1; 72 73 /** 74 * Indicates network supports emergency service in E-UTRA connected to 5GCN only 75 */ 76 public static final int NR_STATUS_EMC_EUTRA_5GCN_ONLY = 2; 77 78 /** 79 * Indicates network supports emergency service in NR connected to 5GCN and 80 * E-UTRA connected to 5GCN 81 */ 82 public static final int NR_STATUS_EMC_NR_EUTRA_5GCN = 3; 83 84 /**@hide*/ 85 @Retention(RetentionPolicy.SOURCE) 86 @IntDef( 87 prefix = {"NR_STATUS_EMC_"}, 88 value = { 89 NR_STATUS_EMC_NOT_SUPPORTED, 90 NR_STATUS_EMC_5GCN_ONLY, 91 NR_STATUS_EMC_EUTRA_5GCN_ONLY, 92 NR_STATUS_EMC_NR_EUTRA_5GCN 93 }) 94 public @interface NrEmcStatus {} 95 96 /** 97 * Indicates network does not support emergency service 98 */ 99 public static final int NR_STATUS_EMF_NOT_SUPPORTED = 0; 100 101 /** 102 * Indicates network supports emergency service fallback in NR connected to 5GCN only 103 */ 104 public static final int NR_STATUS_EMF_5GCN_ONLY = 1; 105 106 /** 107 * Indicates network supports emergency service fallback in E-UTRA connected to 5GCN only 108 */ 109 public static final int NR_STATUS_EMF_EUTRA_5GCN_ONLY = 2; 110 111 /** 112 * Indicates network supports emergency service fallback in NR connected to 5GCN 113 * and E-UTRA connected to 5GCN 114 */ 115 public static final int NR_STATUS_EMF_NR_EUTRA_5GCN = 3; 116 117 /**@hide*/ 118 @Retention(RetentionPolicy.SOURCE) 119 @IntDef( 120 prefix = {"NR_STATUS_EMF_"}, 121 value = { 122 NR_STATUS_EMF_NOT_SUPPORTED, 123 NR_STATUS_EMF_5GCN_ONLY, 124 NR_STATUS_EMF_EUTRA_5GCN_ONLY, 125 NR_STATUS_EMF_NR_EUTRA_5GCN 126 }) 127 public @interface NrEmfStatus {} 128 129 @NrVopsStatus 130 private final int mVopsSupport; 131 @NrEmcStatus 132 private final int mEmcSupport; 133 @NrEmfStatus 134 private final int mEmfSupport; 135 NrVopsSupportInfo(@rVopsStatus int vops, @NrEmcStatus int emc, @NrEmcStatus int emf)136 public NrVopsSupportInfo(@NrVopsStatus int vops, @NrEmcStatus int emc, @NrEmcStatus int emf) { 137 mVopsSupport = vops; 138 mEmcSupport = emc; 139 mEmfSupport = emf; 140 } 141 142 /** 143 * Provides the NR VoPS support capability as described in: 144 * 3GPP 24.501 EPS network feature support -> IMS VoPS 145 */ getVopsSupport()146 public @NrVopsStatus int getVopsSupport() { 147 return mVopsSupport; 148 } 149 150 /** 151 * Provides the NR Emergency bearer support capability as described in: 152 * 3GPP 24.501 EPS network feature support -> EMC, and 153 * 38.331 SIB1 : ims-EmergencySupport 154 */ getEmcSupport()155 public @NrEmcStatus int getEmcSupport() { 156 return mEmcSupport; 157 } 158 159 /** 160 * Provides the NR emergency service fallback support capability as 161 * described in 3GPP 24.501 EPS network feature support -> EMF 162 */ getEmfSupport()163 public @NrEmfStatus int getEmfSupport() { 164 return mEmfSupport; 165 } 166 167 /** 168 * Returns whether VoPS is supported by the network 169 */ 170 @Override isVopsSupported()171 public boolean isVopsSupported() { 172 return mVopsSupport != NR_STATUS_VOPS_NOT_SUPPORTED; 173 } 174 175 /** 176 * Returns whether emergency service is supported by the network 177 */ 178 @Override isEmergencyServiceSupported()179 public boolean isEmergencyServiceSupported() { 180 return mEmcSupport != NR_STATUS_EMC_NOT_SUPPORTED; 181 } 182 183 /** 184 * Returns whether emergency service fallback is supported by the network 185 */ isEmergencyServiceFallbackSupported()186 public boolean isEmergencyServiceFallbackSupported() { 187 return mEmfSupport != NR_STATUS_EMF_NOT_SUPPORTED; 188 } 189 190 /** 191 * Implement the Parcelable interface 192 */ 193 @Override describeContents()194 public int describeContents() { 195 return 0; 196 } 197 198 @Override writeToParcel(@onNull Parcel out, int flags)199 public void writeToParcel(@NonNull Parcel out, int flags) { 200 super.writeToParcel(out, flags, AccessNetworkType.NGRAN); 201 out.writeInt(mVopsSupport); 202 out.writeInt(mEmcSupport); 203 out.writeInt(mEmfSupport); 204 } 205 206 @Override equals(@ullable Object o)207 public boolean equals(@Nullable Object o) { 208 if (o == null || !(o instanceof NrVopsSupportInfo)) { 209 return false; 210 } 211 if (this == o) return true; 212 NrVopsSupportInfo other = (NrVopsSupportInfo) o; 213 return mVopsSupport == other.mVopsSupport 214 && mEmcSupport == other.mEmcSupport 215 && mEmfSupport == other.mEmfSupport; 216 } 217 218 @Override hashCode()219 public int hashCode() { 220 return Objects.hash(mVopsSupport, mEmcSupport, mEmfSupport); 221 } 222 223 /** 224 * @return string representation. 225 */ 226 @NonNull 227 @Override toString()228 public String toString() { 229 return ("NrVopsSupportInfo : " 230 + " mVopsSupport = " + mVopsSupport 231 + " mEmcSupport = " + mEmcSupport 232 + " mEmfSupport = " + mEmfSupport); 233 } 234 235 public static final @android.annotation.NonNull Creator<NrVopsSupportInfo> CREATOR = 236 new Creator<NrVopsSupportInfo>() { 237 @Override 238 public NrVopsSupportInfo createFromParcel(Parcel in) { 239 // Skip the type info. 240 in.readInt(); 241 return new NrVopsSupportInfo(in); 242 } 243 244 @Override 245 public NrVopsSupportInfo[] newArray(int size) { 246 return new NrVopsSupportInfo[size]; 247 } 248 }; 249 250 /** @hide */ createFromParcelBody(Parcel in)251 protected static NrVopsSupportInfo createFromParcelBody(Parcel in) { 252 return new NrVopsSupportInfo(in); 253 } 254 NrVopsSupportInfo(Parcel in)255 private NrVopsSupportInfo(Parcel in) { 256 mVopsSupport = in.readInt(); 257 mEmcSupport = in.readInt(); 258 mEmfSupport = in.readInt(); 259 } 260 } 261