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

Commit 4a1d29e8 authored by William Xiao's avatar William Xiao
Browse files

Enable lockscreen shortcuts when hub V2 flag is enabled

We will flag off enabling the custom_lockscreen_shortcuts_enabled for
future launches. However, that requires a read only flag which doesn't
support teamfooding, so until trunkfood entry, we'll need to rely on
the hub v2 flag to enable lockscreen shortcuts.

Bug: 380335989
Bug: 383391342
Test: atest KeyguardQuickAffordanceLocalUserSelectionManagerTest
      also manually verified on device with flag flips
Flag: com.android.systemui.glanceable_hub_v2
Change-Id: I95e16a6bbaa5cb86fa3097e4d3602fc2363f18c7
parent 91486c33
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import android.provider.Settings
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
import com.android.systemui.communal.domain.interactor.communalSettingsInteractor
import com.android.systemui.kosmos.testDispatcher
import com.android.systemui.kosmos.testScope
import com.android.systemui.kosmos.useUnconfinedTestDispatcher
@@ -84,6 +85,7 @@ class KeyguardQuickAffordanceLegacySettingSyncerTest : SysuiTestCase() {
                            .thenReturn(FakeSharedPreferences())
                    },
                userTracker = FakeUserTracker(),
                communalSettingsInteractor = kosmos.communalSettingsInteractor,
                broadcastDispatcher = fakeBroadcastDispatcher,
            )
        settings.putInt(Settings.Secure.LOCKSCREEN_SHOW_CONTROLS, 0)
+27 −0
Original line number Diff line number Diff line
@@ -20,13 +20,17 @@ package com.android.systemui.keyguard.data.quickaffordance
import android.content.Intent
import android.content.SharedPreferences
import android.content.pm.UserInfo
import android.platform.test.annotations.EnableFlags
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.Flags
import com.android.systemui.SysuiTestCase
import com.android.systemui.backup.BackupHelper
import com.android.systemui.communal.domain.interactor.communalSettingsInteractor
import com.android.systemui.res.R
import com.android.systemui.settings.FakeUserTracker
import com.android.systemui.settings.UserFileManager
import com.android.systemui.testKosmos
import com.android.systemui.util.FakeSharedPreferences
import com.android.systemui.util.mockito.whenever
import com.google.common.truth.Truth.assertThat
@@ -54,6 +58,7 @@ import org.mockito.MockitoAnnotations
@SmallTest
@RunWith(AndroidJUnit4::class)
class KeyguardQuickAffordanceLocalUserSelectionManagerTest : SysuiTestCase() {
    private val kosmos = testKosmos()

    @Mock private lateinit var userFileManager: UserFileManager

@@ -80,6 +85,7 @@ class KeyguardQuickAffordanceLocalUserSelectionManagerTest : SysuiTestCase() {
                context = context,
                userFileManager = userFileManager,
                userTracker = userTracker,
                communalSettingsInteractor = kosmos.communalSettingsInteractor,
                broadcastDispatcher = fakeBroadcastDispatcher,
            )
    }
@@ -309,6 +315,27 @@ class KeyguardQuickAffordanceLocalUserSelectionManagerTest : SysuiTestCase() {
            )
    }

    @EnableFlags(Flags.FLAG_GLANCEABLE_HUB_V2)
    @Test
    fun getSelections_returnsSelectionsIfHubV2Enabled() = runTest {
        overrideResource(R.bool.custom_lockscreen_shortcuts_enabled, false)
        overrideResource(com.android.internal.R.bool.config_glanceableHubEnabled, true)

        overrideResource(R.array.config_keyguardQuickAffordanceDefaults, arrayOf<String>())
        val affordanceIdsBySlotId = mutableListOf<Map<String, List<String>>>()
        val job =
            launch(UnconfinedTestDispatcher()) {
                underTest.selections.toList(affordanceIdsBySlotId)
            }
        val slotId1 = "slot1"
        val affordanceId1 = "affordance1"

        underTest.setSelections(slotId = slotId1, affordanceIds = listOf(affordanceId1))
        assertSelections(affordanceIdsBySlotId.last(), mapOf(slotId1 to listOf(affordanceId1)))

        job.cancel()
    }

    private fun assertSelections(
        observed: Map<String, List<String>>?,
        expected: Map<String, List<String>>,
+2 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import android.os.UserHandle
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
import com.android.systemui.communal.domain.interactor.communalSettingsInteractor
import com.android.systemui.coroutines.collectLastValue
import com.android.systemui.keyguard.data.quickaffordance.FakeKeyguardQuickAffordanceConfig
import com.android.systemui.keyguard.data.quickaffordance.FakeKeyguardQuickAffordanceProviderClientFactory
@@ -88,6 +89,7 @@ class KeyguardQuickAffordanceRepositoryTest : SysuiTestCase() {
                            .thenReturn(FakeSharedPreferences())
                    },
                userTracker = userTracker,
                communalSettingsInteractor = kosmos.communalSettingsInteractor,
                broadcastDispatcher = fakeBroadcastDispatcher,
            )
        client1 = FakeCustomizationProviderClient()
+3 −0
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import com.android.systemui.SysuiTestCase
import com.android.systemui.animation.DialogTransitionAnimator
import com.android.systemui.common.shared.model.ContentDescription
import com.android.systemui.common.shared.model.Icon
import com.android.systemui.communal.domain.interactor.communalSettingsInteractor
import com.android.systemui.coroutines.collectLastValue
import com.android.systemui.coroutines.collectValues
import com.android.systemui.dock.DockManager
@@ -147,6 +148,7 @@ class KeyguardQuickAffordanceInteractorTest : SysuiTestCase() {
                            .thenReturn(FakeSharedPreferences())
                    },
                userTracker = userTracker,
                communalSettingsInteractor = kosmos.communalSettingsInteractor,
                broadcastDispatcher = fakeBroadcastDispatcher,
            )
        val remoteUserSelectionManager =
@@ -196,6 +198,7 @@ class KeyguardQuickAffordanceInteractorTest : SysuiTestCase() {
                biometricSettingsRepository = biometricSettingsRepository,
                backgroundDispatcher = kosmos.testDispatcher,
                appContext = context,
                communalSettingsInteractor = kosmos.communalSettingsInteractor,
                sceneInteractor = { kosmos.sceneInteractor },
            )
        kosmos.keyguardQuickAffordanceInteractor = underTest
+7 −1
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import com.android.systemui.backup.BackupHelper
import com.android.systemui.broadcast.BroadcastDispatcher
import com.android.systemui.common.coroutine.ChannelExt.trySendWithFailureLogging
import com.android.systemui.common.coroutine.ConflatedCallbackFlow.conflatedCallbackFlow
import com.android.systemui.communal.domain.interactor.CommunalSettingsInteractor
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.res.R
import com.android.systemui.settings.UserFileManager
@@ -50,6 +51,7 @@ constructor(
    @ShadeDisplayAware private val context: Context,
    private val userFileManager: UserFileManager,
    private val userTracker: UserTracker,
    private val communalSettingsInteractor: CommunalSettingsInteractor,
    broadcastDispatcher: BroadcastDispatcher,
) : KeyguardQuickAffordanceSelectionManager {

@@ -127,7 +129,11 @@ constructor(

    override fun getSelections(): Map<String, List<String>> {
        // If the custom shortcuts feature is not enabled, ignore prior selections and use defaults
        if (!context.resources.getBoolean(R.bool.custom_lockscreen_shortcuts_enabled)) {
        // TODO(b/383391342): remove isV2FlagEnabled check and just depend on the resource
        if (
            !(context.resources.getBoolean(R.bool.custom_lockscreen_shortcuts_enabled) ||
                communalSettingsInteractor.isV2FlagEnabled())
        ) {
            return defaults
        }

Loading