diff options
author | Elliot Sisteron <elliotsisteron@google.com> | 2023-06-26 10:59:41 +0000 |
---|---|---|
committer | Elliot Sisteron <elliotsisteron@google.com> | 2023-06-26 11:06:21 +0000 |
commit | 5b89345894864c5f25ab27d3af00f2df74a82186 (patch) | |
tree | e2846f5c0eec40a3f5054f6ac505d33912cc780f /service | |
parent | 0ac1ec1039eae88efe5ffede3c30f399cb31e876 (diff) | |
download | Permission-5b89345894864c5f25ab27d3af00f2df74a82186.tar.gz |
Refresh sources on user switch, not add.
On user add:
- The user may not be the running user
- The user will likely not have fully started yet,
even if switched to
Bug: 288541883
Test: atest SafetyCenterFunctionalMultiUsersTestCases
Relnote: Slightly better handling of user switch for Security & Privacy
Change-Id: Ia8ecb5b7184c01c2e8cd45d78885b4e441329c9c
Diffstat (limited to 'service')
-rw-r--r-- | service/java/com/android/safetycenter/SafetyCenterService.java | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/service/java/com/android/safetycenter/SafetyCenterService.java b/service/java/com/android/safetycenter/SafetyCenterService.java index 42a65e706..e3aedafa0 100644 --- a/service/java/com/android/safetycenter/SafetyCenterService.java +++ b/service/java/com/android/safetycenter/SafetyCenterService.java @@ -1065,7 +1065,7 @@ public final class SafetyCenterService extends SystemService { void register(Context context) { IntentFilter filter = new IntentFilter(); - filter.addAction(Intent.ACTION_USER_ADDED); + filter.addAction(Intent.ACTION_USER_SWITCHED); filter.addAction(Intent.ACTION_USER_REMOVED); filter.addAction(Intent.ACTION_MANAGED_PROFILE_ADDED); filter.addAction(Intent.ACTION_MANAGED_PROFILE_REMOVED); @@ -1116,9 +1116,26 @@ public final class SafetyCenterService extends SystemService { case Intent.ACTION_MANAGED_PROFILE_UNAVAILABLE: removeUser(userId); break; - case Intent.ACTION_USER_ADDED: + case Intent.ACTION_USER_SWITCHED: + if (userId != ActivityManager.getCurrentUser()) { + Log.w( + TAG, + "Received broadcast for user id: " + + userId + + ", which is not the current user"); + return; + } + // Fall through case Intent.ACTION_MANAGED_PROFILE_ADDED: case Intent.ACTION_MANAGED_PROFILE_AVAILABLE: + if (!UserUtils.isUserExistent(userId, getContext())) { + Log.w( + TAG, + "Received broadcast for user id: " + + userId + + ", which does not exist"); + return; + } synchronized (mApiLock) { startRefreshingSafetySourcesLocked(REFRESH_REASON_OTHER, userId); mNotificationChannels.createAllChannelsForUser(getContext(), userHandle); |