diff options
| -rw-r--r-- | services/core/java/com/android/server/MmsServiceBroker.java | 22 | ||||
| -rw-r--r-- | services/core/java/com/android/server/TelephonyRegistry.java | 46 |
2 files changed, 20 insertions, 48 deletions
diff --git a/services/core/java/com/android/server/MmsServiceBroker.java b/services/core/java/com/android/server/MmsServiceBroker.java index 92d1da5be7a2..c0f10a3c86e1 100644 --- a/services/core/java/com/android/server/MmsServiceBroker.java +++ b/services/core/java/com/android/server/MmsServiceBroker.java @@ -16,8 +16,6 @@ package com.android.server; -import static android.telephony.SubscriptionManager.INVALID_SIM_SLOT_INDEX; - import android.Manifest; import android.app.AppOpsManager; import android.app.PendingIntent; @@ -39,7 +37,6 @@ import android.os.SystemClock; import android.os.UserHandle; import android.service.carrier.CarrierMessagingService; import android.telephony.SmsManager; -import android.telephony.SubscriptionInfo; import android.telephony.SubscriptionManager; import android.telephony.TelephonyManager; import android.util.Slog; @@ -526,11 +523,11 @@ public class MmsServiceBroker extends SystemService { // Grant permission for the carrier app. Intent intent = new Intent(action); - TelephonyManager telephonyManager = (TelephonyManager) - mContext.getSystemService(Context.TELEPHONY_SERVICE); - List<String> carrierPackages = telephonyManager - .getCarrierPackageNamesForIntentAndPhone( - intent, getPhoneIdFromSubId(subId)); + TelephonyManager telephonyManager = + (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE); + List<String> carrierPackages = + telephonyManager.getCarrierPackageNamesForIntentAndPhone( + intent, SubscriptionManager.getPhoneId(subId)); if (carrierPackages != null && carrierPackages.size() == 1) { LocalServices.getService(UriGrantsManagerInternal.class) .grantUriPermissionFromIntent(callingUid, carrierPackages.get(0), @@ -542,13 +539,4 @@ public class MmsServiceBroker extends SystemService { return contentUri; } } - - private int getPhoneIdFromSubId(int subId) { - SubscriptionManager subManager = (SubscriptionManager) - mContext.getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE); - if (subManager == null) return INVALID_SIM_SLOT_INDEX; - SubscriptionInfo info = subManager.getActiveSubscriptionInfo(subId); - if (info == null) return INVALID_SIM_SLOT_INDEX; - return info.getSimSlotIndex(); - } } diff --git a/services/core/java/com/android/server/TelephonyRegistry.java b/services/core/java/com/android/server/TelephonyRegistry.java index 7f62747b447d..6bc117be7f65 100644 --- a/services/core/java/com/android/server/TelephonyRegistry.java +++ b/services/core/java/com/android/server/TelephonyRegistry.java @@ -16,7 +16,6 @@ package com.android.server; -import static android.telephony.SubscriptionManager.INVALID_SIM_SLOT_INDEX; import static android.telephony.TelephonyManager.ACTION_MULTI_SIM_CONFIG_CHANGED; import static android.telephony.TelephonyRegistryManager.SIM_ACTIVATION_TYPE_DATA; import static android.telephony.TelephonyRegistryManager.SIM_ACTIVATION_TYPE_VOICE; @@ -60,7 +59,6 @@ import android.telephony.PreciseDisconnectCause; import android.telephony.Rlog; import android.telephony.ServiceState; import android.telephony.SignalStrength; -import android.telephony.SubscriptionInfo; import android.telephony.SubscriptionManager; import android.telephony.TelephonyManager; import android.telephony.data.ApnSetting; @@ -99,7 +97,7 @@ import java.util.NoSuchElementException; * and 15973975 by saving the phoneId of the registrant and then using the * phoneId when deciding to to make a callback. This is necessary because * a subId changes from to a dummy value when a SIM is removed and thus won't - * compare properly. Because getPhoneIdFromSubId(int subId) handles + * compare properly. Because SubscriptionManager.getPhoneId(int subId) handles * the dummy value conversion we properly do the callbacks. * * Eventually we may want to remove the notion of dummy value but for now this @@ -133,7 +131,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { int subId = SubscriptionManager.INVALID_SUBSCRIPTION_ID; - int phoneId = SubscriptionManager.INVALID_SIM_SLOT_INDEX; + int phoneId = SubscriptionManager.INVALID_PHONE_INDEX; boolean matchPhoneStateListenerEvent(int events) { return (callback != null) && ((events & this.events) != 0); @@ -233,7 +231,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { private int mDefaultSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID; - private int mDefaultPhoneId = SubscriptionManager.INVALID_SIM_SLOT_INDEX; + private int mDefaultPhoneId = SubscriptionManager.INVALID_PHONE_INDEX; private int[] mRingingCallState; @@ -360,7 +358,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { SubscriptionManager.getDefaultSubscriptionId()); int newDefaultPhoneId = intent.getIntExtra( SubscriptionManager.EXTRA_SLOT_INDEX, - getPhoneIdFromSubId(newDefaultSubId)); + SubscriptionManager.getPhoneId(newDefaultSubId)); if (DBG) { log("onReceive:current mDefaultSubId=" + mDefaultSubId + " current mDefaultPhoneId=" + mDefaultPhoneId @@ -770,7 +768,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { return; } - int phoneId = getPhoneIdFromSubId(subId); + int phoneId = SubscriptionManager.getPhoneId(subId); synchronized (mRecords) { // register IBinder b = callback.asBinder(); @@ -1101,7 +1099,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { // Called only by Telecomm to communicate call state across different phone accounts. So // there is no need to add a valid subId or slotId. broadcastCallStateChanged(state, phoneNumber, - SubscriptionManager.INVALID_SIM_SLOT_INDEX, + SubscriptionManager.INVALID_PHONE_INDEX, SubscriptionManager.INVALID_SUBSCRIPTION_ID); } @@ -1326,7 +1324,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { synchronized (mRecords) { mCarrierNetworkChangeState = active; for (int subId : subIds) { - int phoneId = getPhoneIdFromSubId(subId); + int phoneId = SubscriptionManager.getPhoneId(subId); if (VDBG) { log("notifyCarrierNetworkChange: active=" + active + "subId: " + subId); @@ -1359,7 +1357,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { log("notifyCellInfoForSubscriber: subId=" + subId + " cellInfo=" + cellInfo); } - int phoneId = getPhoneIdFromSubId(subId); + int phoneId = SubscriptionManager.getPhoneId(subId); synchronized (mRecords) { if (validatePhoneId(phoneId)) { mCellInfo.set(phoneId, cellInfo); @@ -1450,7 +1448,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { log("notifyCallForwardingChangedForSubscriber: subId=" + subId + " cfi=" + cfi); } - int phoneId = getPhoneIdFromSubId(subId); + int phoneId = SubscriptionManager.getPhoneId(subId); synchronized (mRecords) { if (validatePhoneId(phoneId)) { mCallForwarding[phoneId] = cfi; @@ -1478,7 +1476,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { if (!checkNotifyPermission("notifyDataActivity()" )) { return; } - int phoneId = getPhoneIdFromSubId(subId); + int phoneId = SubscriptionManager.getPhoneId(subId); synchronized (mRecords) { if (validatePhoneId(phoneId)) { mDataActivity[phoneId] = state; @@ -1629,7 +1627,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { log("notifyCellLocationForSubscriber: subId=" + subId + " cellLocation=" + cellLocation); } - int phoneId = getPhoneIdFromSubId(subId); + int phoneId = SubscriptionManager.getPhoneId(subId); synchronized (mRecords) { if (validatePhoneId(phoneId)) { mCellLocation[phoneId] = cellLocation; @@ -1657,7 +1655,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { if (!checkNotifyPermission("notifyOtaspChanged()" )) { return; } - int phoneId = getPhoneIdFromSubId(subId); + int phoneId = SubscriptionManager.getPhoneId(subId); synchronized (mRecords) { if (validatePhoneId(phoneId)) { mOtaspMode[phoneId] = otaspMode; @@ -1761,7 +1759,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { if (!checkNotifyPermission("notifyImsCallDisconnectCause()")) { return; } - int phoneId = getPhoneIdFromSubId(subId); + int phoneId = SubscriptionManager.getPhoneId(subId); synchronized (mRecords) { if (validatePhoneId(phoneId)) { mImsReasonInfo.set(phoneId, imsReasonInfo); @@ -1821,7 +1819,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { if (VDBG) { log("notifySrvccStateChanged: subId=" + subId + " srvccState=" + state); } - int phoneId = getPhoneIdFromSubId(subId); + int phoneId = SubscriptionManager.getPhoneId(subId); synchronized (mRecords) { if (validatePhoneId(phoneId)) { mSrvccState[phoneId] = state; @@ -2229,7 +2227,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { intent.putExtra(SubscriptionManager.EXTRA_SUBSCRIPTION_INDEX, subId); } // If the phoneId is invalid, the broadcast is for overall call state. - if (phoneId != SubscriptionManager.INVALID_SIM_SLOT_INDEX) { + if (phoneId != SubscriptionManager.INVALID_PHONE_INDEX) { intent.putExtra(PHONE_CONSTANTS_SLOT_KEY, phoneId); intent.putExtra(SubscriptionManager.EXTRA_SLOT_INDEX, phoneId); } @@ -2702,18 +2700,4 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { private static CallQuality createCallQuality() { return new CallQuality(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); } - - private int getPhoneIdFromSubId(int subId) { - SubscriptionManager subManager = (SubscriptionManager) - mContext.getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE); - if (subManager == null) return INVALID_SIM_SLOT_INDEX; - - if (subId == SubscriptionManager.DEFAULT_SUBSCRIPTION_ID) { - subId = SubscriptionManager.getDefaultSubscriptionId(); - } - - SubscriptionInfo info = subManager.getActiveSubscriptionInfo(subId); - if (info == null) return INVALID_SIM_SLOT_INDEX; - return info.getSimSlotIndex(); - } } |