Add new warning dialogue when user is Resetting mobile network settings.

If the user is reseting mobile network settings and have all these
conditions:
- No Wi-fi
- Has check to delete all eSIMs
- Has a least one RAC sim carrier
Then show the warning dialogue.

Test: make, manually test, atest SubSettingLauncherTest, atest ResetNetworkTest,  atest SubscriptionUtilTest
Bug: 328649510
Merged-In: I47d9b868b649b259d5e4008ec742317d2cb7cf51
Change-Id: I47d9b868b649b259d5e4008ec742317d2cb7cf51
(cherry picked from commit 147cc19b53)
This commit is contained in:
Rafael Higuera Silva
2024-03-13 23:18:47 +00:00
parent 2244c6296f
commit 363535192d
8 changed files with 195 additions and 17 deletions

View File

@@ -27,6 +27,9 @@ import android.content.Intent;
import android.view.View;
import android.widget.CheckBox;
import com.android.settings.network.SubscriptionUtil;
import com.android.settings.network.telephony.EuiccRacConnectivityDialogActivity;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
@@ -51,6 +54,7 @@ public class ResetNetworkTest {
@Test
@Ignore
public void showFinalConfirmation_checkboxVisible_eraseEsimChecked() {
SubscriptionUtil.setEnableRacDialogForTesting(true);
mResetNetwork.mEsimContainer.setVisibility(View.VISIBLE);
mResetNetwork.mEsimCheckbox.setChecked(true);
@@ -61,6 +65,21 @@ public class ResetNetworkTest {
.isNotNull();
}
@Test
public void showFinalConfirmation_checkboxVisible_eraseEsimChecked_showRacWarningDialog() {
SubscriptionUtil.setEnableRacDialogForTesting(true);
mResetNetwork.mEsimContainer.setVisibility(View.VISIBLE);
mResetNetwork.mEsimCheckbox.setChecked(true);
mResetNetwork.showFinalConfirmation();
Intent intent = shadowOf(mActivity).getNextStartedActivity();
assertThat(intent).isNotNull();
assertThat(intent.getComponent().getClassName()).isEqualTo(
EuiccRacConnectivityDialogActivity.class.getName());
}
@Test
public void showFinalConfirmation_checkboxVisible_eraseEsimUnchecked() {
mResetNetwork.mEsimContainer.setVisibility(View.VISIBLE);

View File

@@ -67,7 +67,7 @@ public class SubSettingLauncherTest {
}
@Test(expected = IllegalStateException.class)
public void cannotReuseLauncher() {
public void cannotReuseLauncher_launchMethod() {
final SubSettingLauncher launcher = spy(new SubSettingLauncher(mContext))
.setDestination(SubSettingLauncherTest.class.getName())
.setSourceMetricsCategory(123);
@@ -76,6 +76,43 @@ public class SubSettingLauncherTest {
launcher.launch();
}
@Test(expected = IllegalArgumentException.class)
public void verifyIntent_noDestination() {
final SubSettingLauncher launcher =
spy(new SubSettingLauncher(mContext))
.setSourceMetricsCategory(123);
doNothing().when(launcher).launch(any(Intent.class));
launcher.launchWithIntent(launcher.toIntent());
}
@Test(expected = IllegalArgumentException.class)
public void verifyIntent_noMetricsCategory() {
final SubSettingLauncher launcher = spy(new SubSettingLauncher(mContext))
.setDestination(SubSettingLauncherTest.class.getName());
doNothing().when(launcher).launch(any(Intent.class));
launcher.launchWithIntent(launcher.toIntent());
}
@Test(expected = IllegalArgumentException.class)
public void verifyIntent_notTheCorrectClass() {
final SubSettingLauncher launcher = spy(new SubSettingLauncher(mContext))
.setDestination(SubSettingLauncherTest.class.getName())
.setSourceMetricsCategory(123);
doNothing().when(launcher).launch(any(Intent.class));
launcher.launchWithIntent(new Intent(Intent.ACTION_MAIN));
}
@Test(expected = IllegalStateException.class)
public void cannotReuseLauncher_launchAndLaunchWithIntentMethod() {
final SubSettingLauncher launcher =
spy(new SubSettingLauncher(mContext))
.setDestination(SubSettingLauncherTest.class.getName())
.setSourceMetricsCategory(123);
doNothing().when(launcher).launch(any(Intent.class));
launcher.launchWithIntent(launcher.toIntent());
launcher.launch();
}
@Test(expected = IllegalArgumentException.class)
public void launch_noSourceMetricsCategory_shouldCrash() {
final SubSettingLauncher launcher = spy(new SubSettingLauncher(mContext))