From 871fa7343a2ff8de837a721eacfc576b19438e54 Mon Sep 17 00:00:00 2001 From: Zoltan Szatmary-Ban Date: Fri, 16 Jan 2015 12:36:29 +0000 Subject: [PATCH] Ensure notifications are sent when locking/unlocking location share When the restriction 'DISALLOW_SHARE_LOCATION' is applied or removed on a user it is important to send out notifications to content observers of LOCATION_PROVIDERS_ALLOWED. Bug: 18995405 Change-Id: I8b3910a423a012ea9d15470eec101723c9f0eaf7 --- .../devicepolicy/DevicePolicyManagerService.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java index aae496c4d2690..d536906e90a1f 100644 --- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java @@ -4872,6 +4872,19 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { } } mUserManager.setUserRestriction(key, enabled, user); + if (enabled != alreadyRestricted) { + if (UserManager.DISALLOW_SHARE_LOCATION.equals(key)) { + // Send out notifications however as some clients may want to reread the + // value which actually changed due to a restriction having been applied. + final String property = Settings.Secure.SYS_PROP_SETTING_VERSION; + long version = SystemProperties.getLong(property, 0) + 1; + SystemProperties.set(property, Long.toString(version)); + + final String name = Settings.Secure.LOCATION_PROVIDERS_ALLOWED; + Uri url = Uri.withAppendedPath(Settings.Secure.CONTENT_URI, name); + mContext.getContentResolver().notifyChange(url, null, true, userHandle); + } + } } finally { restoreCallingIdentity(id); }