Merge changes from topic "servicelocation" am: bf35744779 am: bdda52bc14
Original change: https://android-review.googlesource.com/c/platform/packages/services/Telephony/+/1356224
Change-Id: I442b23b169e87d0de77df3cbd40ad823e0d17c18
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index ec46469..188a921 100755
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -1945,20 +1945,52 @@
}
}
+ /**
+ * This method has been removed due to privacy and stability concerns.
+ */
+ @Override
public void updateServiceLocation() {
- updateServiceLocationForSubscriber(getDefaultSubscription());
-
+ Log.e(LOG_TAG, "Call to unsupported method updateServiceLocation()");
+ return;
}
- public void updateServiceLocationForSubscriber(int subId) {
- // No permission check needed here: this call is harmless, and it's
- // needed for the ServiceState.requestStateUpdate() call (which is
- // already intentionally exposed to 3rd parties.)
+ @Override
+ public void updateServiceLocationWithPackageName(String callingPackage) {
+ mApp.getSystemService(AppOpsManager.class)
+ .checkPackage(Binder.getCallingUid(), callingPackage);
+
+ final int targetSdk = getTargetSdk(callingPackage);
+ if (targetSdk > android.os.Build.VERSION_CODES.R) {
+ // Callers targeting S have no business invoking this method.
+ return;
+ }
+
+ LocationAccessPolicy.LocationPermissionResult locationResult =
+ LocationAccessPolicy.checkLocationPermission(mApp,
+ new LocationAccessPolicy.LocationPermissionQuery.Builder()
+ .setCallingPackage(callingPackage)
+ .setCallingFeatureId(null)
+ .setCallingPid(Binder.getCallingPid())
+ .setCallingUid(Binder.getCallingUid())
+ .setMethod("updateServiceLocation")
+ .setMinSdkVersionForCoarse(Build.VERSION_CODES.BASE)
+ .setMinSdkVersionForFine(Build.VERSION_CODES.Q)
+ .build());
+ // Apps that lack location permission have no business calling this method;
+ // however, because no permission was declared in the public API, denials must
+ // all be "soft".
+ switch (locationResult) {
+ case DENIED_HARD: /* fall through */
+ case DENIED_SOFT:
+ return;
+ }
+
+ WorkSource workSource = getWorkSource(Binder.getCallingUid());
final long identity = Binder.clearCallingIdentity();
try {
- final Phone phone = getPhone(subId);
+ final Phone phone = getPhone(getDefaultSubscription());
if (phone != null) {
- phone.updateServiceLocation();
+ phone.updateServiceLocation(workSource);
}
} finally {
Binder.restoreCallingIdentity(identity);
@@ -2334,46 +2366,30 @@
}
}
+ /**
+ * This method was removed due to potential issues caused by performing partial
+ * updates of service state, and lack of a credible use case.
+ *
+ * This has the ability to break the telephony implementation by disabling notification of
+ * changes in device connectivity. DO NOT USE THIS!
+ */
@Override
public void enableLocationUpdates() {
- enableLocationUpdatesForSubscriber(getDefaultSubscription());
- }
-
- @Override
- public void enableLocationUpdatesForSubscriber(int subId) {
mApp.enforceCallingOrSelfPermission(
android.Manifest.permission.CONTROL_LOCATION_UPDATES, null);
-
- final long identity = Binder.clearCallingIdentity();
- try {
- final Phone phone = getPhone(subId);
- if (phone != null) {
- phone.enableLocationUpdates();
- }
- } finally {
- Binder.restoreCallingIdentity(identity);
- }
}
+ /**
+ * This method was removed due to potential issues caused by performing partial
+ * updates of service state, and lack of a credible use case.
+ *
+ * This has the ability to break the telephony implementation by disabling notification of
+ * changes in device connectivity. DO NOT USE THIS!
+ */
@Override
public void disableLocationUpdates() {
- disableLocationUpdatesForSubscriber(getDefaultSubscription());
- }
-
- @Override
- public void disableLocationUpdatesForSubscriber(int subId) {
mApp.enforceCallingOrSelfPermission(
android.Manifest.permission.CONTROL_LOCATION_UPDATES, null);
-
- final long identity = Binder.clearCallingIdentity();
- try {
- final Phone phone = getPhone(subId);
- if (phone != null) {
- phone.disableLocationUpdates();
- }
- } finally {
- Binder.restoreCallingIdentity(identity);
- }
}
/**