summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/phone/SystemUIDialogTest.java25
-rw-r--r--packages/SystemUI/src/com/android/systemui/reardisplay/RearDisplayInnerDialogDelegate.kt6
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/ComponentSystemUIDialog.kt1
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/SystemUIDialog.java55
4 files changed, 65 insertions, 22 deletions
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/phone/SystemUIDialogTest.java b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/phone/SystemUIDialogTest.java
index 79b5cc37119f..0652a835cb7c 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/phone/SystemUIDialogTest.java
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/phone/SystemUIDialogTest.java
@@ -27,6 +27,7 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import android.content.BroadcastReceiver;
+import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.Configuration;
@@ -120,6 +121,22 @@ public class SystemUIDialogTest extends SysuiTestCase {
}
@Test
+ public void testRegisterReceiverWithoutAcsd() {
+ SystemUIDialog dialog = createDialogWithDelegate(mContext, mDelegate,
+ false /* shouldAcsdDismissDialog */);
+ final ArgumentCaptor<BroadcastReceiver> broadcastReceiverCaptor =
+ ArgumentCaptor.forClass(BroadcastReceiver.class);
+ final ArgumentCaptor<IntentFilter> intentFilterCaptor =
+ ArgumentCaptor.forClass(IntentFilter.class);
+
+ dialog.show();
+ verify(mBroadcastDispatcher).registerReceiver(broadcastReceiverCaptor.capture(),
+ intentFilterCaptor.capture(), ArgumentMatchers.eq(null), ArgumentMatchers.any());
+ assertTrue(intentFilterCaptor.getValue().hasAction(Intent.ACTION_SCREEN_OFF));
+ assertFalse(intentFilterCaptor.getValue().hasAction(Intent.ACTION_CLOSE_SYSTEM_DIALOGS));
+ }
+
+ @Test
@RequiresFlagsEnabled(Flags.FLAG_PREDICTIVE_BACK_ANIMATE_DIALOGS)
public void usePredictiveBackAnimFlag() {
final SystemUIDialog dialog = new SystemUIDialog(mContext);
@@ -163,7 +180,8 @@ public class SystemUIDialogTest extends SysuiTestCase {
public void delegateIsCalled_inCorrectOrder() {
Configuration configuration = new Configuration();
InOrder inOrder = Mockito.inOrder(mDelegate);
- SystemUIDialog dialog = createDialogWithDelegate();
+ SystemUIDialog dialog = createDialogWithDelegate(mContext, mDelegate,
+ true /* shouldAcsdDismissDialog */);
dialog.show();
dialog.onWindowFocusChanged(/* hasFocus= */ true);
@@ -178,7 +196,8 @@ public class SystemUIDialogTest extends SysuiTestCase {
inOrder.verify(mDelegate).onStop(dialog);
}
- private SystemUIDialog createDialogWithDelegate() {
+ private SystemUIDialog createDialogWithDelegate(Context context,
+ SystemUIDialog.Delegate delegate, boolean shouldAcsdDismissDialog) {
SystemUIDialog.Factory factory = new SystemUIDialog.Factory(
getContext(),
Dependency.get(SystemUIDialogManager.class),
@@ -186,6 +205,6 @@ public class SystemUIDialogTest extends SysuiTestCase {
Dependency.get(BroadcastDispatcher.class),
Dependency.get(DialogTransitionAnimator.class)
);
- return factory.create(mDelegate);
+ return factory.create(delegate, context, shouldAcsdDismissDialog);
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/reardisplay/RearDisplayInnerDialogDelegate.kt b/packages/SystemUI/src/com/android/systemui/reardisplay/RearDisplayInnerDialogDelegate.kt
index 2d6181aa04af..1355ba8bdfd4 100644
--- a/packages/SystemUI/src/com/android/systemui/reardisplay/RearDisplayInnerDialogDelegate.kt
+++ b/packages/SystemUI/src/com/android/systemui/reardisplay/RearDisplayInnerDialogDelegate.kt
@@ -47,7 +47,11 @@ internal constructor(
}
override fun createDialog(): SystemUIDialog {
- return systemUIDialogFactory.create(this, rearDisplayContext)
+ return systemUIDialogFactory.create(
+ this,
+ rearDisplayContext,
+ false, /* shouldAcsdDismissDialog */
+ )
}
override fun onCreate(dialog: SystemUIDialog, savedInstanceState: Bundle?) {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ComponentSystemUIDialog.kt b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ComponentSystemUIDialog.kt
index fe5a02be2fb3..153dd990820d 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ComponentSystemUIDialog.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ComponentSystemUIDialog.kt
@@ -67,6 +67,7 @@ class ComponentSystemUIDialog(
broadcastDispatcher,
dialogTransitionAnimator,
delegate,
+ true, /* shouldAcsdDismissDialog */
),
LifecycleOwner,
SavedStateRegistryOwner,
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/SystemUIDialog.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/SystemUIDialog.java
index 0ad1042a665f..03324d2a3e6a 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/SystemUIDialog.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/SystemUIDialog.java
@@ -145,7 +145,7 @@ public class SystemUIDialog extends AlertDialog implements ViewRootImpl.ConfigCh
*/
public SystemUIDialog create() {
return create(new DialogDelegate<>() {
- }, mContext, DEFAULT_THEME);
+ }, mContext, DEFAULT_THEME, true /* shouldAcsdDismissDialog */);
}
/**
@@ -155,7 +155,7 @@ public class SystemUIDialog extends AlertDialog implements ViewRootImpl.ConfigCh
*/
public SystemUIDialog create(Context context) {
return create(new DialogDelegate<>() {
- }, context, DEFAULT_THEME);
+ }, context, DEFAULT_THEME, true /* shouldAcsdDismissDialog */);
}
/**
@@ -168,8 +168,21 @@ public class SystemUIDialog extends AlertDialog implements ViewRootImpl.ConfigCh
return create(delegate, context, DEFAULT_THEME);
}
+ /**
+ * Creates a new instance of {@link SystemUIDialog} with {@code delegate} as the {@link
+ * Delegate}. When you need to customize the dialog, pass it a delegate.
+ *
+ * This method allows the caller to specify if the dialog should be dismissed in response
+ * to the ACTION_CLOSE_SYSTEM_DIALOGS intent.
+ */
+ public SystemUIDialog create(Delegate delegate, Context context,
+ boolean shouldAcsdDismissDialog) {
+ return create(delegate, context, DEFAULT_THEME, shouldAcsdDismissDialog);
+ }
+
public SystemUIDialog create(Delegate delegate, Context context, @StyleRes int theme) {
- return create((DialogDelegate<SystemUIDialog>) delegate, context, theme);
+ return create((DialogDelegate<SystemUIDialog>) delegate, context, theme,
+ true /* shouldAcsdDismissDialog */);
}
public SystemUIDialog create(Delegate delegate) {
@@ -177,7 +190,7 @@ public class SystemUIDialog extends AlertDialog implements ViewRootImpl.ConfigCh
}
private SystemUIDialog create(DialogDelegate<SystemUIDialog> dialogDelegate,
- Context context, @StyleRes int theme) {
+ Context context, @StyleRes int theme, boolean shouldAcsdDismissDialog) {
return new SystemUIDialog(
context,
theme,
@@ -186,7 +199,8 @@ public class SystemUIDialog extends AlertDialog implements ViewRootImpl.ConfigCh
mSysUiState,
mBroadcastDispatcher,
mDialogTransitionAnimator,
- dialogDelegate);
+ dialogDelegate,
+ shouldAcsdDismissDialog);
}
}
@@ -207,7 +221,8 @@ public class SystemUIDialog extends AlertDialog implements ViewRootImpl.ConfigCh
broadcastDispatcher,
dialogTransitionAnimator,
new DialogDelegate<>() {
- });
+ },
+ true /* shouldAcsdDismissDialog */);
}
public SystemUIDialog(
@@ -227,7 +242,8 @@ public class SystemUIDialog extends AlertDialog implements ViewRootImpl.ConfigCh
sysUiState,
broadcastDispatcher,
dialogTransitionAnimator,
- (DialogDelegate<SystemUIDialog>) delegate);
+ (DialogDelegate<SystemUIDialog>) delegate,
+ true /* shouldAcsdDismissDialog */);
}
public SystemUIDialog(
@@ -238,7 +254,8 @@ public class SystemUIDialog extends AlertDialog implements ViewRootImpl.ConfigCh
SysUiState sysUiState,
BroadcastDispatcher broadcastDispatcher,
DialogTransitionAnimator dialogTransitionAnimator,
- DialogDelegate<SystemUIDialog> delegate) {
+ DialogDelegate<SystemUIDialog> delegate,
+ boolean shouldAcsdDismissDialog) {
super(context, theme);
mContext = context;
mDelegate = delegate;
@@ -249,7 +266,7 @@ public class SystemUIDialog extends AlertDialog implements ViewRootImpl.ConfigCh
getWindow().setAttributes(attrs);
mDismissReceiver = dismissOnDeviceLock ? new DismissReceiver(this, broadcastDispatcher,
- dialogTransitionAnimator) : null;
+ dialogTransitionAnimator, shouldAcsdDismissDialog) : null;
mDialogManager = dialogManager;
mSysUiState = sysUiState;
}
@@ -523,7 +540,8 @@ public class SystemUIDialog extends AlertDialog implements ViewRootImpl.ConfigCh
// TODO(b/219008720): Remove those calls to Dependency.get.
DismissReceiver dismissReceiver = new DismissReceiver(dialog,
Dependency.get(BroadcastDispatcher.class),
- Dependency.get(DialogTransitionAnimator.class));
+ Dependency.get(DialogTransitionAnimator.class),
+ true /* shouldAcsdDismissDialog */);
dialog.setOnDismissListener(d -> {
dismissReceiver.unregister();
if (dismissAction != null) dismissAction.run();
@@ -595,12 +613,7 @@ public class SystemUIDialog extends AlertDialog implements ViewRootImpl.ConfigCh
}
private static class DismissReceiver extends BroadcastReceiver {
- private static final IntentFilter INTENT_FILTER = new IntentFilter();
-
- static {
- INTENT_FILTER.addAction(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
- INTENT_FILTER.addAction(Intent.ACTION_SCREEN_OFF);
- }
+ private final IntentFilter mIntentFilter = new IntentFilter();
private final Dialog mDialog;
private boolean mRegistered;
@@ -608,14 +621,20 @@ public class SystemUIDialog extends AlertDialog implements ViewRootImpl.ConfigCh
private final DialogTransitionAnimator mDialogTransitionAnimator;
DismissReceiver(Dialog dialog, BroadcastDispatcher broadcastDispatcher,
- DialogTransitionAnimator dialogTransitionAnimator) {
+ DialogTransitionAnimator dialogTransitionAnimator,
+ boolean shouldAcsdDismissDialog) {
mDialog = dialog;
mBroadcastDispatcher = broadcastDispatcher;
mDialogTransitionAnimator = dialogTransitionAnimator;
+
+ mIntentFilter.addAction(Intent.ACTION_SCREEN_OFF);
+ if (shouldAcsdDismissDialog) {
+ mIntentFilter.addAction(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
+ }
}
void register() {
- mBroadcastDispatcher.registerReceiver(this, INTENT_FILTER, null, UserHandle.CURRENT);
+ mBroadcastDispatcher.registerReceiver(this, mIntentFilter, null, UserHandle.CURRENT);
mRegistered = true;
}