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

Commit 5a65e2d5 authored by Lee Chou's avatar Lee Chou
Browse files

Authenticated confirmation before deletion of eSim

adds an authentication confirmation before deleting an eSim
this feature is turned on/off in the security page

Bug: 138861284
Test: mp settingsg
Change-Id: I32e0e3bff2091ec1097b3c37fa066d966e3373df
parent c799e923
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -206,6 +206,9 @@
        com.android.settings.intelligence
    </string>

    <!-- Whether the confirmation for sim deletion is defaulted to be on or off-->
    <bool name="config_sim_deletion_confirmation_default_on">false</bool>

    <!-- Package Installer package name -->
    <string name="config_package_installer_package_name" translatable="false">
        com.android.packageinstaller
+5 −0
Original line number Diff line number Diff line
@@ -9013,6 +9013,11 @@
    <!-- [CHAR LIMIT=60] Unlock setting for screen pinning -->
    <string name="screen_pinning_unlock_none">Lock device when unpinning</string>
    <!-- [CHAR LIMIT=60] turn eSim deletion confirmation on/off  -->
    <string name="confirm_sim_deletion_title">Confirm SIM deletion</string>
    <!-- [CHAR LIMIT=NONE] eSim deletion confirmation description  -->
    <string name="confirm_sim_deletion_description">Verify it\u0027s you before erasing a downloaded SIM</string>
    <!-- Opening string on the dialog that prompts the user to confirm that they really want to delete their existing work profile. The administration app icon and name appear after the final colon. [CHAR LIMIT=NONE] -->
    <string name="opening_paragraph_delete_profile_unknown_company">This work profile is managed by:</string>
    <!-- Summary for work profile accounts group. [CHAR LIMIT=25] -->
+8 −1
Original line number Diff line number Diff line
@@ -147,4 +147,11 @@
        android:summary="@string/summary_placeholder"
        android:fragment="com.android.settings.security.ScreenPinningSettings" />

    <SwitchPreference
        android:order="90"
        android:key="confirm_sim_deletion"
        android:title="@string/confirm_sim_deletion_title"
        android:summary="@string/confirm_sim_deletion_description"
        settings:controller="com.android.settings.security.ConfirmSimDeletionPreferenceController"/>

</PreferenceScreen>
 No newline at end of file
+30 −14
Original line number Diff line number Diff line
@@ -18,15 +18,18 @@ package com.android.settings.network.telephony;

import android.content.Context;
import android.content.Intent;
import android.provider.Settings;
import android.telephony.SubscriptionInfo;
import android.telephony.euicc.EuiccManager;

import androidx.fragment.app.Fragment;
import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;

import com.android.settings.R;
import com.android.settings.core.BasePreferenceController;
import com.android.settings.network.SubscriptionUtil;
import com.android.settings.security.ConfirmSimDeletionPreferenceController;
import com.android.settings.wifi.dpp.WifiDppUtils;

/** This controls a preference allowing the user to delete the profile for an eSIM. */
public class DeleteSimProfilePreferenceController extends BasePreferenceController {
@@ -34,16 +37,19 @@ public class DeleteSimProfilePreferenceController extends BasePreferenceControll
    private SubscriptionInfo mSubscriptionInfo;
    private Fragment mParentFragment;
    private int mRequestCode;
    private boolean mConfirmationDefaultOn;

    public DeleteSimProfilePreferenceController(Context context, String preferenceKey) {
        super(context, preferenceKey);
        mConfirmationDefaultOn =
                context.getResources()
                        .getBoolean(R.bool.config_sim_deletion_confirmation_default_on);
    }

    public void init(int subscriptionId, Fragment parentFragment, int requestCode) {
        mParentFragment = parentFragment;

        for (SubscriptionInfo info : SubscriptionUtil.getAvailableSubscriptions(
                mContext)) {
        for (SubscriptionInfo info : SubscriptionUtil.getAvailableSubscriptions(mContext)) {
            if (info.getSubscriptionId() == subscriptionId && info.isEmbedded()) {
                mSubscriptionInfo = info;
                break;
@@ -53,16 +59,27 @@ public class DeleteSimProfilePreferenceController extends BasePreferenceControll
    }

    @Override
    public void displayPreference(PreferenceScreen screen) {
        super.displayPreference(screen);
        final Preference pref = screen.findPreference(getPreferenceKey());
        pref.setOnPreferenceClickListener(p -> {
    public boolean handlePreferenceTreeClick(Preference preference) {
        boolean confirmDeletion =
                Settings.Global.getInt(
                                mContext.getContentResolver(),
                                ConfirmSimDeletionPreferenceController.KEY_CONFIRM_SIM_DELETION,
                                mConfirmationDefaultOn ? 1 : 0)
                        == 1;
        if (confirmDeletion) {
            WifiDppUtils.showLockScreen(mContext, () -> deleteSim());
        } else {
            deleteSim();
        }

        return true;
    }

    private void deleteSim() {
        final Intent intent = new Intent(EuiccManager.ACTION_DELETE_SUBSCRIPTION_PRIVILEGED);
            intent.putExtra(EuiccManager.EXTRA_SUBSCRIPTION_ID,
                    mSubscriptionInfo.getSubscriptionId());
        intent.putExtra(EuiccManager.EXTRA_SUBSCRIPTION_ID, mSubscriptionInfo.getSubscriptionId());
        mParentFragment.startActivityForResult(intent, mRequestCode);
            return true;
        });
        // result handled in MobileNetworkSettings
    }

    @Override
@@ -73,5 +90,4 @@ public class DeleteSimProfilePreferenceController extends BasePreferenceControll
            return CONDITIONALLY_UNAVAILABLE;
        }
    }

}
+5 −3
Original line number Diff line number Diff line
@@ -274,10 +274,12 @@ public class MobileNetworkSettings extends RestrictedDashboardFragment {
                break;

            case REQUEST_CODE_DELETE_SUBSCRIPTION:
                if (resultCode != Activity.RESULT_CANCELED) {
                    final Activity activity = getActivity();
                    if (activity != null && !activity.isFinishing()) {
                        activity.finish();
                    }
                }
                break;

            default:
Loading