Support Double Tap Power to open camera via config resource

"Quickly open camera" screen was previously replaced by the "Double
Tap Power Button" screen and accessible only if the
feature flag
android.service.quickaccesswallet.launch_wallet_option_on_power_double_tap
was disabled.

This CL introduces the possibility to set, via a config resource, "Quickly open camera" as the double tap power
gesture screen.

Test: atest DoubleTapPowerSettingsTest
Test: atest DoubleTapPowerPreferenceControllerTest
Test: atest DoubleTapPowerSettingsUtilsTest
Test: manually modified config and verified screen and gesture behavior
change
Flag: android.service.quickaccesswallet.launch_wallet_option_on_power_double_tap
Bug: 384794943
Change-Id: I5ab4422da09fa90848c66a41829327494080b5a2

Change-Id: I8e04cac3999a7ed99a611ef084c54bc07a5505dc
This commit is contained in:
Lorenzo Lucena Maguire
2024-12-16 22:04:36 +00:00
parent 5979b88c7c
commit 0e64487bc3
12 changed files with 285 additions and 112 deletions

View File

@@ -16,6 +16,9 @@
package com.android.settings.gestures;
import static com.android.settings.gestures.DoubleTapPowerSettingsUtils.DOUBLE_TAP_POWER_LAUNCH_CAMERA_MODE;
import static com.android.settings.gestures.DoubleTapPowerSettingsUtils.DOUBLE_TAP_POWER_MULTI_TARGET_MODE;
import static com.google.common.truth.Truth.assertThat;
import android.platform.test.annotations.DisableFlags;
@@ -25,6 +28,7 @@ import android.provider.SearchIndexableResource;
import android.service.quickaccesswallet.Flags;
import com.android.settings.R;
import com.android.settings.testutils.shadow.SettingsShadowResources;
import org.junit.Before;
import org.junit.Rule;
@@ -32,13 +36,16 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
import java.util.List;
@Config(shadows = SettingsShadowResources.class)
@RunWith(RobolectricTestRunner.class)
public class DoubleTapPowerSettingsTest {
@Rule public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
@Rule
public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
private DoubleTapPowerSettings mSettings;
@Before
@@ -48,10 +55,29 @@ public class DoubleTapPowerSettingsTest {
@Test
@EnableFlags(Flags.FLAG_LAUNCH_WALLET_OPTION_ON_POWER_DOUBLE_TAP)
public void getPreferenceScreenResId_flagEnabled_returnsFlagEnabledResId() {
public void
getPreferenceScreenResId_flagEnabled_configIsMultiTargetMode_returnsMultiTargetResId() {
SettingsShadowResources.overrideResource(
com.android.internal.R.integer.config_doubleTapPowerGestureMode,
DOUBLE_TAP_POWER_MULTI_TARGET_MODE);
mSettings.onAttach(RuntimeEnvironment.getApplication());
assertThat(mSettings.getPreferenceScreenResId()).isEqualTo(R.xml.double_tap_power_settings);
}
@Test
@EnableFlags(Flags.FLAG_LAUNCH_WALLET_OPTION_ON_POWER_DOUBLE_TAP)
public void
getPreferenceScreenResId_flagEnabled_configIsCameraMode_returnsCameraLaunchResId() {
SettingsShadowResources.overrideResource(
com.android.internal.R.integer.config_doubleTapPowerGestureMode,
DOUBLE_TAP_POWER_LAUNCH_CAMERA_MODE);
mSettings.onAttach(RuntimeEnvironment.getApplication());
assertThat(mSettings.getPreferenceScreenResId()).isEqualTo(
R.xml.double_tap_power_to_open_camera_settings);
}
@Test
@DisableFlags(Flags.FLAG_LAUNCH_WALLET_OPTION_ON_POWER_DOUBLE_TAP)
public void getPreferenceScreenResId_flagDisabled_returnsFlagDisabledResId() {
@@ -61,7 +87,12 @@ public class DoubleTapPowerSettingsTest {
@Test
@EnableFlags(Flags.FLAG_LAUNCH_WALLET_OPTION_ON_POWER_DOUBLE_TAP)
public void testSearchIndexProvider_flagEnabled_shouldIndexFlagEnabledResource() {
public void
testSearchIndexProvider_flagEnabled_configIsMultiTargetMode_indexMultiTargetResId() {
SettingsShadowResources.overrideResource(
com.android.internal.R.integer.config_doubleTapPowerGestureMode,
DOUBLE_TAP_POWER_MULTI_TARGET_MODE);
final List<SearchIndexableResource> indexRes =
DoubleTapPowerSettings.SEARCH_INDEX_DATA_PROVIDER.getXmlResourcesToIndex(
RuntimeEnvironment.getApplication(), true /* enabled */);
@@ -70,9 +101,26 @@ public class DoubleTapPowerSettingsTest {
assertThat(indexRes.get(0).xmlResId).isEqualTo(R.xml.double_tap_power_settings);
}
@Test
@EnableFlags(Flags.FLAG_LAUNCH_WALLET_OPTION_ON_POWER_DOUBLE_TAP)
public void
testSearchIndexProvider_flagEnabled_configIsCameraLaunchMode_indexCameraLaunchResId() {
SettingsShadowResources.overrideResource(
com.android.internal.R.integer.config_doubleTapPowerGestureMode,
DOUBLE_TAP_POWER_LAUNCH_CAMERA_MODE);
final List<SearchIndexableResource> indexRes =
DoubleTapPowerSettings.SEARCH_INDEX_DATA_PROVIDER.getXmlResourcesToIndex(
RuntimeEnvironment.getApplication(), true /* enabled */);
assertThat(indexRes).isNotNull();
assertThat(indexRes.get(0).xmlResId).isEqualTo(
R.xml.double_tap_power_to_open_camera_settings);
}
@Test
@DisableFlags(Flags.FLAG_LAUNCH_WALLET_OPTION_ON_POWER_DOUBLE_TAP)
public void testSearchIndexProvider_flagDisabled_shouldIndexFlagDisabledResource() {
public void testSearchIndexProvider_flagDisabled_indexFlagDisabledResource() {
final List<SearchIndexableResource> indexRes =
DoubleTapPowerSettings.SEARCH_INDEX_DATA_PROVIDER.getXmlResourcesToIndex(
RuntimeEnvironment.getApplication(), true /* enabled */);