Merge "Default lockscreen customization on AOSP to disabled" into udc-dev

This commit is contained in:
Brad Hinegardner
2023-05-16 01:50:11 +00:00
committed by Android (Google) Code Review
10 changed files with 61 additions and 3 deletions

View File

@@ -20,6 +20,10 @@ Begins with the device in low power mode, with the display active for [AOD][3] o
An indication to power off the device most likely comes from one of two signals: the user presses the power button or the screen timeout has passed. This may [lock the device](#How-the-device-locks)
#### Long-pressing on keyguard
OEMs may choose to enable a long-press action that displays a button at the bottom of lockscreen. This button links to lockscreen customization. This can be achieved by overriding the `long_press_keyguard_customize_lockscreen_enabled` resource in `packages/SystemUI/res/values/config.xml`.
#### On Lockscreen
#### On Lockscreen, occluded by an activity

View File

@@ -17,7 +17,9 @@ Tests belong in the `packages/SystemUI/tests/src/com/android/systemui/keyguard/d
By default, AOSP ships with a "bottom right" and a "bottom left" slot, each with a slot capacity of `1`, allowing only one Quick Affordance on each side of the lock screen.
### Customizing Slots
OEMs may choose to override the IDs and number of slots and/or override the default capacities. This can be achieved by overridding the `config_keyguardQuickAffordanceSlots` resource in `packages/SystemUI/res/values/config.xml`.
OEMs may choose to enable customization of slots. An entry point in settings will appear when overriding the `custom_lockscreen_shortcuts_enabled` resource in `packages/SystemUI/res/values/config.xml`.
OEMs may also choose to override the IDs and number of slots and/or override the default capacities. This can be achieved by overridding the `config_keyguardQuickAffordanceSlots` resource in `packages/SystemUI/res/values/config.xml`.
### Default Quick Affordances
OEMs may also choose to predefine default Quick Affordances for each slot. To achieve this, a developer may override the `config_keyguardQuickAffordanceDefaults` resource in `packages/SystemUI/res/values/config.xml`. Note that defaults only work until the user of the device selects a different quick affordance for that slot, even if they select the "None" option.

View File

@@ -44,6 +44,12 @@
<!-- orientation of the dead zone when touches have recently occurred elsewhere on screen -->
<integer name="navigation_bar_deadzone_orientation">0</integer>
<!-- Whether or not lockscreen shortcuts can be customized -->
<bool name="custom_lockscreen_shortcuts_enabled">false</bool>
<!-- Whether or not long-pressing on keyguard will display to customize lockscreen -->
<bool name="long_press_keyguard_customize_lockscreen_enabled">false</bool>
<bool name="config_dead_zone_flash">false</bool>
<!-- Whether to enable dimming navigation buttons when wallpaper is not visible, should be

View File

@@ -17,12 +17,14 @@
package com.android.systemui.keyguard.domain.interactor
import android.content.Context
import android.content.Intent
import android.content.IntentFilter
import android.view.accessibility.AccessibilityManager
import androidx.annotation.VisibleForTesting
import com.android.internal.logging.UiEvent
import com.android.internal.logging.UiEventLogger
import com.android.systemui.R
import com.android.systemui.broadcast.BroadcastDispatcher
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Application
@@ -55,6 +57,7 @@ import kotlinx.coroutines.launch
class KeyguardLongPressInteractor
@Inject
constructor(
@Application private val appContext: Context,
@Application private val scope: CoroutineScope,
transitionInteractor: KeyguardTransitionInteractor,
repository: KeyguardRepository,
@@ -169,7 +172,8 @@ constructor(
private fun isFeatureEnabled(): Boolean {
return featureFlags.isEnabled(Flags.LOCK_SCREEN_LONG_PRESS_ENABLED) &&
featureFlags.isEnabled(Flags.REVAMPED_WALLPAPER_UI)
featureFlags.isEnabled(Flags.REVAMPED_WALLPAPER_UI) &&
appContext.resources.getBoolean(R.bool.long_press_keyguard_customize_lockscreen_enabled)
}
/** Updates application state to ask to show the menu. */

View File

@@ -19,12 +19,15 @@ package com.android.systemui.keyguard.domain.interactor
import android.app.AlertDialog
import android.app.admin.DevicePolicyManager
import android.content.Context
import android.content.Intent
import android.util.Log
import com.android.internal.widget.LockPatternUtils
import com.android.systemui.R
import com.android.systemui.animation.DialogLaunchAnimator
import com.android.systemui.animation.Expandable
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.dagger.qualifiers.Background
import com.android.systemui.devicepolicy.areKeyguardShortcutsDisabled
import com.android.systemui.dock.DockManager
@@ -75,6 +78,7 @@ constructor(
private val devicePolicyManager: DevicePolicyManager,
private val dockManager: DockManager,
@Background private val backgroundDispatcher: CoroutineDispatcher,
@Application private val appContext: Context,
) {
private val isUsingRepository: Boolean
get() = featureFlags.isEnabled(Flags.CUSTOMIZABLE_LOCK_SCREEN_QUICK_AFFORDANCES)
@@ -408,7 +412,8 @@ constructor(
name = Contract.FlagsTable.FLAG_NAME_CUSTOM_LOCK_SCREEN_QUICK_AFFORDANCES_ENABLED,
value =
!isFeatureDisabledByDevicePolicy() &&
featureFlags.isEnabled(Flags.CUSTOMIZABLE_LOCK_SCREEN_QUICK_AFFORDANCES),
featureFlags.isEnabled(Flags.CUSTOMIZABLE_LOCK_SCREEN_QUICK_AFFORDANCES) &&
appContext.resources.getBoolean(R.bool.custom_lockscreen_shortcuts_enabled),
),
KeyguardPickerFlag(
name = Contract.FlagsTable.FLAG_NAME_CUSTOM_CLOCKS_ENABLED,

View File

@@ -30,6 +30,7 @@ import android.testing.TestableLooper
import android.view.SurfaceControlViewHost
import androidx.test.filters.SmallTest
import com.android.internal.widget.LockPatternUtils
import com.android.systemui.R
import com.android.systemui.SystemUIAppComponentFactoryBase
import com.android.systemui.SysuiTestCase
import com.android.systemui.animation.DialogLaunchAnimator
@@ -67,6 +68,7 @@ import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.TestScope
import kotlinx.coroutines.test.UnconfinedTestDispatcher
import kotlinx.coroutines.test.runTest
import org.junit.After
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
@@ -103,6 +105,7 @@ class CustomizationProviderTest : SysuiTestCase() {
@Before
fun setUp() {
MockitoAnnotations.initMocks(this)
overrideResource(R.bool.custom_lockscreen_shortcuts_enabled, true)
whenever(previewRenderer.surfacePackage).thenReturn(previewSurfacePackage)
whenever(previewRendererFactory.create(any())).thenReturn(previewRenderer)
whenever(backgroundHandler.looper).thenReturn(TestableLooper.get(this).looper)
@@ -195,6 +198,7 @@ class CustomizationProviderTest : SysuiTestCase() {
devicePolicyManager = devicePolicyManager,
dockManager = dockManager,
backgroundDispatcher = testDispatcher,
appContext = mContext,
)
underTest.previewManager =
KeyguardRemotePreviewManager(
@@ -216,6 +220,13 @@ class CustomizationProviderTest : SysuiTestCase() {
)
}
@After
fun tearDown() {
mContext
.getOrCreateTestableResources()
.removeOverride(R.bool.custom_lockscreen_shortcuts_enabled)
}
@Test
fun onAttachInfo_reportsContext() {
val callback: SystemUIAppComponentFactoryBase.ContextAvailableCallback = mock()

View File

@@ -21,6 +21,7 @@ import android.content.Intent
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.internal.logging.UiEventLogger
import com.android.systemui.R
import com.android.systemui.RoboPilotTest
import com.android.systemui.SysuiTestCase
import com.android.systemui.coroutines.collectLastValue
@@ -39,6 +40,7 @@ import kotlinx.coroutines.test.TestScope
import kotlinx.coroutines.test.advanceTimeBy
import kotlinx.coroutines.test.runCurrent
import kotlinx.coroutines.test.runTest
import org.junit.After
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
@@ -65,6 +67,7 @@ class KeyguardLongPressInteractorTest : SysuiTestCase() {
@Before
fun setUp() {
MockitoAnnotations.initMocks(this)
overrideResource(R.bool.long_press_keyguard_customize_lockscreen_enabled, true)
whenever(accessibilityManager.getRecommendedTimeoutMillis(anyInt(), anyInt())).thenAnswer {
it.arguments[0]
}
@@ -76,6 +79,13 @@ class KeyguardLongPressInteractorTest : SysuiTestCase() {
runBlocking { createUnderTest() }
}
@After
fun tearDown() {
mContext
.getOrCreateTestableResources()
.removeOverride(R.bool.long_press_keyguard_customize_lockscreen_enabled)
}
@Test
fun isEnabled() =
testScope.runTest {
@@ -107,6 +117,17 @@ class KeyguardLongPressInteractorTest : SysuiTestCase() {
}
}
@Test
fun isEnabled_alwaysFalseWhenConfigEnabledBooleanIsFalse() =
testScope.runTest {
overrideResource(R.bool.long_press_keyguard_customize_lockscreen_enabled, false)
createUnderTest()
val isEnabled by collectLastValue(underTest.isLongPressHandlingEnabled)
runCurrent()
assertThat(isEnabled).isFalse()
}
@Test
fun longPressed_menuClicked_showsSettings() =
testScope.runTest {
@@ -267,6 +288,7 @@ class KeyguardLongPressInteractorTest : SysuiTestCase() {
) {
underTest =
KeyguardLongPressInteractor(
appContext = mContext,
scope = testScope.backgroundScope,
transitionInteractor =
KeyguardTransitionInteractor(

View File

@@ -340,6 +340,7 @@ class KeyguardQuickAffordanceInteractorParameterizedTest : SysuiTestCase() {
devicePolicyManager = devicePolicyManager,
dockManager = dockManager,
backgroundDispatcher = testDispatcher,
appContext = mContext,
)
}

View File

@@ -200,6 +200,7 @@ class KeyguardQuickAffordanceInteractorTest : SysuiTestCase() {
devicePolicyManager = devicePolicyManager,
dockManager = dockManager,
backgroundDispatcher = testDispatcher,
appContext = mContext,
)
}

View File

@@ -211,6 +211,7 @@ class KeyguardBottomAreaViewModelTest : SysuiTestCase() {
)
val keyguardLongPressInteractor =
KeyguardLongPressInteractor(
appContext = mContext,
scope = testScope.backgroundScope,
transitionInteractor =
KeyguardTransitionInteractor(
@@ -240,6 +241,7 @@ class KeyguardBottomAreaViewModelTest : SysuiTestCase() {
devicePolicyManager = devicePolicyManager,
dockManager = dockManager,
backgroundDispatcher = testDispatcher,
appContext = mContext,
),
bottomAreaInteractor = KeyguardBottomAreaInteractor(repository = repository),
burnInHelperWrapper = burnInHelperWrapper,