Use a separate intent action for subscription phone state changes.
Global phone state changes and subscription phone state changes are aliased to the same intent. As a result, apps can't distinguish between the two types of updates. This change teases the two apart by using a different intent action for each type of phone state change. This will break carrier apps that depend on subscription phone state changes, but will fix state inconsistencies in non-carrier apps. Bug: 20309009 Change-Id: Ie81c37247917573a3ef5d957fda1087c16736e85
This commit is contained in:
@@ -678,7 +678,7 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub {
|
||||
handleRemoveListLocked();
|
||||
}
|
||||
broadcastCallStateChanged(state, incomingNumber,
|
||||
SubscriptionManager.DEFAULT_SUBSCRIPTION_ID);
|
||||
SubscriptionManager.INVALID_SUBSCRIPTION_ID);
|
||||
}
|
||||
|
||||
public void notifyCallStateForSubscriber(int subId, int state, String incomingNumber) {
|
||||
@@ -1372,6 +1372,12 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub {
|
||||
mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Broadcasts an intent notifying apps of a phone state change. {@code subId} can be
|
||||
* a valid subId, in which case this function fires a subId-specific intent, or it
|
||||
* can be {@code SubscriptionManager.INVALID_SUBSCRIPTION_ID}, in which case we send
|
||||
* a global state change broadcast ({@code TelephonyManager.ACTION_PHONE_STATE_CHANGED}).
|
||||
*/
|
||||
private void broadcastCallStateChanged(int state, String incomingNumber, int subId) {
|
||||
long ident = Binder.clearCallingIdentity();
|
||||
try {
|
||||
@@ -1392,7 +1398,14 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub {
|
||||
if (!TextUtils.isEmpty(incomingNumber)) {
|
||||
intent.putExtra(TelephonyManager.EXTRA_INCOMING_NUMBER, incomingNumber);
|
||||
}
|
||||
intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, subId);
|
||||
|
||||
// If a valid subId was specified, we should fire off a subId-specific state
|
||||
// change intent and include the subId.
|
||||
if (subId != SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
|
||||
intent.setAction(PhoneConstants.ACTION_SUBSCRIPTION_PHONE_STATE_CHANGED);
|
||||
intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, subId);
|
||||
}
|
||||
|
||||
mContext.sendBroadcastAsUser(intent, UserHandle.ALL,
|
||||
android.Manifest.permission.READ_PHONE_STATE,
|
||||
AppOpsManager.OP_READ_PHONE_STATE);
|
||||
|
||||
@@ -150,6 +150,10 @@ public class PhoneConstants {
|
||||
|
||||
public static final String SLOT_KEY = "slot";
|
||||
|
||||
/** Fired when a subscriptions phone state changes. */
|
||||
public static final String ACTION_SUBSCRIPTION_PHONE_STATE_CHANGED =
|
||||
"android.intent.action.SUBSCRIPTION_PHONE_STATE";
|
||||
|
||||
// FIXME: This is used to pass a subId via intents, we need to look at its usage, which is
|
||||
// FIXME: extensive, and see if this should be an array of all active subId's or ...?
|
||||
public static final String SUBSCRIPTION_KEY = "subscription";
|
||||
|
||||
Reference in New Issue
Block a user