diff options
author | Robert Greenwalt <rgreenwalt@google.com> | 2015-06-22 15:56:46 -0700 |
---|---|---|
committer | Robert Greenwalt <rgreenwalt@google.com> | 2015-06-22 15:56:46 -0700 |
commit | d314de0aa495e7a5e5d8a8754f2bdb1d09d45a21 (patch) | |
tree | 7dc139d219225cf9e17e49868c4dc3a3a89caef9 /telephony | |
parent | 9622c0cc900da84c903f0395053dd4d9a9e4f53d (diff) | |
download | frameworks_base-d314de0aa495e7a5e5d8a8754f2bdb1d09d45a21.zip frameworks_base-d314de0aa495e7a5e5d8a8754f2bdb1d09d45a21.tar.gz frameworks_base-d314de0aa495e7a5e5d8a8754f2bdb1d09d45a21.tar.bz2 |
Return reasonable phone type if no sim inserted.
With no sim, there's no subscription, no default phone, etc.
If we're asked for phone type for an invalid sub, just use the
first phone.
bug: 20760370
Change-Id: Ide7b0679e7253e1f1ce563a68fbbec1ff8c24daf
Diffstat (limited to 'telephony')
-rw-r--r-- | telephony/java/android/telephony/TelephonyManager.java | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index b7ca749..cec11cf 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -944,10 +944,17 @@ public class TelephonyManager { /** {@hide} */ @SystemApi public int getCurrentPhoneType(int subId) { - int phoneId = SubscriptionManager.getPhoneId(subId); + int phoneId; + if (subId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) { + // if we don't have any sims, we don't have subscriptions, but we + // still may want to know what type of phone we've got. + phoneId = 0; + } else { + phoneId = SubscriptionManager.getPhoneId(subId); + } try{ ITelephony telephony = getITelephony(); - if (telephony != null) { + if (telephony != null && subId != SubscriptionManager.INVALID_SUBSCRIPTION_ID) { return telephony.getActivePhoneTypeForSubscriber(subId); } else { // This can happen when the ITelephony interface is not up yet. |