Merge "Return reasonable phone type if no sim inserted." into mnc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
0c5c8570dc
@@ -944,10 +944,17 @@ public class TelephonyManager {
|
|||||||
/** {@hide} */
|
/** {@hide} */
|
||||||
@SystemApi
|
@SystemApi
|
||||||
public int getCurrentPhoneType(int subId) {
|
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{
|
try{
|
||||||
ITelephony telephony = getITelephony();
|
ITelephony telephony = getITelephony();
|
||||||
if (telephony != null) {
|
if (telephony != null && subId != SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
|
||||||
return telephony.getActivePhoneTypeForSubscriber(subId);
|
return telephony.getActivePhoneTypeForSubscriber(subId);
|
||||||
} else {
|
} else {
|
||||||
// This can happen when the ITelephony interface is not up yet.
|
// This can happen when the ITelephony interface is not up yet.
|
||||||
|
|||||||
Reference in New Issue
Block a user