summaryrefslogtreecommitdiff
path: root/services/devicepolicy
diff options
context:
space:
mode:
authorEran Messeri <eranm@google.com>2020-05-27 09:55:41 +0100
committerEran Messeri <eranm@google.com>2020-05-27 10:59:13 +0100
commitf7fd4fb116d366cc2107f5b4c7c92440898481a6 (patch)
tree4e8a0af979ba135b04547c20f1523c27326e9964 /services/devicepolicy
parent20467761276db28cd9786c9341601ef4d9b032a8 (diff)
Only notify when admin enables location for the user
Only notify the user when the admin enables location services on their device, not on every state change. Prior to this change the user would be notified when the admin disables location services, with a misleading notification indicating apps now have location available. Tested by installing TestDPC, setting it as device owner, then toggling location on and off and observing user is notified only on turning location on. Test both legacy and new method flows. Bug: 156602188 Test: Manual using TestDPC (see above) Change-Id: Ia757802bd7da1afeecfd8071598b692c69860c66
Diffstat (limited to 'services/devicepolicy')
-rw-r--r--services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java17
1 files changed, 10 insertions, 7 deletions
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
index b7a9ba56c013..8d32d7c970bc 100644
--- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
+++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
@@ -11951,11 +11951,11 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
user);
mInjector.getLocationManager().setLocationEnabledForUser(locationEnabled, user);
- // make a best effort to only show the notification if the admin is actually changing
- // something. this is subject to race conditions with settings changes, but those are
+ // 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 (wasLocationEnabled != locationEnabled) {
- showLocationSettingsChangedNotification(user);
+ if (locationEnabled && (wasLocationEnabled != locationEnabled)) {
+ showLocationSettingsEnabledNotification(user);
}
});
@@ -11968,7 +11968,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
.write();
}
- private void showLocationSettingsChangedNotification(UserHandle user) {
+ private void showLocationSettingsEnabledNotification(UserHandle user) {
Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS)
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
// Fill the component explicitly to prevent the PendingIntent from being intercepted
@@ -12100,8 +12100,11 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
saveSettingsLocked(callingUserId);
}
mInjector.settingsSecurePutStringForUser(setting, value, callingUserId);
- if (setting.equals(Settings.Secure.LOCATION_MODE)) {
- showLocationSettingsChangedNotification(UserHandle.of(callingUserId));
+ // Notify the user if it's the location mode setting that's been set, to any value
+ // other than 'off'.
+ if (setting.equals(Settings.Secure.LOCATION_MODE)
+ && (Integer.parseInt(value) != 0)) {
+ showLocationSettingsEnabledNotification(UserHandle.of(callingUserId));
}
});
}