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

Commit 20aee984 authored by Chen Xu's avatar Chen Xu Committed by android-build-merger
Browse files

Merge "notify on all the subIds with carrier privileges" into qt-dev

am: 1329e8e7

Change-Id: I22968792923eaa9747e3c60b12399d9a7372940a
parents e3d2585b 1329e8e7
Loading
Loading
Loading
Loading
+21 −23
Original line number Diff line number Diff line
@@ -66,6 +66,7 @@ import com.android.internal.telephony.PhoneConstantConversions;
import com.android.internal.telephony.PhoneConstants;
import com.android.internal.telephony.TelephonyIntents;
import com.android.internal.telephony.TelephonyPermissions;
import com.android.internal.util.ArrayUtils;
import com.android.internal.util.DumpUtils;
import com.android.internal.util.IndentingPrintWriter;
import com.android.server.am.BatteryStatsService;
@@ -1164,28 +1165,24 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {

    @Override
    public void notifyCarrierNetworkChange(boolean active) {
        // only CarrierService with carrier privilege rule should have the permission.
        int subId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
        try {
            subId = Arrays.stream(SubscriptionManager.from(mContext)
        // only CarrierService with carrier privilege rule should have the permission
        int[] subIds = Arrays.stream(SubscriptionManager.from(mContext)
                    .getActiveSubscriptionIdList())
                    .filter(i -> TelephonyPermissions.checkCarrierPrivilegeForSubId(i))
                    .findFirst().getAsInt();
        } catch (NoSuchElementException ex) {
                    .filter(i -> TelephonyPermissions.checkCarrierPrivilegeForSubId(i)).toArray();
        if (ArrayUtils.isEmpty(subIds)) {
            loge("notifyCarrierNetworkChange without carrier privilege");
        }
            // the active subId does not have carrier privilege.
        if (subId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
            throw new SecurityException("notifyCarrierNetworkChange without carrier privilege");
        }

        synchronized (mRecords) {
            mCarrierNetworkChangeState = active;
            for (int subId : subIds) {
                int phoneId = SubscriptionManager.getPhoneId(subId);

                if (VDBG) {
                    log("notifyCarrierNetworkChange: active=" + active + "subId: " + subId);
                }

        synchronized (mRecords) {
            mCarrierNetworkChangeState = active;
                for (Record r : mRecords) {
                    if (r.matchPhoneStateListenerEvent(
                            PhoneStateListener.LISTEN_CARRIER_NETWORK_CHANGE) &&
@@ -1197,6 +1194,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
                        }
                    }
                }
            }
            handleRemoveListLocked();
        }
    }