Loading core/java/android/telephony/TelephonyCallback.java +19 −8 Original line number Diff line number Diff line Loading @@ -106,6 +106,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 Loading Loading @@ -485,8 +489,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 Loading @@ -504,8 +509,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 Loading Loading @@ -691,10 +697,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 Loading Loading @@ -1284,6 +1288,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). Loading Loading @@ -1462,6 +1469,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 */ Loading services/core/java/com/android/server/TelephonyRegistry.java +22 −28 Original line number Diff line number Diff line Loading @@ -493,9 +493,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, Loading Loading @@ -1359,9 +1357,12 @@ 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); if (VDBG) { log("listen: call onBarringInfoChanged=" + barringInfo); } if (barringInfo != null) { BarringInfo biNoLocation = barringInfo.createLocationInfoSanitizedCopy(); try { r.callback.onBarringInfoChanged( checkFineLocationAccess(r, Build.VERSION_CODES.BASE) Loading @@ -1370,6 +1371,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { remove(r.binder); } } } if (events.contains( TelephonyCallback.EVENT_PHYSICAL_CHANNEL_CONFIG_CHANGED)) { try { Loading Loading @@ -3618,6 +3620,8 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { private boolean checkListenerPermission(Set<Integer> events, int subId, String callingPackage, @Nullable String callingFeatureId, String message) { boolean isPermissionCheckSuccessful = true; if (isLocationPermissionRequired(events)) { LocationAccessPolicy.LocationPermissionQuery.Builder locationQueryBuilder = new LocationAccessPolicy.LocationPermissionQuery.Builder() .setCallingPackage(callingPackage) Loading @@ -3625,22 +3629,12 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { .setMethod(message + " events: " + events) .setCallingPid(Binder.getCallingPid()) .setCallingUid(Binder.getCallingUid()); boolean shouldCheckLocationPermissions = false; if (isLocationPermissionRequired(events)) { // 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()); Loading Loading
core/java/android/telephony/TelephonyCallback.java +19 −8 Original line number Diff line number Diff line Loading @@ -106,6 +106,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 Loading Loading @@ -485,8 +489,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 Loading @@ -504,8 +509,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 Loading Loading @@ -691,10 +697,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 Loading Loading @@ -1284,6 +1288,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). Loading Loading @@ -1462,6 +1469,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 */ Loading
services/core/java/com/android/server/TelephonyRegistry.java +22 −28 Original line number Diff line number Diff line Loading @@ -493,9 +493,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, Loading Loading @@ -1359,9 +1357,12 @@ 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); if (VDBG) { log("listen: call onBarringInfoChanged=" + barringInfo); } if (barringInfo != null) { BarringInfo biNoLocation = barringInfo.createLocationInfoSanitizedCopy(); try { r.callback.onBarringInfoChanged( checkFineLocationAccess(r, Build.VERSION_CODES.BASE) Loading @@ -1370,6 +1371,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { remove(r.binder); } } } if (events.contains( TelephonyCallback.EVENT_PHYSICAL_CHANNEL_CONFIG_CHANGED)) { try { Loading Loading @@ -3618,6 +3620,8 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { private boolean checkListenerPermission(Set<Integer> events, int subId, String callingPackage, @Nullable String callingFeatureId, String message) { boolean isPermissionCheckSuccessful = true; if (isLocationPermissionRequired(events)) { LocationAccessPolicy.LocationPermissionQuery.Builder locationQueryBuilder = new LocationAccessPolicy.LocationPermissionQuery.Builder() .setCallingPackage(callingPackage) Loading @@ -3625,22 +3629,12 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { .setMethod(message + " events: " + events) .setCallingPid(Binder.getCallingPid()) .setCallingUid(Binder.getCallingUid()); boolean shouldCheckLocationPermissions = false; if (isLocationPermissionRequired(events)) { // 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()); Loading