From 5f612a4b442494d08259a976eccb7192ffa0c534 Mon Sep 17 00:00:00 2001 From: Antony Sargent Date: Thu, 11 Jul 2019 11:04:09 -0700 Subject: [PATCH] Fix erasing of eSIMs for some devices Doing a factory data reset used to always erase eSIMs. Then a few months ago we added a default-on checkbox to let users opt out of erasing the eSIM during this process, but only had it show for some devices (ones which support the "fastboot oem esim_erase" command) by adding a system property named masterclear.allow_retain_esim_profiles_after_fdr. When recently updating the strings shown in the factory data reset screen and the confirmation dialog, we changed the code so that if that the checkbox is hidden we'll pass false for the ERASE_ESIMS_EXTRA parameter sent to the factory data reset confirmation dialog. This had the unintended side effect of making devices that don't specify true for masterclear.allow_retain_esim_profiles_after_fdr skip erasing the eSIM. This CL fixes that by removing the "is the checkbox hidden" check, going back to the previous behavior of just using the checkbox value, which is on by default even if hidden. Fixes: 135284765 Test: make RunSettingsRoboTests Change-Id: Ia9f335920e4e3c4a90f0a6a49d1722a0c19ea83d --- src/com/android/settings/MasterClear.java | 3 +-- tests/robotests/src/com/android/settings/MasterClearTest.java | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/com/android/settings/MasterClear.java b/src/com/android/settings/MasterClear.java index 14a6aed9e79..0df39842f9d 100644 --- a/src/com/android/settings/MasterClear.java +++ b/src/com/android/settings/MasterClear.java @@ -182,8 +182,7 @@ public class MasterClear extends InstrumentedFragment implements OnGlobalLayoutL void showFinalConfirmation() { final Bundle args = new Bundle(); args.putBoolean(ERASE_EXTERNAL_EXTRA, mExternalStorage.isChecked()); - args.putBoolean(ERASE_ESIMS_EXTRA, - mEsimStorageContainer.getVisibility() == View.VISIBLE && mEsimStorage.isChecked()); + args.putBoolean(ERASE_ESIMS_EXTRA, mEsimStorage.isChecked()); new SubSettingLauncher(getContext()) .setDestination(MasterClearConfirm.class.getName()) .setArguments(args) diff --git a/tests/robotests/src/com/android/settings/MasterClearTest.java b/tests/robotests/src/com/android/settings/MasterClearTest.java index 813e4aafa67..73adf937c86 100644 --- a/tests/robotests/src/com/android/settings/MasterClearTest.java +++ b/tests/robotests/src/com/android/settings/MasterClearTest.java @@ -163,7 +163,7 @@ public class MasterClearTest { verify(context).startActivity(intent.capture()); assertThat(intent.getValue().getBundleExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_ARGUMENTS) .getBoolean(MasterClear.ERASE_ESIMS_EXTRA, false)) - .isFalse(); + .isTrue(); } @Test