diff --git a/res/values/strings.xml b/res/values/strings.xml
index e23a09d69ce..ea2530caea8 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -12309,14 +12309,14 @@
Use Wi\u2011Fi for calls to improve quality
-
- Cross SIM calling
+
+ Backup calling
-
- Allow %1$s call over the default data SIM when %1$s is unavailable.
+
+ If %1$s is unavailable, use your mobile data SIM to make and receive %1$s calls.
- cross sim calling
+ backup calling
Incoming MMS message
diff --git a/res/xml/mobile_network_settings.xml b/res/xml/mobile_network_settings.xml
index eeb9d5c9bf6..a100d6b04b5 100644
--- a/res/xml/mobile_network_settings.xml
+++ b/res/xml/mobile_network_settings.xml
@@ -172,12 +172,12 @@
settings:controller="com.android.settings.network.telephony.VideoCallingPreferenceController"/>
+ android:summary="@string/backup_calling_setting_summary"
+ settings:keywords="@string/keywords_backup_calling"
+ settings:controller="com.android.settings.network.telephony.BackupCallingPreferenceController"/>
diff --git a/res/xml/network_provider_calls_sms.xml b/res/xml/network_provider_calls_sms.xml
index 2fa2eb79446..a677d1b349a 100644
--- a/res/xml/network_provider_calls_sms.xml
+++ b/res/xml/network_provider_calls_sms.xml
@@ -44,6 +44,14 @@
settings:allowDividerAbove="true"
/>
+
+
subList = getActiveSubscriptions();
+ if (subList.size() < 2) {
+ return CONDITIONALLY_UNAVAILABLE;
+ }
+ return (getPreferences(subList).size() >= 1) ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
+ }
+
+ @Override
+ public void displayPreference(PreferenceScreen screen) {
+ super.displayPreference(screen);
+
+ PreferenceCategory prefCategory = screen.findPreference(getPreferenceKey());
+ updatePreferenceList(prefCategory);
+ prefCategory.setVisible(isAvailable());
+ }
+
+ @Override
+ public void updateState(Preference preference) {
+ super.updateState(preference);
+ // Do nothing in this case since preference is invisible
+ if (preference == null) {
+ return;
+ }
+ updatePreferenceList((PreferenceCategory) preference);
+ }
+
+ private String getPreferenceKey(int subscriptionId) {
+ return getPreferenceKey() + "_subId_" + subscriptionId;
+ }
+
+ private SwitchPreference getPreference(SubscriptionInfo subInfo) {
+ int subId = subInfo.getSubscriptionId();
+ BackupCallingPreferenceController prefCtrl =
+ new BackupCallingPreferenceController(mContext, getPreferenceKey(subId));
+ prefCtrl.init(subId);
+ if (prefCtrl.getAvailabilityStatus(subId) != BasePreferenceController.AVAILABLE) {
+ return null;
+ }
+ SwitchPreference pref = new SwitchPreference(mContext);
+ prefCtrl.updateState(pref);
+ pref.setTitle(subInfo.getDisplayName());
+ return pref;
+ }
+
+ private List getPreferences(List subList) {
+ return subList.stream()
+ .map(subInfo -> getPreference(subInfo))
+ .filter(Objects::nonNull)
+ .collect(Collectors.toList());
+ }
+
+ private List getActiveSubscriptions() {
+ return SubscriptionUtil.getActiveSubscriptions(
+ mContext.getSystemService(SubscriptionManager.class));
+ }
+
+ private void updatePreferenceList(PreferenceCategory prefCategory) {
+ List prefList = getPreferences(getActiveSubscriptions());
+
+ prefCategory.removeAll();
+ for (SwitchPreference pref : prefList) {
+ prefCategory.addPreference(pref);
+ }
+ }
+}
diff --git a/tests/unit/src/com/android/settings/network/telephony/CrossSimCallingPreferenceControllerTest.java b/tests/unit/src/com/android/settings/network/telephony/BackupCallingPreferenceControllerTest.java
similarity index 87%
rename from tests/unit/src/com/android/settings/network/telephony/CrossSimCallingPreferenceControllerTest.java
rename to tests/unit/src/com/android/settings/network/telephony/BackupCallingPreferenceControllerTest.java
index 4b8a2728e6f..4e110f0d018 100644
--- a/tests/unit/src/com/android/settings/network/telephony/CrossSimCallingPreferenceControllerTest.java
+++ b/tests/unit/src/com/android/settings/network/telephony/BackupCallingPreferenceControllerTest.java
@@ -32,17 +32,17 @@ import org.junit.Test;
import org.junit.runner.RunWith;
@RunWith(AndroidJUnit4.class)
-public class CrossSimCallingPreferenceControllerTest {
+public class BackupCallingPreferenceControllerTest {
private static final int SUB_ID = 2;
- private CrossSimCallingPreferenceController mController;
+ private BackupCallingPreferenceController mController;
private Context mContext;
@Before
public void setUp() {
mContext = spy(ApplicationProvider.getApplicationContext());
- mController = new CrossSimCallingPreferenceController(mContext, "cross_sim_calling_key");
+ mController = new BackupCallingPreferenceController(mContext, "backup_calling_key");
mController.init(SUB_ID);
}