Add sensitivity configuration to long press power dialog

This gives the user the ability to configure the length of the long press power gesture. The configuration values are read from config.xml and can be customized per device.

Bug: 193792060
Test: Manual test on Pixel 6 and Pixel 4 hardware devices
Test: Unit tests with make -j64 RunSettingsRoboTests ROBOTEST_FILTER="com.android.settings.gestures.*"
Change-Id: Ia6595c1337244b01e9c8b2ef04dd97a9a0f03de2
This commit is contained in:
Jernej Virag
2021-08-11 19:54:25 +00:00
committed by Govinda Wasserman
parent f4977c5e36
commit de2f00df41
12 changed files with 569 additions and 62 deletions

View File

@@ -16,30 +16,23 @@
package com.android.settings.gestures;
import android.content.Context;
import android.provider.Settings;
import static com.android.settings.gestures.PowerMenuSettingsUtils.LONG_PRESS_POWER_ASSISTANT_VALUE;
import static com.android.settings.gestures.PowerMenuSettingsUtils.LONG_PRESS_POWER_GLOBAL_ACTIONS;
import android.content.Context;
import com.android.internal.annotations.VisibleForTesting;
import com.android.settings.R;
import com.android.settings.core.BasePreferenceController;
public class PowerMenuPreferenceController extends BasePreferenceController {
private static final String POWER_BUTTON_LONG_PRESS_SETTING =
Settings.Global.POWER_BUTTON_LONG_PRESS;
@VisibleForTesting
static final int LONG_PRESS_POWER_GLOBAL_ACTIONS = 1;
@VisibleForTesting
static final int LONG_PRESS_POWER_ASSISTANT_VALUE = 5;
public PowerMenuPreferenceController(Context context, String key) {
super(context, key);
}
@Override
public CharSequence getSummary() {
final int powerButtonValue = getPowerButtonLongPressValue(mContext);
final int powerButtonValue = PowerMenuSettingsUtils.getPowerButtonSettingValue(mContext);
if (powerButtonValue == LONG_PRESS_POWER_ASSISTANT_VALUE) {
return mContext.getText(R.string.power_menu_summary_long_press_for_assist_enabled);
} else if (powerButtonValue == LONG_PRESS_POWER_GLOBAL_ACTIONS) {
@@ -60,11 +53,4 @@ public class PowerMenuPreferenceController extends BasePreferenceController {
return mContext.getResources().getBoolean(
com.android.internal.R.bool.config_longPressOnPowerForAssistantSettingAvailable);
}
private static int getPowerButtonLongPressValue(Context context) {
return Settings.Global.getInt(context.getContentResolver(),
POWER_BUTTON_LONG_PRESS_SETTING,
context.getResources().getInteger(
com.android.internal.R.integer.config_longPressOnPowerBehavior));
}
}