diff options
| author | 2016-03-18 13:28:40 -0700 | |
|---|---|---|
| committer | 2016-04-25 10:33:34 -0700 | |
| commit | 2c222510f602197354f9eb1f26871a70e5892606 (patch) | |
| tree | cfeda7e72d9265add9e9911e89b94f2b20ccf660 | |
| parent | 7ecd7671b75b2ae7c4d20928722b4a1d41bd62ff (diff) | |
Change to return phone count as 0 if voice, sms, data not supported.
If any of the 3 is supported, and multi-sim capabilities are unknown,
return 1.
Bug: 23016052
Change-Id: Id19aaf33d9a86fc24116704c668977c727c2a1f2
| -rw-r--r-- | telephony/java/android/telephony/TelephonyManager.java | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index 394fc27bf9b2..01c75cfae7cc 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -24,6 +24,7 @@ import android.app.ActivityThread; import android.content.ContentResolver; import android.content.Context; import android.content.Intent; +import android.net.ConnectivityManager; import android.net.Uri; import android.os.BatteryStats; import android.os.ResultReceiver; @@ -183,6 +184,7 @@ public class TelephonyManager { /** * Returns the number of phones available. + * Returns 0 if none of voice, sms, data is not supported * Returns 1 for Single standby mode (Single SIM functionality) * Returns 2 for Dual standby mode.(Dual SIM functionality) */ @@ -190,7 +192,28 @@ public class TelephonyManager { int phoneCount = 1; switch (getMultiSimConfiguration()) { case UNKNOWN: - phoneCount = 1; + // if voice or sms or data is supported, return 1 otherwise 0 + if (isVoiceCapable() || isSmsCapable()) { + phoneCount = 1; + } else { + // todo: try to clean this up further by getting rid of the nested conditions + if (mContext == null) { + phoneCount = 1; + } else { + // check for data support + ConnectivityManager cm = (ConnectivityManager)mContext.getSystemService( + Context.CONNECTIVITY_SERVICE); + if (cm == null) { + phoneCount = 1; + } else { + if (cm.isNetworkSupported(ConnectivityManager.TYPE_MOBILE)) { + phoneCount = 1; + } else { + phoneCount = 0; + } + } + } + } break; case DSDS: case DSDA: |