Merge "Add new getServiceStateForSlot API" into 24D1-dev am: 25750d0bbf
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/services/Telephony/+/27284532
Change-Id: Ie8a412137b5f20aaf2f8e99a775694319de3db28
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index 8de8ae1..d7eb4b8 100644
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -8795,12 +8795,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;
@@ -8819,7 +8825,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)
@@ -8837,7 +8843,7 @@
.setCallingFeatureId(callingFeatureId)
.setCallingPid(Binder.getCallingPid())
.setCallingUid(Binder.getCallingUid())
- .setMethod("getServiceStateForSubscriber")
+ .setMethod("getServiceStateForSlot")
.setLogAsInfo(true)
.setMinSdkVersionForCoarse(Build.VERSION_CODES.Q)
.setMinSdkVersionForFine(Integer.MAX_VALUE)
@@ -8847,26 +8853,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.