From 5e6e983cadb9c69fac91e0210308b4b62c1def7b Mon Sep 17 00:00:00 2001 From: Nathan Harold Date: Tue, 17 Dec 2019 13:06:54 -0800 Subject: [PATCH] Add Callback for Registration Failure Add a callback to PhoneStateListener to indicate that a registration procedure has failed. Bug: 143187047 Test: make update-api && make Change-Id: I4a4ba4479dfd465a9d8063135f3b4bf4e1323e99 --- api/current.txt | 2 + api/system-current.txt | 3 + api/test-current.txt | 2 + .../android/telephony/PhoneStateListener.java | 59 +++++++++++++++++++ .../telephony/TelephonyRegistryManager.java | 34 ++++++++++- .../telephony/IPhoneStateListener.aidl | 2 + .../telephony/ITelephonyRegistry.aidl | 2 + .../com/android/server/TelephonyRegistry.java | 42 ++++++++++++- .../java/android/telephony/CellIdentity.java | 27 +++++++++ .../android/telephony/CellIdentityCdma.java | 3 +- .../android/telephony/CellIdentityGsm.java | 3 +- .../android/telephony/CellIdentityLte.java | 3 +- .../android/telephony/CellIdentityNr.java | 3 +- .../telephony/CellIdentityTdscdma.java | 3 +- .../android/telephony/CellIdentityWcdma.java | 3 +- .../telephony/NetworkRegistrationInfo.java | 24 ++++++-- .../java/android/telephony/ServiceState.java | 5 +- .../internal/telephony/RILConstants.java | 1 + 18 files changed, 203 insertions(+), 18 deletions(-) diff --git a/api/current.txt b/api/current.txt index c734db5196a90..bb77536a4da56 100644 --- a/api/current.txt +++ b/api/current.txt @@ -45542,6 +45542,7 @@ package android.telephony { method @RequiresPermission("android.permission.READ_PRECISE_PHONE_STATE") public void onImsCallDisconnectCauseChanged(@NonNull android.telephony.ims.ImsReasonInfo); method public void onMessageWaitingIndicatorChanged(boolean); method @RequiresPermission("android.permission.MODIFY_PHONE_STATE") public void onPreciseDataConnectionStateChanged(@NonNull android.telephony.PreciseDataConnectionState); + method public void onRegistrationFailed(@NonNull android.telephony.CellIdentity, @NonNull String, int, int, int); method public void onServiceStateChanged(android.telephony.ServiceState); method @Deprecated public void onSignalStrengthChanged(int); method public void onSignalStrengthsChanged(android.telephony.SignalStrength); @@ -45559,6 +45560,7 @@ package android.telephony { field public static final int LISTEN_MESSAGE_WAITING_INDICATOR = 4; // 0x4 field public static final int LISTEN_NONE = 0; // 0x0 field @RequiresPermission("android.permission.MODIFY_PHONE_STATE") public static final int LISTEN_PRECISE_DATA_CONNECTION_STATE = 4096; // 0x1000 + field @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public static final int LISTEN_REGISTRATION_FAILURE = 1073741824; // 0x40000000 field public static final int LISTEN_SERVICE_STATE = 1; // 0x1 field @Deprecated public static final int LISTEN_SIGNAL_STRENGTH = 2; // 0x2 field public static final int LISTEN_SIGNAL_STRENGTHS = 256; // 0x100 diff --git a/api/system-current.txt b/api/system-current.txt index 6e05db9d2d2e3..be832f60a540e 100755 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -9539,7 +9539,9 @@ package android.telephony { method public void writeToParcel(android.os.Parcel, int); field @NonNull public static final android.os.Parcelable.Creator CREATOR; field public static final int DOMAIN_CS = 1; // 0x1 + field public static final int DOMAIN_CS_PS = 3; // 0x3 field public static final int DOMAIN_PS = 2; // 0x2 + field public static final int DOMAIN_UNKNOWN = 0; // 0x0 field public static final int REGISTRATION_STATE_DENIED = 3; // 0x3 field public static final int REGISTRATION_STATE_HOME = 1; // 0x1 field public static final int REGISTRATION_STATE_NOT_REGISTERED_OR_SEARCHING = 0; // 0x0 @@ -10156,6 +10158,7 @@ package android.telephony { method public void addOnSubscriptionsChangedListener(@NonNull android.telephony.SubscriptionManager.OnSubscriptionsChangedListener, @NonNull java.util.concurrent.Executor); method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void notifyCallStateChangedForAllSubscriptions(int, @Nullable String); method public void notifyCarrierNetworkChange(boolean); + method public void notifyRegistrationFailed(int, int, @NonNull android.telephony.CellIdentity, @NonNull String, int, int, int); method public void removeOnOpportunisticSubscriptionsChangedListener(@NonNull android.telephony.SubscriptionManager.OnOpportunisticSubscriptionsChangedListener); method public void removeOnSubscriptionsChangedListener(@NonNull android.telephony.SubscriptionManager.OnSubscriptionsChangedListener); } diff --git a/api/test-current.txt b/api/test-current.txt index e7153e61647ff..6bda2266084de 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -3170,7 +3170,9 @@ package android.telephony { method public void writeToParcel(android.os.Parcel, int); field @NonNull public static final android.os.Parcelable.Creator CREATOR; field public static final int DOMAIN_CS = 1; // 0x1 + field public static final int DOMAIN_CS_PS = 3; // 0x3 field public static final int DOMAIN_PS = 2; // 0x2 + field public static final int DOMAIN_UNKNOWN = 0; // 0x0 field public static final int REGISTRATION_STATE_DENIED = 3; // 0x3 field public static final int REGISTRATION_STATE_HOME = 1; // 0x1 field public static final int REGISTRATION_STATE_NOT_REGISTERED_OR_SEARCHING = 0; // 0x0 diff --git a/core/java/android/telephony/PhoneStateListener.java b/core/java/android/telephony/PhoneStateListener.java index 7841f991c4bc0..6a2a31b3ed7b4 100644 --- a/core/java/android/telephony/PhoneStateListener.java +++ b/core/java/android/telephony/PhoneStateListener.java @@ -369,6 +369,21 @@ public class PhoneStateListener { @RequiresPermission(Manifest.permission.READ_ACTIVE_EMERGENCY_SESSION) public static final int LISTEN_OUTGOING_EMERGENCY_SMS = 0x20000000; + /** + * Listen for Registration Failures. + * + * Listen for indications that a registration procedure has failed in either the CS or PS + * domain. This indication does not necessarily indicate a change of service state, which should + * be tracked via {@link #LISTEN_SERVICE_STATE}. + * + *

Requires permission {@link android.Manifest.permission#READ_PHONE_STATE} or the calling + * app has carrier privileges (see {@link TelephonyManager#hasCarrierPrivileges}). + * + * @see #onRegistrationFailed() + */ + @RequiresPermission(Manifest.permission.READ_PHONE_STATE) + public static final int LISTEN_REGISTRATION_FAILURE = 0x40000000; + /* * Subscription used to listen to the phone state changes * @hide @@ -931,6 +946,38 @@ public class PhoneStateListener { // default implementation empty } + /** + * Report that Registration or a Location/Routing/Tracking Area update has failed. + * + *

Indicate whenever a registration procedure, including a location, routing, or tracking + * area update fails. This includes procedures that do not necessarily result in a change of + * the modem's registration status. If the modem's registration status changes, that is + * reflected in the onNetworkStateChanged() and subsequent get{Voice/Data}RegistrationState(). + * + *

Because registration failures are ephemeral, this callback is not sticky. + * Registrants will not receive the most recent past value when registering. + * + * @param cellIdentity the CellIdentity, which must include the globally unique identifier + * for the cell (for example, all components of the CGI or ECGI). + * @param chosenPlmn a 5 or 6 digit alphanumeric PLMN (MCC|MNC) among those broadcast by the + * cell that was chosen for the failed registration attempt. + * @param domain DOMAIN_CS, DOMAIN_PS or both in case of a combined procedure. + * @param causeCode the primary failure cause code of the procedure. + * For GSM/UMTS (MM), values are in TS 24.008 Sec 10.5.95 + * For GSM/UMTS (GMM), values are in TS 24.008 Sec 10.5.147 + * For LTE (EMM), cause codes are TS 24.301 Sec 9.9.3.9 + * For NR (5GMM), cause codes are TS 24.501 Sec 9.11.3.2 + * Integer.MAX_VALUE if this value is unused. + * @param additionalCauseCode the cause code of any secondary/combined procedure if appropriate. + * For UMTS, if a combined attach succeeds for PS only, then the GMM cause code shall be + * included as an additionalCauseCode. For LTE (ESM), cause codes are in + * TS 24.301 9.9.4.4. Integer.MAX_VALUE if this value is unused. + */ + public void onRegistrationFailed(@NonNull CellIdentity cellIdentity, @NonNull String chosenPlmn, + @NetworkRegistrationInfo.Domain int domain, int causeCode, int additionalCauseCode) { + // default implementation empty + } + /** * The callback methods need to be called on the handler thread where * this object was created. If the binder did that for us it'd be nice. @@ -1203,6 +1250,18 @@ public class PhoneStateListener { () -> psl.onImsCallDisconnectCauseChanged(disconnectCause))); } + + public void onRegistrationFailed(@NonNull CellIdentity cellIdentity, + @NonNull String chosenPlmn, @NetworkRegistrationInfo.Domain int domain, + int causeCode, int additionalCauseCode) { + PhoneStateListener psl = mPhoneStateListenerWeakRef.get(); + if (psl == null) return; + + Binder.withCleanCallingIdentity( + () -> mExecutor.execute(() -> psl.onRegistrationFailed( + cellIdentity, chosenPlmn, domain, causeCode, additionalCauseCode))); + // default implementation empty + } } diff --git a/core/java/android/telephony/TelephonyRegistryManager.java b/core/java/android/telephony/TelephonyRegistryManager.java index 1b2fedad842e9..b94475ac05cee 100644 --- a/core/java/android/telephony/TelephonyRegistryManager.java +++ b/core/java/android/telephony/TelephonyRegistryManager.java @@ -614,9 +614,9 @@ public class TelephonyRegistryManager { * Notify call disconnect causes which contains {@link DisconnectCause} and {@link * android.telephony.PreciseDisconnectCause}. * - * @param subId for which call disconnected. * @param slotIndex for which call disconnected. Can be derived from subId except when subId is * invalid. + * @param subId for which call disconnected. * @param cause {@link DisconnectCause} for the disconnected call. * @param preciseCause {@link android.telephony.PreciseDisconnectCause} for the disconnected * call. @@ -675,4 +675,36 @@ public class TelephonyRegistryManager { } } + + /** + * Report that Registration or a Location/Routing/Tracking Area update has failed. + * + * @param slotIndex for which call disconnected. Can be derived from subId except when subId is + * invalid. + * @param subId for which cellinfo changed. + * @param cellIdentity the CellIdentity, which must include the globally unique identifier + * for the cell (for example, all components of the CGI or ECGI). + * @param chosenPlmn a 5 or 6 digit alphanumeric PLMN (MCC|MNC) among those broadcast by the + * cell that was chosen for the failed registration attempt. + * @param domain DOMAIN_CS, DOMAIN_PS or both in case of a combined procedure. + * @param causeCode the primary failure cause code of the procedure. + * For GSM/UMTS (MM), values are in TS 24.008 Sec 10.5.95 + * For GSM/UMTS (GMM), values are in TS 24.008 Sec 10.5.147 + * For LTE (EMM), cause codes are TS 24.301 Sec 9.9.3.9 + * For NR (5GMM), cause codes are TS 24.501 Sec 9.11.3.2 + * Integer.MAX_VALUE if this value is unused. + * @param additionalCauseCode the cause code of any secondary/combined procedure if appropriate. + * For UMTS, if a combined attach succeeds for PS only, then the GMM cause code shall be + * included as an additionalCauseCode. For LTE (ESM), cause codes are in + * TS 24.301 9.9.4.4. Integer.MAX_VALUE if this value is unused. + */ + public void notifyRegistrationFailed(int slotIndex, int subId, + @NonNull CellIdentity cellIdentity, @NonNull String chosenPlmn, + @NetworkRegistrationInfo.Domain int domain, int causeCode, int additionalCauseCode) { + try { + sRegistry.notifyRegistrationFailed(slotIndex, subId, cellIdentity, + chosenPlmn, domain, causeCode, additionalCauseCode); + } catch (RemoteException ex) { + } + } } diff --git a/core/java/com/android/internal/telephony/IPhoneStateListener.aidl b/core/java/com/android/internal/telephony/IPhoneStateListener.aidl index 6c7e3dc84425a..6fd271c5490f5 100644 --- a/core/java/com/android/internal/telephony/IPhoneStateListener.aidl +++ b/core/java/com/android/internal/telephony/IPhoneStateListener.aidl @@ -62,4 +62,6 @@ oneway interface IPhoneStateListener { void onOutgoingEmergencySms(in EmergencyNumber sentEmergencyNumber); void onCallDisconnectCauseChanged(in int disconnectCause, in int preciseDisconnectCause); void onImsCallDisconnectCauseChanged(in ImsReasonInfo imsReasonInfo); + void onRegistrationFailed(in CellIdentity cellIdentity, + String chosenPlmn, int domain, int causeCode, int additionalCauseCode); } diff --git a/core/java/com/android/internal/telephony/ITelephonyRegistry.aidl b/core/java/com/android/internal/telephony/ITelephonyRegistry.aidl index 4e405037f6ef9..6933f166a06d7 100644 --- a/core/java/com/android/internal/telephony/ITelephonyRegistry.aidl +++ b/core/java/com/android/internal/telephony/ITelephonyRegistry.aidl @@ -97,4 +97,6 @@ interface ITelephonyRegistry { void notifyCallQualityChanged(in CallQuality callQuality, int phoneId, int subId, int callNetworkType); void notifyImsDisconnectCause(int subId, in ImsReasonInfo imsReasonInfo); + void notifyRegistrationFailed(int slotIndex, int subId, in CellIdentity cellIdentity, + String chosenPlmn, int domain, int causeCode, int additionalCauseCode); } diff --git a/services/core/java/com/android/server/TelephonyRegistry.java b/services/core/java/com/android/server/TelephonyRegistry.java index 783715cd84bcd..9070d32e7b90d 100644 --- a/services/core/java/com/android/server/TelephonyRegistry.java +++ b/services/core/java/com/android/server/TelephonyRegistry.java @@ -23,6 +23,7 @@ import static android.telephony.TelephonyRegistryManager.SIM_ACTIVATION_TYPE_VOI import static java.util.Arrays.copyOf; +import android.annotation.NonNull; import android.annotation.Nullable; import android.app.ActivityManager; import android.app.AppOpsManager; @@ -274,11 +275,12 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { static final int ENFORCE_PHONE_STATE_PERMISSION_MASK = PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR | PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR - | PhoneStateListener.LISTEN_EMERGENCY_NUMBER_LIST; + | PhoneStateListener.LISTEN_EMERGENCY_NUMBER_LIST + | PhoneStateListener.LISTEN_REGISTRATION_FAILURE; static final int PRECISE_PHONE_STATE_PERMISSION_MASK = - PhoneStateListener.LISTEN_PRECISE_CALL_STATE | - PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE; + PhoneStateListener.LISTEN_PRECISE_CALL_STATE + | PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE; static final int READ_ACTIVE_EMERGENCY_SESSION_PERMISSION_MASK = PhoneStateListener.LISTEN_OUTGOING_EMERGENCY_CALL @@ -2050,6 +2052,40 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { } } + @Override + public void notifyRegistrationFailed(int phoneId, int subId, @NonNull CellIdentity cellIdentity, + @NonNull String chosenPlmn, int domain, int causeCode, int additionalCauseCode) { + if (!checkNotifyPermission("notifyRegistrationFailed()")) { + return; + } + + // In case callers don't have fine location access, pre-construct a location-free version + // of the CellIdentity. This will still have the PLMN ID, which should be sufficient for + // most purposes. + final CellIdentity noLocationCi = cellIdentity.sanitizeLocationInfo(); + + synchronized (mRecords) { + if (validatePhoneId(phoneId)) { + for (Record r : mRecords) { + if (r.matchPhoneStateListenerEvent( + PhoneStateListener.LISTEN_REGISTRATION_FAILURE) + && idMatch(r.subId, subId, phoneId)) { + try { + r.callback.onRegistrationFailed( + checkFineLocationAccess(r, Build.VERSION_CODES.R) + ? cellIdentity : noLocationCi, + chosenPlmn, domain, causeCode, + additionalCauseCode); + } catch (RemoteException ex) { + mRemoveList.add(r.binder); + } + } + } + } + handleRemoveListLocked(); + } + } + @Override public void dump(FileDescriptor fd, PrintWriter writer, String[] args) { final IndentingPrintWriter pw = new IndentingPrintWriter(writer, " "); diff --git a/telephony/java/android/telephony/CellIdentity.java b/telephony/java/android/telephony/CellIdentity.java index e523fbab2bb08..ce32dce834db9 100644 --- a/telephony/java/android/telephony/CellIdentity.java +++ b/telephony/java/android/telephony/CellIdentity.java @@ -185,6 +185,14 @@ public abstract class CellIdentity implements Parcelable { @SystemApi public abstract @NonNull CellLocation asCellLocation(); + /** + * Create and a return a new instance of CellIdentity with location-identifying information + * removed. + * + * @hide + */ + public abstract @NonNull CellIdentity sanitizeLocationInfo(); + @Override public boolean equals(Object other) { if (!(other instanceof CellIdentity)) { @@ -312,4 +320,23 @@ public abstract class CellIdentity implements Parcelable { return true; } + /** @hide */ + public static CellIdentity create(android.hardware.radio.V1_5.CellIdentity ci) { + if (ci == null) return null; + switch (ci.getDiscriminator()) { + case android.hardware.radio.V1_5.CellIdentity.hidl_discriminator.gsm: + return new CellIdentityGsm(ci.gsm()); + case android.hardware.radio.V1_5.CellIdentity.hidl_discriminator.cdma: + return new CellIdentityCdma(ci.cdma()); + case android.hardware.radio.V1_5.CellIdentity.hidl_discriminator.lte: + return new CellIdentityLte(ci.lte()); + case android.hardware.radio.V1_5.CellIdentity.hidl_discriminator.wcdma: + return new CellIdentityWcdma(ci.wcdma()); + case android.hardware.radio.V1_5.CellIdentity.hidl_discriminator.tdscdma: + return new CellIdentityTdscdma(ci.tdscdma()); + case android.hardware.radio.V1_5.CellIdentity.hidl_discriminator.nr: + return new CellIdentityNr(ci.nr()); + default: return null; + } + } } diff --git a/telephony/java/android/telephony/CellIdentityCdma.java b/telephony/java/android/telephony/CellIdentityCdma.java index 54236b426d983..1a6bf33cec71f 100644 --- a/telephony/java/android/telephony/CellIdentityCdma.java +++ b/telephony/java/android/telephony/CellIdentityCdma.java @@ -128,7 +128,8 @@ public final class CellIdentityCdma extends CellIdentity { } /** @hide */ - public CellIdentityCdma sanitizeLocationInfo() { + @Override + public @NonNull CellIdentityCdma sanitizeLocationInfo() { return new CellIdentityCdma(CellInfo.UNAVAILABLE, CellInfo.UNAVAILABLE, CellInfo.UNAVAILABLE, CellInfo.UNAVAILABLE, CellInfo.UNAVAILABLE, mAlphaLong, mAlphaShort); diff --git a/telephony/java/android/telephony/CellIdentityGsm.java b/telephony/java/android/telephony/CellIdentityGsm.java index 4e4454d6a1c2f..2ecdfce928259 100644 --- a/telephony/java/android/telephony/CellIdentityGsm.java +++ b/telephony/java/android/telephony/CellIdentityGsm.java @@ -104,7 +104,8 @@ public final class CellIdentityGsm extends CellIdentity { } /** @hide */ - public CellIdentityGsm sanitizeLocationInfo() { + @Override + public @NonNull CellIdentityGsm sanitizeLocationInfo() { return new CellIdentityGsm(CellInfo.UNAVAILABLE, CellInfo.UNAVAILABLE, CellInfo.UNAVAILABLE, CellInfo.UNAVAILABLE, mMccStr, mMncStr, mAlphaLong, mAlphaShort); } diff --git a/telephony/java/android/telephony/CellIdentityLte.java b/telephony/java/android/telephony/CellIdentityLte.java index c3fc73b775d7e..15c91752badfa 100644 --- a/telephony/java/android/telephony/CellIdentityLte.java +++ b/telephony/java/android/telephony/CellIdentityLte.java @@ -121,7 +121,8 @@ public final class CellIdentityLte extends CellIdentity { } /** @hide */ - public CellIdentityLte sanitizeLocationInfo() { + @Override + public @NonNull CellIdentityLte sanitizeLocationInfo() { return new CellIdentityLte(CellInfo.UNAVAILABLE, CellInfo.UNAVAILABLE, CellInfo.UNAVAILABLE, CellInfo.UNAVAILABLE, CellInfo.UNAVAILABLE, mMccStr, mMncStr, mAlphaLong, mAlphaShort); diff --git a/telephony/java/android/telephony/CellIdentityNr.java b/telephony/java/android/telephony/CellIdentityNr.java index e3fec7b7f8205..f08a5807c2b62 100644 --- a/telephony/java/android/telephony/CellIdentityNr.java +++ b/telephony/java/android/telephony/CellIdentityNr.java @@ -69,7 +69,8 @@ public final class CellIdentityNr extends CellIdentity { } /** @hide */ - public CellIdentityNr sanitizeLocationInfo() { + @Override + public @NonNull CellIdentityNr sanitizeLocationInfo() { return new CellIdentityNr(CellInfo.UNAVAILABLE, CellInfo.UNAVAILABLE, CellInfo.UNAVAILABLE, mMccStr, mMncStr, CellInfo.UNAVAILABLE, mAlphaLong, mAlphaShort); } diff --git a/telephony/java/android/telephony/CellIdentityTdscdma.java b/telephony/java/android/telephony/CellIdentityTdscdma.java index 8f812b6b892e7..4bb3a95a9f1d8 100644 --- a/telephony/java/android/telephony/CellIdentityTdscdma.java +++ b/telephony/java/android/telephony/CellIdentityTdscdma.java @@ -97,7 +97,8 @@ public final class CellIdentityTdscdma extends CellIdentity { } /** @hide */ - public CellIdentityTdscdma sanitizeLocationInfo() { + @Override + public @NonNull CellIdentityTdscdma sanitizeLocationInfo() { return new CellIdentityTdscdma(mMccStr, mMncStr, CellInfo.UNAVAILABLE, CellInfo.UNAVAILABLE, CellInfo.UNAVAILABLE, CellInfo.UNAVAILABLE, mAlphaLong, mAlphaShort); } diff --git a/telephony/java/android/telephony/CellIdentityWcdma.java b/telephony/java/android/telephony/CellIdentityWcdma.java index 556bc32e7c36b..3e78c2957c3d9 100644 --- a/telephony/java/android/telephony/CellIdentityWcdma.java +++ b/telephony/java/android/telephony/CellIdentityWcdma.java @@ -98,7 +98,8 @@ public final class CellIdentityWcdma extends CellIdentity { } /** @hide */ - public CellIdentityWcdma sanitizeLocationInfo() { + @Override + public @NonNull CellIdentityWcdma sanitizeLocationInfo() { return new CellIdentityWcdma(CellInfo.UNAVAILABLE, CellInfo.UNAVAILABLE, CellInfo.UNAVAILABLE, CellInfo.UNAVAILABLE, mMccStr, mMncStr, mAlphaLong, mAlphaShort); diff --git a/telephony/java/android/telephony/NetworkRegistrationInfo.java b/telephony/java/android/telephony/NetworkRegistrationInfo.java index fc717e7465b10..cbd5ed665898e 100644 --- a/telephony/java/android/telephony/NetworkRegistrationInfo.java +++ b/telephony/java/android/telephony/NetworkRegistrationInfo.java @@ -46,13 +46,17 @@ public final class NetworkRegistrationInfo implements Parcelable { * @hide */ @Retention(RetentionPolicy.SOURCE) - @IntDef(prefix = "DOMAIN_", value = {DOMAIN_CS, DOMAIN_PS}) + @IntDef(prefix = "DOMAIN_", value = {DOMAIN_UNKNOWN, DOMAIN_CS, DOMAIN_PS, DOMAIN_CS_PS}) public @interface Domain {} + /** Unknown / Unspecified domain */ + public static final int DOMAIN_UNKNOWN = 0; /** Circuit switching domain */ - public static final int DOMAIN_CS = 1; + public static final int DOMAIN_CS = android.hardware.radio.V1_5.Domain.CS; /** Packet switching domain */ - public static final int DOMAIN_PS = 2; + public static final int DOMAIN_PS = android.hardware.radio.V1_5.Domain.PS; + /** Applicable to both CS and PS Domain */ + public static final int DOMAIN_CS_PS = DOMAIN_CS | DOMAIN_PS; /** * Network registration state @@ -504,11 +508,21 @@ public final class NetworkRegistrationInfo implements Parcelable { } } + /** @hide */ + static @NonNull String domainToString(@Domain int domain) { + switch (domain) { + case DOMAIN_CS: return "CS"; + case DOMAIN_PS: return "PS"; + case DOMAIN_CS_PS: return "CS_PS"; + default: return "UNKNOWN"; + } + } + @NonNull @Override public String toString() { return new StringBuilder("NetworkRegistrationInfo{") - .append(" domain=").append((mDomain == DOMAIN_CS) ? "CS" : "PS") + .append(" domain=").append(domainToString(mDomain)) .append(" transportType=").append( AccessNetworkConstants.transportTypeToString(mTransportType)) .append(" registrationState=").append(registrationStateToString(mRegistrationState)) @@ -646,7 +660,7 @@ public final class NetworkRegistrationInfo implements Parcelable { * .build(); * */ - public static final class Builder{ + public static final class Builder { @Domain private int mDomain; diff --git a/telephony/java/android/telephony/ServiceState.java b/telephony/java/android/telephony/ServiceState.java index 0a6183c139500..644fae9504c3f 100644 --- a/telephony/java/android/telephony/ServiceState.java +++ b/telephony/java/android/telephony/ServiceState.java @@ -1882,7 +1882,7 @@ public class ServiceState implements Parcelable { synchronized (mNetworkRegistrationInfos) { for (NetworkRegistrationInfo networkRegistrationInfo : mNetworkRegistrationInfos) { - if (networkRegistrationInfo.getDomain() == domain) { + if ((networkRegistrationInfo.getDomain() & domain) != 0) { list.add(new NetworkRegistrationInfo(networkRegistrationInfo)); } } @@ -1898,7 +1898,6 @@ public class ServiceState implements Parcelable { * @param transportType The transport type * @return The matching {@link NetworkRegistrationInfo} * @hide - * */ @Nullable @SystemApi @@ -1907,7 +1906,7 @@ public class ServiceState implements Parcelable { synchronized (mNetworkRegistrationInfos) { for (NetworkRegistrationInfo networkRegistrationInfo : mNetworkRegistrationInfos) { if (networkRegistrationInfo.getTransportType() == transportType - && networkRegistrationInfo.getDomain() == domain) { + && (networkRegistrationInfo.getDomain() & domain) != 0) { return new NetworkRegistrationInfo(networkRegistrationInfo); } } diff --git a/telephony/java/com/android/internal/telephony/RILConstants.java b/telephony/java/com/android/internal/telephony/RILConstants.java index 9cbcd7fc6b043..42ddb4d391610 100644 --- a/telephony/java/com/android/internal/telephony/RILConstants.java +++ b/telephony/java/com/android/internal/telephony/RILConstants.java @@ -555,4 +555,5 @@ public interface RILConstants { int RIL_UNSOL_PHYSICAL_CHANNEL_CONFIG = 1101; int RIL_UNSOL_EMERGENCY_NUMBER_LIST = 1102; int RIL_UNSOL_UICC_APPLICATIONS_ENABLEMENT_CHANGED = 1103; + int RIL_UNSOL_REGISTRATION_FAILED = 1104; }