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

Commit 475b5796 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 5503058 from 0df1785a to qt-release

Change-Id: I4a1990dd7cdfc2372ba0f3ac45aa7be3550af88d
parents 87f37e7d 0df1785a
Loading
Loading
Loading
Loading
+50 −4
Original line number Diff line number Diff line
@@ -85,6 +85,10 @@ public class PhoneSwitcher extends Handler {
    private static final int DEFAULT_NETWORK_CHANGE_TIMEOUT_MS = 5000;
    private static final int MODEM_COMMAND_RETRY_PERIOD_MS     = 5000;

    // If there are no subscriptions in a device, then the phone to be used for emergency should
    // always be the "first" phone.
    private static final int DEFAULT_EMERGENCY_PHONE_ID = 0;

    private final List<DcRequest> mPrioritizedDcRequests = new ArrayList<DcRequest>();
    private final RegistrantList mActivePhoneRegistrants;
    private final SubscriptionController mSubscriptionController;
@@ -455,6 +459,10 @@ public class PhoneSwitcher extends Handler {
        for (Phone p : mPhones) {
            if (p == null) continue;
            if (p.isInEcm() || p.isInEmergencyCall()) return true;
            Phone imsPhone = p.getImsPhone();
            if (imsPhone != null && (imsPhone.isInEcm() || imsPhone.isInEmergencyCall())) {
                return true;
            }
        }
        return false;
    }
@@ -578,9 +586,15 @@ public class PhoneSwitcher extends Handler {
            mPrimaryDataSubId = primaryDataSubId;
        }

        // Check to see if there is any active subscription on any phone
        boolean hasAnyActiveSubscription = false;

        // Check if phoneId to subId mapping is changed.
        for (int i = 0; i < mNumPhones; i++) {
            int sub = mSubscriptionController.getSubIdUsingPhoneId(i);

            if (SubscriptionManager.isValidSubscriptionId(sub)) hasAnyActiveSubscription = true;

            if (sub != mPhoneSubscriptions[i]) {
                sb.append(" phone[").append(i).append("] ").append(mPhoneSubscriptions[i]);
                sb.append("->").append(sub);
@@ -589,9 +603,22 @@ public class PhoneSwitcher extends Handler {
            }
        }

        if (!hasAnyActiveSubscription) {
            transitionToEmergencyPhone();
        } else {
            if (VDBG) log("Found an active subscription");
        }

        // Check if phoneId for preferred data is changed.
        int oldPreferredDataPhoneId = mPreferredDataPhoneId;
        updatePreferredDataPhoneId();

        // When there are no subscriptions, the preferred data phone ID is invalid, but we want
        // to keep a valid phoneId for Emergency, so skip logic that updates for preferred data
        // phone ID. Ideally there should be a single set of checks that evaluate the correct
        // phoneId on a service-by-service basis (EIMS being one), but for now... just bypass
        // this logic in the no-SIM case.
        if (hasAnyActiveSubscription) updatePreferredDataPhoneId();

        if (oldPreferredDataPhoneId != mPreferredDataPhoneId) {
            sb.append(" preferred phoneId ").append(oldPreferredDataPhoneId)
                    .append("->").append(mPreferredDataPhoneId);
@@ -738,8 +765,7 @@ public class PhoneSwitcher extends Handler {
        // if Internet PDN is established on the non-preferred phone, it will interrupt
        // Internet connection on the preferred phone. So we only accept Internet request with
        // preferred data subscription or no specified subscription.
        if (netRequest.networkCapabilities.hasCapability(
                NetworkCapabilities.NET_CAPABILITY_INTERNET)
        if (netRequest.hasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
                && subId != preferredDataSubId && subId != mValidator.getSubIdInValidation()) {
            // Returning INVALID_PHONE_INDEX will result in netRequest not being handled.
            return INVALID_PHONE_INDEX;
@@ -816,6 +842,18 @@ public class PhoneSwitcher extends Handler {
        mPreferredDataSubId = mSubscriptionController.getSubIdUsingPhoneId(mPreferredDataPhoneId);
    }

    private void transitionToEmergencyPhone() {
        if (mPreferredDataPhoneId != DEFAULT_EMERGENCY_PHONE_ID) {
            log("No active subscriptions: resetting preferred phone to 0 for emergency");
            mPreferredDataPhoneId = DEFAULT_EMERGENCY_PHONE_ID;
        }

        if (mPreferredDataSubId != INVALID_SUBSCRIPTION_ID) {
            mPreferredDataSubId = INVALID_SUBSCRIPTION_ID;
            notifyPreferredDataSubIdChanged();
        }
    }

    private Phone findPhoneById(final int phoneId) {
        if (phoneId < 0 || phoneId >= mNumPhones) {
            return null;
@@ -827,13 +865,21 @@ public class PhoneSwitcher extends Handler {
        validatePhoneId(phoneId);

        // In any case, if phone state is inactive, don't apply the network request.
        if (!isPhoneActive(phoneId)) return false;
        if (!isPhoneActive(phoneId) || (
                mSubscriptionController.getSubIdUsingPhoneId(phoneId) == INVALID_SUBSCRIPTION_ID
                && !isEmergencyNetworkRequest(networkRequest))) {
            return false;
        }

        int phoneIdToHandle = phoneIdForRequest(networkRequest);

        return phoneId == phoneIdToHandle;
    }

    boolean isEmergencyNetworkRequest(NetworkRequest networkRequest) {
        return networkRequest.hasCapability(NetworkCapabilities.NET_CAPABILITY_EIMS);
    }

    @VisibleForTesting
    protected boolean isPhoneActive(int phoneId) {
        return mPhoneStates[phoneId].active;
+10 −2
Original line number Diff line number Diff line
@@ -3574,7 +3574,15 @@ public class SubscriptionController extends ISub.Stub {
    }

    private @ApnSetting.ApnType int getWhiteListedApnDataTypes(int subId, String callingPackage) {
        return Integer.valueOf(getSubscriptionProperty(subId,
                SubscriptionManager.WHITE_LISTED_APN_DATA, callingPackage));
        String whiteListedApnData = getSubscriptionProperty(subId,
                SubscriptionManager.WHITE_LISTED_APN_DATA, callingPackage);

        try {
            return Integer.valueOf(whiteListedApnData);
        } catch (NumberFormatException e) {
            loge("[getWhiteListedApnDataTypes] couldn't parse apn data:" + whiteListedApnData);
        }

        return ApnSetting.TYPE_NONE;
    }
}
+13 −1
Original line number Diff line number Diff line
@@ -740,6 +740,7 @@ public class DcTracker extends Handler {
        }

        initEmergencyApnSetting();
        addEmergencyApnSetting();

        mProvisionActionName = "com.android.internal.telephony.PROVISION" + phone.getPhoneId();

@@ -3968,6 +3969,7 @@ public class DcTracker extends Handler {
        pw.println(" mDataStallTxRxSum=" + mDataStallTxRxSum);
        pw.println(" mDataStallAlarmTag=" + mDataStallAlarmTag);
        pw.println(" mDataStallNoRxEnabled=" + mDataStallNoRxEnabled);
        pw.println(" mEmergencyApn=" + mEmergencyApn);
        pw.println(" mSentSinceLastRecv=" + mSentSinceLastRecv);
        pw.println(" mNoRecvPollCount=" + mNoRecvPollCount);
        pw.println(" mResolver=" + mResolver);
@@ -4091,7 +4093,7 @@ public class DcTracker extends Handler {

    /**
     * Read APN configuration from Telephony.db for Emergency APN
     * All opertors recognize the connection request for EPDN based on APN type
     * All operators recognize the connection request for EPDN based on APN type
     * PLMN name,APN name are not mandatory parameters
     */
    private void initEmergencyApnSetting() {
@@ -4112,6 +4114,15 @@ public class DcTracker extends Handler {
            }
            cursor.close();
        }
        if (mEmergencyApn != null) return;

        // If no emergency APN setting has been found, make one using reasonable defaults
        mEmergencyApn = new ApnSetting.Builder()
                .setEntryName("Emergency")
                .setProtocol(ApnSetting.PROTOCOL_IPV4V6)
                .setApnName("sos")
                .setApnTypeBitmask(ApnSetting.TYPE_EMERGENCY)
                .build();
    }

    /**
@@ -4131,6 +4142,7 @@ public class DcTracker extends Handler {
            if (!mAllApnSettings.contains(mEmergencyApn)) {
                mAllApnSettings.add(mEmergencyApn);
                log("Adding emergency APN : " + mEmergencyApn);
                return;
            }
        }
    }
+9 −16
Original line number Diff line number Diff line
@@ -15,8 +15,6 @@
 */
package com.android.internal.telephony.euicc;

import static android.telephony.euicc.EuiccManager.EUICC_OTA_STATUS_UNAVAILABLE;

import android.Manifest;
import android.Manifest.permission;
import android.annotation.Nullable;
@@ -173,10 +171,9 @@ public class EuiccController extends IEuiccController.Stub {
        long token = Binder.clearCallingIdentity();
        try {
            if (!callerCanReadPhoneStatePrivileged
                    && !canManageActiveSubscriptionOnTargetSim(cardId, callingPackage)) {
                    && !canManageSubscriptionOnTargetSim(cardId, callingPackage)) {
                throw new SecurityException(
                        "Must have carrier privileges on active subscription to read EID for "
                                + "cardId="
                        "Must have carrier privileges on subscription to read EID for cardId="
                                + cardId);
            }

@@ -1128,7 +1125,7 @@ public class EuiccController extends IEuiccController.Stub {
    private @OtaStatus int blockingGetOtaStatusFromEuiccService(int cardId) {
        CountDownLatch latch = new CountDownLatch(1);
        AtomicReference<Integer> statusRef =
                new AtomicReference<>(EUICC_OTA_STATUS_UNAVAILABLE);
                new AtomicReference<>(EuiccManager.EUICC_OTA_STATUS_UNAVAILABLE);
        mConnector.getOtaStatus(cardId, new EuiccConnector.GetOtaStatusCommandCallback() {
            @Override
            public void onGetOtaStatusComplete(@OtaStatus int status) {
@@ -1212,7 +1209,7 @@ public class EuiccController extends IEuiccController.Stub {
    // given cardId.
    private boolean canManageActiveSubscriptionOnTargetSim(int cardId, String callingPackage) {
        List<SubscriptionInfo> subInfoList = mSubscriptionManager
                .getActiveSubscriptionInfoList(/* userVisibleonly */false);
                .getActiveSubscriptionInfoList(/* userVisibleOnly */false);
        if (subInfoList == null || subInfoList.size() == 0) {
            // No active subscription on any SIM.
            return false;
@@ -1240,7 +1237,7 @@ public class EuiccController extends IEuiccController.Stub {
    // embedded subscription.
    private boolean canManageSubscriptionOnTargetSim(int cardId, String callingPackage) {
        List<SubscriptionInfo> subInfoList = mSubscriptionManager
                .getActiveSubscriptionInfoList(/* userVisibleonly */false);
                .getActiveSubscriptionInfoList(false /* userVisibleonly */);
        // No active subscription on any SIM.
        if (subInfoList == null || subInfoList.size() == 0) {
            return false;
@@ -1263,6 +1260,7 @@ public class EuiccController extends IEuiccController.Stub {
                }
            }
            if (!isEuicc) {
                Log.i(TAG, "The target SIM is not an eUICC.");
                return false;
            }

@@ -1271,20 +1269,15 @@ public class EuiccController extends IEuiccController.Stub {
            // return true directly.
            for (SubscriptionInfo subInfo : subInfoList) {
                // subInfo.isEmbedded() can only be true for the target SIM.
                if (subInfo.getCardId() == cardId) {
                if (subInfo.isEmbedded() && subInfo.getCardId() == cardId) {
                    return mSubscriptionManager.canManageSubscription(subInfo, callingPackage);
                }
            }

            // There is no active subscription on the target SIM, checks whether the caller can
            // manage any active subscription on any other SIM.
            for (SubscriptionInfo subInfo : subInfoList) {
                if (subInfo.getCardId() != cardId
                        && mSubscriptionManager.canManageSubscription(subInfo, callingPackage)) {
                    return true;
                }
            }
            return false;
            return mTelephonyManager.checkCarrierPrivilegesForPackageAnyPhone(callingPackage)
                    == TelephonyManager.CARRIER_PRIVILEGE_STATUS_HAS_ACCESS;
        } else {
            for (SubscriptionInfo subInfo : subInfoList) {
                if (subInfo.isEmbedded()
+1 −2
Original line number Diff line number Diff line
@@ -116,7 +116,6 @@ public class PhoneSwitcherTest extends TelephonyTest {
        NetworkRequest internetNetworkRequest = addInternetNetworkRequest(null, 50);
        waitABit();

        assertFalse("data allowed after request", mDataAllowed[0]);
        assertFalse("phone active after request", mPhoneSwitcher
                .shouldApplyNetworkRequest(internetNetworkRequest, 0));

@@ -132,7 +131,6 @@ public class PhoneSwitcherTest extends TelephonyTest {
        setDefaultDataSubId(0);

        verify(mActivePhoneSwitchHandler, never()).sendMessageAtTime(any(), anyLong());
        assertFalse("data allowed", mDataAllowed[0]);

        setSlotIndexToSubId(0, 0);
        mSubChangedListener.onSubscriptionsChanged();
@@ -413,6 +411,7 @@ public class PhoneSwitcherTest extends TelephonyTest {
        mPhoneSwitcher.registerForActivePhoneSwitch(mActivePhoneSwitchHandler,
                ACTIVE_PHONE_SWITCH, null);
        verify(mActivePhoneSwitchHandler, times(2)).sendMessageAtTime(any(), anyLong());
        clearInvocations(mMockRadioConfig);
        clearInvocations(mActivePhoneSwitchHandler);

        // Phone 0 has sub 1, phone 1 has sub 2.
Loading