Merge "Fixing UI issue to display preferred network type." into lmp-mr1-dev
diff --git a/src/com/android/phone/NotificationMgr.java b/src/com/android/phone/NotificationMgr.java
index 88a13bd..c38be71 100644
--- a/src/com/android/phone/NotificationMgr.java
+++ b/src/com/android/phone/NotificationMgr.java
@@ -590,32 +590,38 @@
*/
void updateNetworkSelection(int serviceState) {
if (TelephonyCapabilities.supportsNetworkSelection(mPhone)) {
- // get the shared preference of network_selection.
- // empty is auto mode, otherwise it is the operator alpha name
- // in case there is no operator name, check the operator numeric
- SharedPreferences sp =
- PreferenceManager.getDefaultSharedPreferences(mContext);
- String networkSelection =
- sp.getString(PhoneBase.NETWORK_SELECTION_NAME_KEY, "");
- if (TextUtils.isEmpty(networkSelection)) {
- networkSelection =
- sp.getString(PhoneBase.NETWORK_SELECTION_KEY, "");
- }
+ int subId = mPhone.getSubId();
+ if (SubscriptionManager.isValidSubscriptionId(subId)) {
+ // get the shared preference of network_selection.
+ // empty is auto mode, otherwise it is the operator alpha name
+ // in case there is no operator name, check the operator numeric
+ SharedPreferences sp =
+ PreferenceManager.getDefaultSharedPreferences(mContext);
+ String networkSelection =
+ sp.getString(PhoneBase.NETWORK_SELECTION_NAME_KEY + subId, "");
+ if (TextUtils.isEmpty(networkSelection)) {
+ networkSelection =
+ sp.getString(PhoneBase.NETWORK_SELECTION_KEY + subId, "");
+ }
- if (DBG) log("updateNetworkSelection()..." + "state = " +
- serviceState + " new network " + networkSelection);
+ if (DBG) log("updateNetworkSelection()..." + "state = " +
+ serviceState + " new network " + networkSelection);
- if (serviceState == ServiceState.STATE_OUT_OF_SERVICE
- && !TextUtils.isEmpty(networkSelection)) {
- if (!mSelectedUnavailableNotify) {
- showNetworkSelection(networkSelection);
- mSelectedUnavailableNotify = true;
+ if (serviceState == ServiceState.STATE_OUT_OF_SERVICE
+ && !TextUtils.isEmpty(networkSelection)) {
+ if (!mSelectedUnavailableNotify) {
+ showNetworkSelection(networkSelection);
+ mSelectedUnavailableNotify = true;
+ }
+ } else {
+ if (mSelectedUnavailableNotify) {
+ cancelNetworkSelection();
+ mSelectedUnavailableNotify = false;
+ }
}
} else {
- if (mSelectedUnavailableNotify) {
- cancelNetworkSelection();
- mSelectedUnavailableNotify = false;
- }
+ if (DBG) log("updateNetworkSelection()..." + "state = " +
+ serviceState + " not updating network due to invalid subId " + subId);
}
}
}
diff --git a/src/com/android/services/telephony/TelephonyGlobals.java b/src/com/android/services/telephony/TelephonyGlobals.java
index 11c3c64..02ef639 100644
--- a/src/com/android/services/telephony/TelephonyGlobals.java
+++ b/src/com/android/services/telephony/TelephonyGlobals.java
@@ -21,6 +21,9 @@
import com.android.internal.telephony.Phone;
import com.android.internal.telephony.PhoneFactory;
+import java.util.ArrayList;
+import java.util.List;
+
/**
* Singleton entry point for the telephony-services app. Initializes ongoing systems relating to
* PSTN calls. This is started when the device starts and will be restarted automatically
@@ -36,7 +39,8 @@
/** The application context. */
private final Context mContext;
- private TtyManager mTtyManager;
+ // For supporting MSIM phone, change Phone and TtyManager as 1 to 1
+ private List<TtyManager> mTtyManagers = new ArrayList<>();
/**
* Persists the specified parameters.
@@ -55,10 +59,10 @@
}
public void onCreate() {
- // TODO: Make this work with Multi-SIM devices
- Phone phone = PhoneFactory.getDefaultPhone();
- if (phone != null) {
- mTtyManager = new TtyManager(mContext, phone);
+ // Make this work with Multi-SIM devices
+ Phone[] phones = PhoneFactory.getPhones();
+ for (Phone phone : phones) {
+ mTtyManagers.add(new TtyManager(mContext, phone));
}
TelecomAccountRegistry.getInstance(mContext).setupOnBoot();
diff --git a/src/com/android/services/telephony/TtyManager.java b/src/com/android/services/telephony/TtyManager.java
index 6c8a495..a3aeeb2 100644
--- a/src/com/android/services/telephony/TtyManager.java
+++ b/src/com/android/services/telephony/TtyManager.java
@@ -122,13 +122,12 @@
private static int telecomModeToPhoneMode(int telecomMode) {
switch (telecomMode) {
+ // AT command only has 0 and 1, so mapping VCO
+ // and HCO to FULL
case TelecomManager.TTY_MODE_FULL:
- return Phone.TTY_MODE_FULL;
case TelecomManager.TTY_MODE_VCO:
- return Phone.TTY_MODE_VCO;
case TelecomManager.TTY_MODE_HCO:
- return Phone.TTY_MODE_HCO;
- case TelecomManager.TTY_MODE_OFF:
+ return Phone.TTY_MODE_FULL;
default:
return Phone.TTY_MODE_OFF;
}