Add new getServiceStateForSlot API
Bug: 339023069
Test: atest TelephonyManagerTest
Manual Test: Flashed build on device - SMS, MMS, Calls are working fine
Change-Id: Ibbcab2c56a65a058e867b62a2541ed435d784c79
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index f410fad..70ebcdf 100644
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -8784,12 +8784,18 @@
}
/**
- * Returns the service state information on specified subscription.
+ * Returns the service state information on specified SIM slot.
*/
@Override
- public ServiceState getServiceStateForSubscriber(int subId,
- boolean renounceFineLocationAccess, boolean renounceCoarseLocationAccess,
- String callingPackage, String callingFeatureId) {
+ public ServiceState getServiceStateForSlot(int slotIndex, boolean renounceFineLocationAccess,
+ boolean renounceCoarseLocationAccess, String callingPackage, String callingFeatureId) {
+ Phone phone = PhoneFactory.getPhone(slotIndex);
+ if (phone == null) {
+ loge("getServiceStateForSlot retuning null for invalid slotIndex=" + slotIndex);
+ return null;
+ }
+
+ int subId = phone.getSubId();
if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState(
mApp, subId, callingPackage, callingFeatureId, "getServiceStateForSubscriber")) {
return null;
@@ -8808,7 +8814,7 @@
.setCallingFeatureId(callingFeatureId)
.setCallingPid(Binder.getCallingPid())
.setCallingUid(Binder.getCallingUid())
- .setMethod("getServiceStateForSubscriber")
+ .setMethod("getServiceStateForSlot")
.setLogAsInfo(true)
.setMinSdkVersionForFine(Build.VERSION_CODES.Q)
.setMinSdkVersionForCoarse(Build.VERSION_CODES.Q)
@@ -8826,7 +8832,7 @@
.setCallingFeatureId(callingFeatureId)
.setCallingPid(Binder.getCallingPid())
.setCallingUid(Binder.getCallingUid())
- .setMethod("getServiceStateForSubscriber")
+ .setMethod("getServiceStateForSlot")
.setLogAsInfo(true)
.setMinSdkVersionForCoarse(Build.VERSION_CODES.Q)
.setMinSdkVersionForFine(Integer.MAX_VALUE)
@@ -8836,26 +8842,18 @@
coarseLocationResult == LocationAccessPolicy.LocationPermissionResult.ALLOWED;
}
- final Phone phone = getPhone(subId);
- if (phone == null) {
- return null;
- }
-
final long identity = Binder.clearCallingIdentity();
-
- boolean isCallingPackageDataService = phone.getDataServicePackages()
- .contains(callingPackage);
try {
- // isActiveSubId requires READ_PHONE_STATE, which we already check for above
SubscriptionInfoInternal subInfo = getSubscriptionManagerService()
.getSubscriptionInfoInternal(subId);
- if (subInfo == null || !subInfo.isActive()) {
- Rlog.d(LOG_TAG, "getServiceStateForSubscriber returning null for inactive "
- + "subId=" + subId);
+ if (subInfo != null && !subInfo.isActive()) {
+ log("getServiceStateForSlot returning null for inactive subId=" + subId);
return null;
}
ServiceState ss = phone.getServiceState();
+ boolean isCallingPackageDataService = phone.getDataServicePackages()
+ .contains(callingPackage);
// Scrub out the location info in ServiceState depending on what level of access
// the caller has.