Loading packages/SystemUI/src/com/android/systemui/GuestResumeSessionReceiver.java +1 −1 Original line number Diff line number Diff line Loading @@ -128,7 +128,7 @@ public class GuestResumeSessionReceiver extends BroadcastReceiver { UserSwitcherController userSwitcherController, UiEventLogger uiEventLogger, int userId) { super(context); super(context, false /* dismissOnDeviceLock */); setTitle(context.getString(R.string.guest_wipe_session_title)); setMessage(context.getString(R.string.guest_wipe_session_message)); Loading packages/SystemUI/src/com/android/systemui/statusbar/phone/SystemUIDialog.java +8 −2 Original line number Diff line number Diff line Loading @@ -63,6 +63,8 @@ public class SystemUIDialog extends AlertDialog implements ViewRootImpl.ConfigCh // TODO(b/203389579): Remove this once the dialog width on large screens has been agreed on. private static final String FLAG_TABLET_DIALOG_WIDTH = "persist.systemui.flag_tablet_dialog_width"; private static final int DEFAULT_THEME = R.style.Theme_SystemUI_Dialog; private static final boolean DEFAULT_DISMISS_ON_DEVICE_LOCK = true; private final Context mContext; @Nullable private final DismissReceiver mDismissReceiver; Loading @@ -78,11 +80,15 @@ public class SystemUIDialog extends AlertDialog implements ViewRootImpl.ConfigCh private List<Runnable> mOnCreateRunnables = new ArrayList<>(); public SystemUIDialog(Context context) { this(context, R.style.Theme_SystemUI_Dialog); this(context, DEFAULT_THEME, DEFAULT_DISMISS_ON_DEVICE_LOCK); } public SystemUIDialog(Context context, int theme) { this(context, theme, true /* dismissOnDeviceLock */); this(context, theme, DEFAULT_DISMISS_ON_DEVICE_LOCK); } public SystemUIDialog(Context context, boolean dismissOnDeviceLock) { this(context, DEFAULT_THEME, dismissOnDeviceLock); } public SystemUIDialog(Context context, int theme, boolean dismissOnDeviceLock) { Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/SystemUIDialogTest.java +18 −4 Original line number Diff line number Diff line Loading @@ -14,10 +14,12 @@ package com.android.systemui.statusbar.phone; import static junit.framework.Assert.assertFalse; import static junit.framework.Assert.assertTrue; import static org.mockito.Matchers.any; import static org.mockito.Matchers.eq; import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; import android.content.BroadcastReceiver; Loading @@ -43,7 +45,6 @@ import org.mockito.MockitoAnnotations; @SmallTest public class SystemUIDialogTest extends SysuiTestCase { private SystemUIDialog mDialog; @Mock private BroadcastDispatcher mBroadcastDispatcher; Loading @@ -52,12 +53,11 @@ public class SystemUIDialogTest extends SysuiTestCase { MockitoAnnotations.initMocks(this); mDependency.injectTestDependency(BroadcastDispatcher.class, mBroadcastDispatcher); mDialog = new SystemUIDialog(mContext); } @Test public void testRegisterReceiver() { final SystemUIDialog mDialog = new SystemUIDialog(mContext); final ArgumentCaptor<BroadcastReceiver> broadcastReceiverCaptor = ArgumentCaptor.forClass(BroadcastReceiver.class); final ArgumentCaptor<IntentFilter> intentFilterCaptor = Loading @@ -66,10 +66,24 @@ public class SystemUIDialogTest extends SysuiTestCase { mDialog.show(); verify(mBroadcastDispatcher).registerReceiver(broadcastReceiverCaptor.capture(), intentFilterCaptor.capture(), eq(null), any()); assertTrue(intentFilterCaptor.getValue().hasAction(Intent.ACTION_SCREEN_OFF)); assertTrue(intentFilterCaptor.getValue().hasAction(Intent.ACTION_CLOSE_SYSTEM_DIALOGS)); mDialog.dismiss(); verify(mBroadcastDispatcher).unregisterReceiver(eq(broadcastReceiverCaptor.getValue())); } @Test public void testNoRegisterReceiver() { final SystemUIDialog mDialog = new SystemUIDialog(mContext, false); mDialog.show(); verify(mBroadcastDispatcher, never()).registerReceiver(any(), any(), eq(null), any()); assertTrue(mDialog.isShowing()); mDialog.dismiss(); verify(mBroadcastDispatcher, never()).unregisterReceiver(any()); assertFalse(mDialog.isShowing()); } } Loading
packages/SystemUI/src/com/android/systemui/GuestResumeSessionReceiver.java +1 −1 Original line number Diff line number Diff line Loading @@ -128,7 +128,7 @@ public class GuestResumeSessionReceiver extends BroadcastReceiver { UserSwitcherController userSwitcherController, UiEventLogger uiEventLogger, int userId) { super(context); super(context, false /* dismissOnDeviceLock */); setTitle(context.getString(R.string.guest_wipe_session_title)); setMessage(context.getString(R.string.guest_wipe_session_message)); Loading
packages/SystemUI/src/com/android/systemui/statusbar/phone/SystemUIDialog.java +8 −2 Original line number Diff line number Diff line Loading @@ -63,6 +63,8 @@ public class SystemUIDialog extends AlertDialog implements ViewRootImpl.ConfigCh // TODO(b/203389579): Remove this once the dialog width on large screens has been agreed on. private static final String FLAG_TABLET_DIALOG_WIDTH = "persist.systemui.flag_tablet_dialog_width"; private static final int DEFAULT_THEME = R.style.Theme_SystemUI_Dialog; private static final boolean DEFAULT_DISMISS_ON_DEVICE_LOCK = true; private final Context mContext; @Nullable private final DismissReceiver mDismissReceiver; Loading @@ -78,11 +80,15 @@ public class SystemUIDialog extends AlertDialog implements ViewRootImpl.ConfigCh private List<Runnable> mOnCreateRunnables = new ArrayList<>(); public SystemUIDialog(Context context) { this(context, R.style.Theme_SystemUI_Dialog); this(context, DEFAULT_THEME, DEFAULT_DISMISS_ON_DEVICE_LOCK); } public SystemUIDialog(Context context, int theme) { this(context, theme, true /* dismissOnDeviceLock */); this(context, theme, DEFAULT_DISMISS_ON_DEVICE_LOCK); } public SystemUIDialog(Context context, boolean dismissOnDeviceLock) { this(context, DEFAULT_THEME, dismissOnDeviceLock); } public SystemUIDialog(Context context, int theme, boolean dismissOnDeviceLock) { Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/SystemUIDialogTest.java +18 −4 Original line number Diff line number Diff line Loading @@ -14,10 +14,12 @@ package com.android.systemui.statusbar.phone; import static junit.framework.Assert.assertFalse; import static junit.framework.Assert.assertTrue; import static org.mockito.Matchers.any; import static org.mockito.Matchers.eq; import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; import android.content.BroadcastReceiver; Loading @@ -43,7 +45,6 @@ import org.mockito.MockitoAnnotations; @SmallTest public class SystemUIDialogTest extends SysuiTestCase { private SystemUIDialog mDialog; @Mock private BroadcastDispatcher mBroadcastDispatcher; Loading @@ -52,12 +53,11 @@ public class SystemUIDialogTest extends SysuiTestCase { MockitoAnnotations.initMocks(this); mDependency.injectTestDependency(BroadcastDispatcher.class, mBroadcastDispatcher); mDialog = new SystemUIDialog(mContext); } @Test public void testRegisterReceiver() { final SystemUIDialog mDialog = new SystemUIDialog(mContext); final ArgumentCaptor<BroadcastReceiver> broadcastReceiverCaptor = ArgumentCaptor.forClass(BroadcastReceiver.class); final ArgumentCaptor<IntentFilter> intentFilterCaptor = Loading @@ -66,10 +66,24 @@ public class SystemUIDialogTest extends SysuiTestCase { mDialog.show(); verify(mBroadcastDispatcher).registerReceiver(broadcastReceiverCaptor.capture(), intentFilterCaptor.capture(), eq(null), any()); assertTrue(intentFilterCaptor.getValue().hasAction(Intent.ACTION_SCREEN_OFF)); assertTrue(intentFilterCaptor.getValue().hasAction(Intent.ACTION_CLOSE_SYSTEM_DIALOGS)); mDialog.dismiss(); verify(mBroadcastDispatcher).unregisterReceiver(eq(broadcastReceiverCaptor.getValue())); } @Test public void testNoRegisterReceiver() { final SystemUIDialog mDialog = new SystemUIDialog(mContext, false); mDialog.show(); verify(mBroadcastDispatcher, never()).registerReceiver(any(), any(), eq(null), any()); assertTrue(mDialog.isShowing()); mDialog.dismiss(); verify(mBroadcastDispatcher, never()).unregisterReceiver(any()); assertFalse(mDialog.isShowing()); } }