Added multi sim support for Brazil channel 50 messages.
Now we display the channel 50 enable/disable menu to the user
if one of the inserted sim is Brazilian sim. Though we only enable
channel 50 on the Brazilian sim subs.
bug: 28787384
Change-Id: Iaec5da8d849d4dcda43e7d5725c332a6e9c7e1db
diff --git a/src/com/android/cellbroadcastreceiver/CellBroadcastSettings.java b/src/com/android/cellbroadcastreceiver/CellBroadcastSettings.java
index 6a1e290..f5d5966 100644
--- a/src/com/android/cellbroadcastreceiver/CellBroadcastSettings.java
+++ b/src/com/android/cellbroadcastreceiver/CellBroadcastSettings.java
@@ -232,13 +232,21 @@
TelephonyManager tm = (TelephonyManager) getActivity().getSystemService(
Context.TELEPHONY_SERVICE);
- int subId = SubscriptionManager.getDefaultSmsSubscriptionId();
- if (subId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
- subId = SubscriptionManager.getDefaultSubscriptionId();
- }
+ // We display channel 50 enable/disable menu if one of the followings is true
+ // 1. The setting through resource overlay is set to true.
+ // 2. At least one SIM inserted is Brazilian SIM.
- boolean enableChannel50Support = res.getBoolean(R.bool.show_brazil_settings) ||
- COUNTRY_BRAZIL.equals(tm.getSimCountryIso(subId));
+ boolean enableChannel50Support = res.getBoolean(R.bool.show_brazil_settings);
+
+ if (!enableChannel50Support) {
+ SubscriptionManager sm = SubscriptionManager.from(getContext());
+ for (int subId : sm.getActiveSubscriptionIdList()) {
+ if (COUNTRY_BRAZIL.equals(tm.getSimCountryIso(subId))) {
+ enableChannel50Support = true;
+ break;
+ }
+ }
+ }
if (!enableChannel50Support) {
preferenceScreen.removePreference(findPreference(KEY_CATEGORY_BRAZIL_SETTINGS));