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
Change-Id: I47d9b868b649b259d5e4008ec742317d2cb7cf51
This commit is contained in:
Rafael Higuera Silva
2024-03-13 23:18:47 +00:00
parent 14b1831fda
commit 147cc19b53
8 changed files with 195 additions and 17 deletions

View File

@@ -80,6 +80,7 @@ public class SubscriptionUtil {
private static List<SubscriptionInfo> sAvailableResultsForTesting;
private static List<SubscriptionInfo> sActiveResultsForTesting;
@Nullable private static Boolean sEnableRacDialogForTesting;
@VisibleForTesting
public static void setAvailableSubscriptionsForTesting(List<SubscriptionInfo> results) {
@@ -91,6 +92,11 @@ public class SubscriptionUtil {
sActiveResultsForTesting = results;
}
@VisibleForTesting
public static void setEnableRacDialogForTesting(boolean enableRacDialog) {
sEnableRacDialogForTesting = enableRacDialog;
}
public static List<SubscriptionInfo> getActiveSubscriptions(SubscriptionManager manager) {
//TODO (b/315499317) : Refactor the subscription utils.
@@ -875,6 +881,19 @@ public class SubscriptionUtil {
return Arrays.stream(carriersThatUseRAC).anyMatch(cid -> cid == carrierId);
}
/**
* Check if warning dialog should be presented when erasing all eSIMS.
*
* @param context Context to check if any sim carrier use RAC and device Wi-Fi connection.
* @return {@code true} if dialog should be presented to the user.
*/
public static boolean shouldShowRacDialog(@NonNull Context context) {
if (sEnableRacDialogForTesting != null) {
return sEnableRacDialogForTesting;
}
return !isConnectedToWifi(context) && hasSubscriptionWithRacCarrier(context);
}
/**
* Retrieves NetworkCapabilities for the active network.
*