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

Commit c21a0241 authored by Beverly's avatar Beverly Committed by Beverly Tai
Browse files

Hide alternate bouncer when the back gesture is triggered

Fixes: 330917390
Flag: ACONFIG com.android.systemui.device_entry_udfps_refactor TEAMFOOD
Test: Bring up the alternate bouncer over the camera app. Navigate
back and observe user ends up on the camera app and the alternate
bouncer is gone.

Change-Id: I4977c767c49485a5c792c2bdb5d2a63c4f76941e
parent 3e2fe15e
Loading
Loading
Loading
Loading
+35 −3
Original line number Diff line number Diff line
@@ -19,14 +19,16 @@ package com.android.systemui.keyguard.ui.binder
import android.graphics.PixelFormat
import android.view.Gravity
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.WindowManager
import android.window.OnBackInvokedCallback
import android.window.OnBackInvokedDispatcher
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.constraintlayout.widget.ConstraintSet
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.repeatOnLifecycle
import com.android.systemui.CoreStartable
import com.android.systemui.biometrics.Utils
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.deviceentry.shared.DeviceEntryUdfpsRefactor
@@ -70,8 +72,9 @@ constructor(
                    WindowManager.LayoutParams.MATCH_PARENT,
                    WindowManager.LayoutParams.MATCH_PARENT,
                    WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG,
                    Utils.FINGERPRINT_OVERLAY_LAYOUT_PARAM_FLAGS,
                    PixelFormat.TRANSLUCENT
                    WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN or
                        WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED,
                    PixelFormat.TRANSLUCENT,
                )
                .apply {
                    title = "AlternateBouncerView"
@@ -113,6 +116,34 @@ constructor(
        }

        windowManager.get().removeView(alternateBouncerView)
        alternateBouncerView!!.removeOnAttachStateChangeListener(onAttachAddBackGestureHandler)
        alternateBouncerView = null
    }

    private val onAttachAddBackGestureHandler =
        object : View.OnAttachStateChangeListener {
            private val onBackInvokedCallback: OnBackInvokedCallback = OnBackInvokedCallback {
                onBackRequested()
            }

            override fun onViewAttachedToWindow(view: View) {
                view
                    .findOnBackInvokedDispatcher()
                    ?.registerOnBackInvokedCallback(
                        OnBackInvokedDispatcher.PRIORITY_OVERLAY,
                        onBackInvokedCallback,
                    )
            }

            override fun onViewDetachedFromWindow(view: View) {
                view
                    .findOnBackInvokedDispatcher()
                    ?.unregisterOnBackInvokedCallback(onBackInvokedCallback)
            }

            fun onBackRequested() {
                alternateBouncerDependencies.get().viewModel.hideAlternateBouncer()
            }
        }

    private fun addViewToWindowManager() {
@@ -125,6 +156,7 @@ constructor(
                as ConstraintLayout

        windowManager.get().addView(alternateBouncerView, layoutParams)
        alternateBouncerView!!.addOnAttachStateChangeListener(onAttachAddBackGestureHandler)
    }

    /** Binds the view to the view-model, continuing to update the former based on the latter. */