Extract and fix logic for showing rac dialog.
Added tests to make sure the logic makes sense. Bug: 335745726 Test: make, manual, atest SubscriptionUtilRoboTest, atest SubscriptionUtilTest, atest ResetNetworkTest Change-Id: I7092f2747f1ca1f9ef4dc99275a916b9e24d8b28
This commit is contained in:
@@ -542,9 +542,7 @@ public class SubscriptionUtil {
|
||||
return;
|
||||
}
|
||||
|
||||
if (isCarrierRac(context, carrierId)
|
||||
&& (!isConnectedToWifi(context)
|
||||
|| isConnectedToMobileDataWithDifferentSubId(context, subId))) {
|
||||
if (shouldShowRacDialogWhenErasingEsim(context, subId, carrierId)) {
|
||||
context.startActivity(EuiccRacConnectivityDialogActivity.getIntent(context, subId));
|
||||
} else {
|
||||
context.startActivity(DeleteEuiccSubscriptionDialogActivity.getIntent(context, subId));
|
||||
@@ -883,18 +881,35 @@ public class SubscriptionUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if warning dialog should be presented when erasing all eSIMS.
|
||||
* 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) {
|
||||
public static boolean shouldShowRacDialogWhenErasingAllEsims(@NonNull Context context) {
|
||||
if (sEnableRacDialogForTesting != null) {
|
||||
return sEnableRacDialogForTesting;
|
||||
}
|
||||
|
||||
return !isConnectedToWifi(context) && hasSubscriptionWithRacCarrier(context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if warning dialog should be presented when erasing eSIM.
|
||||
*
|
||||
* @param context Context to check if any sim carrier use RAC and device Wi-Fi connection.
|
||||
* @param subId Subscription ID for the single eSIM.
|
||||
* @param carrierId Carrier ID for the single eSIM.
|
||||
* @return {@code true} if dialog should be presented to the user.
|
||||
*/
|
||||
@VisibleForTesting
|
||||
static boolean shouldShowRacDialogWhenErasingEsim(
|
||||
@NonNull Context context, int subId, int carrierId) {
|
||||
return isCarrierRac(context, carrierId)
|
||||
&& !isConnectedToWifi(context)
|
||||
&& !isConnectedToMobileDataWithDifferentSubId(context, subId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves NetworkCapabilities for the active network.
|
||||
*
|
||||
|
Reference in New Issue
Block a user