From 5e523fa37818679d6f7e5398e82389a6bef93d6e Mon Sep 17 00:00:00 2001 From: jovanak Date: Tue, 10 Apr 2018 15:59:11 -0700 Subject: [PATCH] Adds user broadcasts to UserManagerHelper. Same broadcasts supported by UserSwitcherController. Car User switcher listens to user changes. Switcher needs to hear when the user is switched to dismiss the keyguard,which causes the switching animation to terminate. Bug:77653809 Test: Unit tests. Change-Id: I633cbd9045e7254dcc173ca0e1118fca06c669df --- .../com/android/settingslib/users/UserManagerHelper.java | 3 +++ .../android/settingslib/users/UserManagerHelperTest.java | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/SettingsLib/src/com/android/settingslib/users/UserManagerHelper.java b/packages/SettingsLib/src/com/android/settingslib/users/UserManagerHelper.java index c4ca339b39be0..8ae98799daab2 100644 --- a/packages/SettingsLib/src/com/android/settingslib/users/UserManagerHelper.java +++ b/packages/SettingsLib/src/com/android/settingslib/users/UserManagerHelper.java @@ -348,6 +348,9 @@ public final class UserManagerHelper { filter.addAction(Intent.ACTION_USER_REMOVED); filter.addAction(Intent.ACTION_USER_ADDED); filter.addAction(Intent.ACTION_USER_INFO_CHANGED); + filter.addAction(Intent.ACTION_USER_SWITCHED); + filter.addAction(Intent.ACTION_USER_STOPPED); + filter.addAction(Intent.ACTION_USER_UNLOCKED); mContext.registerReceiverAsUser(mUserChangeReceiver, UserHandle.ALL, filter, null, null); } diff --git a/packages/SettingsLib/tests/integ/src/com/android/settingslib/users/UserManagerHelperTest.java b/packages/SettingsLib/tests/integ/src/com/android/settingslib/users/UserManagerHelperTest.java index 3f1fcbb2966b0..edf45e629c11e 100644 --- a/packages/SettingsLib/tests/integ/src/com/android/settingslib/users/UserManagerHelperTest.java +++ b/packages/SettingsLib/tests/integ/src/com/android/settingslib/users/UserManagerHelperTest.java @@ -335,10 +335,14 @@ public class UserManagerHelperTest { // Verify the presence of each intent in the filter. // Verify the exact number of filters. Every time a new intent is added, this test should // get updated. - assertThat(filterCaptor.getValue().countActions()).isEqualTo(3); + assertThat(filterCaptor.getValue().countActions()).isEqualTo(6); assertThat(filterCaptor.getValue().hasAction(Intent.ACTION_USER_REMOVED)).isTrue(); assertThat(filterCaptor.getValue().hasAction(Intent.ACTION_USER_ADDED)).isTrue(); assertThat(filterCaptor.getValue().hasAction(Intent.ACTION_USER_INFO_CHANGED)).isTrue(); + assertThat(filterCaptor.getValue().hasAction(Intent.ACTION_USER_SWITCHED)).isTrue(); + assertThat(filterCaptor.getValue().hasAction(Intent.ACTION_USER_STOPPED)).isTrue(); + assertThat(filterCaptor.getValue().hasAction(Intent.ACTION_USER_UNLOCKED)).isTrue(); + // Verify that calling the receiver calls the listener. receiverCaptor.getValue().onReceive(mContext, new Intent());