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

Commit 27f0e494 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 8594052 from b8a73751 to tm-d1-release

Change-Id: If688c37557e4217002b48803d5b0189ba163e2ce
parents b9d1d942 b8a73751
Loading
Loading
Loading
Loading
+51 −4
Original line number Diff line number Diff line
@@ -20,10 +20,12 @@ import android.annotation.CallbackExecutor;
import android.annotation.NonNull;
import android.content.ContentResolver;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.os.SystemProperties;
import android.preference.PreferenceManager;
import android.provider.Settings;
import android.sysprop.TelephonyProperties;
import android.telephony.CarrierConfigManager;
@@ -185,7 +187,9 @@ public class DataSettingsManager extends Handler {
    public void handleMessage(Message msg) {
        switch (msg.what) {
            case EVENT_DATA_CONFIG_UPDATED: {
                // TODO: Add config changed logic if any settings are related to carrier configs
                if (mDataConfigManager.isConfigCarrierSpecific()) {
                    setDefaultDataRoamingEnabled();
                }
                break;
            }
            case EVENT_CALL_STATE_CHANGED: {
@@ -515,9 +519,9 @@ public class DataSettingsManager extends Handler {
    }

    /**
     * Check whether data roaming is enabled by default, if either the
     * {@link CarrierConfigManager#KEY_CARRIER_DEFAULT_DATA_ROAMING_ENABLED_BOOL} value and
     * system property "ro.com.android.dataroaming" are true.
     * Check whether data roaming is enabled by default.
     * This is true if {@link CarrierConfigManager#KEY_CARRIER_DEFAULT_DATA_ROAMING_ENABLED_BOOL}
     * or the system property "ro.com.android.dataroaming" are true.
     * @return {@code true} if data roaming is enabled by default and {@code false} otherwise.
     */
    public boolean isDefaultDataRoamingEnabled() {
@@ -526,6 +530,49 @@ public class DataSettingsManager extends Handler {
                        .isDataRoamingEnabledByDefault();
    }

    /**
     * Set default value for {@link android.provider.Settings.Global#DATA_ROAMING} if the user
     * has not manually set the value. The default value is {@link #isDefaultDataRoamingEnabled()}.
     */
    public void setDefaultDataRoamingEnabled() {
        // For SSSS, this is a per-phone property from DATA_ROAMING_IS_USER_SETTING_KEY.
        // For DSDS, this is a per-sub property from Settings.Global.DATA_ROAMING + subId.
        // If the user has not manually set the value, use the default from carrier configurations.
        boolean useCarrierSpecificDefault = false;
        if (mPhone.getContext().getSystemService(TelephonyManager.class).getSimCount() != 1) {
            String setting = Settings.Global.DATA_ROAMING + mPhone.getSubId();
            try {
                Settings.Global.getInt(mResolver, setting);
            } catch (Settings.SettingNotFoundException ex) {
                // For multi-SIM phones, use the default value if uninitialized.
                useCarrierSpecificDefault = true;
            }
        } else if (!isDataRoamingFromUserAction()) {
            // For single-SIM phones, use the default value if user action is not set.
            useCarrierSpecificDefault = true;
        }
        log("setDefaultDataRoamingEnabled: useCarrierSpecificDefault=" + useCarrierSpecificDefault);
        if (useCarrierSpecificDefault) {
            boolean defaultVal = isDefaultDataRoamingEnabled();
            setDataRoamingEnabled(defaultVal);
        }
    }

    /**
     * Get whether the user has manually enabled or disabled data roaming from settings.
     * @return {@code true} if the user has enabled data roaming and {@code false} if they have not.
     */
    private boolean isDataRoamingFromUserAction() {
        final SharedPreferences sp = PreferenceManager
                .getDefaultSharedPreferences(mPhone.getContext());
        // Since we don't want to unset user preferences after a system update, default to true if
        // the preference does not exist and set it to false explicitly from factory reset.
        if (!sp.contains(Phone.DATA_ROAMING_IS_USER_SETTING_KEY)) {
            sp.edit().putBoolean(Phone.DATA_ROAMING_IS_USER_SETTING_KEY, false).commit();
        }
        return sp.getBoolean(Phone.DATA_ROAMING_IS_USER_SETTING_KEY, true);
    }

    private @NonNull DataEnabledOverride getDataEnabledOverride() {
        return new DataEnabledOverride(SubscriptionController.getInstance()
                .getDataEnabledOverrideRules(mSubId));
+50 −0
Original line number Diff line number Diff line
@@ -172,12 +172,18 @@ public class UiccController extends Handler {
    // SharedPreference key for saving the known card strings (ICCIDs and EIDs) ordered by card ID
    private static final String CARD_STRINGS = "card_strings";

    // SharedPreference key for saving the flag to set removable eSIM as default eUICC or not.
    private static final String REMOVABLE_ESIM_AS_DEFAULT = "removable_esim";

    // Whether the device has an eUICC built in.
    private boolean mHasBuiltInEuicc = false;

    // Whether the device has a currently active built in eUICC
    private boolean mHasActiveBuiltInEuicc = false;

    // Use removable eSIM as default eUICC. This flag will be set from phone debug hidden menu
    private boolean mUseRemovableEsimAsDefault = false;

    // The physical slots which correspond to built-in eUICCs
    private final int[] mEuiccSlots;

@@ -260,6 +266,10 @@ public class UiccController extends Handler {
                this, EVENT_MULTI_SIM_CONFIG_CHANGED, null);

        mPinStorage = new PinStorage(mContext);
        if (!TelephonyUtils.IS_USER) {
            mUseRemovableEsimAsDefault = PreferenceManager.getDefaultSharedPreferences(mContext)
                    .getBoolean(REMOVABLE_ESIM_AS_DEFAULT, false);
        }
    }

    /**
@@ -935,6 +945,21 @@ public class UiccController extends Handler {
        if (mDefaultEuiccCardId == TEMPORARILY_UNSUPPORTED_CARD_ID) {
            return UNSUPPORTED_CARD_ID;
        }
        // To support removable eSIM to pass GCT/PTCRB test in DSDS mode, we should make sure all
        // the download/activation requests are by default route to the removable eSIM slot.
        // To satisfy above condition, we should return removable eSIM cardId as default.
        if (mUseRemovableEsimAsDefault && !TelephonyUtils.IS_USER) {
            for (UiccSlot slot : mUiccSlots) {
                if (slot != null && slot.isRemovable() && slot.isEuicc() && slot.isActive()) {
                    int cardId = convertToPublicCardId(slot.getEid());
                    Rlog.d(LOG_TAG,
                            "getCardIdForDefaultEuicc: Removable eSIM is default, cardId: "
                                    + cardId);
                    return cardId;
                }
            }
            Rlog.d(LOG_TAG, "getCardIdForDefaultEuicc: No removable eSIM slot is found");
        }
        return mDefaultEuiccCardId;
    }

@@ -1398,6 +1423,30 @@ public class UiccController extends Handler {
        return false;
    }

    /**
     * Set removable eSIM as default.
     * This API is added for test purpose to set removable eSIM as default eUICC.
     * @param isDefault Flag to set removable eSIM as default or not.
     */
    public void setRemovableEsimAsDefaultEuicc(boolean isDefault) {
        mUseRemovableEsimAsDefault = isDefault;
        SharedPreferences.Editor editor =
                PreferenceManager.getDefaultSharedPreferences(mContext).edit();
        editor.putBoolean(REMOVABLE_ESIM_AS_DEFAULT, isDefault);
        editor.apply();
        Rlog.d(LOG_TAG, "setRemovableEsimAsDefaultEuicc isDefault: " + isDefault);
    }

    /**
     * Returns whether the removable eSIM is default eUICC or not.
     * This API is added for test purpose to check whether removable eSIM is default eUICC or not.
     */
    public boolean isRemovableEsimDefaultEuicc() {
        Rlog.d(LOG_TAG, "mUseRemovableEsimAsDefault: " + mUseRemovableEsimAsDefault);
        return mUseRemovableEsimAsDefault;
    }


    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
    private void log(String string) {
        Rlog.d(LOG_TAG, string);
@@ -1435,6 +1484,7 @@ public class UiccController extends Handler {
        pw.println(" mCardStrings=" + mCardStrings);
        pw.println(" mDefaultEuiccCardId=" + mDefaultEuiccCardId);
        pw.println(" mPhoneIdToSlotId=" + Arrays.toString(mPhoneIdToSlotId));
        pw.println(" mUseRemovableEsimAsDefault=" + mUseRemovableEsimAsDefault);
        pw.println(" mUiccSlots: size=" + mUiccSlots.length);
        for (int i = 0; i < mUiccSlots.length; i++) {
            if (mUiccSlots[i] == null) {
+3 −0
Original line number Diff line number Diff line
@@ -1436,6 +1436,9 @@ public class DataNetworkControllerTest extends TelephonyTest {
                CarrierConfigManager.KEY_CARRIER_METERED_ROAMING_APN_TYPES_STRINGS,
                new String[]{"default", "dun", "supl"});
        carrierConfigChanged();
        // Manually set data roaming to false in case ro.com.android.dataroaming is true.
        // TODO(b/232575718): Figure out a way to mock ro.com.android.dataroaming for tests.
        mDataNetworkControllerUT.getDataSettingsManager().setDataRoamingEnabled(false);
        // Device is roaming
        serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE,
                NetworkRegistrationInfo.REGISTRATION_STATE_ROAMING);