Fix flash notification preview not working for second user issue
When switching to second user and try to preview the flash notification effect it'll not work. The root cause is the receiver is registered in system process and the broadcast is sent as second user. Needs to send the broadcast as system user to let the receiver receive the preview broadcast. Bug: 286039180 Test: atest FlashNotificationsPreviewPreferenceControllerTest Test: switch to second user and test the preview function Change-Id: I7dd553dac9fd66dab59eaec25849aac9f92989b6
This commit is contained in:
@@ -131,7 +131,7 @@ public class FlashNotificationsPreviewPreferenceControllerTest {
|
||||
@Test
|
||||
public void testHandlePreferenceTreeClick_invalidPreference() {
|
||||
mController.handlePreferenceTreeClick(mock(Preference.class));
|
||||
verify(mContext, never()).sendBroadcast(any());
|
||||
verify(mContext, never()).sendBroadcastAsUser(any(), any());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -139,7 +139,7 @@ public class FlashNotificationsPreviewPreferenceControllerTest {
|
||||
mController.handlePreferenceTreeClick(mPreference);
|
||||
|
||||
ArgumentCaptor<Intent> captor = ArgumentCaptor.forClass(Intent.class);
|
||||
verify(mContext).sendBroadcast(captor.capture());
|
||||
verify(mContext).sendBroadcastAsUser(captor.capture(), any());
|
||||
Intent captured = captor.getValue();
|
||||
|
||||
assertThat(captured.getAction()).isEqualTo(ACTION_FLASH_NOTIFICATION_START_PREVIEW);
|
||||
@@ -150,7 +150,7 @@ public class FlashNotificationsPreviewPreferenceControllerTest {
|
||||
mController.handlePreferenceTreeClick(mPreference);
|
||||
|
||||
ArgumentCaptor<Intent> captor = ArgumentCaptor.forClass(Intent.class);
|
||||
verify(mContext).sendBroadcast(captor.capture());
|
||||
verify(mContext).sendBroadcastAsUser(captor.capture(), any());
|
||||
Intent captured = captor.getValue();
|
||||
|
||||
assertThat(captured.getIntExtra(EXTRA_FLASH_NOTIFICATION_PREVIEW_TYPE, TYPE_LONG_PREVIEW))
|
||||
|
Reference in New Issue
Block a user