Merge "AOD: Implement long press gesture to launch assist" into oc-dr1-dev

This commit is contained in:
Adrian Roos
2017-07-13 12:01:52 +00:00
committed by Android (Google) Code Review
9 changed files with 54 additions and 4 deletions

View File

@@ -6514,6 +6514,12 @@ public final class Settings {
*/
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.
* @hide

View File

@@ -36,6 +36,7 @@ public class AmbientDisplayConfiguration {
return pulseOnNotificationEnabled(user)
|| pulseOnPickupEnabled(user)
|| pulseOnDoubleTapEnabled(user)
|| pulseOnLongPressEnabled(user)
|| alwaysOnEnabled(user);
}
@@ -79,6 +80,19 @@ public class AmbientDisplayConfiguration {
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) {
return boolSettingDefaultOn(Settings.Secure.DOZE_ALWAYS_ON, user)
&& alwaysOnAvailable();

View File

@@ -1849,6 +1849,9 @@
<!-- Type of the double tap sensor. Empty if double tap is not supported. -->
<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
devices where the display has be tuned to be power efficient in DOZE and/or DOZE_SUSPEND
states. -->

View File

@@ -3044,6 +3044,8 @@
<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_allowedSystemInstantAppSettings" />
<java-symbol type="array" name="config_allowedSecureInstantAppSettings" />

View File

@@ -430,6 +430,7 @@ public class SettingsBackupTest {
Settings.Secure.DISABLED_SYSTEM_INPUT_METHODS,
Settings.Secure.DISPLAY_DENSITY_FORCED,
Settings.Secure.DOZE_ALWAYS_ON,
Settings.Secure.DOZE_PULSE_ON_LONG_PRESS,
Settings.Secure.EMERGENCY_ASSISTANCE_APPLICATION,
Settings.Secure.ENABLED_NOTIFICATION_ASSISTANT,
Settings.Secure.ENABLED_NOTIFICATION_POLICY_ACCESS_PACKAGES,

View File

@@ -35,7 +35,7 @@ public class DozeLog {
private static final int SIZE = Build.IS_DEBUGGABLE ? 400 : 50;
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_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_PICKUP = 3;
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;
@@ -179,6 +180,7 @@ public class DozeLog {
case PULSE_REASON_SENSOR_SIGMOTION: return "sigmotion";
case PULSE_REASON_SENSOR_PICKUP: return "pickup";
case PULSE_REASON_SENSOR_DOUBLE_TAP: return "doubletap";
case PULSE_REASON_SENSOR_LONG_PRESS: return "longpress";
default: throw new IllegalArgumentException("bad reason: " + pulseReason);
}
}

View File

@@ -98,7 +98,14 @@ public class DozeSensors {
Settings.Secure.DOZE_PULSE_ON_DOUBLE_TAP,
true /* configured */,
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();
@@ -263,6 +270,7 @@ public class DozeSensors {
final int mPulseReason;
final String mSetting;
final boolean mReportsTouchCoordinates;
final boolean mSettingDefault;
private boolean mRequested;
private boolean mRegistered;
@@ -270,8 +278,15 @@ public class DozeSensors {
public TriggerSensor(Sensor sensor, String setting, boolean configured, int pulseReason,
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;
mSetting = setting;
mSettingDefault = settingDef;
mConfigured = configured;
mPulseReason = pulseReason;
mReportsTouchCoordinates = reportsTouchCoordinates;
@@ -305,7 +320,7 @@ public class DozeSensors {
if (TextUtils.isEmpty(mSetting)) {
return true;
}
return Settings.Secure.getIntForUser(mResolver, mSetting, 1,
return Settings.Secure.getIntForUser(mResolver, mSetting, mSettingDefault ? 1 : 0,
UserHandle.USER_CURRENT) != 0;
}

View File

@@ -123,8 +123,9 @@ public class DozeTriggers implements DozeMachine.Part {
float screenX, float screenY) {
boolean isDoubleTap = pulseReason == DozeLog.PULSE_REASON_SENSOR_DOUBLE_TAP;
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) -> {
if (result == ProximityCheck.RESULT_NEAR) {
// In pocket, drop event.

View File

@@ -5336,6 +5336,12 @@ public class StatusBar extends SystemUI implements DemoMode,
@Override
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() {
@Override