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

Commit dec456bf authored by Brad Hinegardner's avatar Brad Hinegardner Committed by Automerger Merge Worker
Browse files

Merge "Disable need to long-press lockscreen shortcuts when device is docked"...

Merge "Disable need to long-press lockscreen shortcuts when device is docked" into udc-dev am: e597433f

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



Change-Id: I2438f56d0402fe79be786d197da50038e780a337
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents ae7ed162 e597433f
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -268,6 +268,7 @@ filegroup {
        "tests/src/com/android/systemui/keyguard/ui/viewmodel/PrimaryBouncerToGoneTransitionViewModelTest.kt",
        // Keyguard helper
        "tests/src/com/android/systemui/keyguard/data/quickaffordance/FakeKeyguardQuickAffordanceConfig.kt",
        "tests/src/com/android/systemui/dock/DockManagerFake.java",
        "tests/src/com/android/systemui/dump/LogBufferHelper.kt",
        "tests/src/com/android/systemui/statusbar/phone/FakeKeyguardStateController.java",
        "tests/src/com/android/systemui/keyguard/domain/quickaffordance/FakeKeyguardQuickAffordanceRegistry.kt",
+34 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2023 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.systemui.dock

import com.android.systemui.common.coroutine.ConflatedCallbackFlow
import kotlinx.coroutines.channels.awaitClose
import kotlinx.coroutines.flow.Flow

/**
 * Retrieves whether or not the device is docked according to DockManager. Emits a starting value
 *  of isDocked.
 */
fun DockManager.retrieveIsDocked(): Flow<Boolean> =
    ConflatedCallbackFlow.conflatedCallbackFlow {
        val callback = DockManager.DockEventListener { trySend(isDocked) }
        addListener(callback)
        trySend(isDocked)

        awaitClose { removeListener(callback) }
    }
 No newline at end of file
+9 −2
Original line number Diff line number Diff line
@@ -27,6 +27,8 @@ import com.android.systemui.animation.Expandable
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Background
import com.android.systemui.devicepolicy.areKeyguardShortcutsDisabled
import com.android.systemui.dock.DockManager
import com.android.systemui.dock.retrieveIsDocked
import com.android.systemui.flags.FeatureFlags
import com.android.systemui.flags.Flags
import com.android.systemui.keyguard.data.quickaffordance.KeyguardQuickAffordanceConfig
@@ -71,6 +73,7 @@ constructor(
    private val launchAnimator: DialogLaunchAnimator,
    private val logger: KeyguardQuickAffordancesMetricsLogger,
    private val devicePolicyManager: DevicePolicyManager,
    private val dockManager: DockManager,
    @Background private val backgroundDispatcher: CoroutineDispatcher,
) {
    private val isUsingRepository: Boolean
@@ -81,8 +84,12 @@ constructor(
     *
     * If `false`, the UI goes back to using single taps.
     */
    val useLongPress: Boolean
        get() = featureFlags.isEnabled(Flags.CUSTOMIZABLE_LOCK_SCREEN_QUICK_AFFORDANCES)
    fun useLongPress(): Flow<Boolean> =
        if (featureFlags.isEnabled(Flags.CUSTOMIZABLE_LOCK_SCREEN_QUICK_AFFORDANCES)) {
            dockManager.retrieveIsDocked().map { !it }
        } else {
            flowOf(false)
        }

    /** Returns an observable for the quick affordance at the given position. */
    suspend fun quickAffordance(
+5 −2
Original line number Diff line number Diff line
@@ -184,7 +184,8 @@ constructor(
                    bottomAreaInteractor.animateDozingTransitions.distinctUntilChanged(),
                    areQuickAffordancesFullyOpaque,
                    selectedPreviewSlotId,
                ) { model, animateReveal, isFullyOpaque, selectedPreviewSlotId ->
                    quickAffordanceInteractor.useLongPress(),
                ) { model, animateReveal, isFullyOpaque, selectedPreviewSlotId, useLongPress ->
                    val slotId = position.toSlotId()
                    val isSelected = selectedPreviewSlotId == slotId
                    model.toViewModel(
@@ -200,6 +201,7 @@ constructor(
                                !isSelected,
                        forceInactive = previewMode.isInPreviewMode,
                        slotId = slotId,
                        useLongPress = useLongPress,
                    )
                }
                .distinctUntilChanged()
@@ -213,6 +215,7 @@ constructor(
        isDimmed: Boolean,
        forceInactive: Boolean,
        slotId: String,
        useLongPress: Boolean,
    ): KeyguardQuickAffordanceViewModel {
        return when (this) {
            is KeyguardQuickAffordanceModel.Visible ->
@@ -231,7 +234,7 @@ constructor(
                    isClickable = isClickable,
                    isActivated = !forceInactive && activationState is ActivationState.Active,
                    isSelected = isSelected,
                    useLongPress = quickAffordanceInteractor.useLongPress,
                    useLongPress = useLongPress,
                    isDimmed = isDimmed,
                    slotId = slotId,
                )
+6 −0
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ import com.android.internal.widget.LockPatternUtils
import com.android.systemui.SystemUIAppComponentFactoryBase
import com.android.systemui.SysuiTestCase
import com.android.systemui.animation.DialogLaunchAnimator
import com.android.systemui.dock.DockManagerFake
import com.android.systemui.flags.FakeFeatureFlags
import com.android.systemui.flags.Flags
import com.android.systemui.keyguard.data.quickaffordance.FakeKeyguardQuickAffordanceConfig
@@ -94,6 +95,8 @@ class CustomizationProviderTest : SysuiTestCase() {
    @Mock private lateinit var devicePolicyManager: DevicePolicyManager
    @Mock private lateinit var logger: KeyguardQuickAffordancesMetricsLogger

    private lateinit var dockManager: DockManagerFake

    private lateinit var underTest: CustomizationProvider
    private lateinit var testScope: TestScope

@@ -104,6 +107,8 @@ class CustomizationProviderTest : SysuiTestCase() {
        whenever(previewRendererFactory.create(any())).thenReturn(previewRenderer)
        whenever(backgroundHandler.looper).thenReturn(TestableLooper.get(this).looper)

        dockManager = DockManagerFake()

        underTest = CustomizationProvider()
        val testDispatcher = UnconfinedTestDispatcher()
        testScope = TestScope(testDispatcher)
@@ -188,6 +193,7 @@ class CustomizationProviderTest : SysuiTestCase() {
                launchAnimator = launchAnimator,
                logger = logger,
                devicePolicyManager = devicePolicyManager,
                dockManager = dockManager,
                backgroundDispatcher = testDispatcher,
            )
        underTest.previewManager =
Loading