Loading core/java/android/app/admin/DevicePolicyManager.java +3 −0 Original line number Diff line number Diff line Loading @@ -10368,6 +10368,9 @@ public class DevicePolicyManager { /** * Called by device owners to set the user's global location setting. * * <p><b>Note: </b> this call is ignored on * {@link android.content.pm.PackageManager#FEATURE_AUTOMOTIVE automotive builds}. * * @param admin Which {@link DeviceAdminReceiver} this request is associated with * @param locationEnabled whether location should be enabled or disabled * @throws SecurityException if {@code admin} is not a device owner. Loading services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +12 −4 Original line number Diff line number Diff line Loading @@ -11931,17 +11931,25 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { final CallerIdentity caller = getCallerIdentity(who); Preconditions.checkCallAuthorization(isDeviceOwner(caller)); UserHandle userHandle = caller.getUserHandle(); if (mIsAutomotive) { Slogf.v(LOG_TAG, "setLocationEnabled(%s, %b): ignoring for user %s on automotive build", who.flattenToShortString(), locationEnabled, userHandle); return; } mInjector.binderWithCleanCallingIdentity(() -> { boolean wasLocationEnabled = mInjector.getLocationManager().isLocationEnabledForUser( caller.getUserHandle()); mInjector.getLocationManager().setLocationEnabledForUser(locationEnabled, caller.getUserHandle()); userHandle); Slogf.v(LOG_TAG, "calling locationManager.setLocationEnabledForUser(%b, %s)", locationEnabled, userHandle); mInjector.getLocationManager().setLocationEnabledForUser(locationEnabled, userHandle); // make a best effort to only show the notification if the admin is actually enabling // location. this is subject to race conditions with settings changes, but those are // unlikely to realistically interfere if (locationEnabled && !wasLocationEnabled) { showLocationSettingsEnabledNotification(caller.getUserHandle()); showLocationSettingsEnabledNotification(userHandle); } }); Loading
core/java/android/app/admin/DevicePolicyManager.java +3 −0 Original line number Diff line number Diff line Loading @@ -10368,6 +10368,9 @@ public class DevicePolicyManager { /** * Called by device owners to set the user's global location setting. * * <p><b>Note: </b> this call is ignored on * {@link android.content.pm.PackageManager#FEATURE_AUTOMOTIVE automotive builds}. * * @param admin Which {@link DeviceAdminReceiver} this request is associated with * @param locationEnabled whether location should be enabled or disabled * @throws SecurityException if {@code admin} is not a device owner. Loading
services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +12 −4 Original line number Diff line number Diff line Loading @@ -11931,17 +11931,25 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { final CallerIdentity caller = getCallerIdentity(who); Preconditions.checkCallAuthorization(isDeviceOwner(caller)); UserHandle userHandle = caller.getUserHandle(); if (mIsAutomotive) { Slogf.v(LOG_TAG, "setLocationEnabled(%s, %b): ignoring for user %s on automotive build", who.flattenToShortString(), locationEnabled, userHandle); return; } mInjector.binderWithCleanCallingIdentity(() -> { boolean wasLocationEnabled = mInjector.getLocationManager().isLocationEnabledForUser( caller.getUserHandle()); mInjector.getLocationManager().setLocationEnabledForUser(locationEnabled, caller.getUserHandle()); userHandle); Slogf.v(LOG_TAG, "calling locationManager.setLocationEnabledForUser(%b, %s)", locationEnabled, userHandle); mInjector.getLocationManager().setLocationEnabledForUser(locationEnabled, userHandle); // make a best effort to only show the notification if the admin is actually enabling // location. this is subject to race conditions with settings changes, but those are // unlikely to realistically interfere if (locationEnabled && !wasLocationEnabled) { showLocationSettingsEnabledNotification(caller.getUserHandle()); showLocationSettingsEnabledNotification(userHandle); } });