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
This commit is contained in:
Zoltan Szatmary-Ban
2015-01-16 12:36:29 +00:00
parent 3379c1cb62
commit 871fa7343a

View File

@@ -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);
}