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

Commit fb141721 authored by Steve Statia's avatar Steve Statia Committed by Android (Google) Code Review
Browse files

Merge "Move getActiveSubscriptionInfo to solve deadlock" into main

parents 712b1cfb 8047e4e2
Loading
Loading
Loading
Loading
+37 −10
Original line number Diff line number Diff line
@@ -1126,6 +1126,21 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
            return;
        }

        int phoneId = -1;
        int subscriptionId = SubscriptionManager.DEFAULT_SUBSCRIPTION_ID;
        if(Flags.preventSystemServerAndPhoneDeadlock()) {
            // Legacy applications pass SubscriptionManager.DEFAULT_SUB_ID,
            // force all illegal subId to SubscriptionManager.DEFAULT_SUB_ID
            if (!SubscriptionManager.isValidSubscriptionId(subId)) {
                if (DBG) {
                    log("invalid subscription id, use default id");
                }
            } else { //APP specify subID
                subscriptionId = subId;
            }
            phoneId = getPhoneIdFromSubId(subscriptionId);
        }

        synchronized (mRecords) {
            // register
            IBinder b = callback.asBinder();
@@ -1145,6 +1160,8 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
            r.renounceFineLocationAccess = renounceFineLocationAccess;
            r.callerUid = Binder.getCallingUid();
            r.callerPid = Binder.getCallingPid();

            if(!Flags.preventSystemServerAndPhoneDeadlock()) {
                // Legacy applications pass SubscriptionManager.DEFAULT_SUB_ID,
                // force all illegal subId to SubscriptionManager.DEFAULT_SUB_ID
                if (!SubscriptionManager.isValidSubscriptionId(subId)) {
@@ -1156,6 +1173,10 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
                    r.subId = subId;
                }
                r.phoneId = getPhoneIdFromSubId(r.subId);
            } else {
                r.subId = subscriptionId;
                r.phoneId = phoneId;
            }
            r.eventList = events;

            if (DBG) {
@@ -1893,8 +1914,14 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
    }

    private void notifyCarrierNetworkChangeWithPermission(int subId, boolean active) {
        int phoneId = -1;
        if(Flags.preventSystemServerAndPhoneDeadlock()) {
            phoneId = getPhoneIdFromSubId(subId);
        }
        synchronized (mRecords) {
            int phoneId = getPhoneIdFromSubId(subId);
            if(!Flags.preventSystemServerAndPhoneDeadlock()) {
                phoneId = getPhoneIdFromSubId(subId);
            }
            mCarrierNetworkChangeState[phoneId] = active;

            if (VDBG) {