Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d62b8cf8 authored by Matt Pietal's avatar Matt Pietal
Browse files

Controls in Lockscreen Dialog

After an action is taken by the user while the device is locked, we
need to start the bouncer and continue the action after successful
unlock. This action now supports either launching the
GlobalActionsDialog again or continuing in the newer dialog.

Bug: 179782498
Test: manual
Change-Id: I3829bed7e999fcfc2924d19e0f2ab0cac0afcb77
parent 015c5af3
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -24,6 +24,9 @@ import android.service.controls.Control
 */
interface ControlActionCoordinator {

    // Handle actions launched from GlobalActionsDialog or ControlDialog
    var startedFromGlobalActions: Boolean

    /**
     * Close any dialogs which may have been open
     */
+15 −5
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ import android.service.controls.actions.CommandAction
import android.service.controls.actions.FloatAction
import android.util.Log
import android.view.HapticFeedbackConstants
import com.android.systemui.broadcast.BroadcastDispatcher
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Main
import com.android.systemui.globalactions.GlobalActionsComponent
@@ -37,6 +38,7 @@ import com.android.systemui.plugins.ActivityStarter
import com.android.systemui.statusbar.policy.KeyguardStateController
import com.android.systemui.util.concurrency.DelayableExecutor
import com.android.wm.shell.TaskViewFactory
import dagger.Lazy
import java.util.Optional
import javax.inject.Inject

@@ -48,13 +50,17 @@ class ControlActionCoordinatorImpl @Inject constructor(
    private val activityStarter: ActivityStarter,
    private val keyguardStateController: KeyguardStateController,
    private val globalActionsComponent: GlobalActionsComponent,
    private val taskViewFactory: Optional<TaskViewFactory>
    private val taskViewFactory: Optional<TaskViewFactory>,
    private val broadcastDispatcher: BroadcastDispatcher,
    private val lazyUiController: Lazy<ControlsUiController>
) : ControlActionCoordinator {
    private var dialog: Dialog? = null
    private val vibrator = context.getSystemService(Context.VIBRATOR_SERVICE) as Vibrator
    private var pendingAction: Action? = null
    private var actionsInProgress = mutableSetOf<String>()

    override var startedFromGlobalActions: Boolean = true

    companion object {
        private const val RESPONSE_TIMEOUT_IN_MILLIS = 3000L
    }
@@ -131,8 +137,8 @@ class ControlActionCoordinatorImpl @Inject constructor(

    private fun bouncerOrRun(action: Action) {
        if (keyguardStateController.isShowing()) {
            var closeGlobalActions = !keyguardStateController.isUnlocked()
            if (closeGlobalActions) {
            var closeDialog = !keyguardStateController.isUnlocked()
            if (closeDialog) {
                context.sendBroadcast(Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS))

                // pending actions will only run after the control state has been refreshed
@@ -141,8 +147,12 @@ class ControlActionCoordinatorImpl @Inject constructor(

            activityStarter.dismissKeyguardThenExecute({
                Log.d(ControlsUiController.TAG, "Device unlocked, invoking controls action")
                if (closeGlobalActions) {
                if (closeDialog) {
                    if (startedFromGlobalActions) {
                        globalActionsComponent.handleShowGlobalActionsMenu()
                    } else {
                        ControlsDialog(context, broadcastDispatcher).show(lazyUiController.get())
                    }
                } else {
                    action.invoke()
                }
+1 −1
Original line number Diff line number Diff line
@@ -66,7 +66,7 @@ class ControlsDialog(

        val vg = requireViewById<ViewGroup>(com.android.systemui.R.id.global_actions_controls)
        vg.alpha = 0f
        controller.show(vg, { /* do nothing */ })
        controller.show(vg, { /* do nothing */ }, false /* startedFromGlobalActions */)

        vg.animate()
            .alpha(1f)
+1 −1
Original line number Diff line number Diff line
@@ -29,7 +29,7 @@ interface ControlsUiController {
        public const val EXTRA_ANIMATE = "extra_animate"
    }

    fun show(parent: ViewGroup, dismissGlobalActions: Runnable)
    fun show(parent: ViewGroup, onDismiss: Runnable, startedFromGlobalActions: Boolean)
    fun hide()

    /**
+11 −5
Original line number Diff line number Diff line
@@ -102,7 +102,7 @@ class ControlsUiControllerImpl @Inject constructor (
    private lateinit var lastItems: List<SelectionItem>
    private var popup: ListPopupWindow? = null
    private var hidden = true
    private lateinit var dismissGlobalActions: Runnable
    private lateinit var onDismiss: Runnable
    private val popupThemedContext = ContextThemeWrapper(context, R.style.Control_ListPopupWindow)
    private var retainCache = false

@@ -145,13 +145,19 @@ class ControlsUiControllerImpl @Inject constructor (
        }
    }

    override fun show(parent: ViewGroup, dismissGlobalActions: Runnable) {
    override fun show(
        parent: ViewGroup,
        onDismiss: Runnable,
        startedFromGlobalActions: Boolean
    ) {
        Log.d(ControlsUiController.TAG, "show()")
        this.parent = parent
        this.dismissGlobalActions = dismissGlobalActions
        this.onDismiss = onDismiss
        hidden = false
        retainCache = false

        controlActionCoordinator.startedFromGlobalActions = startedFromGlobalActions

        allStructures = controlsController.get().getFavorites()
        selectedStructure = loadPreference(allStructures)

@@ -187,7 +193,7 @@ class ControlsUiControllerImpl @Inject constructor (
                controlViewsById.clear()
                controlsById.clear()

                show(parent, dismissGlobalActions)
                show(parent, onDismiss, controlActionCoordinator.startedFromGlobalActions)
                val showAnim = ObjectAnimator.ofFloat(parent, "alpha", 0.0f, 1.0f)
                showAnim.setInterpolator(DecelerateInterpolator(1.0f))
                showAnim.setDuration(FADE_IN_MILLIS)
@@ -260,7 +266,7 @@ class ControlsUiControllerImpl @Inject constructor (
    private fun startActivity(context: Context, intent: Intent) {
        // Force animations when transitioning from a dialog to an activity
        intent.putExtra(ControlsUiController.EXTRA_ANIMATE, true)
        dismissGlobalActions.run()
        onDismiss.run()

        activityStarter.dismissKeyguardThenExecute({
            shadeController.collapsePanel(false)
Loading