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

Commit 09b6a2fe authored by Xin Li's avatar Xin Li
Browse files

Merge Android 12L

Bug: 222710654
Merged-In: Id8bbfbbdba87d09ff647bee9e35402c6a485a638
Change-Id: I09d59640f1a7a73e723031b1fa55fde51b0065a8
parents 3266b0d6 8a795390
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
amitmahajan@google.com
breadley@google.com
fionaxu@google.com
jackyu@google.com
+46 −1
Original line number Diff line number Diff line
@@ -457,7 +457,8 @@ public class GsmCdmaPhone extends Phone {
                CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED);
        filter.addAction(TelecomManager.ACTION_CURRENT_TTY_MODE_CHANGED);
        filter.addAction(TelecomManager.ACTION_TTY_PREFERRED_MODE_CHANGED);
        mContext.registerReceiver(mBroadcastReceiver, filter);
        mContext.registerReceiver(mBroadcastReceiver, filter,
                android.Manifest.permission.MODIFY_PHONE_STATE, null);

        mCDM = new CarrierKeyDownloadManager(this);
        mCIM = new CarrierInfoManager();
@@ -3010,6 +3011,7 @@ public class GsmCdmaPhone extends Phone {
                updateCdmaRoamingSettingsAfterCarrierConfigChanged(b);

                updateNrSettingsAfterCarrierConfigChanged(b);
                updateVoNrSettings(b);
                updateSsOverCdmaSupported(b);
                loadAllowedNetworksFromSubscriptionDatabase();
                // Obtain new radio capabilities from the modem, since some are SIM-dependent
@@ -3322,6 +3324,10 @@ public class GsmCdmaPhone extends Phone {
                resetCarrierKeysForImsiEncryption();
                break;
            }
            case EVENT_SET_VONR_ENABLED_DONE:
                logd("EVENT_SET_VONR_ENABLED_DONE is done");
                break;

            default:
                super.handleMessage(msg);
        }
@@ -4751,6 +4757,45 @@ public class GsmCdmaPhone extends Phone {
        mIsCarrierNrSupported = !ArrayUtils.isEmpty(nrAvailabilities);
    }

    private void updateVoNrSettings(PersistableBundle config) {
        UiccSlot slot = mUiccController.getUiccSlotForPhone(mPhoneId);

        // If no card is present, do nothing.
        if (slot == null || slot.getCardState() != IccCardStatus.CardState.CARDSTATE_PRESENT) {
            return;
        }

        if (config == null) {
            loge("didn't get the vonr_enabled_bool from the carrier config.");
            return;
        }

        boolean mIsVonrEnabledByCarrier =
                config.getBoolean(CarrierConfigManager.KEY_VONR_ENABLED_BOOL);

        String result = SubscriptionController.getInstance().getSubscriptionProperty(
                getSubId(),
                SubscriptionManager.NR_ADVANCED_CALLING_ENABLED);

        int setting = -1;
        if (result != null) {
            setting = Integer.parseInt(result);
        }

        logd("VoNR setting from telephony.db:"
                + setting
                + " ,vonr_enabled_bool:"
                + mIsVonrEnabledByCarrier);

        if (!mIsVonrEnabledByCarrier) {
            mCi.setVoNrEnabled(false, obtainMessage(EVENT_SET_VONR_ENABLED_DONE), null);
        } else if (setting == 1 || setting == -1) {
            mCi.setVoNrEnabled(true, obtainMessage(EVENT_SET_VONR_ENABLED_DONE), null);
        } else if (setting == 0) {
            mCi.setVoNrEnabled(false, obtainMessage(EVENT_SET_VONR_ENABLED_DONE), null);
        }
    }

    private void updateCdmaRoamingSettingsAfterCarrierConfigChanged(PersistableBundle config) {
        if (config == null) {
            loge("didn't get the cdma_roaming_mode changes from the carrier config.");
+2 −2
Original line number Diff line number Diff line
@@ -597,8 +597,8 @@ public class IccSmsInterfaceManager {
            String destAddr, String scAddr, String text, PendingIntent sentIntent,
            PendingIntent deliveryIntent, boolean persistMessageForNonDefaultSmsApp, int priority,
            boolean expectMore, int validityPeriod) {
        if (!mSmsPermissions.checkCallingOrSelfCanSendSms(callingPackage, callingAttributionTag,
                "Sending SMS message")) {
        if (!mSmsPermissions.checkCallingCanSendText(persistMessageForNonDefaultSmsApp,
                    callingPackage, callingAttributionTag, "Sending SMS message")) {
            returnUnspecifiedFailure(sentIntent);
            return;
        }
+95 −29
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.internal.telephony;

import android.annotation.NonNull;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
@@ -33,13 +34,14 @@ import android.telephony.ServiceState;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyDisplayInfo;
import android.telephony.TelephonyManager;
import android.telephony.data.ApnSetting;
import android.telephony.data.DataCallResponse;
import android.text.TextUtils;
import android.util.ArrayMap;
import android.util.ArraySet;

import com.android.internal.telephony.dataconnection.DataConnection;
import com.android.internal.telephony.dataconnection.DcController;
import com.android.internal.telephony.dataconnection.DcController.PhysicalLinkState;
import com.android.internal.telephony.dataconnection.DcTracker;
import com.android.internal.telephony.uicc.IccUtils;
import com.android.internal.telephony.util.ArrayUtils;
import com.android.internal.util.IState;
import com.android.internal.util.IndentingPrintWriter;
@@ -54,6 +56,7 @@ import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.IntStream;
@@ -99,8 +102,9 @@ public class NetworkTypeController extends StateMachine {
    private static final int EVENT_PHYSICAL_CHANNEL_CONFIG_CHANGED = 13;
    private static final int EVENT_PCO_DATA_CHANGED = 14;
    private static final int EVENT_BANDWIDTH_CHANGED = 15;
    private static final int EVENT_DATA_CALL_LIST_CHANGED = 16;

    private static final String[] sEvents = new String[EVENT_PCO_DATA_CHANGED + 1];
    private static final String[] sEvents = new String[EVENT_DATA_CALL_LIST_CHANGED + 1];
    static {
        sEvents[EVENT_UPDATE] = "EVENT_UPDATE";
        sEvents[EVENT_QUIT] = "EVENT_QUIT";
@@ -118,6 +122,7 @@ public class NetworkTypeController extends StateMachine {
        sEvents[EVENT_INITIALIZE] = "EVENT_INITIALIZE";
        sEvents[EVENT_PHYSICAL_CHANNEL_CONFIG_CHANGED] = "EVENT_PHYSICAL_CHANNEL_CONFIG_CHANGED";
        sEvents[EVENT_PCO_DATA_CHANGED] = "EVENT_PCO_DATA_CHANGED";
        sEvents[EVENT_DATA_CALL_LIST_CHANGED] = "EVENT_DATA_CALL_LIST_CHANGED";
    }

    private final Phone mPhone;
@@ -152,6 +157,10 @@ public class NetworkTypeController extends StateMachine {
    private boolean mIsPhysicalChannelConfig16Supported;
    private Boolean mIsNrAdvancedAllowedByPco = false;
    private int mNrAdvancedCapablePcoId = 0;
    /** The key is the cid, the value is the PCO data. */
    private final @NonNull Map<Integer, PcoData> mPcoDataMap = new ArrayMap<>();
    /** Active data connection cid set. */
    private final @NonNull Set<Integer> mActiveDcCidSet = new ArraySet<>();
    private boolean mIsUsingUserDataForRrcDetection = false;
    private boolean mEnableNrAdvancedWhileRoaming = true;

@@ -222,7 +231,13 @@ public class NetworkTypeController extends StateMachine {
        IntentFilter filter = new IntentFilter();
        filter.addAction(CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED);
        mPhone.getContext().registerReceiver(mIntentReceiver, filter, null, mPhone);

        // TODO: This is a temporarily solution for S. Ideally PCO and data call list changed event
        //  should not be exposed outside of the data modules. PCO for 5G icon has been well
        //  supported in the new data architecture in T. This temp solution must be removed in T
        //  along with other old data modules.
        mPhone.mCi.registerForPcoData(getHandler(), EVENT_PCO_DATA_CHANGED, null);
        mPhone.mCi.registerForDataCallListChanged(getHandler(), EVENT_DATA_CALL_LIST_CHANGED, null);
    }

    private void unRegisterForAllEvents() {
@@ -235,6 +250,7 @@ public class NetworkTypeController extends StateMachine {
        mPhone.getDeviceStateMonitor().unregisterForPhysicalChannelConfigNotifChanged(getHandler());
        mPhone.getContext().unregisterReceiver(mIntentReceiver);
        mPhone.mCi.unregisterForPcoData(getHandler());
        mPhone.mCi.unregisterForDataCallListChanged(getHandler());
    }

    private void parseCarrierConfigs() {
@@ -518,10 +534,12 @@ public class NetworkTypeController extends StateMachine {
                    registerForAllEvents();
                    parseCarrierConfigs();
                    break;
                case EVENT_PCO_DATA_CHANGED:
                    handlePcoData((AsyncResult) msg.obj);
                    break;
                case EVENT_DATA_RAT_CHANGED:
                case EVENT_NR_STATE_CHANGED:
                case EVENT_NR_FREQUENCY_CHANGED:
                case EVENT_PCO_DATA_CHANGED:
                case EVENT_BANDWIDTH_CHANGED:
                    // ignored
                    break;
@@ -563,6 +581,10 @@ public class NetworkTypeController extends StateMachine {
                    resetAllTimers();
                    transitionTo(mLegacyState);
                    break;
                case EVENT_DATA_CALL_LIST_CHANGED:
                    ar = (AsyncResult) msg.obj;
                    handleDataCallList((List<DataCallResponse>) ar.result);
                    break;
                default:
                    throw new RuntimeException("Received invalid event: " + msg.what);
            }
@@ -855,6 +877,7 @@ public class NetworkTypeController extends StateMachine {
            if (DBG) log("NrConnectedState: process " + getEventName(msg.what));
            updateTimers();
            int rat = getDataNetworkType();
            AsyncResult ar;
            switch (msg.what) {
                case EVENT_DATA_RAT_CHANGED:
                    if (rat == TelephonyManager.NETWORK_TYPE_NR || isLte(rat) && isNrConnected()) {
@@ -876,6 +899,12 @@ public class NetworkTypeController extends StateMachine {
                    break;
                case EVENT_PCO_DATA_CHANGED:
                    handlePcoData((AsyncResult) msg.obj);
                    updateNrAdvancedState();
                    break;
                case EVENT_DATA_CALL_LIST_CHANGED:
                    ar = (AsyncResult) msg.obj;
                    handleDataCallList((List<DataCallResponse>) ar.result);
                    updateNrAdvancedState();
                    break;
                case EVENT_NR_FREQUENCY_CHANGED:
                case EVENT_PHYSICAL_CHANNEL_CONFIG_CHANGED:
@@ -885,7 +914,7 @@ public class NetworkTypeController extends StateMachine {
                    updateNrAdvancedState();
                    break;
                case EVENT_PHYSICAL_LINK_STATE_CHANGED:
                    AsyncResult ar = (AsyncResult) msg.obj;
                    ar = (AsyncResult) msg.obj;
                    mPhysicalLinkState = (int) ar.result;
                    if (!isNrConnected()) {
                        log("NR state changed. Sending EVENT_NR_STATE_CHANGED");
@@ -924,8 +953,40 @@ public class NetworkTypeController extends StateMachine {
            }
            mIsNrAdvanced = isNrAdvanced();
        }
    }

    private final NrConnectedState mNrConnectedState = new NrConnectedState();

    // TODO: This is a temporarily solution for S. Ideally PCO and data call list changed event
    //  should not be exposed outside of the data modules. PCO for 5G icon has been well
    //  supported in the new data architecture in T. This temp solution must be removed in T
    //  along with other old data modules.
    private void handleDataCallList(@NonNull List<DataCallResponse> dataCallResponseList) {
        if (mNrAdvancedCapablePcoId == 0) return;
        mActiveDcCidSet.clear();
        for (DataCallResponse response : dataCallResponseList) {
            if (response.getLinkStatus() == DataCallResponse.LINK_STATUS_ACTIVE
                    || response.getLinkStatus() == DataCallResponse.LINK_STATUS_DORMANT) {
                mActiveDcCidSet.add(response.getId());
            }
        }

        log("Active cids=" + mActiveDcCidSet);
        boolean nrAdvancedAllowedByPco = mPcoDataMap.values().stream()
                .anyMatch(pco -> pco.contents[pco.contents.length - 1] == 1
                        && mActiveDcCidSet.contains(pco.cid));
        if (mIsNrAdvancedAllowedByPco != nrAdvancedAllowedByPco) {
            mIsNrAdvancedAllowedByPco = nrAdvancedAllowedByPco;
            log("nrAdvancedAllowedByPco=" + nrAdvancedAllowedByPco);
        }
    }

    // TODO: This is a temporarily solution for S. Ideally PCO and data call list changed event
    //  should not be exposed outside of the data modules. PCO for 5G icon has been well
    //  supported in the new data architecture in T. This temp solution must be removed in T
    //  along with other old data modules.
    private void handlePcoData(AsyncResult ar) {
        if (mNrAdvancedCapablePcoId == 0) return;
        if (ar.exception != null) {
            loge("PCO_DATA exception: " + ar.exception);
            return;
@@ -934,25 +995,24 @@ public class NetworkTypeController extends StateMachine {
        if (pcodata == null) {
            return;
        }
            log("EVENT_PCO_DATA_CHANGED: pco data: " + pcodata);
            DcTracker dcTracker = mPhone.getDcTracker(
                    AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
            DataConnection dc =
                    dcTracker != null ? dcTracker.getDataConnectionByContextId(pcodata.cid) : null;
            ApnSetting apnSettings = dc != null ? dc.getApnSetting() : null;
            if (apnSettings != null && apnSettings.canHandleType(ApnSetting.TYPE_DEFAULT)
                    && mNrAdvancedCapablePcoId > 0
                    && pcodata.pcoId == mNrAdvancedCapablePcoId
            ) {
                log("EVENT_PCO_DATA_CHANGED: Nr Advanced is allowed by PCO.");
                mIsNrAdvancedAllowedByPco = pcodata.contents[0] == 1;
                updateNrAdvancedState();
        log("EVENT_PCO_DATA_CHANGED: pco data: " + pcodata + ", "
                + IccUtils.bytesToHexString(pcodata.contents));
        if (pcodata.pcoId != mNrAdvancedCapablePcoId || pcodata.contents == null
                || pcodata.contents.length == 0) {
            log("Dropped irrelevant PCO data");
            return;
        }

        mPcoDataMap.put(pcodata.cid, pcodata);
        boolean nrAdvancedAllowedByPco = mPcoDataMap.values().stream()
                .anyMatch(pco -> pco.contents[pco.contents.length - 1] == 1
                        && mActiveDcCidSet.contains(pco.cid));
        if (mIsNrAdvancedAllowedByPco != nrAdvancedAllowedByPco) {
            mIsNrAdvancedAllowedByPco = nrAdvancedAllowedByPco;
            log("nrAdvancedAllowedByPco=" + nrAdvancedAllowedByPco);
        }
    }

    private final NrConnectedState mNrConnectedState = new NrConnectedState();

    private void transitionWithTimerTo(IState destState) {
        String destName = destState.getName();
        OverrideTimerRule rule = mOverrideTimerRules.get(mPreviousState);
@@ -1008,6 +1068,12 @@ public class NetworkTypeController extends StateMachine {
    }

    private void updateTimers() {
        if ((mPhone.getCachedAllowedNetworkTypesBitmask()
                & TelephonyManager.NETWORK_TYPE_BITMASK_NR) == 0) {
            resetAllTimers();
            return;
        }

        String currentState = getCurrentState().getName();

        if (mIsPrimaryTimerActive && getOverrideNetworkType() == getCurrentOverrideNetworkType()) {
+2 −1
Original line number Diff line number Diff line
@@ -237,8 +237,9 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
    protected static final int EVENT_BARRING_INFO_CHANGED = 58;
    protected static final int EVENT_LINK_CAPACITY_CHANGED = 59;
    protected static final int EVENT_RESET_CARRIER_KEY_IMSI_ENCRYPTION = 60;
    protected static final int EVENT_SET_VONR_ENABLED_DONE = 61;

    protected static final int EVENT_LAST = EVENT_RESET_CARRIER_KEY_IMSI_ENCRYPTION;
    protected static final int EVENT_LAST = EVENT_SET_VONR_ENABLED_DONE;

    // For shared prefs.
    private static final String GSM_ROAMING_LIST_OVERRIDE_PREFIX = "gsm_roaming_list_";
Loading