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

Commit 9f835887 authored by Tomasz Wasilczyk's avatar Tomasz Wasilczyk Committed by Android (Google) Code Review
Browse files

Merge changes I21811d41,Ia507d2d3 into main

* changes:
  Fix Telephony stack for Minimal Automotive Telephony
  Add minimal_telephony_cdm_check flag
parents 0db22fad d07a68b9
Loading
Loading
Loading
Loading
+8 −1
Original line number Original line Diff line number Diff line
@@ -27,3 +27,10 @@ flag {
    description: "This flag prevents repeat invocation of call related APIs in RIL when the device is not voice capable"
    description: "This flag prevents repeat invocation of call related APIs in RIL when the device is not voice capable"
    bug: "290833783"
    bug: "290833783"
}
}

flag {
    name: "minimal_telephony_cdm_check"
    namespace: "telephony"
    description: "This flag disables Calling/Data/Messaging features if their respective feature is missing"
    bug: "310710841"
}
+8 −1
Original line number Original line Diff line number Diff line
@@ -21,6 +21,7 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Context;
import android.content.Intent;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.os.AsyncResult;
import android.os.AsyncResult;
import android.os.Build;
import android.os.Build;
import android.os.Bundle;
import android.os.Bundle;
@@ -159,6 +160,12 @@ public class GsmCdmaCallTracker extends CallTracker {
    public GsmCdmaCallTracker(GsmCdmaPhone phone, FeatureFlags featureFlags) {
    public GsmCdmaCallTracker(GsmCdmaPhone phone, FeatureFlags featureFlags) {
        super(featureFlags);
        super(featureFlags);


        if (mFeatureFlags.minimalTelephonyCdmCheck()
                && !phone.getContext().getPackageManager().hasSystemFeature(
                    PackageManager.FEATURE_TELEPHONY_CALLING)) {
            throw new UnsupportedOperationException("GsmCdmaCallTracker requires calling");
        }

        this.mPhone = phone;
        this.mPhone = phone;
        mCi = phone.mCi;
        mCi = phone.mCi;
        mCi.registerForCallStateChanged(this, EVENT_CALL_STATE_CHANGE, null);
        mCi.registerForCallStateChanged(this, EVENT_CALL_STATE_CHANGE, null);
@@ -1492,7 +1499,7 @@ public class GsmCdmaCallTracker extends CallTracker {


        switch (msg.what) {
        switch (msg.what) {
            case EVENT_POLL_CALLS_RESULT:
            case EVENT_POLL_CALLS_RESULT:
                Rlog.d(LOG_TAG, "Event EVENT_POLL_CALLS_RESULT Received");
                if (DBG_POLL) Rlog.d(LOG_TAG, "Event EVENT_POLL_CALLS_RESULT Received");


                if (msg == mLastRelevantPoll) {
                if (msg == mLastRelevantPoll) {
                    if (DBG_POLL) log(
                    if (DBG_POLL) log(
+51 −17
Original line number Original line Diff line number Diff line
@@ -42,6 +42,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.database.SQLException;
import android.database.SQLException;
import android.hardware.radio.modem.ImeiInfo;
import android.hardware.radio.modem.ImeiInfo;
import android.net.Uri;
import android.net.Uri;
@@ -370,9 +371,11 @@ public class GsmCdmaPhone extends Phone {
                SignalStrengthController.class.getName()).makeSignalStrengthController(this);
                SignalStrengthController.class.getName()).makeSignalStrengthController(this);
        mSST = mTelephonyComponentFactory.inject(ServiceStateTracker.class.getName())
        mSST = mTelephonyComponentFactory.inject(ServiceStateTracker.class.getName())
                .makeServiceStateTracker(this, this.mCi, featureFlags);
                .makeServiceStateTracker(this, this.mCi, featureFlags);
        if (hasCalling()) {
            mEmergencyNumberTracker = mTelephonyComponentFactory
            mEmergencyNumberTracker = mTelephonyComponentFactory
                    .inject(EmergencyNumberTracker.class.getName()).makeEmergencyNumberTracker(
                    .inject(EmergencyNumberTracker.class.getName()).makeEmergencyNumberTracker(
                        this, this.mCi);
                            this, this.mCi, mFeatureFlags);
        }
        mDeviceStateMonitor = mTelephonyComponentFactory.inject(DeviceStateMonitor.class.getName())
        mDeviceStateMonitor = mTelephonyComponentFactory.inject(DeviceStateMonitor.class.getName())
                .makeDeviceStateMonitor(this, mFeatureFlags);
                .makeDeviceStateMonitor(this, mFeatureFlags);


@@ -412,9 +415,11 @@ public class GsmCdmaPhone extends Phone {


        mCallWaitingController = new CallWaitingController(this);
        mCallWaitingController = new CallWaitingController(this);


        if (hasCalling()) {
            loadTtyMode();
            loadTtyMode();


            CallManager.getInstance().registerPhone(this);
            CallManager.getInstance().registerPhone(this);
        }


        mSubscriptionsChangedListener =
        mSubscriptionsChangedListener =
                new SubscriptionManager.OnSubscriptionsChangedListener() {
                new SubscriptionManager.OnSubscriptionsChangedListener() {
@@ -464,13 +469,21 @@ public class GsmCdmaPhone extends Phone {
        }
        }
    };
    };


    private boolean hasCalling() {
        if (!mFeatureFlags.minimalTelephonyCdmCheck()) return true;
        return mContext.getPackageManager().hasSystemFeature(
            PackageManager.FEATURE_TELEPHONY_CALLING);
    }

    private void initOnce(CommandsInterface ci) {
    private void initOnce(CommandsInterface ci) {
        if (ci instanceof SimulatedRadioControl) {
        if (ci instanceof SimulatedRadioControl) {
            mSimulatedRadioControl = (SimulatedRadioControl) ci;
            mSimulatedRadioControl = (SimulatedRadioControl) ci;
        }
        }


        if (hasCalling()) {
            mCT = mTelephonyComponentFactory.inject(GsmCdmaCallTracker.class.getName())
            mCT = mTelephonyComponentFactory.inject(GsmCdmaCallTracker.class.getName())
                    .makeGsmCdmaCallTracker(this, mFeatureFlags);
                    .makeGsmCdmaCallTracker(this, mFeatureFlags);
        }
        mIccPhoneBookIntManager = mTelephonyComponentFactory
        mIccPhoneBookIntManager = mTelephonyComponentFactory
                .inject(IccPhoneBookInterfaceManager.class.getName())
                .inject(IccPhoneBookInterfaceManager.class.getName())
                .makeIccPhoneBookInterfaceManager(this);
                .makeIccPhoneBookInterfaceManager(this);
@@ -693,7 +706,7 @@ public class GsmCdmaPhone extends Phone {
        unregisterForIccRecordEvents();
        unregisterForIccRecordEvents();
        registerForIccRecordEvents();
        registerForIccRecordEvents();


        mCT.updatePhoneType();
        if (mCT != null) mCT.updatePhoneType();


        int radioState = mCi.getRadioState();
        int radioState = mCi.getRadioState();
        if (radioState != TelephonyManager.RADIO_POWER_UNAVAILABLE) {
        if (radioState != TelephonyManager.RADIO_POWER_UNAVAILABLE) {
@@ -753,6 +766,8 @@ public class GsmCdmaPhone extends Phone {
    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
    @Override
    @Override
    public PhoneConstants.State getState() {
    public PhoneConstants.State getState() {
        if (!hasCalling()) return PhoneConstants.State.IDLE;

        if (mImsPhone != null) {
        if (mImsPhone != null) {
            PhoneConstants.State imsState = mImsPhone.getState();
            PhoneConstants.State imsState = mImsPhone.getState();
            if (imsState != PhoneConstants.State.IDLE) {
            if (imsState != PhoneConstants.State.IDLE) {
@@ -837,6 +852,7 @@ public class GsmCdmaPhone extends Phone {


    @Override
    @Override
    public boolean isDataSuspended() {
    public boolean isDataSuspended() {
        if (mCT == null) return false;
        return mCT.mState != PhoneConstants.State.IDLE && !mSST.isConcurrentVoiceAndDataAllowed();
        return mCT.mState != PhoneConstants.State.IDLE && !mSST.isConcurrentVoiceAndDataAllowed();
    }
    }


@@ -884,7 +900,7 @@ public class GsmCdmaPhone extends Phone {


    @Override
    @Override
    public boolean isInEmergencyCall() {
    public boolean isInEmergencyCall() {
        if (isPhoneTypeGsm()) {
        if (!hasCalling() || isPhoneTypeGsm()) {
            return false;
            return false;
        } else {
        } else {
            return mCT.isInEmergencyCall();
            return mCT.isInEmergencyCall();
@@ -893,7 +909,7 @@ public class GsmCdmaPhone extends Phone {


    @Override
    @Override
    protected void setIsInEmergencyCall() {
    protected void setIsInEmergencyCall() {
        if (!isPhoneTypeGsm()) {
        if (!hasCalling() && !isPhoneTypeGsm()) {
            mCT.setIsInEmergencyCall();
            mCT.setIsInEmergencyCall();
        }
        }
    }
    }
@@ -985,6 +1001,7 @@ public class GsmCdmaPhone extends Phone {


    @Override
    @Override
    public void acceptCall(int videoState) throws CallStateException {
    public void acceptCall(int videoState) throws CallStateException {
        if (!hasCalling()) throw new CallStateException();
        Phone imsPhone = mImsPhone;
        Phone imsPhone = mImsPhone;
        if ( imsPhone != null && imsPhone.getRingingCall().isRinging() ) {
        if ( imsPhone != null && imsPhone.getRingingCall().isRinging() ) {
            imsPhone.acceptCall(videoState);
            imsPhone.acceptCall(videoState);
@@ -995,6 +1012,7 @@ public class GsmCdmaPhone extends Phone {


    @Override
    @Override
    public void rejectCall() throws CallStateException {
    public void rejectCall() throws CallStateException {
        if (!hasCalling()) throw new CallStateException();
        mCT.rejectCall();
        mCT.rejectCall();
    }
    }


@@ -1025,6 +1043,7 @@ public class GsmCdmaPhone extends Phone {


    @Override
    @Override
    public boolean canConference() {
    public boolean canConference() {
        if (!hasCalling()) return false;
        if (mImsPhone != null && mImsPhone.canConference()) {
        if (mImsPhone != null && mImsPhone.canConference()) {
            return true;
            return true;
        }
        }
@@ -1075,12 +1094,13 @@ public class GsmCdmaPhone extends Phone {


    @Override
    @Override
    public void clearDisconnected() {
    public void clearDisconnected() {
        if (!hasCalling()) return;
        mCT.clearDisconnected();
        mCT.clearDisconnected();
    }
    }


    @Override
    @Override
    public boolean canTransfer() {
    public boolean canTransfer() {
        if (isPhoneTypeGsm()) {
        if (hasCalling() && isPhoneTypeGsm()) {
            return mCT.canTransfer();
            return mCT.canTransfer();
        } else {
        } else {
            loge("canTransfer: not possible in CDMA");
            loge("canTransfer: not possible in CDMA");
@@ -1090,7 +1110,7 @@ public class GsmCdmaPhone extends Phone {


    @Override
    @Override
    public void explicitCallTransfer() {
    public void explicitCallTransfer() {
        if (isPhoneTypeGsm()) {
        if (hasCalling() && isPhoneTypeGsm()) {
            mCT.explicitCallTransfer();
            mCT.explicitCallTransfer();
        } else {
        } else {
            loge("explicitCallTransfer: not possible in CDMA");
            loge("explicitCallTransfer: not possible in CDMA");
@@ -1104,11 +1124,13 @@ public class GsmCdmaPhone extends Phone {


    @Override
    @Override
    public GsmCdmaCall getBackgroundCall() {
    public GsmCdmaCall getBackgroundCall() {
        if (!hasCalling()) return null;
        return mCT.mBackgroundCall;
        return mCT.mBackgroundCall;
    }
    }


    @Override
    @Override
    public Call getRingingCall() {
    public Call getRingingCall() {
        if (!hasCalling()) return null;
        Phone imsPhone = mImsPhone;
        Phone imsPhone = mImsPhone;
        // It returns the ringing call of ImsPhone if the ringing call of GSMPhone isn't ringing.
        // It returns the ringing call of ImsPhone if the ringing call of GSMPhone isn't ringing.
        // In CallManager.registerPhone(), it always registers ringing call of ImsPhone, because
        // In CallManager.registerPhone(), it always registers ringing call of ImsPhone, because
@@ -1184,7 +1206,7 @@ public class GsmCdmaPhone extends Phone {


    private boolean handleCallDeflectionIncallSupplementaryService(
    private boolean handleCallDeflectionIncallSupplementaryService(
            String dialString) {
            String dialString) {
        if (dialString.length() > 1) {
        if (!hasCalling() || dialString.length() > 1) {
            return false;
            return false;
        }
        }


@@ -1209,7 +1231,7 @@ public class GsmCdmaPhone extends Phone {
    private boolean handleCallWaitingIncallSupplementaryService(String dialString) {
    private boolean handleCallWaitingIncallSupplementaryService(String dialString) {
        int len = dialString.length();
        int len = dialString.length();


        if (len > 2) {
        if (!hasCalling() || len > 2) {
            return false;
            return false;
        }
        }


@@ -1429,6 +1451,9 @@ public class GsmCdmaPhone extends Phone {
    @Override
    @Override
    public Connection dial(String dialString, @NonNull DialArgs dialArgs,
    public Connection dial(String dialString, @NonNull DialArgs dialArgs,
            Consumer<Phone> chosenPhoneConsumer) throws CallStateException {
            Consumer<Phone> chosenPhoneConsumer) throws CallStateException {
        if (!hasCalling()) {
            throw new CallStateException("Calling feature is not supported!");
        }
        if (!isPhoneTypeGsm() && dialArgs.uusInfo != null) {
        if (!isPhoneTypeGsm() && dialArgs.uusInfo != null) {
            throw new CallStateException("Sending UUS information NOT supported in CDMA!");
            throw new CallStateException("Sending UUS information NOT supported in CDMA!");
        }
        }
@@ -2148,7 +2173,9 @@ public class GsmCdmaPhone extends Phone {


    @Override
    @Override
    public int getEmergencyNumberDbVersion() {
    public int getEmergencyNumberDbVersion() {
        return getEmergencyNumberTracker().getEmergencyNumberDbVersion();
        EmergencyNumberTracker tracker = getEmergencyNumberTracker();
        if (tracker == null) return -1;
        return tracker.getEmergencyNumberDbVersion();
    }
    }


    @Override
    @Override
@@ -3134,6 +3161,8 @@ public class GsmCdmaPhone extends Phone {
     */
     */
    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
    private void syncClirSetting() {
    private void syncClirSetting() {
        if (!hasCalling()) return;

        SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getContext());
        SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getContext());
        migrateClirSettingIfNeeded(sp);
        migrateClirSettingIfNeeded(sp);


@@ -3339,8 +3368,10 @@ public class GsmCdmaPhone extends Phone {
                if (b != null) {
                if (b != null) {
                    updateBroadcastEmergencyCallStateChangesAfterCarrierConfigChanged(b);
                    updateBroadcastEmergencyCallStateChangesAfterCarrierConfigChanged(b);
                    updateCdmaRoamingSettingsAfterCarrierConfigChanged(b);
                    updateCdmaRoamingSettingsAfterCarrierConfigChanged(b);
                    if (hasCalling()) {
                        updateNrSettingsAfterCarrierConfigChanged(b);
                        updateNrSettingsAfterCarrierConfigChanged(b);
                        updateVoNrSettings(b);
                        updateVoNrSettings(b);
                    }
                    updateSsOverCdmaSupported(b);
                    updateSsOverCdmaSupported(b);
                    updateCarrierN1ModeSupported(b);
                    updateCarrierN1ModeSupported(b);
                } else {
                } else {
@@ -4912,6 +4943,7 @@ public class GsmCdmaPhone extends Phone {
     * Handler of RIL Voice Radio Technology changed event.
     * Handler of RIL Voice Radio Technology changed event.
     */
     */
    private void onVoiceRegStateOrRatChanged(int vrs, int vrat) {
    private void onVoiceRegStateOrRatChanged(int vrs, int vrat) {
        if (!hasCalling()) return;
        logd("onVoiceRegStateOrRatChanged");
        logd("onVoiceRegStateOrRatChanged");
        mCT.dispatchCsCallRadioTech(getCsCallRadioTech(vrs, vrat));
        mCT.dispatchCsCallRadioTech(getCsCallRadioTech(vrs, vrat));
    }
    }
@@ -5113,6 +5145,8 @@ public class GsmCdmaPhone extends Phone {
     * Load the current TTY mode in GsmCdmaPhone based on Telecom and UI settings.
     * Load the current TTY mode in GsmCdmaPhone based on Telecom and UI settings.
     */
     */
    private void loadTtyMode() {
    private void loadTtyMode() {
        if (!hasCalling()) return;

        int ttyMode = TelecomManager.TTY_MODE_OFF;
        int ttyMode = TelecomManager.TTY_MODE_OFF;
        TelecomManager telecomManager = mContext.getSystemService(TelecomManager.class);
        TelecomManager telecomManager = mContext.getSystemService(TelecomManager.class);
        if (telecomManager != null) {
        if (telecomManager != null) {
+65 −32
Original line number Original line Diff line number Diff line
@@ -35,6 +35,7 @@ import android.annotation.NonNull;
import android.app.PendingIntent;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Context;
import android.content.Intent;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.AsyncResult;
import android.os.AsyncResult;
import android.os.Handler;
import android.os.Handler;
import android.os.Looper;
import android.os.Looper;
@@ -52,6 +53,7 @@ import android.util.Log;


import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.telephony.data.DataSettingsManager.DataSettingsManagerCallback;
import com.android.internal.telephony.data.DataSettingsManager.DataSettingsManagerCallback;
import com.android.internal.telephony.flags.FeatureFlags;
import com.android.internal.telephony.subscription.SubscriptionInfoInternal;
import com.android.internal.telephony.subscription.SubscriptionInfoInternal;
import com.android.internal.telephony.subscription.SubscriptionManagerService;
import com.android.internal.telephony.subscription.SubscriptionManagerService;
import com.android.internal.telephony.util.ArrayUtils;
import com.android.internal.telephony.util.ArrayUtils;
@@ -122,6 +124,7 @@ public class MultiSimSettingController extends Handler {


    protected final Context mContext;
    protected final Context mContext;
    private final SubscriptionManagerService mSubscriptionManagerService;
    private final SubscriptionManagerService mSubscriptionManagerService;
    private final @NonNull FeatureFlags mFeatureFlags;


    // Keep a record of active primary (non-opportunistic) subscription list.
    // Keep a record of active primary (non-opportunistic) subscription list.
    @NonNull private List<Integer> mPrimarySubList = new ArrayList<>();
    @NonNull private List<Integer> mPrimarySubList = new ArrayList<>();
@@ -201,10 +204,11 @@ public class MultiSimSettingController extends Handler {
    /**
    /**
     * Init instance of MultiSimSettingController.
     * Init instance of MultiSimSettingController.
     */
     */
    public static MultiSimSettingController init(Context context) {
    public static MultiSimSettingController init(Context context,
            @NonNull FeatureFlags featureFlags) {
        synchronized (MultiSimSettingController.class) {
        synchronized (MultiSimSettingController.class) {
            if (sInstance == null) {
            if (sInstance == null) {
                sInstance = new MultiSimSettingController(context);
                sInstance = new MultiSimSettingController(context, featureFlags);
            } else {
            } else {
                Log.wtf(LOG_TAG, "init() called multiple times!  sInstance = " + sInstance);
                Log.wtf(LOG_TAG, "init() called multiple times!  sInstance = " + sInstance);
            }
            }
@@ -213,9 +217,10 @@ public class MultiSimSettingController extends Handler {
    }
    }


    @VisibleForTesting
    @VisibleForTesting
    public MultiSimSettingController(Context context) {
    public MultiSimSettingController(Context context, @NonNull FeatureFlags featureFlags) {
        mContext = context;
        mContext = context;
        mSubscriptionManagerService = SubscriptionManagerService.getInstance();
        mSubscriptionManagerService = SubscriptionManagerService.getInstance();
        mFeatureFlags = featureFlags;


        // Initialize mCarrierConfigLoadedSubIds and register to listen to carrier config change.
        // Initialize mCarrierConfigLoadedSubIds and register to listen to carrier config change.
        TelephonyManager telephonyManager = ((TelephonyManager) mContext.getSystemService(
        TelephonyManager telephonyManager = ((TelephonyManager) mContext.getSystemService(
@@ -239,6 +244,24 @@ public class MultiSimSettingController extends Handler {
                        onCarrierConfigChanged(slotIndex, subId));
                        onCarrierConfigChanged(slotIndex, subId));
    }
    }


    private boolean hasCalling() {
        if (!mFeatureFlags.minimalTelephonyCdmCheck()) return true;
        return mContext.getPackageManager().hasSystemFeature(
                PackageManager.FEATURE_TELEPHONY_CALLING);
    }

    private boolean hasData() {
        if (!mFeatureFlags.minimalTelephonyCdmCheck()) return true;
        return mContext.getPackageManager().hasSystemFeature(
                PackageManager.FEATURE_TELEPHONY_DATA);
    }

    private boolean hasMessaging() {
        if (!mFeatureFlags.minimalTelephonyCdmCheck()) return true;
        return mContext.getPackageManager().hasSystemFeature(
                PackageManager.FEATURE_TELEPHONY_MESSAGING);
    }

    /**
    /**
     * Notify MOBILE_DATA of a subscription is changed.
     * Notify MOBILE_DATA of a subscription is changed.
     */
     */
@@ -606,35 +629,43 @@ public class MultiSimSettingController extends Handler {
                || mActiveModemCount == 1)) {
                || mActiveModemCount == 1)) {
            int subId = mPrimarySubList.get(0);
            int subId = mPrimarySubList.get(0);
            if (DBG) log("updateDefaultValues: to only primary sub " + subId);
            if (DBG) log("updateDefaultValues: to only primary sub " + subId);
            mSubscriptionManagerService.setDefaultDataSubId(subId);
            if (hasData()) mSubscriptionManagerService.setDefaultDataSubId(subId);
            mSubscriptionManagerService.setDefaultVoiceSubId(subId);
            if (hasCalling()) mSubscriptionManagerService.setDefaultVoiceSubId(subId);
            mSubscriptionManagerService.setDefaultSmsSubId(subId);
            if (hasMessaging()) mSubscriptionManagerService.setDefaultSmsSubId(subId);
            sendDefaultSubConfirmedNotification(subId);
            sendDefaultSubConfirmedNotification(subId);
            return;
            return;
        }
        }


        if (DBG) log("updateDefaultValues: records: " + mPrimarySubList);
        if (DBG) log("updateDefaultValues: records: " + mPrimarySubList);


        boolean dataSelected, voiceSelected, smsSelected;
        boolean dataSelected = false;
        boolean voiceSelected = false;
        boolean smsSelected = false;


        if (hasData()) {
            // Update default data subscription.
            // Update default data subscription.
            if (DBG) log("updateDefaultValues: Update default data subscription");
            if (DBG) log("updateDefaultValues: Update default data subscription");
            dataSelected = updateDefaultValue(mPrimarySubList,
            dataSelected = updateDefaultValue(mPrimarySubList,
                    mSubscriptionManagerService.getDefaultDataSubId(),
                    mSubscriptionManagerService.getDefaultDataSubId(),
                    mSubscriptionManagerService::setDefaultDataSubId);
                    mSubscriptionManagerService::setDefaultDataSubId);
        }


        if (hasCalling()) {
            // Update default voice subscription.
            // Update default voice subscription.
            if (DBG) log("updateDefaultValues: Update default voice subscription");
            if (DBG) log("updateDefaultValues: Update default voice subscription");
            voiceSelected = updateDefaultValue(mPrimarySubList,
            voiceSelected = updateDefaultValue(mPrimarySubList,
                    mSubscriptionManagerService.getDefaultVoiceSubId(),
                    mSubscriptionManagerService.getDefaultVoiceSubId(),
                    mSubscriptionManagerService::setDefaultVoiceSubId);
                    mSubscriptionManagerService::setDefaultVoiceSubId);
        }


        if (hasMessaging()) {
            // Update default sms subscription.
            // Update default sms subscription.
            if (DBG) log("updateDefaultValues: Update default sms subscription");
            if (DBG) log("updateDefaultValues: Update default sms subscription");
            smsSelected = updateDefaultValue(mPrimarySubList,
            smsSelected = updateDefaultValue(mPrimarySubList,
                    mSubscriptionManagerService.getDefaultSmsSubId(),
                    mSubscriptionManagerService.getDefaultSmsSubId(),
                    mSubscriptionManagerService::setDefaultSmsSubId,
                    mSubscriptionManagerService::setDefaultSmsSubId,
                    mIsAskEverytimeSupportedForSms);
                    mIsAskEverytimeSupportedForSms);
        }


        boolean autoFallbackEnabled = mContext.getResources().getBoolean(
        boolean autoFallbackEnabled = mContext.getResources().getBoolean(
                com.android.internal.R.bool.config_voice_data_sms_auto_fallback);
                com.android.internal.R.bool.config_voice_data_sms_auto_fallback);
@@ -1023,11 +1054,11 @@ public class MultiSimSettingController extends Handler {


        int autoDefaultSubId = primarySubList.get(0);
        int autoDefaultSubId = primarySubList.get(0);


        if ((primarySubList.size() == 1) && !smsSelected) {
        if (hasMessaging() && (primarySubList.size() == 1) && !smsSelected) {
            mSubscriptionManagerService.setDefaultSmsSubId(autoDefaultSubId);
            mSubscriptionManagerService.setDefaultSmsSubId(autoDefaultSubId);
        }
        }


        if ((primarySubList.size() == 1) && !voiceSelected) {
        if (hasCalling() && (primarySubList.size() == 1) && !voiceSelected) {
            mSubscriptionManagerService.setDefaultVoiceSubId(autoDefaultSubId);
            mSubscriptionManagerService.setDefaultVoiceSubId(autoDefaultSubId);
        }
        }


@@ -1036,6 +1067,7 @@ public class MultiSimSettingController extends Handler {
        log("User pref subId = " + userPrefDataSubId + " current dds " + defaultDataSubId
        log("User pref subId = " + userPrefDataSubId + " current dds " + defaultDataSubId
                + " next active subId " + autoDefaultSubId);
                + " next active subId " + autoDefaultSubId);


        if (hasData()) {
            // If earlier user selected DDS is now available, set that as DDS subId.
            // If earlier user selected DDS is now available, set that as DDS subId.
            if (primarySubList.contains(userPrefDataSubId)
            if (primarySubList.contains(userPrefDataSubId)
                    && SubscriptionManager.isValidSubscriptionId(userPrefDataSubId)
                    && SubscriptionManager.isValidSubscriptionId(userPrefDataSubId)
@@ -1044,6 +1076,7 @@ public class MultiSimSettingController extends Handler {
            } else if (!dataSelected) {
            } else if (!dataSelected) {
                mSubscriptionManagerService.setDefaultDataSubId(autoDefaultSubId);
                mSubscriptionManagerService.setDefaultDataSubId(autoDefaultSubId);
            }
            }
        }


        if (DBG) {
        if (DBG) {
            log("updateUserPreferences: after dds = "
            log("updateUserPreferences: after dds = "
+1 −1
Original line number Original line Diff line number Diff line
@@ -212,7 +212,7 @@ public class PhoneFactory {
                        Looper.myLooper(), featureFlags);
                        Looper.myLooper(), featureFlags);


                TelephonyComponentFactory.getInstance().inject(MultiSimSettingController.class.
                TelephonyComponentFactory.getInstance().inject(MultiSimSettingController.class.
                        getName()).initMultiSimSettingController(context);
                        getName()).initMultiSimSettingController(context, featureFlags);


                if (context.getPackageManager().hasSystemFeature(
                if (context.getPackageManager().hasSystemFeature(
                        PackageManager.FEATURE_TELEPHONY_EUICC)) {
                        PackageManager.FEATURE_TELEPHONY_EUICC)) {
Loading