diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java index 38b19ae98934a..c23cacb6a4c21 100644 --- a/core/java/android/app/admin/DevicePolicyManager.java +++ b/core/java/android/app/admin/DevicePolicyManager.java @@ -10369,11 +10369,11 @@ public class DevicePolicyManager { /** * Called by device owners to set the user's global location setting. * - *
Note: 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 + * @param locationEnabled whether location should be enabled or disabled. Note: on + * {@link android.content.pm.PackageManager#FEATURE_AUTOMOTIVE automotive builds}, calls to + * disable will be ignored. * @throws SecurityException if {@code admin} is not a device owner. */ public void setLocationEnabled(@NonNull ComponentName admin, boolean locationEnabled) { diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java index 23a67b72c7346..3d9fdae80b94d 100644 --- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java @@ -11987,8 +11987,8 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { Preconditions.checkCallAuthorization(isDeviceOwner(caller)); UserHandle userHandle = caller.getUserHandle(); - if (mIsAutomotive) { - Slogf.v(LOG_TAG, "setLocationEnabled(%s, %b): ignoring for user %s on automotive build", + if (mIsAutomotive && !locationEnabled) { + Slogf.i(LOG_TAG, "setLocationEnabled(%s, %b): ignoring for user %s on automotive build", who.flattenToShortString(), locationEnabled, userHandle); return; } @@ -11996,8 +11996,8 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { mInjector.binderWithCleanCallingIdentity(() -> { boolean wasLocationEnabled = mInjector.getLocationManager().isLocationEnabledForUser( userHandle); - Slogf.v(LOG_TAG, "calling locationManager.setLocationEnabledForUser(%b, %s)", - locationEnabled, userHandle); + Slogf.v(LOG_TAG, "calling locationMgr.setLocationEnabledForUser(%b, %s) when it was %b", + locationEnabled, userHandle, wasLocationEnabled); mInjector.getLocationManager().setLocationEnabledForUser(locationEnabled, userHandle); // make a best effort to only show the notification if the admin is actually enabling