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

Commit 73047c69 authored by Hui Wang's avatar Hui Wang Committed by Automerger Merge Worker
Browse files

Merge "Fixed UID mismatch in telephony registry" am: c2fa03fc

parents 678d21fe c2fa03fc
Loading
Loading
Loading
Loading
+49 −48
Original line number Diff line number Diff line
@@ -1578,18 +1578,20 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
            return;
        }

        final long callingIdentity = Binder.clearCallingIdentity();
        try {
            synchronized (mRecords) {
            String str = "notifyServiceStateForSubscriber: subId=" + subId + " phoneId=" + phoneId
                    + " state=" + state;
                String str = "notifyServiceStateForSubscriber: subId=" + subId + " phoneId="
                        + phoneId + " state=" + state;
                if (VDBG) {
                    log(str);
                }
                mLocalLog.log(str);
            // for service state updates, don't notify clients when subId is invalid. This prevents
            // us from sending incorrect notifications like b/133140128
                // for service state updates, don't notify clients when subId is invalid. This
                // prevents us from sending incorrect notifications like b/133140128
                // In the future, we can remove this logic for every notification here and add a
            // callback so listeners know when their PhoneStateListener's subId becomes invalid, but
            // for now we use the simplest fix.
                // callback so listeners know when their PhoneStateListener's subId becomes invalid,
                // but for now we use the simplest fix.
                if (validatePhoneId(phoneId) && SubscriptionManager.isValidSubscriptionId(subId)) {
                    mServiceState[phoneId] = state;

@@ -1614,7 +1616,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
                                if (DBG) {
                                    log("notifyServiceStateForSubscriber: callback.onSSC r=" + r
                                            + " subId=" + subId + " phoneId=" + phoneId
                                        + " state=" + state);
                                            + " state=" + stateToSend);
                                }
                                r.callback.onServiceStateChanged(stateToSend);
                            } catch (RemoteException ex) {
@@ -1629,6 +1631,9 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
                handleRemoveListLocked();
            }
            broadcastServiceStateChanged(state, phoneId, subId);
        } finally {
            Binder.restoreCallingIdentity(callingIdentity);
        }
    }

    public void notifySimActivationStateChangedForPhoneId(int phoneId, int subId,
@@ -3161,13 +3166,10 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
    public static final String ACTION_SIGNAL_STRENGTH_CHANGED = "android.intent.action.SIG_STR";

    private void broadcastServiceStateChanged(ServiceState state, int phoneId, int subId) {
        final long ident = Binder.clearCallingIdentity();
        try {
            mBatteryStats.notePhoneState(state.getState());
        } catch (RemoteException re) {
            // Can't do much
        } finally {
            Binder.restoreCallingIdentity(ident);
        }

        // Send the broadcast exactly once to all possible disjoint sets of apps.
@@ -3184,8 +3186,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
        // - Sanitized ServiceState sent to all other apps with READ_PHONE_STATE
        // - Sanitized ServiceState sent to all other apps with READ_PRIVILEGED_PHONE_STATE but not
        //   READ_PHONE_STATE
        if (Binder.withCleanCallingIdentity(() ->
                LocationAccessPolicy.isLocationModeEnabled(mContext, mContext.getUserId()))) {
        if (LocationAccessPolicy.isLocationModeEnabled(mContext, mContext.getUserId())) {
            Intent fullIntent = createServiceStateIntent(state, subId, phoneId, false);
            mContext.createContextAsUser(UserHandle.ALL, 0).sendBroadcastMultiplePermissions(
                    fullIntent,