diff options
author | Julia Reynolds <juliacr@google.com> | 2015-08-13 09:01:33 -0400 |
---|---|---|
committer | Julia Reynolds <juliacr@google.com> | 2015-08-13 09:01:33 -0400 |
commit | ea6c4489598fce95ac0e22ff13290a9fb264db5a (patch) | |
tree | 1439a242260961d957cc638786794cf74c983039 /services | |
parent | bd29b07eab3956796a7a09d7612e42e22616f458 (diff) | |
download | frameworks_base-ea6c4489598fce95ac0e22ff13290a9fb264db5a.zip frameworks_base-ea6c4489598fce95ac0e22ff13290a9fb264db5a.tar.gz frameworks_base-ea6c4489598fce95ac0e22ff13290a9fb264db5a.tar.bz2 |
Clear calling identity before getting the current user.
This is necessary so non-privilged apps can call setInterruptionFilter.
Bug: 23156657
Change-Id: Ia903a39626c93957276d66805446cd25a91341b5
Diffstat (limited to 'services')
-rw-r--r-- | services/core/java/com/android/server/notification/NotificationManagerService.java | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java index 9426b76..4351798 100644 --- a/services/core/java/com/android/server/notification/NotificationManagerService.java +++ b/services/core/java/com/android/server/notification/NotificationManagerService.java @@ -3615,22 +3615,28 @@ public class NotificationManagerService extends SystemService { public ArraySet<String> getGrantedPackages() { final ArraySet<String> pkgs = new ArraySet<>(); - final String setting = Settings.Secure.getStringForUser( - getContext().getContentResolver(), - Settings.Secure.ENABLED_NOTIFICATION_POLICY_ACCESS_PACKAGES, - ActivityManager.getCurrentUser()); - if (setting != null) { - final String[] tokens = setting.split(SEPARATOR); - for (int i = 0; i < tokens.length; i++) { - String token = tokens[i]; - if (token != null) { - token.trim(); - } - if (TextUtils.isEmpty(token)) { - continue; + + long identity = Binder.clearCallingIdentity(); + try { + final String setting = Settings.Secure.getStringForUser( + getContext().getContentResolver(), + Settings.Secure.ENABLED_NOTIFICATION_POLICY_ACCESS_PACKAGES, + ActivityManager.getCurrentUser()); + if (setting != null) { + final String[] tokens = setting.split(SEPARATOR); + for (int i = 0; i < tokens.length; i++) { + String token = tokens[i]; + if (token != null) { + token.trim(); + } + if (TextUtils.isEmpty(token)) { + continue; + } + pkgs.add(token); } - pkgs.add(token); } + } finally { + Binder.restoreCallingIdentity(identity); } return pkgs; } |