Merge "Adds LPP sensitivity for Assistant invocation" into sc-qpr1-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
25864687e2
@@ -14914,6 +14914,16 @@ public final class Settings {
|
||||
public static final String POWER_BUTTON_LONG_PRESS =
|
||||
"power_button_long_press";
|
||||
|
||||
/**
|
||||
* Override internal R.integer.config_longPressOnPowerDurationMs. It determines the length
|
||||
* of power button press to be considered a long press in milliseconds.
|
||||
* Used by PhoneWindowManager.
|
||||
* @hide
|
||||
*/
|
||||
@Readable
|
||||
public static final String POWER_BUTTON_LONG_PRESS_DURATION_MS =
|
||||
"power_button_long_press_duration_ms";
|
||||
|
||||
/**
|
||||
* Overrides internal R.integer.config_veryLongPressOnPowerBehavior.
|
||||
* Allowable values detailed in frameworks/base/core/res/res/values/config.xml.
|
||||
|
||||
@@ -771,6 +771,8 @@ message GlobalSettingsProto {
|
||||
optional SettingProto power_manager_constants = 93;
|
||||
reserved 94; // Used to be priv_app_oob_enabled
|
||||
|
||||
optional SettingProto power_button_long_press_duration_ms = 154 [ (android.privacy).dest = DEST_AUTOMATIC ];
|
||||
|
||||
message PrepaidSetup {
|
||||
option (android.msg_privacy).dest = DEST_EXPLICIT;
|
||||
|
||||
@@ -1063,5 +1065,5 @@ message GlobalSettingsProto {
|
||||
|
||||
// Please insert fields in alphabetical order and group them into messages
|
||||
// if possible (to avoid reaching the method limit).
|
||||
// Next tag = 154;
|
||||
// Next tag = 155;
|
||||
}
|
||||
|
||||
@@ -957,6 +957,20 @@
|
||||
-->
|
||||
<integer name="config_longPressOnPowerBehavior">5</integer>
|
||||
|
||||
<!-- The time in milliseconds after which a press on power button is considered "long". -->
|
||||
<integer name="config_longPressOnPowerDurationMs">500</integer>
|
||||
|
||||
<!-- The possible UI options to be surfaced for configuring long press power on duration
|
||||
action. Value set in config_longPressOnPowerDurationMs should be one of the available
|
||||
options to allow users to restore default. -->
|
||||
<integer-array name="config_longPressOnPowerDurationSettings">
|
||||
<item>250</item>
|
||||
<item>350</item>
|
||||
<item>500</item>
|
||||
<item>650</item>
|
||||
<item>750</item>
|
||||
</integer-array>
|
||||
|
||||
<!-- Whether the setting to change long press on power behaviour from default to assistant (5)
|
||||
is available in Settings.
|
||||
-->
|
||||
|
||||
@@ -439,6 +439,8 @@
|
||||
<java-symbol type="integer" name="config_extraFreeKbytesAbsolute" />
|
||||
<java-symbol type="integer" name="config_immersive_mode_confirmation_panic" />
|
||||
<java-symbol type="integer" name="config_longPressOnPowerBehavior" />
|
||||
<java-symbol type="integer" name="config_longPressOnPowerDurationMs" />
|
||||
<java-symbol type="array" name="config_longPressOnPowerDurationSettings" />
|
||||
<java-symbol type="bool" name="config_longPressOnPowerForAssistantSettingAvailable" />
|
||||
<java-symbol type="integer" name="config_veryLongPressOnPowerBehavior" />
|
||||
<java-symbol type="integer" name="config_veryLongPressTimeout" />
|
||||
|
||||
@@ -76,5 +76,6 @@ public class GlobalSettings {
|
||||
Settings.Global.ARE_USER_DISABLED_HDR_FORMATS_ALLOWED,
|
||||
Settings.Global.DEVICE_CONFIG_SYNC_DISABLED,
|
||||
Settings.Global.POWER_BUTTON_LONG_PRESS,
|
||||
Settings.Global.POWER_BUTTON_LONG_PRESS_DURATION_MS
|
||||
};
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import static android.media.AudioFormat.SURROUND_SOUND_ENCODING;
|
||||
import static android.provider.settings.validators.SettingsValidators.ANY_INTEGER_VALIDATOR;
|
||||
import static android.provider.settings.validators.SettingsValidators.ANY_STRING_VALIDATOR;
|
||||
import static android.provider.settings.validators.SettingsValidators.BOOLEAN_VALIDATOR;
|
||||
import static android.provider.settings.validators.SettingsValidators.NONE_NEGATIVE_LONG_VALIDATOR;
|
||||
import static android.provider.settings.validators.SettingsValidators.PACKAGE_NAME_VALIDATOR;
|
||||
import static android.provider.settings.validators.SettingsValidators.PERCENTAGE_INTEGER_VALIDATOR;
|
||||
import static android.view.Display.HdrCapabilities.HDR_TYPES;
|
||||
@@ -140,6 +141,7 @@ public class GlobalSettingsValidators {
|
||||
/* last= */Global.ONE_HANDED_KEYGUARD_SIDE_RIGHT));
|
||||
VALIDATORS.put(Global.DISABLE_WINDOW_BLURS, BOOLEAN_VALIDATOR);
|
||||
VALIDATORS.put(Global.DEVICE_CONFIG_SYNC_DISABLED, BOOLEAN_VALIDATOR);
|
||||
VALIDATORS.put(Global.POWER_BUTTON_LONG_PRESS_DURATION_MS, NONE_NEGATIVE_LONG_VALIDATOR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1195,6 +1195,9 @@ class SettingsProtoDumpUtil {
|
||||
dumpSetting(s, p,
|
||||
Settings.Global.POWER_MANAGER_CONSTANTS,
|
||||
GlobalSettingsProto.POWER_MANAGER_CONSTANTS);
|
||||
dumpSetting(s, p,
|
||||
Settings.Global.POWER_BUTTON_LONG_PRESS_DURATION_MS,
|
||||
GlobalSettingsProto.POWER_BUTTON_LONG_PRESS_DURATION_MS);
|
||||
|
||||
final long prepaidSetupToken = p.start(GlobalSettingsProto.PREPAID_SETUP);
|
||||
dumpSetting(s, p,
|
||||
|
||||
@@ -484,6 +484,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
||||
int mLidNavigationAccessibility;
|
||||
int mShortPressOnPowerBehavior;
|
||||
int mLongPressOnPowerBehavior;
|
||||
long mLongPressOnPowerAssistantTimeoutMs;
|
||||
int mVeryLongPressOnPowerBehavior;
|
||||
int mDoublePressOnPowerBehavior;
|
||||
int mTriplePressOnPowerBehavior;
|
||||
@@ -731,6 +732,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
||||
resolver.registerContentObserver(Settings.Global.getUriFor(
|
||||
Settings.Global.POWER_BUTTON_LONG_PRESS), false, this,
|
||||
UserHandle.USER_ALL);
|
||||
resolver.registerContentObserver(Settings.Global.getUriFor(
|
||||
Settings.Global.POWER_BUTTON_LONG_PRESS_DURATION_MS), false, this,
|
||||
UserHandle.USER_ALL);
|
||||
resolver.registerContentObserver(Settings.Global.getUriFor(
|
||||
Settings.Global.POWER_BUTTON_VERY_LONG_PRESS), false, this,
|
||||
UserHandle.USER_ALL);
|
||||
@@ -1732,6 +1736,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
||||
com.android.internal.R.integer.config_shortPressOnPowerBehavior);
|
||||
mLongPressOnPowerBehavior = mContext.getResources().getInteger(
|
||||
com.android.internal.R.integer.config_longPressOnPowerBehavior);
|
||||
mLongPressOnPowerAssistantTimeoutMs = mContext.getResources().getInteger(
|
||||
com.android.internal.R.integer.config_longPressOnPowerDurationMs);
|
||||
mVeryLongPressOnPowerBehavior = mContext.getResources().getInteger(
|
||||
com.android.internal.R.integer.config_veryLongPressOnPowerBehavior);
|
||||
mDoublePressOnPowerBehavior = mContext.getResources().getInteger(
|
||||
@@ -1955,7 +1961,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
||||
*/
|
||||
private final class PowerKeyRule extends SingleKeyGestureDetector.SingleKeyRule {
|
||||
PowerKeyRule(int gestures) {
|
||||
super(KEYCODE_POWER, gestures);
|
||||
super(mContext, KEYCODE_POWER, gestures);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1969,6 +1975,15 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
||||
mSingleKeyGestureDetector.beganFromNonInteractive());
|
||||
}
|
||||
|
||||
@Override
|
||||
long getLongPressTimeoutMs() {
|
||||
if (getResolvedLongPressOnPowerBehavior() == LONG_PRESS_POWER_ASSISTANT) {
|
||||
return mLongPressOnPowerAssistantTimeoutMs;
|
||||
} else {
|
||||
return super.getLongPressTimeoutMs();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
void onLongPress(long eventTime) {
|
||||
if (mSingleKeyGestureDetector.beganFromNonInteractive()
|
||||
@@ -1997,7 +2012,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
||||
*/
|
||||
private final class BackKeyRule extends SingleKeyGestureDetector.SingleKeyRule {
|
||||
BackKeyRule(int gestures) {
|
||||
super(KEYCODE_BACK, gestures);
|
||||
super(mContext, KEYCODE_BACK, gestures);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -2017,7 +2032,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
||||
}
|
||||
|
||||
private void initSingleKeyGestureRules() {
|
||||
mSingleKeyGestureDetector = new SingleKeyGestureDetector(mContext);
|
||||
mSingleKeyGestureDetector = new SingleKeyGestureDetector();
|
||||
|
||||
int powerKeyGestures = 0;
|
||||
if (hasVeryLongPressOnPowerBehavior()) {
|
||||
@@ -2115,6 +2130,11 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
||||
Settings.Global.POWER_BUTTON_LONG_PRESS,
|
||||
mContext.getResources().getInteger(
|
||||
com.android.internal.R.integer.config_longPressOnPowerBehavior));
|
||||
mLongPressOnPowerAssistantTimeoutMs = Settings.Global.getLong(
|
||||
mContext.getContentResolver(),
|
||||
Settings.Global.POWER_BUTTON_LONG_PRESS_DURATION_MS,
|
||||
mContext.getResources().getInteger(
|
||||
com.android.internal.R.integer.config_longPressOnPowerDurationMs));
|
||||
mVeryLongPressOnPowerBehavior = Settings.Global.getInt(resolver,
|
||||
Settings.Global.POWER_BUTTON_VERY_LONG_PRESS,
|
||||
mContext.getResources().getInteger(
|
||||
@@ -5328,6 +5348,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
||||
pw.print(prefix);
|
||||
pw.print("mLongPressOnPowerBehavior=");
|
||||
pw.println(longPressOnPowerBehaviorToString(mLongPressOnPowerBehavior));
|
||||
pw.print(prefix);
|
||||
pw.print("mLongPressOnPowerAssistantTimeoutMs=");
|
||||
pw.println(mLongPressOnPowerAssistantTimeoutMs);
|
||||
pw.print(prefix);
|
||||
pw.print("mVeryLongPressOnPowerBehavior=");
|
||||
pw.println(veryLongPressOnPowerBehaviorToString(mVeryLongPressOnPowerBehavior));
|
||||
|
||||
@@ -44,9 +44,6 @@ public final class SingleKeyGestureDetector {
|
||||
private static final int MSG_KEY_VERY_LONG_PRESS = 1;
|
||||
private static final int MSG_KEY_DELAYED_PRESS = 2;
|
||||
|
||||
private final long mLongPressTimeout;
|
||||
private final long mVeryLongPressTimeout;
|
||||
|
||||
private volatile int mKeyPressCounter;
|
||||
private boolean mBeganFromNonInteractive = false;
|
||||
|
||||
@@ -86,12 +83,19 @@ public final class SingleKeyGestureDetector {
|
||||
* </pre>
|
||||
*/
|
||||
abstract static class SingleKeyRule {
|
||||
|
||||
private final int mKeyCode;
|
||||
private final int mSupportedGestures;
|
||||
private final long mDefaultLongPressTimeout;
|
||||
private final long mDefaultVeryLongPressTimeout;
|
||||
|
||||
SingleKeyRule(int keyCode, @KeyGestureFlag int supportedGestures) {
|
||||
SingleKeyRule(Context context, int keyCode, @KeyGestureFlag int supportedGestures) {
|
||||
mKeyCode = keyCode;
|
||||
mSupportedGestures = supportedGestures;
|
||||
mDefaultLongPressTimeout =
|
||||
ViewConfiguration.get(context).getDeviceGlobalActionKeyTimeout();
|
||||
mDefaultVeryLongPressTimeout = context.getResources().getInteger(
|
||||
com.android.internal.R.integer.config_veryLongPressTimeout);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -133,10 +137,28 @@ public final class SingleKeyGestureDetector {
|
||||
* Callback when multi press (>= 2) has been detected.
|
||||
*/
|
||||
void onMultiPress(long downTime, int count) {}
|
||||
/**
|
||||
* Returns the timeout in milliseconds for a long press.
|
||||
*
|
||||
* If multipress is also supported, this should always be greater than the multipress
|
||||
* timeout. If very long press is supported, this should always be less than the very long
|
||||
* press timeout.
|
||||
*/
|
||||
long getLongPressTimeoutMs() {
|
||||
return mDefaultLongPressTimeout;
|
||||
}
|
||||
/**
|
||||
* Callback when long press has been detected.
|
||||
*/
|
||||
void onLongPress(long eventTime) {}
|
||||
/**
|
||||
* Returns the timeout in milliseconds for a very long press.
|
||||
*
|
||||
* If long press is supported, this should always be longer than the long press timeout.
|
||||
*/
|
||||
long getVeryLongPressTimeoutMs() {
|
||||
return mDefaultVeryLongPressTimeout;
|
||||
}
|
||||
/**
|
||||
* Callback when very long press has been detected.
|
||||
*/
|
||||
@@ -151,10 +173,7 @@ public final class SingleKeyGestureDetector {
|
||||
}
|
||||
}
|
||||
|
||||
public SingleKeyGestureDetector(Context context) {
|
||||
mLongPressTimeout = ViewConfiguration.get(context).getDeviceGlobalActionKeyTimeout();
|
||||
mVeryLongPressTimeout = context.getResources().getInteger(
|
||||
com.android.internal.R.integer.config_veryLongPressTimeout);
|
||||
public SingleKeyGestureDetector() {
|
||||
mHandler = new KeyHandler();
|
||||
}
|
||||
|
||||
@@ -225,14 +244,14 @@ public final class SingleKeyGestureDetector {
|
||||
final Message msg = mHandler.obtainMessage(MSG_KEY_LONG_PRESS, keyCode, 0,
|
||||
eventTime);
|
||||
msg.setAsynchronous(true);
|
||||
mHandler.sendMessageDelayed(msg, mLongPressTimeout);
|
||||
mHandler.sendMessageDelayed(msg, mActiveRule.getLongPressTimeoutMs());
|
||||
}
|
||||
|
||||
if (mActiveRule.supportVeryLongPress()) {
|
||||
final Message msg = mHandler.obtainMessage(MSG_KEY_VERY_LONG_PRESS, keyCode, 0,
|
||||
eventTime);
|
||||
msg.setAsynchronous(true);
|
||||
mHandler.sendMessageDelayed(msg, mVeryLongPressTimeout);
|
||||
mHandler.sendMessageDelayed(msg, mActiveRule.getVeryLongPressTimeoutMs());
|
||||
}
|
||||
} else {
|
||||
mHandler.removeMessages(MSG_KEY_LONG_PRESS);
|
||||
|
||||
@@ -69,7 +69,7 @@ public class SingleKeyGestureTests {
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
mDetector = new SingleKeyGestureDetector(mContext);
|
||||
mDetector = new SingleKeyGestureDetector();
|
||||
initSingleKeyGestureRules();
|
||||
mWaitTimeout = ViewConfiguration.getMultiPressTimeout() + 50;
|
||||
mLongPressTime = ViewConfiguration.get(mContext).getDeviceGlobalActionKeyTimeout() + 50;
|
||||
@@ -78,7 +78,7 @@ public class SingleKeyGestureTests {
|
||||
}
|
||||
|
||||
private void initSingleKeyGestureRules() {
|
||||
mDetector.addRule(new SingleKeyGestureDetector.SingleKeyRule(KEYCODE_POWER,
|
||||
mDetector.addRule(new SingleKeyGestureDetector.SingleKeyRule(mContext, KEYCODE_POWER,
|
||||
KEY_LONGPRESS | KEY_VERYLONGPRESS) {
|
||||
@Override
|
||||
int getMaxMultiPressCount() {
|
||||
|
||||
Reference in New Issue
Block a user