Merge "Add Callback for Registration Failure"

This commit is contained in:
Treehugger Robot
2020-01-13 20:58:00 +00:00
committed by Gerrit Code Review
18 changed files with 203 additions and 18 deletions

View File

@@ -45040,6 +45040,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);
@@ -45057,6 +45058,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

View File

@@ -8687,7 +8687,9 @@ package android.telephony {
method public void writeToParcel(android.os.Parcel, int);
field @NonNull public static final android.os.Parcelable.Creator<android.telephony.NetworkRegistrationInfo> 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
@@ -9292,6 +9294,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);
}

View File

@@ -2964,7 +2964,9 @@ package android.telephony {
method public void writeToParcel(android.os.Parcel, int);
field @NonNull public static final android.os.Parcelable.Creator<android.telephony.NetworkRegistrationInfo> 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

View File

@@ -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}.
*
* <p>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.
*
* <p>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().
*
* <p>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
}
}

View File

@@ -621,9 +621,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.
@@ -682,4 +682,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) {
}
}
}

View File

@@ -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);
}

View File

@@ -98,4 +98,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);
}

View File

@@ -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
@@ -2049,6 +2051,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, " ");

View File

@@ -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;
}
}
}

View File

@@ -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);

View File

@@ -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);
}

View File

@@ -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);

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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);

View File

@@ -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();
* </code></pre>
*/
public static final class Builder{
public static final class Builder {
@Domain
private int mDomain;

View File

@@ -1886,7 +1886,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));
}
}
@@ -1902,7 +1902,6 @@ public class ServiceState implements Parcelable {
* @param transportType The transport type
* @return The matching {@link NetworkRegistrationInfo}
* @hide
*
*/
@Nullable
@SystemApi
@@ -1911,7 +1910,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);
}
}

View File

@@ -554,4 +554,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;
}