summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/java/android/telephony/TelephonyCallback.java27
-rw-r--r--services/core/java/com/android/server/TelephonyRegistry.java50
2 files changed, 41 insertions, 36 deletions
diff --git a/core/java/android/telephony/TelephonyCallback.java b/core/java/android/telephony/TelephonyCallback.java
index e90ae757abd2..4ad1ab0bc1dc 100644
--- a/core/java/android/telephony/TelephonyCallback.java
+++ b/core/java/android/telephony/TelephonyCallback.java
@@ -104,6 +104,10 @@ public class TelephonyCallback {
/**
* Event for changes to the network service state (cellular).
*
+ * <p>Requires {@link Manifest.permission#ACCESS_FINE_LOCATION} or {@link
+ * Manifest.permission#ACCESS_COARSE_LOCATION} depending on the accuracy of the location info
+ * listeners want to get.
+ *
* @hide
* @see ServiceStateListener#onServiceStateChanged
* @see ServiceState
@@ -483,8 +487,9 @@ public class TelephonyCallback {
* <p>Requires permission {@link android.Manifest.permission#READ_PRECISE_PHONE_STATE} or
* the calling app has carrier privileges (see {@link TelephonyManager#hasCarrierPrivileges}).
*
- * <p>Also requires the {@link Manifest.permission#ACCESS_FINE_LOCATION} permission, regardless
- * of whether the calling app has carrier privileges.
+ * <p>Requires the {@link Manifest.permission#ACCESS_FINE_LOCATION} permission in case that
+ * listener want to get location info in {@link CellIdentity} regardless of whether the calling
+ * app has carrier privileges.
*
* @hide
* @see RegistrationFailedListener#onRegistrationFailed
@@ -502,8 +507,9 @@ public class TelephonyCallback {
* <p>Requires permission {@link android.Manifest.permission#READ_PRECISE_PHONE_STATE} or
* the calling app has carrier privileges (see {@link TelephonyManager#hasCarrierPrivileges}).
*
- * <p>Also requires the {@link Manifest.permission#ACCESS_FINE_LOCATION} permission, regardless
- * of whether the calling app has carrier privileges.
+ * <p>Requires the {@link Manifest.permission#ACCESS_FINE_LOCATION} permission in case that
+ * listener want to get {@link BarringInfo} which includes location info in {@link CellIdentity}
+ * regardless of whether the calling app has carrier privileges.
*
* @hide
* @see BarringInfoListener#onBarringInfoChanged
@@ -675,10 +681,8 @@ public class TelephonyCallback {
* Only apps holding the {@link Manifest.permission#ACCESS_FINE_LOCATION} permission will
* receive all the information in {@link ServiceState}, otherwise the cellIdentity
* will be null if apps only holding the {@link Manifest.permission#ACCESS_COARSE_LOCATION}
- * permission.
- * Network operator name in long/short alphanumeric format and numeric id will be null if
- * apps holding neither {@link android.Manifest.permission#ACCESS_FINE_LOCATION} nor
- * {@link android.Manifest.permission#ACCESS_COARSE_LOCATION}.
+ * permission. Network operator name in long/short alphanumeric format and numeric id will
+ * be null if apps holding neither {@link android.Manifest.permission#ACCESS_FINE_LOCATION}
*
* @see ServiceState#STATE_EMERGENCY_ONLY
* @see ServiceState#STATE_IN_SERVICE
@@ -1268,6 +1272,9 @@ public class TelephonyCallback {
* {@link android.Manifest.permission#READ_PRECISE_PHONE_STATE} and
* {@link android.Manifest.permission#ACCESS_FINE_LOCATION}.
*
+ * If the calling app doesn't have {@link android.Manifest.permission#ACCESS_FINE_LOCATION},
+ * it will receive {@link CellIdentity} without location-sensitive information included.
+ *
* @param cellIdentity the CellIdentity, which must include the globally unique
* identifier
* for the cell (for example, all components of the CGI or ECGI).
@@ -1446,6 +1453,10 @@ public class TelephonyCallback {
* {@link android.Manifest.permission#READ_PRECISE_PHONE_STATE} and
* {@link android.Manifest.permission#ACCESS_FINE_LOCATION}.
*
+ * If the calling app doesn't have {@link android.Manifest.permission#ACCESS_FINE_LOCATION},
+ * it will receive {@link BarringInfo} including {@link CellIdentity} without
+ * location-sensitive information included.
+ *
* @param barringInfo for all services on the current cell.
* @see android.telephony.BarringInfo
*/
diff --git a/services/core/java/com/android/server/TelephonyRegistry.java b/services/core/java/com/android/server/TelephonyRegistry.java
index ee922f9b98df..4b85fa82d0e8 100644
--- a/services/core/java/com/android/server/TelephonyRegistry.java
+++ b/services/core/java/com/android/server/TelephonyRegistry.java
@@ -487,9 +487,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
private boolean isLocationPermissionRequired(Set<Integer> events) {
return events.contains(TelephonyCallback.EVENT_CELL_LOCATION_CHANGED)
- || events.contains(TelephonyCallback.EVENT_CELL_INFO_CHANGED)
- || events.contains(TelephonyCallback.EVENT_REGISTRATION_FAILURE)
- || events.contains(TelephonyCallback.EVENT_BARRING_INFO_CHANGED);
+ || events.contains(TelephonyCallback.EVENT_CELL_INFO_CHANGED);
}
private boolean isPhoneStatePermissionRequired(Set<Integer> events, String callingPackage,
@@ -1349,15 +1347,19 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
}
if (events.contains(TelephonyCallback.EVENT_BARRING_INFO_CHANGED)) {
BarringInfo barringInfo = mBarringInfo.get(r.phoneId);
- BarringInfo biNoLocation = barringInfo != null
- ? barringInfo.createLocationInfoSanitizedCopy() : null;
- if (VDBG) log("listen: call onBarringInfoChanged=" + barringInfo);
- try {
- r.callback.onBarringInfoChanged(
- checkFineLocationAccess(r, Build.VERSION_CODES.BASE)
- ? barringInfo : biNoLocation);
- } catch (RemoteException ex) {
- remove(r.binder);
+ if (VDBG) {
+ log("listen: call onBarringInfoChanged=" + barringInfo);
+ }
+ if (barringInfo != null) {
+ BarringInfo biNoLocation = barringInfo.createLocationInfoSanitizedCopy();
+
+ try {
+ r.callback.onBarringInfoChanged(
+ checkFineLocationAccess(r, Build.VERSION_CODES.BASE)
+ ? barringInfo : biNoLocation);
+ } catch (RemoteException ex) {
+ remove(r.binder);
+ }
}
}
if (events.contains(
@@ -3522,29 +3524,21 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
private boolean checkListenerPermission(Set<Integer> events, int subId, String callingPackage,
@Nullable String callingFeatureId, String message) {
- LocationAccessPolicy.LocationPermissionQuery.Builder locationQueryBuilder =
- new LocationAccessPolicy.LocationPermissionQuery.Builder()
- .setCallingPackage(callingPackage)
- .setCallingFeatureId(callingFeatureId)
- .setMethod(message + " events: " + events)
- .setCallingPid(Binder.getCallingPid())
- .setCallingUid(Binder.getCallingUid());
-
- boolean shouldCheckLocationPermissions = false;
-
+ boolean isPermissionCheckSuccessful = true;
if (isLocationPermissionRequired(events)) {
+ LocationAccessPolicy.LocationPermissionQuery.Builder locationQueryBuilder =
+ new LocationAccessPolicy.LocationPermissionQuery.Builder()
+ .setCallingPackage(callingPackage)
+ .setCallingFeatureId(callingFeatureId)
+ .setMethod(message + " events: " + events)
+ .setCallingPid(Binder.getCallingPid())
+ .setCallingUid(Binder.getCallingUid());
// Everything that requires fine location started in Q. So far...
locationQueryBuilder.setMinSdkVersionForFine(Build.VERSION_CODES.Q);
// If we're enforcing fine starting in Q, we also want to enforce coarse even for
// older SDK versions.
locationQueryBuilder.setMinSdkVersionForCoarse(0);
locationQueryBuilder.setMinSdkVersionForEnforcement(0);
- shouldCheckLocationPermissions = true;
- }
-
- boolean isPermissionCheckSuccessful = true;
-
- if (shouldCheckLocationPermissions) {
LocationAccessPolicy.LocationPermissionResult result =
LocationAccessPolicy.checkLocationPermission(
mContext, locationQueryBuilder.build());