diff options
| author | 2019-01-30 21:19:57 -0800 | |
|---|---|---|
| committer | 2019-01-31 19:08:08 -0800 | |
| commit | 19661a4b4a79c461c0cbdd29e1265ed77124bc6b (patch) | |
| tree | a9bc58e15585884afa7363a32f920baa77115ae1 | |
| parent | f97346024864791cacab68b6cb9ba74978ea8217 (diff) | |
Move getPhoneCount implementation back to TelephonyManager.
Moving it inside iTelephony creates problems. Some components call
getPhoneCount during initialization while iTelephony service is not
even running, which will cause phone process to crash.
Bug: 123667461
Test: manual
Change-Id: I51199eaf0bd87055c21fe61af50f4c353137d621
| -rw-r--r-- | telephony/java/android/telephony/TelephonyManager.java | 39 | ||||
| -rw-r--r-- | telephony/java/com/android/internal/telephony/ITelephony.aidl | 5 |
2 files changed, 19 insertions, 25 deletions
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index a1fb09017bcd..7c3bde4293c7 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -354,27 +354,26 @@ public class TelephonyManager { * Returns 3 for Tri standby mode.(Tri SIM functionality) */ public int getPhoneCount() { - int phoneCount = 0; - - // check for voice and data support, 0 if not supported - if (!isVoiceCapable() && !isSmsCapable()) { - ConnectivityManager cm = (ConnectivityManager) mContext.getSystemService( - Context.CONNECTIVITY_SERVICE); - if (cm != null) { - if (!cm.isNetworkSupported(ConnectivityManager.TYPE_MOBILE)) { - return phoneCount; + int phoneCount = 1; + switch (getMultiSimConfiguration()) { + case UNKNOWN: + ConnectivityManager cm = mContext == null ? null : (ConnectivityManager) mContext + .getSystemService(Context.CONNECTIVITY_SERVICE); + // check for voice and data support, 0 if not supported + if (!isVoiceCapable() && !isSmsCapable() && cm != null + && !cm.isNetworkSupported(ConnectivityManager.TYPE_MOBILE)) { + phoneCount = 0; + } else { + phoneCount = 1; } - } - } - - phoneCount = 1; - try { - ITelephony telephony = getITelephony(); - if (telephony != null) { - phoneCount = telephony.getNumOfActiveSims(); - } - } catch (RemoteException ex) { - Rlog.e(TAG, "getNumOfActiveSims RemoteException", ex); + break; + case DSDS: + case DSDA: + phoneCount = PhoneConstants.MAX_PHONE_COUNT_DUAL_SIM; + break; + case TSTS: + phoneCount = PhoneConstants.MAX_PHONE_COUNT_TRI_SIM; + break; } return phoneCount; } diff --git a/telephony/java/com/android/internal/telephony/ITelephony.aidl b/telephony/java/com/android/internal/telephony/ITelephony.aidl index 762d8860afcd..bc43feaf0e15 100644 --- a/telephony/java/com/android/internal/telephony/ITelephony.aidl +++ b/telephony/java/com/android/internal/telephony/ITelephony.aidl @@ -1843,11 +1843,6 @@ interface ITelephony { * @hide */ void switchMultiSimConfig(int numOfSims); - /** - * Get how many modems have been activated on the phone - * @hide - */ - int getNumOfActiveSims(); /** * Get if reboot is required upon altering modems configurations |