Merge "Controls UI - Blank activity when launched on lock screen" into rvc-dev am: 18b5f5fa35

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/12004850

Change-Id: I2ccf96354b1230f57740a74c05893da47d08ee40
diff --git a/packages/SystemUI/src/com/android/systemui/controls/ui/ControlActionCoordinatorImpl.kt b/packages/SystemUI/src/com/android/systemui/controls/ui/ControlActionCoordinatorImpl.kt
index c073642..22d6b6b 100644
--- a/packages/SystemUI/src/com/android/systemui/controls/ui/ControlActionCoordinatorImpl.kt
+++ b/packages/SystemUI/src/com/android/systemui/controls/ui/ControlActionCoordinatorImpl.kt
@@ -128,15 +128,22 @@
         }
 
     private fun bouncerOrRun(action: Action) {
-        if (!keyguardStateController.isUnlocked()) {
-            context.sendBroadcast(Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS))
+        if (keyguardStateController.isShowing()) {
+            var closeGlobalActions = !keyguardStateController.isUnlocked()
+            if (closeGlobalActions) {
+                context.sendBroadcast(Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS))
 
-            // pending actions will only run after the control state has been refreshed
-            pendingAction = action
+                // pending actions will only run after the control state has been refreshed
+                pendingAction = action
+            }
 
             activityStarter.dismissKeyguardThenExecute({
                 Log.d(ControlsUiController.TAG, "Device unlocked, invoking controls action")
-                globalActionsComponent.handleShowGlobalActionsMenu()
+                if (closeGlobalActions) {
+                    globalActionsComponent.handleShowGlobalActionsMenu()
+                } else {
+                    action.invoke()
+                }
                 true
             }, { pendingAction = null }, true /* afterKeyguardGone */)
         } else {
diff --git a/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java b/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java
index eed5200..b2e9164 100644
--- a/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java
+++ b/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java
@@ -2637,10 +2637,10 @@
     }
 
     private boolean shouldShowControls() {
-        return (mKeyguardStateController.isUnlocked() || mShowLockScreenCardsAndControls)
-                && controlsAvailable()
-                && mLockPatternUtils.getStrongAuthForUser(getCurrentUser().id)
-                    != STRONG_AUTH_REQUIRED_AFTER_BOOT;
+        boolean showOnLockScreen = mShowLockScreenCardsAndControls && mLockPatternUtils
+                .getStrongAuthForUser(getCurrentUser().id) != STRONG_AUTH_REQUIRED_AFTER_BOOT;
+        return controlsAvailable()
+                && (mKeyguardStateController.isUnlocked() || showOnLockScreen);
     }
 
     private boolean controlsAvailable() {