Merge "TelephonyManager: cache service handles"
This commit is contained in:
committed by
Android (Google) Code Review
commit
b342a82bc3
@@ -801,11 +801,7 @@ public final class SmsManager {
|
||||
"Invalid pdu format. format must be either 3gpp or 3gpp2");
|
||||
}
|
||||
try {
|
||||
ISms iSms = ISms.Stub.asInterface(
|
||||
TelephonyFrameworkInitializer
|
||||
.getTelephonyServiceManager()
|
||||
.getSmsServiceRegisterer()
|
||||
.get());
|
||||
ISms iSms = TelephonyManager.getSmsService();
|
||||
if (iSms != null) {
|
||||
iSms.injectSmsPduForSubscriber(
|
||||
getSubscriptionId(), pdu, format, receivedIntent);
|
||||
@@ -1642,7 +1638,7 @@ public final class SmsManager {
|
||||
* the service does not exist.
|
||||
*/
|
||||
private static ISms getISmsServiceOrThrow() {
|
||||
ISms iSms = getISmsService();
|
||||
ISms iSms = TelephonyManager.getSmsService();
|
||||
if (iSms == null) {
|
||||
throw new UnsupportedOperationException("Sms is not supported");
|
||||
}
|
||||
@@ -1650,11 +1646,7 @@ public final class SmsManager {
|
||||
}
|
||||
|
||||
private static ISms getISmsService() {
|
||||
return ISms.Stub.asInterface(
|
||||
TelephonyFrameworkInitializer
|
||||
.getTelephonyServiceManager()
|
||||
.getSmsServiceRegisterer()
|
||||
.get());
|
||||
return TelephonyManager.getSmsService();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2091,11 +2083,7 @@ public final class SmsManager {
|
||||
public boolean isSMSPromptEnabled() {
|
||||
ISms iSms = null;
|
||||
try {
|
||||
iSms = ISms.Stub.asInterface(
|
||||
TelephonyFrameworkInitializer
|
||||
.getTelephonyServiceManager()
|
||||
.getSmsServiceRegisterer()
|
||||
.get());
|
||||
iSms = TelephonyManager.getSmsService();
|
||||
return iSms.isSMSPromptEnabled();
|
||||
} catch (RemoteException ex) {
|
||||
return false;
|
||||
|
||||
@@ -1141,11 +1141,7 @@ public class SubscriptionManager {
|
||||
SubscriptionInfo subInfo = null;
|
||||
|
||||
try {
|
||||
ISub iSub = ISub.Stub.asInterface(
|
||||
TelephonyFrameworkInitializer
|
||||
.getTelephonyServiceManager()
|
||||
.getSubscriptionServiceRegisterer()
|
||||
.get());
|
||||
ISub iSub = TelephonyManager.getSubscriptionService();
|
||||
if (iSub != null) {
|
||||
subInfo = iSub.getActiveSubscriptionInfo(subId, mContext.getOpPackageName(),
|
||||
mContext.getFeatureId());
|
||||
@@ -1179,11 +1175,7 @@ public class SubscriptionManager {
|
||||
SubscriptionInfo result = null;
|
||||
|
||||
try {
|
||||
ISub iSub = ISub.Stub.asInterface(
|
||||
TelephonyFrameworkInitializer
|
||||
.getTelephonyServiceManager()
|
||||
.getSubscriptionServiceRegisterer()
|
||||
.get());
|
||||
ISub iSub = TelephonyManager.getSubscriptionService();
|
||||
if (iSub != null) {
|
||||
result = iSub.getActiveSubscriptionInfoForIccId(iccId, mContext.getOpPackageName(),
|
||||
mContext.getFeatureId());
|
||||
@@ -1217,11 +1209,7 @@ public class SubscriptionManager {
|
||||
SubscriptionInfo result = null;
|
||||
|
||||
try {
|
||||
ISub iSub = ISub.Stub.asInterface(
|
||||
TelephonyFrameworkInitializer
|
||||
.getTelephonyServiceManager()
|
||||
.getSubscriptionServiceRegisterer()
|
||||
.get());
|
||||
ISub iSub = TelephonyManager.getSubscriptionService();
|
||||
if (iSub != null) {
|
||||
result = iSub.getActiveSubscriptionInfoForSimSlotIndex(slotIndex,
|
||||
mContext.getOpPackageName(), mContext.getFeatureId());
|
||||
@@ -1245,11 +1233,7 @@ public class SubscriptionManager {
|
||||
List<SubscriptionInfo> result = null;
|
||||
|
||||
try {
|
||||
ISub iSub = ISub.Stub.asInterface(
|
||||
TelephonyFrameworkInitializer
|
||||
.getTelephonyServiceManager()
|
||||
.getSubscriptionServiceRegisterer()
|
||||
.get());
|
||||
ISub iSub = TelephonyManager.getSubscriptionService();
|
||||
if (iSub != null) {
|
||||
result = iSub.getAllSubInfoList(mContext.getOpPackageName(),
|
||||
mContext.getFeatureId());
|
||||
@@ -1330,11 +1314,7 @@ public class SubscriptionManager {
|
||||
List<SubscriptionInfo> activeList = null;
|
||||
|
||||
try {
|
||||
ISub iSub = ISub.Stub.asInterface(
|
||||
TelephonyFrameworkInitializer
|
||||
.getTelephonyServiceManager()
|
||||
.getSubscriptionServiceRegisterer()
|
||||
.get());
|
||||
ISub iSub = TelephonyManager.getSubscriptionService();
|
||||
if (iSub != null) {
|
||||
activeList = iSub.getActiveSubscriptionInfoList(mContext.getOpPackageName(),
|
||||
mContext.getFeatureId());
|
||||
@@ -1385,11 +1365,7 @@ public class SubscriptionManager {
|
||||
List<SubscriptionInfo> result = null;
|
||||
|
||||
try {
|
||||
ISub iSub = ISub.Stub.asInterface(
|
||||
TelephonyFrameworkInitializer
|
||||
.getTelephonyServiceManager()
|
||||
.getSubscriptionServiceRegisterer()
|
||||
.get());
|
||||
ISub iSub = TelephonyManager.getSubscriptionService();
|
||||
if (iSub != null) {
|
||||
result = iSub.getAvailableSubscriptionInfoList(mContext.getOpPackageName(),
|
||||
mContext.getFeatureId());
|
||||
@@ -1428,11 +1404,7 @@ public class SubscriptionManager {
|
||||
List<SubscriptionInfo> result = null;
|
||||
|
||||
try {
|
||||
ISub iSub = ISub.Stub.asInterface(
|
||||
TelephonyFrameworkInitializer
|
||||
.getTelephonyServiceManager()
|
||||
.getSubscriptionServiceRegisterer()
|
||||
.get());
|
||||
ISub iSub = TelephonyManager.getSubscriptionService();
|
||||
if (iSub != null) {
|
||||
result = iSub.getAccessibleSubscriptionInfoList(mContext.getOpPackageName());
|
||||
}
|
||||
@@ -1461,11 +1433,7 @@ public class SubscriptionManager {
|
||||
public void requestEmbeddedSubscriptionInfoListRefresh() {
|
||||
int cardId = TelephonyManager.from(mContext).getCardIdForDefaultEuicc();
|
||||
try {
|
||||
ISub iSub = ISub.Stub.asInterface(
|
||||
TelephonyFrameworkInitializer
|
||||
.getTelephonyServiceManager()
|
||||
.getSubscriptionServiceRegisterer()
|
||||
.get());
|
||||
ISub iSub = TelephonyManager.getSubscriptionService();
|
||||
if (iSub != null) {
|
||||
iSub.requestEmbeddedSubscriptionInfoListRefresh(cardId);
|
||||
}
|
||||
@@ -1494,11 +1462,7 @@ public class SubscriptionManager {
|
||||
@SystemApi
|
||||
public void requestEmbeddedSubscriptionInfoListRefresh(int cardId) {
|
||||
try {
|
||||
ISub iSub = ISub.Stub.asInterface(
|
||||
TelephonyFrameworkInitializer
|
||||
.getTelephonyServiceManager()
|
||||
.getSubscriptionServiceRegisterer()
|
||||
.get());
|
||||
ISub iSub = TelephonyManager.getSubscriptionService();
|
||||
if (iSub != null) {
|
||||
iSub.requestEmbeddedSubscriptionInfoListRefresh(cardId);
|
||||
}
|
||||
@@ -1519,11 +1483,7 @@ public class SubscriptionManager {
|
||||
int result = 0;
|
||||
|
||||
try {
|
||||
ISub iSub = ISub.Stub.asInterface(
|
||||
TelephonyFrameworkInitializer
|
||||
.getTelephonyServiceManager()
|
||||
.getSubscriptionServiceRegisterer()
|
||||
.get());
|
||||
ISub iSub = TelephonyManager.getSubscriptionService();
|
||||
if (iSub != null) {
|
||||
result = iSub.getAllSubInfoCount(mContext.getOpPackageName(),
|
||||
mContext.getFeatureId());
|
||||
@@ -1552,11 +1512,7 @@ public class SubscriptionManager {
|
||||
int result = 0;
|
||||
|
||||
try {
|
||||
ISub iSub = ISub.Stub.asInterface(
|
||||
TelephonyFrameworkInitializer
|
||||
.getTelephonyServiceManager()
|
||||
.getSubscriptionServiceRegisterer()
|
||||
.get());
|
||||
ISub iSub = TelephonyManager.getSubscriptionService();
|
||||
if (iSub != null) {
|
||||
result = iSub.getActiveSubInfoCount(mContext.getOpPackageName(),
|
||||
mContext.getFeatureId());
|
||||
@@ -1577,11 +1533,7 @@ public class SubscriptionManager {
|
||||
int result = 0;
|
||||
|
||||
try {
|
||||
ISub iSub = ISub.Stub.asInterface(
|
||||
TelephonyFrameworkInitializer
|
||||
.getTelephonyServiceManager()
|
||||
.getSubscriptionServiceRegisterer()
|
||||
.get());
|
||||
ISub iSub = TelephonyManager.getSubscriptionService();
|
||||
if (iSub != null) {
|
||||
result = iSub.getActiveSubInfoCountMax();
|
||||
}
|
||||
@@ -1638,11 +1590,7 @@ public class SubscriptionManager {
|
||||
}
|
||||
|
||||
try {
|
||||
ISub iSub = ISub.Stub.asInterface(
|
||||
TelephonyFrameworkInitializer
|
||||
.getTelephonyServiceManager()
|
||||
.getSubscriptionServiceRegisterer()
|
||||
.get());
|
||||
ISub iSub = TelephonyManager.getSubscriptionService();
|
||||
if (iSub == null) {
|
||||
Log.e(LOG_TAG, "[addSubscriptionInfoRecord]- ISub service is null");
|
||||
return;
|
||||
@@ -1676,11 +1624,7 @@ public class SubscriptionManager {
|
||||
}
|
||||
|
||||
try {
|
||||
ISub iSub = ISub.Stub.asInterface(
|
||||
TelephonyFrameworkInitializer
|
||||
.getTelephonyServiceManager()
|
||||
.getSubscriptionServiceRegisterer()
|
||||
.get());
|
||||
ISub iSub = TelephonyManager.getSubscriptionService();
|
||||
if (iSub == null) {
|
||||
Log.e(LOG_TAG, "[removeSubscriptionInfoRecord]- ISub service is null");
|
||||
return;
|
||||
@@ -1783,11 +1727,7 @@ public class SubscriptionManager {
|
||||
int result = INVALID_SIM_SLOT_INDEX;
|
||||
|
||||
try {
|
||||
ISub iSub = ISub.Stub.asInterface(
|
||||
TelephonyFrameworkInitializer
|
||||
.getTelephonyServiceManager()
|
||||
.getSubscriptionServiceRegisterer()
|
||||
.get());
|
||||
ISub iSub = TelephonyManager.getSubscriptionService();
|
||||
if (iSub != null) {
|
||||
result = iSub.getSlotIndex(subscriptionId);
|
||||
}
|
||||
@@ -1821,11 +1761,7 @@ public class SubscriptionManager {
|
||||
int[] subId = null;
|
||||
|
||||
try {
|
||||
ISub iSub = ISub.Stub.asInterface(
|
||||
TelephonyFrameworkInitializer
|
||||
.getTelephonyServiceManager()
|
||||
.getSubscriptionServiceRegisterer()
|
||||
.get());
|
||||
ISub iSub = TelephonyManager.getSubscriptionService();
|
||||
if (iSub != null) {
|
||||
subId = iSub.getSubId(slotIndex);
|
||||
}
|
||||
@@ -1849,11 +1785,7 @@ public class SubscriptionManager {
|
||||
int result = INVALID_PHONE_INDEX;
|
||||
|
||||
try {
|
||||
ISub iSub = ISub.Stub.asInterface(
|
||||
TelephonyFrameworkInitializer
|
||||
.getTelephonyServiceManager()
|
||||
.getSubscriptionServiceRegisterer()
|
||||
.get());
|
||||
ISub iSub = TelephonyManager.getSubscriptionService();
|
||||
if (iSub != null) {
|
||||
result = iSub.getPhoneId(subId);
|
||||
}
|
||||
@@ -1887,11 +1819,7 @@ public class SubscriptionManager {
|
||||
int subId = INVALID_SUBSCRIPTION_ID;
|
||||
|
||||
try {
|
||||
ISub iSub = ISub.Stub.asInterface(
|
||||
TelephonyFrameworkInitializer
|
||||
.getTelephonyServiceManager()
|
||||
.getSubscriptionServiceRegisterer()
|
||||
.get());
|
||||
ISub iSub = TelephonyManager.getSubscriptionService();
|
||||
if (iSub != null) {
|
||||
subId = iSub.getDefaultSubId();
|
||||
}
|
||||
@@ -1914,11 +1842,7 @@ public class SubscriptionManager {
|
||||
int subId = INVALID_SUBSCRIPTION_ID;
|
||||
|
||||
try {
|
||||
ISub iSub = ISub.Stub.asInterface(
|
||||
TelephonyFrameworkInitializer
|
||||
.getTelephonyServiceManager()
|
||||
.getSubscriptionServiceRegisterer()
|
||||
.get());
|
||||
ISub iSub = TelephonyManager.getSubscriptionService();
|
||||
if (iSub != null) {
|
||||
subId = iSub.getDefaultVoiceSubId();
|
||||
}
|
||||
@@ -1948,11 +1872,7 @@ public class SubscriptionManager {
|
||||
public void setDefaultVoiceSubscriptionId(int subscriptionId) {
|
||||
if (VDBG) logd("setDefaultVoiceSubId sub id = " + subscriptionId);
|
||||
try {
|
||||
ISub iSub = ISub.Stub.asInterface(
|
||||
TelephonyFrameworkInitializer
|
||||
.getTelephonyServiceManager()
|
||||
.getSubscriptionServiceRegisterer()
|
||||
.get());
|
||||
ISub iSub = TelephonyManager.getSubscriptionService();
|
||||
if (iSub != null) {
|
||||
iSub.setDefaultVoiceSubId(subscriptionId);
|
||||
}
|
||||
@@ -2000,11 +1920,7 @@ public class SubscriptionManager {
|
||||
int subId = INVALID_SUBSCRIPTION_ID;
|
||||
|
||||
try {
|
||||
ISub iSub = ISub.Stub.asInterface(
|
||||
TelephonyFrameworkInitializer
|
||||
.getTelephonyServiceManager()
|
||||
.getSubscriptionServiceRegisterer()
|
||||
.get());
|
||||
ISub iSub = TelephonyManager.getSubscriptionService();
|
||||
if (iSub != null) {
|
||||
subId = iSub.getDefaultSmsSubId();
|
||||
}
|
||||
@@ -2030,11 +1946,7 @@ public class SubscriptionManager {
|
||||
public void setDefaultSmsSubId(int subscriptionId) {
|
||||
if (VDBG) logd("setDefaultSmsSubId sub id = " + subscriptionId);
|
||||
try {
|
||||
ISub iSub = ISub.Stub.asInterface(
|
||||
TelephonyFrameworkInitializer
|
||||
.getTelephonyServiceManager()
|
||||
.getSubscriptionServiceRegisterer()
|
||||
.get());
|
||||
ISub iSub = TelephonyManager.getSubscriptionService();
|
||||
if (iSub != null) {
|
||||
iSub.setDefaultSmsSubId(subscriptionId);
|
||||
}
|
||||
@@ -2072,11 +1984,7 @@ public class SubscriptionManager {
|
||||
int subId = INVALID_SUBSCRIPTION_ID;
|
||||
|
||||
try {
|
||||
ISub iSub = ISub.Stub.asInterface(
|
||||
TelephonyFrameworkInitializer
|
||||
.getTelephonyServiceManager()
|
||||
.getSubscriptionServiceRegisterer()
|
||||
.get());
|
||||
ISub iSub = TelephonyManager.getSubscriptionService();
|
||||
if (iSub != null) {
|
||||
subId = iSub.getDefaultDataSubId();
|
||||
}
|
||||
@@ -2102,11 +2010,7 @@ public class SubscriptionManager {
|
||||
public void setDefaultDataSubId(int subscriptionId) {
|
||||
if (VDBG) logd("setDataSubscription sub id = " + subscriptionId);
|
||||
try {
|
||||
ISub iSub = ISub.Stub.asInterface(
|
||||
TelephonyFrameworkInitializer
|
||||
.getTelephonyServiceManager()
|
||||
.getSubscriptionServiceRegisterer()
|
||||
.get());
|
||||
ISub iSub = TelephonyManager.getSubscriptionService();
|
||||
if (iSub != null) {
|
||||
iSub.setDefaultDataSubId(subscriptionId);
|
||||
}
|
||||
@@ -2137,11 +2041,7 @@ public class SubscriptionManager {
|
||||
/** @hide */
|
||||
public void clearSubscriptionInfo() {
|
||||
try {
|
||||
ISub iSub = ISub.Stub.asInterface(
|
||||
TelephonyFrameworkInitializer
|
||||
.getTelephonyServiceManager()
|
||||
.getSubscriptionServiceRegisterer()
|
||||
.get());
|
||||
ISub iSub = TelephonyManager.getSubscriptionService();
|
||||
if (iSub != null) {
|
||||
iSub.clearSubInfo();
|
||||
}
|
||||
@@ -2277,11 +2177,7 @@ public class SubscriptionManager {
|
||||
*/
|
||||
public @NonNull int[] getActiveSubscriptionIdList(boolean visibleOnly) {
|
||||
try {
|
||||
ISub iSub = ISub.Stub.asInterface(
|
||||
TelephonyFrameworkInitializer
|
||||
.getTelephonyServiceManager()
|
||||
.getSubscriptionServiceRegisterer()
|
||||
.get());
|
||||
ISub iSub = TelephonyManager.getSubscriptionService();
|
||||
if (iSub != null) {
|
||||
int[] subId = iSub.getActiveSubIdList(visibleOnly);
|
||||
if (subId != null) return subId;
|
||||
@@ -2332,11 +2228,7 @@ public class SubscriptionManager {
|
||||
int simState = TelephonyManager.SIM_STATE_UNKNOWN;
|
||||
|
||||
try {
|
||||
ISub iSub = ISub.Stub.asInterface(
|
||||
TelephonyFrameworkInitializer
|
||||
.getTelephonyServiceManager()
|
||||
.getSubscriptionServiceRegisterer()
|
||||
.get());
|
||||
ISub iSub = TelephonyManager.getSubscriptionService();
|
||||
if (iSub != null) {
|
||||
simState = iSub.getSimStateForSlotIndex(slotIndex);
|
||||
}
|
||||
@@ -2355,11 +2247,7 @@ public class SubscriptionManager {
|
||||
*/
|
||||
public static void setSubscriptionProperty(int subId, String propKey, String propValue) {
|
||||
try {
|
||||
ISub iSub = ISub.Stub.asInterface(
|
||||
TelephonyFrameworkInitializer
|
||||
.getTelephonyServiceManager()
|
||||
.getSubscriptionServiceRegisterer()
|
||||
.get());
|
||||
ISub iSub = TelephonyManager.getSubscriptionService();
|
||||
if (iSub != null) {
|
||||
iSub.setSubscriptionProperty(subId, propKey, propValue);
|
||||
}
|
||||
@@ -2379,11 +2267,7 @@ public class SubscriptionManager {
|
||||
Context context) {
|
||||
String resultValue = null;
|
||||
try {
|
||||
ISub iSub = ISub.Stub.asInterface(
|
||||
TelephonyFrameworkInitializer
|
||||
.getTelephonyServiceManager()
|
||||
.getSubscriptionServiceRegisterer()
|
||||
.get());
|
||||
ISub iSub = TelephonyManager.getSubscriptionService();
|
||||
if (iSub != null) {
|
||||
resultValue = iSub.getSubscriptionProperty(subId, propKey,
|
||||
context.getOpPackageName(), context.getFeatureId());
|
||||
@@ -2547,11 +2431,7 @@ public class SubscriptionManager {
|
||||
@UnsupportedAppUsage
|
||||
public boolean isActiveSubId(int subId) {
|
||||
try {
|
||||
ISub iSub = ISub.Stub.asInterface(
|
||||
TelephonyFrameworkInitializer
|
||||
.getTelephonyServiceManager()
|
||||
.getSubscriptionServiceRegisterer()
|
||||
.get());
|
||||
ISub iSub = TelephonyManager.getSubscriptionService();
|
||||
if (iSub != null) {
|
||||
return iSub.isActiveSubId(subId, mContext.getOpPackageName(),
|
||||
mContext.getFeatureId());
|
||||
@@ -2747,11 +2627,7 @@ public class SubscriptionManager {
|
||||
@TelephonyManager.SetOpportunisticSubscriptionResult Consumer<Integer> callback) {
|
||||
if (VDBG) logd("[setPreferredDataSubscriptionId]+ subId:" + subId);
|
||||
try {
|
||||
ISub iSub = ISub.Stub.asInterface(
|
||||
TelephonyFrameworkInitializer
|
||||
.getTelephonyServiceManager()
|
||||
.getSubscriptionServiceRegisterer()
|
||||
.get());
|
||||
ISub iSub = TelephonyManager.getSubscriptionService();
|
||||
if (iSub == null) return;
|
||||
|
||||
ISetOpportunisticDataCallback callbackStub = new ISetOpportunisticDataCallback.Stub() {
|
||||
@@ -2794,11 +2670,7 @@ public class SubscriptionManager {
|
||||
public int getPreferredDataSubscriptionId() {
|
||||
int preferredSubId = SubscriptionManager.DEFAULT_SUBSCRIPTION_ID;
|
||||
try {
|
||||
ISub iSub = ISub.Stub.asInterface(
|
||||
TelephonyFrameworkInitializer
|
||||
.getTelephonyServiceManager()
|
||||
.getSubscriptionServiceRegisterer()
|
||||
.get());
|
||||
ISub iSub = TelephonyManager.getSubscriptionService();
|
||||
if (iSub != null) {
|
||||
preferredSubId = iSub.getPreferredDataSubscriptionId();
|
||||
}
|
||||
@@ -2829,11 +2701,7 @@ public class SubscriptionManager {
|
||||
List<SubscriptionInfo> subInfoList = null;
|
||||
|
||||
try {
|
||||
ISub iSub = ISub.Stub.asInterface(
|
||||
TelephonyFrameworkInitializer
|
||||
.getTelephonyServiceManager()
|
||||
.getSubscriptionServiceRegisterer()
|
||||
.get());
|
||||
ISub iSub = TelephonyManager.getSubscriptionService();
|
||||
if (iSub != null) {
|
||||
subInfoList = iSub.getOpportunisticSubscriptions(contextPkg, contextFeature);
|
||||
}
|
||||
@@ -2934,11 +2802,7 @@ public class SubscriptionManager {
|
||||
ParcelUuid groupUuid = null;
|
||||
int[] subIdArray = subIdList.stream().mapToInt(i->i).toArray();
|
||||
try {
|
||||
ISub iSub = ISub.Stub.asInterface(
|
||||
TelephonyFrameworkInitializer
|
||||
.getTelephonyServiceManager()
|
||||
.getSubscriptionServiceRegisterer()
|
||||
.get());
|
||||
ISub iSub = TelephonyManager.getSubscriptionService();
|
||||
if (iSub != null) {
|
||||
groupUuid = iSub.createSubscriptionGroup(subIdArray, pkgForDebug);
|
||||
} else {
|
||||
@@ -2988,11 +2852,7 @@ public class SubscriptionManager {
|
||||
int[] subIdArray = subIdList.stream().mapToInt(i->i).toArray();
|
||||
|
||||
try {
|
||||
ISub iSub = ISub.Stub.asInterface(
|
||||
TelephonyFrameworkInitializer
|
||||
.getTelephonyServiceManager()
|
||||
.getSubscriptionServiceRegisterer()
|
||||
.get());
|
||||
ISub iSub = TelephonyManager.getSubscriptionService();
|
||||
if (iSub != null) {
|
||||
iSub.addSubscriptionsIntoGroup(subIdArray, groupUuid, pkgForDebug);
|
||||
} else {
|
||||
@@ -3044,11 +2904,7 @@ public class SubscriptionManager {
|
||||
int[] subIdArray = subIdList.stream().mapToInt(i->i).toArray();
|
||||
|
||||
try {
|
||||
ISub iSub = ISub.Stub.asInterface(
|
||||
TelephonyFrameworkInitializer
|
||||
.getTelephonyServiceManager()
|
||||
.getSubscriptionServiceRegisterer()
|
||||
.get());
|
||||
ISub iSub = TelephonyManager.getSubscriptionService();
|
||||
if (iSub != null) {
|
||||
iSub.removeSubscriptionsFromGroup(subIdArray, groupUuid, pkgForDebug);
|
||||
} else {
|
||||
@@ -3093,11 +2949,7 @@ public class SubscriptionManager {
|
||||
|
||||
List<SubscriptionInfo> result = null;
|
||||
try {
|
||||
ISub iSub = ISub.Stub.asInterface(
|
||||
TelephonyFrameworkInitializer
|
||||
.getTelephonyServiceManager()
|
||||
.getSubscriptionServiceRegisterer()
|
||||
.get());
|
||||
ISub iSub = TelephonyManager.getSubscriptionService();
|
||||
if (iSub != null) {
|
||||
result = iSub.getSubscriptionsInGroup(groupUuid, contextPkg, contextFeature);
|
||||
} else {
|
||||
@@ -3210,11 +3062,7 @@ public class SubscriptionManager {
|
||||
logd("setSubscriptionActivated subId= " + subscriptionId + " enable " + enable);
|
||||
}
|
||||
try {
|
||||
ISub iSub = ISub.Stub.asInterface(
|
||||
TelephonyFrameworkInitializer
|
||||
.getTelephonyServiceManager()
|
||||
.getSubscriptionServiceRegisterer()
|
||||
.get());
|
||||
ISub iSub = TelephonyManager.getSubscriptionService();
|
||||
if (iSub != null) {
|
||||
return iSub.setSubscriptionEnabled(enable, subscriptionId);
|
||||
}
|
||||
@@ -3303,11 +3151,7 @@ public class SubscriptionManager {
|
||||
@RequiresPermission(Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
|
||||
public boolean isSubscriptionEnabled(int subscriptionId) {
|
||||
try {
|
||||
ISub iSub = ISub.Stub.asInterface(
|
||||
TelephonyFrameworkInitializer
|
||||
.getTelephonyServiceManager()
|
||||
.getSubscriptionServiceRegisterer()
|
||||
.get());
|
||||
ISub iSub = TelephonyManager.getSubscriptionService();
|
||||
if (iSub != null) {
|
||||
return iSub.isSubscriptionEnabled(subscriptionId);
|
||||
}
|
||||
@@ -3330,11 +3174,7 @@ public class SubscriptionManager {
|
||||
int subId = INVALID_SUBSCRIPTION_ID;
|
||||
|
||||
try {
|
||||
ISub iSub = ISub.Stub.asInterface(
|
||||
TelephonyFrameworkInitializer
|
||||
.getTelephonyServiceManager()
|
||||
.getSubscriptionServiceRegisterer()
|
||||
.get());
|
||||
ISub iSub = TelephonyManager.getSubscriptionService();
|
||||
if (iSub != null) {
|
||||
subId = iSub.getEnabledSubscriptionId(slotIndex);
|
||||
}
|
||||
@@ -3360,11 +3200,7 @@ public class SubscriptionManager {
|
||||
int result = 0;
|
||||
|
||||
try {
|
||||
ISub iSub = ISub.Stub.asInterface(
|
||||
TelephonyFrameworkInitializer
|
||||
.getTelephonyServiceManager()
|
||||
.getSubscriptionServiceRegisterer()
|
||||
.get());
|
||||
ISub iSub = TelephonyManager.getSubscriptionService();
|
||||
if (iSub != null) {
|
||||
result = helper.callMethod(iSub);
|
||||
}
|
||||
@@ -3387,11 +3223,7 @@ public class SubscriptionManager {
|
||||
*/
|
||||
public static int getActiveDataSubscriptionId() {
|
||||
try {
|
||||
ISub iSub = ISub.Stub.asInterface(
|
||||
TelephonyFrameworkInitializer
|
||||
.getTelephonyServiceManager()
|
||||
.getSubscriptionServiceRegisterer()
|
||||
.get());
|
||||
ISub iSub = TelephonyManager.getSubscriptionService();
|
||||
if (iSub != null) {
|
||||
return iSub.getActiveDataSubscriptionId();
|
||||
}
|
||||
|
||||
@@ -54,6 +54,7 @@ import android.os.Binder;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.IBinder;
|
||||
import android.os.PersistableBundle;
|
||||
import android.os.Process;
|
||||
import android.os.RemoteException;
|
||||
@@ -93,6 +94,7 @@ import android.util.Log;
|
||||
import android.util.Pair;
|
||||
|
||||
import com.android.ims.internal.IImsServiceFeatureCallback;
|
||||
import com.android.internal.annotations.GuardedBy;
|
||||
import com.android.internal.annotations.VisibleForTesting;
|
||||
import com.android.internal.telephony.CellNetworkScanResult;
|
||||
import com.android.internal.telephony.IBooleanConsumer;
|
||||
@@ -100,6 +102,8 @@ import com.android.internal.telephony.INumberVerificationCallback;
|
||||
import com.android.internal.telephony.IOns;
|
||||
import com.android.internal.telephony.IPhoneSubInfo;
|
||||
import com.android.internal.telephony.ISetOpportunisticDataCallback;
|
||||
import com.android.internal.telephony.ISms;
|
||||
import com.android.internal.telephony.ISub;
|
||||
import com.android.internal.telephony.ITelephony;
|
||||
import com.android.internal.telephony.IUpdateAvailableNetworksCallback;
|
||||
import com.android.internal.telephony.OperatorInfo;
|
||||
@@ -295,6 +299,21 @@ public class TelephonyManager {
|
||||
private SubscriptionManager mSubscriptionManager;
|
||||
private TelephonyScanManager mTelephonyScanManager;
|
||||
|
||||
/** Cached service handles, cleared by resetServiceHandles() at death */
|
||||
private static final Object sCacheLock = new Object();
|
||||
|
||||
/** @hide */
|
||||
private static boolean sServiceHandleCacheEnabled = true;
|
||||
|
||||
@GuardedBy("sCacheLock")
|
||||
private static IPhoneSubInfo sIPhoneSubInfo;
|
||||
@GuardedBy("sCacheLock")
|
||||
private static ISub sISub;
|
||||
@GuardedBy("sCacheLock")
|
||||
private static ISms sISms;
|
||||
@GuardedBy("sCacheLock")
|
||||
private static final DeathRecipient sServiceDeath = new DeathRecipient();
|
||||
|
||||
/** Enum indicating multisim variants
|
||||
* DSDS - Dual SIM Dual Standby
|
||||
* DSDA - Dual SIM Dual Active
|
||||
@@ -1991,7 +2010,7 @@ public class TelephonyManager {
|
||||
public String getDeviceId(int slotIndex) {
|
||||
// FIXME this assumes phoneId == slotIndex
|
||||
try {
|
||||
IPhoneSubInfo info = getSubscriberInfo();
|
||||
IPhoneSubInfo info = getSubscriberInfoService();
|
||||
if (info == null)
|
||||
return null;
|
||||
return info.getDeviceIdForPhone(slotIndex, mContext.getOpPackageName(),
|
||||
@@ -2245,7 +2264,7 @@ public class TelephonyManager {
|
||||
|
||||
private String getNaiBySubscriberId(int subId) {
|
||||
try {
|
||||
IPhoneSubInfo info = getSubscriberInfo();
|
||||
IPhoneSubInfo info = getSubscriberInfoService();
|
||||
if (info == null)
|
||||
return null;
|
||||
String nai = info.getNaiForSubscriber(subId, mContext.getOpPackageName(),
|
||||
@@ -3944,7 +3963,7 @@ public class TelephonyManager {
|
||||
@UnsupportedAppUsage
|
||||
public String getSimSerialNumber(int subId) {
|
||||
try {
|
||||
IPhoneSubInfo info = getSubscriberInfo();
|
||||
IPhoneSubInfo info = getSubscriberInfoService();
|
||||
if (info == null)
|
||||
return null;
|
||||
return info.getIccSerialNumberForSubscriber(subId, mContext.getOpPackageName(),
|
||||
@@ -4217,7 +4236,7 @@ public class TelephonyManager {
|
||||
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P)
|
||||
public String getSubscriberId(int subId) {
|
||||
try {
|
||||
IPhoneSubInfo info = getSubscriberInfo();
|
||||
IPhoneSubInfo info = getSubscriberInfoService();
|
||||
if (info == null)
|
||||
return null;
|
||||
return info.getSubscriberIdForSubscriber(subId, mContext.getOpPackageName(),
|
||||
@@ -4253,7 +4272,7 @@ public class TelephonyManager {
|
||||
@Nullable
|
||||
public ImsiEncryptionInfo getCarrierInfoForImsiEncryption(@KeyType int keyType) {
|
||||
try {
|
||||
IPhoneSubInfo info = getSubscriberInfo();
|
||||
IPhoneSubInfo info = getSubscriberInfoService();
|
||||
if (info == null) {
|
||||
Rlog.e(TAG,"IMSI error: Subscriber Info is null");
|
||||
return null;
|
||||
@@ -4296,7 +4315,7 @@ public class TelephonyManager {
|
||||
@SystemApi
|
||||
public void resetCarrierKeysForImsiEncryption() {
|
||||
try {
|
||||
IPhoneSubInfo info = getSubscriberInfo();
|
||||
IPhoneSubInfo info = getSubscriberInfoService();
|
||||
if (info == null) {
|
||||
Rlog.e(TAG, "IMSI error: Subscriber Info is null");
|
||||
if (!isSystemProcess()) {
|
||||
@@ -4361,7 +4380,7 @@ public class TelephonyManager {
|
||||
*/
|
||||
public void setCarrierInfoForImsiEncryption(ImsiEncryptionInfo imsiEncryptionInfo) {
|
||||
try {
|
||||
IPhoneSubInfo info = getSubscriberInfo();
|
||||
IPhoneSubInfo info = getSubscriberInfoService();
|
||||
if (info == null) return;
|
||||
info.setCarrierInfoForImsiEncryption(mSubId, mContext.getOpPackageName(),
|
||||
imsiEncryptionInfo);
|
||||
@@ -4385,7 +4404,7 @@ public class TelephonyManager {
|
||||
@RequiresPermission(android.Manifest.permission.READ_PHONE_STATE)
|
||||
public String getGroupIdLevel1() {
|
||||
try {
|
||||
IPhoneSubInfo info = getSubscriberInfo();
|
||||
IPhoneSubInfo info = getSubscriberInfoService();
|
||||
if (info == null)
|
||||
return null;
|
||||
return info.getGroupIdLevel1ForSubscriber(getSubId(), mContext.getOpPackageName(),
|
||||
@@ -4409,7 +4428,7 @@ public class TelephonyManager {
|
||||
@UnsupportedAppUsage
|
||||
public String getGroupIdLevel1(int subId) {
|
||||
try {
|
||||
IPhoneSubInfo info = getSubscriberInfo();
|
||||
IPhoneSubInfo info = getSubscriberInfoService();
|
||||
if (info == null)
|
||||
return null;
|
||||
return info.getGroupIdLevel1ForSubscriber(subId, mContext.getOpPackageName(),
|
||||
@@ -4472,7 +4491,7 @@ public class TelephonyManager {
|
||||
return number;
|
||||
}
|
||||
try {
|
||||
IPhoneSubInfo info = getSubscriberInfo();
|
||||
IPhoneSubInfo info = getSubscriberInfoService();
|
||||
if (info == null)
|
||||
return null;
|
||||
return info.getLine1NumberForSubscriber(subId, mContext.getOpPackageName(),
|
||||
@@ -4563,7 +4582,7 @@ public class TelephonyManager {
|
||||
return alphaTag;
|
||||
}
|
||||
try {
|
||||
IPhoneSubInfo info = getSubscriberInfo();
|
||||
IPhoneSubInfo info = getSubscriberInfoService();
|
||||
if (info == null)
|
||||
return null;
|
||||
return info.getLine1AlphaTagForSubscriber(subId, getOpPackageName(),
|
||||
@@ -4651,7 +4670,7 @@ public class TelephonyManager {
|
||||
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P)
|
||||
public String getMsisdn(int subId) {
|
||||
try {
|
||||
IPhoneSubInfo info = getSubscriberInfo();
|
||||
IPhoneSubInfo info = getSubscriberInfoService();
|
||||
if (info == null)
|
||||
return null;
|
||||
return info.getMsisdnForSubscriber(subId, getOpPackageName(), getFeatureId());
|
||||
@@ -4685,7 +4704,7 @@ public class TelephonyManager {
|
||||
@UnsupportedAppUsage
|
||||
public String getVoiceMailNumber(int subId) {
|
||||
try {
|
||||
IPhoneSubInfo info = getSubscriberInfo();
|
||||
IPhoneSubInfo info = getSubscriberInfoService();
|
||||
if (info == null)
|
||||
return null;
|
||||
return info.getVoiceMailNumberForSubscriber(subId, getOpPackageName(),
|
||||
@@ -5284,7 +5303,7 @@ public class TelephonyManager {
|
||||
@UnsupportedAppUsage
|
||||
public String getVoiceMailAlphaTag(int subId) {
|
||||
try {
|
||||
IPhoneSubInfo info = getSubscriberInfo();
|
||||
IPhoneSubInfo info = getSubscriberInfoService();
|
||||
if (info == null)
|
||||
return null;
|
||||
return info.getVoiceMailAlphaTagForSubscriber(subId, getOpPackageName(),
|
||||
@@ -5332,7 +5351,7 @@ public class TelephonyManager {
|
||||
@UnsupportedAppUsage
|
||||
public String getIsimImpi() {
|
||||
try {
|
||||
IPhoneSubInfo info = getSubscriberInfo();
|
||||
IPhoneSubInfo info = getSubscriberInfoService();
|
||||
if (info == null)
|
||||
return null;
|
||||
//get the Isim Impi based on subId
|
||||
@@ -5359,7 +5378,7 @@ public class TelephonyManager {
|
||||
@RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
|
||||
public String getIsimDomain() {
|
||||
try {
|
||||
IPhoneSubInfo info = getSubscriberInfo();
|
||||
IPhoneSubInfo info = getSubscriberInfoService();
|
||||
if (info == null)
|
||||
return null;
|
||||
//get the Isim Domain based on subId
|
||||
@@ -5383,7 +5402,7 @@ public class TelephonyManager {
|
||||
@RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
|
||||
public String[] getIsimImpu() {
|
||||
try {
|
||||
IPhoneSubInfo info = getSubscriberInfo();
|
||||
IPhoneSubInfo info = getSubscriberInfoService();
|
||||
if (info == null)
|
||||
return null;
|
||||
//get the Isim Impu based on subId
|
||||
@@ -5396,19 +5415,6 @@ public class TelephonyManager {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
@UnsupportedAppUsage
|
||||
private IPhoneSubInfo getSubscriberInfo() {
|
||||
// get it each time because that process crashes a lot
|
||||
return IPhoneSubInfo.Stub.asInterface(
|
||||
TelephonyFrameworkInitializer
|
||||
.getTelephonyServiceManager()
|
||||
.getPhoneSubServiceRegisterer()
|
||||
.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* Device call state: No activity.
|
||||
*/
|
||||
@@ -5464,6 +5470,14 @@ public class TelephonyManager {
|
||||
return getCallStateForSlot(phoneId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
@UnsupportedAppUsage
|
||||
private IPhoneSubInfo getSubscriberInfo() {
|
||||
return getSubscriberInfoService();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Telephony call state for calls on a specific SIM slot.
|
||||
* <p>
|
||||
@@ -7124,7 +7138,7 @@ public class TelephonyManager {
|
||||
@RequiresPermission(Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
|
||||
public String getIsimIst() {
|
||||
try {
|
||||
IPhoneSubInfo info = getSubscriberInfo();
|
||||
IPhoneSubInfo info = getSubscriberInfoService();
|
||||
if (info == null)
|
||||
return null;
|
||||
//get the Isim Ist based on subId
|
||||
@@ -7146,7 +7160,7 @@ public class TelephonyManager {
|
||||
@UnsupportedAppUsage
|
||||
public String[] getIsimPcscf() {
|
||||
try {
|
||||
IPhoneSubInfo info = getSubscriberInfo();
|
||||
IPhoneSubInfo info = getSubscriberInfoService();
|
||||
if (info == null)
|
||||
return null;
|
||||
//get the Isim Pcscf based on subId
|
||||
@@ -7227,7 +7241,7 @@ public class TelephonyManager {
|
||||
@UnsupportedAppUsage
|
||||
public String getIccAuthentication(int subId, int appType, int authType, String data) {
|
||||
try {
|
||||
IPhoneSubInfo info = getSubscriberInfo();
|
||||
IPhoneSubInfo info = getSubscriberInfoService();
|
||||
if (info == null)
|
||||
return null;
|
||||
return info.getIccSimChallengeResponse(subId, appType, authType, data);
|
||||
@@ -13086,4 +13100,153 @@ public class TelephonyManager {
|
||||
throw e.rethrowFromSystemServer();
|
||||
}
|
||||
}
|
||||
|
||||
private static class DeathRecipient implements IBinder.DeathRecipient {
|
||||
@Override
|
||||
public void binderDied() {
|
||||
resetServiceCache();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset everything in the service cache; if one handle died then they are
|
||||
* all probably broken.
|
||||
* @hide
|
||||
*/
|
||||
private static void resetServiceCache() {
|
||||
synchronized (sCacheLock) {
|
||||
if (sISub != null) {
|
||||
sISub.asBinder().unlinkToDeath(sServiceDeath, 0);
|
||||
sISub = null;
|
||||
}
|
||||
if (sISms != null) {
|
||||
sISms.asBinder().unlinkToDeath(sServiceDeath, 0);
|
||||
sISms = null;
|
||||
}
|
||||
if (sIPhoneSubInfo != null) {
|
||||
sIPhoneSubInfo.asBinder().unlinkToDeath(sServiceDeath, 0);
|
||||
sIPhoneSubInfo = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
static IPhoneSubInfo getSubscriberInfoService() {
|
||||
// Keeps cache disabled until test fixes are checked into AOSP.
|
||||
if (true) {
|
||||
return IPhoneSubInfo.Stub.asInterface(
|
||||
TelephonyFrameworkInitializer
|
||||
.getTelephonyServiceManager()
|
||||
.getPhoneSubServiceRegisterer()
|
||||
.get());
|
||||
}
|
||||
|
||||
if (sIPhoneSubInfo == null) {
|
||||
IPhoneSubInfo temp = IPhoneSubInfo.Stub.asInterface(
|
||||
TelephonyFrameworkInitializer
|
||||
.getTelephonyServiceManager()
|
||||
.getPhoneSubServiceRegisterer()
|
||||
.get());
|
||||
synchronized (sCacheLock) {
|
||||
if (sIPhoneSubInfo == null && temp != null) {
|
||||
try {
|
||||
sIPhoneSubInfo = temp;
|
||||
sIPhoneSubInfo.asBinder().linkToDeath(sServiceDeath, 0);
|
||||
} catch (Exception e) {
|
||||
// something has gone horribly wrong
|
||||
sIPhoneSubInfo = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return sIPhoneSubInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
static ISub getSubscriptionService() {
|
||||
// Keeps cache disabled until test fixes are checked into AOSP.
|
||||
if (true) {
|
||||
return ISub.Stub.asInterface(
|
||||
TelephonyFrameworkInitializer
|
||||
.getTelephonyServiceManager()
|
||||
.getSubscriptionServiceRegisterer()
|
||||
.get());
|
||||
}
|
||||
|
||||
if (sISub == null) {
|
||||
ISub temp = ISub.Stub.asInterface(
|
||||
TelephonyFrameworkInitializer
|
||||
.getTelephonyServiceManager()
|
||||
.getSubscriptionServiceRegisterer()
|
||||
.get());
|
||||
synchronized (sCacheLock) {
|
||||
if (sISub == null && temp != null) {
|
||||
try {
|
||||
sISub = temp;
|
||||
sISub.asBinder().linkToDeath(sServiceDeath, 0);
|
||||
} catch (Exception e) {
|
||||
// something has gone horribly wrong
|
||||
sISub = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return sISub;
|
||||
}
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
static ISms getSmsService() {
|
||||
// Keeps cache disabled until test fixes are checked into AOSP.
|
||||
if (true) {
|
||||
return ISms.Stub.asInterface(
|
||||
TelephonyFrameworkInitializer
|
||||
.getTelephonyServiceManager()
|
||||
.getSmsServiceRegisterer()
|
||||
.get());
|
||||
}
|
||||
|
||||
if (sISms == null) {
|
||||
ISms temp = ISms.Stub.asInterface(
|
||||
TelephonyFrameworkInitializer
|
||||
.getTelephonyServiceManager()
|
||||
.getSmsServiceRegisterer()
|
||||
.get());
|
||||
synchronized (sCacheLock) {
|
||||
if (sISms == null && temp != null) {
|
||||
try {
|
||||
sISms = temp;
|
||||
sISms.asBinder().linkToDeath(sServiceDeath, 0);
|
||||
} catch (Exception e) {
|
||||
// something has gone horribly wrong
|
||||
sISms = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return sISms;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disables service handle caching for tests that utilize mock services.
|
||||
* @hide
|
||||
*/
|
||||
@VisibleForTesting
|
||||
public static void disableServiceHandleCaching() {
|
||||
sServiceHandleCacheEnabled = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reenables service handle caching.
|
||||
* @hide
|
||||
*/
|
||||
@VisibleForTesting
|
||||
public static void enableServiceHandleCaching() {
|
||||
sServiceHandleCacheEnabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user