Merge "AOD: Implement long press gesture to launch assist" into oc-dr1-dev
This commit is contained in:
@@ -6514,6 +6514,12 @@ public final class Settings {
|
|||||||
*/
|
*/
|
||||||
public static final String DOZE_PULSE_ON_PICK_UP = "doze_pulse_on_pick_up";
|
public static final String DOZE_PULSE_ON_PICK_UP = "doze_pulse_on_pick_up";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the device should pulse on long press gesture.
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public static final String DOZE_PULSE_ON_LONG_PRESS = "doze_pulse_on_long_press";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether the device should pulse on double tap gesture.
|
* Whether the device should pulse on double tap gesture.
|
||||||
* @hide
|
* @hide
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ public class AmbientDisplayConfiguration {
|
|||||||
return pulseOnNotificationEnabled(user)
|
return pulseOnNotificationEnabled(user)
|
||||||
|| pulseOnPickupEnabled(user)
|
|| pulseOnPickupEnabled(user)
|
||||||
|| pulseOnDoubleTapEnabled(user)
|
|| pulseOnDoubleTapEnabled(user)
|
||||||
|
|| pulseOnLongPressEnabled(user)
|
||||||
|| alwaysOnEnabled(user);
|
|| alwaysOnEnabled(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,6 +80,19 @@ public class AmbientDisplayConfiguration {
|
|||||||
return mContext.getResources().getString(R.string.config_dozeDoubleTapSensorType);
|
return mContext.getResources().getString(R.string.config_dozeDoubleTapSensorType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String longPressSensorType() {
|
||||||
|
return mContext.getResources().getString(R.string.config_dozeLongPressSensorType);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean pulseOnLongPressEnabled(int user) {
|
||||||
|
return pulseOnLongPressAvailable() && boolSettingDefaultOff(
|
||||||
|
Settings.Secure.DOZE_PULSE_ON_LONG_PRESS, user);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean pulseOnLongPressAvailable() {
|
||||||
|
return !TextUtils.isEmpty(longPressSensorType());
|
||||||
|
}
|
||||||
|
|
||||||
public boolean alwaysOnEnabled(int user) {
|
public boolean alwaysOnEnabled(int user) {
|
||||||
return boolSettingDefaultOn(Settings.Secure.DOZE_ALWAYS_ON, user)
|
return boolSettingDefaultOn(Settings.Secure.DOZE_ALWAYS_ON, user)
|
||||||
&& alwaysOnAvailable();
|
&& alwaysOnAvailable();
|
||||||
|
|||||||
@@ -1849,6 +1849,9 @@
|
|||||||
<!-- Type of the double tap sensor. Empty if double tap is not supported. -->
|
<!-- Type of the double tap sensor. Empty if double tap is not supported. -->
|
||||||
<string name="config_dozeDoubleTapSensorType" translatable="false"></string>
|
<string name="config_dozeDoubleTapSensorType" translatable="false"></string>
|
||||||
|
|
||||||
|
<!-- Type of the long press sensor. Empty if long press is not supported. -->
|
||||||
|
<string name="config_dozeLongPressSensorType" translatable="false"></string>
|
||||||
|
|
||||||
<!-- Control whether the always on display mode is available. This should only be enabled on
|
<!-- Control whether the always on display mode is available. This should only be enabled on
|
||||||
devices where the display has be tuned to be power efficient in DOZE and/or DOZE_SUSPEND
|
devices where the display has be tuned to be power efficient in DOZE and/or DOZE_SUSPEND
|
||||||
states. -->
|
states. -->
|
||||||
|
|||||||
@@ -3044,6 +3044,8 @@
|
|||||||
|
|
||||||
<java-symbol type="array" name="config_hideWhenDisabled_packageNames" />
|
<java-symbol type="array" name="config_hideWhenDisabled_packageNames" />
|
||||||
|
|
||||||
|
<java-symbol type="string" name="config_dozeLongPressSensorType" />
|
||||||
|
|
||||||
<java-symbol type="array" name="config_allowedGlobalInstantAppSettings" />
|
<java-symbol type="array" name="config_allowedGlobalInstantAppSettings" />
|
||||||
<java-symbol type="array" name="config_allowedSystemInstantAppSettings" />
|
<java-symbol type="array" name="config_allowedSystemInstantAppSettings" />
|
||||||
<java-symbol type="array" name="config_allowedSecureInstantAppSettings" />
|
<java-symbol type="array" name="config_allowedSecureInstantAppSettings" />
|
||||||
|
|||||||
@@ -430,6 +430,7 @@ public class SettingsBackupTest {
|
|||||||
Settings.Secure.DISABLED_SYSTEM_INPUT_METHODS,
|
Settings.Secure.DISABLED_SYSTEM_INPUT_METHODS,
|
||||||
Settings.Secure.DISPLAY_DENSITY_FORCED,
|
Settings.Secure.DISPLAY_DENSITY_FORCED,
|
||||||
Settings.Secure.DOZE_ALWAYS_ON,
|
Settings.Secure.DOZE_ALWAYS_ON,
|
||||||
|
Settings.Secure.DOZE_PULSE_ON_LONG_PRESS,
|
||||||
Settings.Secure.EMERGENCY_ASSISTANCE_APPLICATION,
|
Settings.Secure.EMERGENCY_ASSISTANCE_APPLICATION,
|
||||||
Settings.Secure.ENABLED_NOTIFICATION_ASSISTANT,
|
Settings.Secure.ENABLED_NOTIFICATION_ASSISTANT,
|
||||||
Settings.Secure.ENABLED_NOTIFICATION_POLICY_ACCESS_PACKAGES,
|
Settings.Secure.ENABLED_NOTIFICATION_POLICY_ACCESS_PACKAGES,
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ public class DozeLog {
|
|||||||
private static final int SIZE = Build.IS_DEBUGGABLE ? 400 : 50;
|
private static final int SIZE = Build.IS_DEBUGGABLE ? 400 : 50;
|
||||||
static final SimpleDateFormat FORMAT = new SimpleDateFormat("MM-dd HH:mm:ss.SSS");
|
static final SimpleDateFormat FORMAT = new SimpleDateFormat("MM-dd HH:mm:ss.SSS");
|
||||||
|
|
||||||
private static final int PULSE_REASONS = 5;
|
private static final int PULSE_REASONS = 6;
|
||||||
|
|
||||||
public static final int PULSE_REASON_NONE = -1;
|
public static final int PULSE_REASON_NONE = -1;
|
||||||
public static final int PULSE_REASON_INTENT = 0;
|
public static final int PULSE_REASON_INTENT = 0;
|
||||||
@@ -43,6 +43,7 @@ public class DozeLog {
|
|||||||
public static final int PULSE_REASON_SENSOR_SIGMOTION = 2;
|
public static final int PULSE_REASON_SENSOR_SIGMOTION = 2;
|
||||||
public static final int PULSE_REASON_SENSOR_PICKUP = 3;
|
public static final int PULSE_REASON_SENSOR_PICKUP = 3;
|
||||||
public static final int PULSE_REASON_SENSOR_DOUBLE_TAP = 4;
|
public static final int PULSE_REASON_SENSOR_DOUBLE_TAP = 4;
|
||||||
|
public static final int PULSE_REASON_SENSOR_LONG_PRESS = 5;
|
||||||
|
|
||||||
private static boolean sRegisterKeyguardCallback = true;
|
private static boolean sRegisterKeyguardCallback = true;
|
||||||
|
|
||||||
@@ -179,6 +180,7 @@ public class DozeLog {
|
|||||||
case PULSE_REASON_SENSOR_SIGMOTION: return "sigmotion";
|
case PULSE_REASON_SENSOR_SIGMOTION: return "sigmotion";
|
||||||
case PULSE_REASON_SENSOR_PICKUP: return "pickup";
|
case PULSE_REASON_SENSOR_PICKUP: return "pickup";
|
||||||
case PULSE_REASON_SENSOR_DOUBLE_TAP: return "doubletap";
|
case PULSE_REASON_SENSOR_DOUBLE_TAP: return "doubletap";
|
||||||
|
case PULSE_REASON_SENSOR_LONG_PRESS: return "longpress";
|
||||||
default: throw new IllegalArgumentException("bad reason: " + pulseReason);
|
default: throw new IllegalArgumentException("bad reason: " + pulseReason);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -98,7 +98,14 @@ public class DozeSensors {
|
|||||||
Settings.Secure.DOZE_PULSE_ON_DOUBLE_TAP,
|
Settings.Secure.DOZE_PULSE_ON_DOUBLE_TAP,
|
||||||
true /* configured */,
|
true /* configured */,
|
||||||
DozeLog.PULSE_REASON_SENSOR_DOUBLE_TAP,
|
DozeLog.PULSE_REASON_SENSOR_DOUBLE_TAP,
|
||||||
dozeParameters.doubleTapReportsTouchCoordinates())
|
dozeParameters.doubleTapReportsTouchCoordinates()),
|
||||||
|
new TriggerSensor(
|
||||||
|
findSensorWithType(config.longPressSensorType()),
|
||||||
|
Settings.Secure.DOZE_PULSE_ON_LONG_PRESS,
|
||||||
|
false /* settingDef */,
|
||||||
|
true /* configured */,
|
||||||
|
DozeLog.PULSE_REASON_SENSOR_LONG_PRESS,
|
||||||
|
true /* reports touch coordinates */),
|
||||||
};
|
};
|
||||||
|
|
||||||
mProxSensor = new ProxSensor();
|
mProxSensor = new ProxSensor();
|
||||||
@@ -263,6 +270,7 @@ public class DozeSensors {
|
|||||||
final int mPulseReason;
|
final int mPulseReason;
|
||||||
final String mSetting;
|
final String mSetting;
|
||||||
final boolean mReportsTouchCoordinates;
|
final boolean mReportsTouchCoordinates;
|
||||||
|
final boolean mSettingDefault;
|
||||||
|
|
||||||
private boolean mRequested;
|
private boolean mRequested;
|
||||||
private boolean mRegistered;
|
private boolean mRegistered;
|
||||||
@@ -270,8 +278,15 @@ public class DozeSensors {
|
|||||||
|
|
||||||
public TriggerSensor(Sensor sensor, String setting, boolean configured, int pulseReason,
|
public TriggerSensor(Sensor sensor, String setting, boolean configured, int pulseReason,
|
||||||
boolean reportsTouchCoordinates) {
|
boolean reportsTouchCoordinates) {
|
||||||
|
this(sensor, setting, true /* settingDef */, configured, pulseReason,
|
||||||
|
reportsTouchCoordinates);
|
||||||
|
}
|
||||||
|
|
||||||
|
public TriggerSensor(Sensor sensor, String setting, boolean settingDef,
|
||||||
|
boolean configured, int pulseReason, boolean reportsTouchCoordinates) {
|
||||||
mSensor = sensor;
|
mSensor = sensor;
|
||||||
mSetting = setting;
|
mSetting = setting;
|
||||||
|
mSettingDefault = settingDef;
|
||||||
mConfigured = configured;
|
mConfigured = configured;
|
||||||
mPulseReason = pulseReason;
|
mPulseReason = pulseReason;
|
||||||
mReportsTouchCoordinates = reportsTouchCoordinates;
|
mReportsTouchCoordinates = reportsTouchCoordinates;
|
||||||
@@ -305,7 +320,7 @@ public class DozeSensors {
|
|||||||
if (TextUtils.isEmpty(mSetting)) {
|
if (TextUtils.isEmpty(mSetting)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return Settings.Secure.getIntForUser(mResolver, mSetting, 1,
|
return Settings.Secure.getIntForUser(mResolver, mSetting, mSettingDefault ? 1 : 0,
|
||||||
UserHandle.USER_CURRENT) != 0;
|
UserHandle.USER_CURRENT) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -123,8 +123,9 @@ public class DozeTriggers implements DozeMachine.Part {
|
|||||||
float screenX, float screenY) {
|
float screenX, float screenY) {
|
||||||
boolean isDoubleTap = pulseReason == DozeLog.PULSE_REASON_SENSOR_DOUBLE_TAP;
|
boolean isDoubleTap = pulseReason == DozeLog.PULSE_REASON_SENSOR_DOUBLE_TAP;
|
||||||
boolean isPickup = pulseReason == DozeLog.PULSE_REASON_SENSOR_PICKUP;
|
boolean isPickup = pulseReason == DozeLog.PULSE_REASON_SENSOR_PICKUP;
|
||||||
|
boolean isLongPress = pulseReason == DozeLog.PULSE_REASON_SENSOR_LONG_PRESS;
|
||||||
|
|
||||||
if (mConfig.alwaysOnEnabled(UserHandle.USER_CURRENT)) {
|
if (mConfig.alwaysOnEnabled(UserHandle.USER_CURRENT) && !isLongPress) {
|
||||||
proximityCheckThenCall((result) -> {
|
proximityCheckThenCall((result) -> {
|
||||||
if (result == ProximityCheck.RESULT_NEAR) {
|
if (result == ProximityCheck.RESULT_NEAR) {
|
||||||
// In pocket, drop event.
|
// In pocket, drop event.
|
||||||
|
|||||||
@@ -5336,6 +5336,12 @@ public class StatusBar extends SystemUI implements DemoMode,
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void pulseWhileDozing(@NonNull PulseCallback callback, int reason) {
|
public void pulseWhileDozing(@NonNull PulseCallback callback, int reason) {
|
||||||
|
if (reason == DozeLog.PULSE_REASON_SENSOR_LONG_PRESS) {
|
||||||
|
mPowerManager.wakeUp(SystemClock.uptimeMillis(), "com.android.systemui:NODOZE");
|
||||||
|
startAssist(new Bundle());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
mDozeScrimController.pulse(new PulseCallback() {
|
mDozeScrimController.pulse(new PulseCallback() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user