Loading src/com/android/settings/network/EraseEuiccDataDialogFragment.java +20 −7 Original line number Diff line number Diff line Loading @@ -32,7 +32,9 @@ 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; public class EraseEuiccDataDialogFragment extends InstrumentedDialogFragment implements DialogInterface.OnClickListener { Loading Loading @@ -73,6 +75,18 @@ public class EraseEuiccDataDialogFragment extends InstrumentedDialogFragment imp } if (which == DialogInterface.BUTTON_POSITIVE) { if (ConfirmationSimDeletionPredicate.getSingleton().test(getContext())) { // 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(getContext(), () -> runAsyncWipe()); } else { runAsyncWipe(); } } } private void runAsyncWipe() { AsyncTask.execute(new Runnable() { @Override public void run() { Loading @@ -82,4 +96,3 @@ public class EraseEuiccDataDialogFragment extends InstrumentedDialogFragment imp }); } } } src/com/android/settings/network/helper/ConfirmationSimDeletionPredicate.java 0 → 100644 +66 −0 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; } } src/com/android/settings/security/ConfirmSimDeletionPreferenceController.java +3 −1 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ import androidx.preference.TwoStatePreference; import com.android.settings.R; import com.android.settings.core.BasePreferenceController; import com.android.settings.network.helper.ConfirmationSimDeletionPredicate; import com.android.settings.network.telephony.MobileNetworkUtils; import com.android.settings.overlay.FeatureFactory; import com.android.settings.wifi.dpp.WifiDppUtils; Loading @@ -34,7 +35,8 @@ import com.android.settingslib.core.instrumentation.MetricsFeatureProvider; /** Enable/disable user confirmation before deleting an eSim */ public class ConfirmSimDeletionPreferenceController extends BasePreferenceController implements Preference.OnPreferenceChangeListener{ public static final String KEY_CONFIRM_SIM_DELETION = "confirm_sim_deletion"; public static final String KEY_CONFIRM_SIM_DELETION = ConfirmationSimDeletionPredicate.KEY_CONFIRM_SIM_DELETION; private boolean mConfirmationDefaultOn; private MetricsFeatureProvider mMetricsFeatureProvider; Loading Loading
src/com/android/settings/network/EraseEuiccDataDialogFragment.java +20 −7 Original line number Diff line number Diff line Loading @@ -32,7 +32,9 @@ 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; public class EraseEuiccDataDialogFragment extends InstrumentedDialogFragment implements DialogInterface.OnClickListener { Loading Loading @@ -73,6 +75,18 @@ public class EraseEuiccDataDialogFragment extends InstrumentedDialogFragment imp } if (which == DialogInterface.BUTTON_POSITIVE) { if (ConfirmationSimDeletionPredicate.getSingleton().test(getContext())) { // 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(getContext(), () -> runAsyncWipe()); } else { runAsyncWipe(); } } } private void runAsyncWipe() { AsyncTask.execute(new Runnable() { @Override public void run() { Loading @@ -82,4 +96,3 @@ public class EraseEuiccDataDialogFragment extends InstrumentedDialogFragment imp }); } } }
src/com/android/settings/network/helper/ConfirmationSimDeletionPredicate.java 0 → 100644 +66 −0 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; } }
src/com/android/settings/security/ConfirmSimDeletionPreferenceController.java +3 −1 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ import androidx.preference.TwoStatePreference; import com.android.settings.R; import com.android.settings.core.BasePreferenceController; import com.android.settings.network.helper.ConfirmationSimDeletionPredicate; import com.android.settings.network.telephony.MobileNetworkUtils; import com.android.settings.overlay.FeatureFactory; import com.android.settings.wifi.dpp.WifiDppUtils; Loading @@ -34,7 +35,8 @@ import com.android.settingslib.core.instrumentation.MetricsFeatureProvider; /** Enable/disable user confirmation before deleting an eSim */ public class ConfirmSimDeletionPreferenceController extends BasePreferenceController implements Preference.OnPreferenceChangeListener{ public static final String KEY_CONFIRM_SIM_DELETION = "confirm_sim_deletion"; public static final String KEY_CONFIRM_SIM_DELETION = ConfirmationSimDeletionPredicate.KEY_CONFIRM_SIM_DELETION; private boolean mConfirmationDefaultOn; private MetricsFeatureProvider mMetricsFeatureProvider; Loading