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

Commit db1402a4 authored by Jan Tomljanovic's avatar Jan Tomljanovic
Browse files

Always confirm eSim removal.

Test: atest DeleteSimProfilePreferenceControllerTest
Bug: 313604661

Change-Id: I0c43790bf43bedcc2e8075aa7be0b25876c731b4
parent 4345908c
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -258,9 +258,6 @@
        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
+0 −8
Original line number Diff line number Diff line
@@ -204,14 +204,6 @@
        settings:keywords="@string/keywords_app_pinning"
        settings:controller="com.android.settings.security.ScreenPinningPreferenceController" />

    <SwitchPreferenceCompat
        android:order="290"
        android:key="confirm_sim_deletion"
        android:title="@string/confirm_sim_deletion_title"
        android:summary="@string/confirm_sim_deletion_description"
        settings:isPreferenceVisible="@bool/config_show_sim_info"
        settings:controller="com.android.settings.security.ConfirmSimDeletionPreferenceController" />

    <Preference
        android:order="300"
        android:id="@+id/memtag_page"
+0 −8
Original line number Diff line number Diff line
@@ -106,14 +106,6 @@
        settings:keywords="@string/keywords_app_pinning"
        settings:controller="com.android.settings.security.ScreenPinningPreferenceController" />

    <SwitchPreferenceCompat
        android:order="290"
        android:key="confirm_sim_deletion"
        android:title="@string/confirm_sim_deletion_title"
        android:summary="@string/confirm_sim_deletion_description"
        settings:isPreferenceVisible="@bool/config_show_sim_info"
        settings:controller="com.android.settings.security.ConfirmSimDeletionPreferenceController" />

  <com.android.settingslib.RestrictedPreference
        android:order="300"
        android:id="@+id/memtag_page"
+1 −9
Original line number Diff line number Diff line
@@ -32,7 +32,6 @@ import androidx.fragment.app.FragmentManager;

import com.android.settings.R;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
import com.android.settings.network.helper.ConfirmationSimDeletionPredicate;
import com.android.settings.system.ResetDashboardFragment;
import com.android.settings.wifi.dpp.WifiDppUtils;

@@ -76,14 +75,7 @@ public class EraseEuiccDataDialogFragment extends InstrumentedDialogFragment imp

        if (which == DialogInterface.BUTTON_POSITIVE) {
            Context context = getContext();
            if (ConfirmationSimDeletionPredicate.getSingleton().test(context)) {
                // Create a "verify it's you" verification over keyguard
                // when "erase" button been pressed.
                // This might protect from erasing by some automation process.
            WifiDppUtils.showLockScreen(context, () -> runAsyncWipe(context));
            } else {
                runAsyncWipe(context);
            }
        }
    }

+0 −66
Original line number Diff line number Diff line
/*
 * Copyright (C) 2021 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.android.settings.network.helper;

import android.app.KeyguardManager;
import android.content.Context;
import android.provider.Settings;

import com.android.settings.R;

import java.util.function.Predicate;

/**
 * {@link Predicate} for detecting the configuration of confirm SIM deletion.
 */
public class ConfirmationSimDeletionPredicate implements Predicate<Context> {

    public static final String KEY_CONFIRM_SIM_DELETION = "confirm_sim_deletion";

    private static final ConfirmationSimDeletionPredicate sSingleton =
            new ConfirmationSimDeletionPredicate();

    // Get singleton of this predicate
    public static final ConfirmationSimDeletionPredicate getSingleton() {
        return sSingleton;
    }

    /**
     * Get default configuration of confirm SIM deletion.
     *
     * @param Context context
     * @return the configuration of confirm SIM deletion
     */
    private static boolean getDefaultValue(Context context) {
        return context.getResources()
                .getBoolean(R.bool.config_sim_deletion_confirmation_default_on);
    }

    /**
     * Get the configuration of confirm SIM deletion.
     *
     * @param Context context
     * @return the configuration of confirm SIM deletion
     */
    public boolean test(Context context) {
        final KeyguardManager keyguardManager = context.getSystemService(KeyguardManager.class);
        if ((keyguardManager != null) && !keyguardManager.isKeyguardSecure()) {
            return false;
        }
        return Settings.Global.getInt(context.getContentResolver(), KEY_CONFIRM_SIM_DELETION,
                getDefaultValue(context) ? 1 : 0) == 1;
    }
}
Loading