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

Commit a6033f91 authored by William Leshner's avatar William Leshner Committed by Android (Google) Code Review
Browse files

Merge "Remove lock screen shortcut for opening glanceable hub." into main

parents f9df4d64 4e303dbe
Loading
Loading
Loading
Loading
+0 −7
Original line number Diff line number Diff line
@@ -1845,13 +1845,6 @@ flag {
    bug: "379364381"
}

flag {
    name: "glanceable_hub_shortcut_button"
    namespace: "systemui"
    description: "Adds a shortcut button to lockscreen to show glanceable hub."
    bug: "378173531"
}

flag {
    name: "spatial_model_launcher_pushback"
    namespace: "systemui"
+0 −155
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 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.keyguard.data.quickaffordance

import android.platform.test.annotations.DisableFlags
import android.platform.test.annotations.EnableFlags
import android.platform.test.flag.junit.FlagsParameterization
import androidx.test.filters.SmallTest
import com.android.systemui.Flags
import com.android.systemui.SysuiTestCase
import com.android.systemui.communal.data.repository.communalSceneRepository
import com.android.systemui.communal.domain.interactor.setCommunalV2Available
import com.android.systemui.communal.domain.interactor.setCommunalV2Enabled
import com.android.systemui.communal.shared.model.CommunalScenes
import com.android.systemui.flags.parameterizeSceneContainerFlag
import com.android.systemui.keyguard.data.repository.fakeKeyguardRepository
import com.android.systemui.kosmos.Kosmos
import com.android.systemui.kosmos.collectLastValue
import com.android.systemui.kosmos.runCurrent
import com.android.systemui.kosmos.runTest
import com.android.systemui.scene.data.repository.sceneContainerRepository
import com.android.systemui.scene.shared.model.Scenes
import com.android.systemui.testKosmos
import com.google.common.truth.Truth.assertThat
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.MockitoAnnotations
import platform.test.runner.parameterized.ParameterizedAndroidJunit4
import platform.test.runner.parameterized.Parameters

@SmallTest
@EnableFlags(Flags.FLAG_GLANCEABLE_HUB_V2)
@RunWith(ParameterizedAndroidJunit4::class)
class GlanceableHubQuickAffordanceConfigTest(flags: FlagsParameterization?) : SysuiTestCase() {
    private val kosmos = testKosmos()
    private val Kosmos.underTest by Kosmos.Fixture { glanceableHubQuickAffordanceConfig }

    init {
        mSetFlagsRule.setFlagsParameterization(flags!!)
    }

    @Before
    fun setUp() {
        MockitoAnnotations.initMocks(this)

        // Access the class immediately so that flows are instantiated.
        // GlanceableHubQuickAffordanceConfig accesses StateFlow.value directly so we need the flows
        // to start flowing before runCurrent is called in the tests.
        kosmos.underTest
    }

    @Test
    fun lockscreenState_whenGlanceableHubEnabled_returnsVisible() =
        kosmos.runTest {
            kosmos.setCommunalV2Available(true)
            runCurrent()

            val lockScreenState by collectLastValue(underTest.lockScreenState)

            assertThat(lockScreenState)
                .isInstanceOf(KeyguardQuickAffordanceConfig.LockScreenState.Visible::class.java)
        }

    @Test
    fun lockscreenState_whenGlanceableHubDisabled_returnsHidden() =
        kosmos.runTest {
            setCommunalV2Enabled(false)
            val lockScreenState by collectLastValue(underTest.lockScreenState)
            runCurrent()

            assertThat(lockScreenState)
                .isEqualTo(KeyguardQuickAffordanceConfig.LockScreenState.Hidden)
        }

    @Test
    fun lockscreenState_whenGlanceableHubNotAvailable_returnsHidden() =
        kosmos.runTest {
            // Hub is enabled, but not available.
            setCommunalV2Enabled(true)
            fakeKeyguardRepository.setKeyguardShowing(false)
            val lockScreenState by collectLastValue(underTest.lockScreenState)
            runCurrent()

            assertThat(lockScreenState)
                .isEqualTo(KeyguardQuickAffordanceConfig.LockScreenState.Hidden)
        }

    @Test
    fun pickerScreenState_whenGlanceableHubEnabled_returnsDefault() =
        kosmos.runTest {
            setCommunalV2Enabled(true)
            runCurrent()

            assertThat(underTest.getPickerScreenState())
                .isEqualTo(KeyguardQuickAffordanceConfig.PickerScreenState.Default())
        }

    @Test
    fun pickerScreenState_whenGlanceableHubDisabled_returnsDisabled() =
        kosmos.runTest {
            setCommunalV2Enabled(false)
            runCurrent()

            assertThat(
                underTest.getPickerScreenState()
                    is KeyguardQuickAffordanceConfig.PickerScreenState.Disabled
            )
        }

    @Test
    @DisableFlags(Flags.FLAG_SCENE_CONTAINER)
    fun onTriggered_changesSceneToCommunal() =
        kosmos.runTest {
            underTest.onTriggered(expandable = null)
            runCurrent()

            assertThat(kosmos.communalSceneRepository.currentScene.value)
                .isEqualTo(CommunalScenes.Communal)
        }

    @Test
    @EnableFlags(Flags.FLAG_SCENE_CONTAINER)
    fun testTransitionToGlanceableHub_sceneContainer() =
        kosmos.runTest {
            underTest.onTriggered(expandable = null)
            runCurrent()

            assertThat(kosmos.sceneContainerRepository.currentScene.value)
                .isEqualTo(Scenes.Communal)
        }

    companion object {
        @JvmStatic
        @Parameters(name = "{0}")
        fun getParams(): List<FlagsParameterization> {
            return parameterizeSceneContainerFlag()
        }
    }
}
+0 −26
Original line number Diff line number Diff line
<!--
  ~ Copyright (C) 2024 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.
  -->

<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="24dp"
    android:height="24dp"
    android:tint="?attr/colorControlNormal"
    android:viewportHeight="960"
    android:viewportWidth="960">
    <path
        android:fillColor="@android:color/black"
        android:pathData="M666,520L440,294L666,68L892,294L666,520ZM120,440L120,120L440,120L440,440L120,440ZM520,840L520,520L840,520L840,840L520,840ZM120,840L120,520L440,520L440,840L120,840ZM200,360L360,360L360,200L200,200L200,360ZM667,408L780,295L667,182L554,295L667,408ZM600,760L760,760L760,600L600,600L600,760ZM200,760L360,760L360,600L200,600L200,760ZM360,360L360,360L360,360L360,360L360,360ZM554,295L554,295L554,295L554,295L554,295ZM360,600L360,600L360,600L360,600L360,600ZM600,600L600,600L600,600L600,600L600,600Z" />
</vector>
+0 −6
Original line number Diff line number Diff line
@@ -1351,12 +1351,6 @@
    <string name="communal_widgets_disclaimer_text">To open an app using a widget, you\u2019ll need to verify it\u2019s you. Also, keep in mind that anyone can view them, even when your tablet\u2019s locked. Some widgets may not have been intended for your lock screen and may be unsafe to add here.</string>
    <!-- Button for user to verify they understand the information presented. [CHAR LIMIT=50] -->
    <string name="communal_widgets_disclaimer_button">Got it</string>
    <!-- Label for a lock screen affordance to show widgets on the lock screen. [CHAR LIMIT=20] -->
    <string name="glanceable_hub_lockscreen_affordance_label">Widgets</string>
    <!-- Text explaining why the lock screen affordance to show widgets on the lockscreen is disabled and how to enable the affordance in settings. [CHAR LIMIT=NONE] -->
    <string name="glanceable_hub_lockscreen_affordance_disabled_text">To add the \"Widgets\" shortcut, make sure \"Show widgets on lock screen\" is enabled in settings.</string>
    <!-- Label for a button used to open Settings in order to enable showing widgets on the lock screen. [CHAR LIMIT=NONE] -->
    <string name="glanceable_hub_lockscreen_affordance_action_button_label">Settings</string>
    <!-- Content description for a "show screensaver" button on glanceable hub. [CHAR LIMIT=NONE] -->
    <string name="accessibility_glanceable_hub_to_dream_button">Show screensaver button</string>
    <!-- Title shown in hub onboarding bottom sheet. [CHAR LIMIT=50] -->
+0 −1
Original line number Diff line number Diff line
@@ -28,7 +28,6 @@ object BuiltInKeyguardQuickAffordanceKeys {
    const val CREATE_NOTE = "create_note"
    const val DO_NOT_DISTURB = "do_not_disturb"
    const val FLASHLIGHT = "flashlight"
    const val GLANCEABLE_HUB = "glanceable_hub"
    const val HOME_CONTROLS = "home"
    const val MUTE = "mute"
    const val QR_CODE_SCANNER = "qr_code_scanner"
Loading