Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 61a3ab09 authored by Sharvil Nanavati's avatar Sharvil Nanavati
Browse files

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
parent a5b55a01
Loading
Loading
Loading
Loading
+15 −2
Original line number Diff line number Diff line
@@ -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);
        }

        // 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);
+4 −0
Original line number Diff line number Diff line
@@ -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";