Merge "Double tap and lift should take to lock screen"

This commit is contained in:
Andrew Lehmer
2018-08-13 15:54:27 +00:00
committed by Android (Google) Code Review
10 changed files with 38 additions and 56 deletions

View File

@@ -7154,9 +7154,9 @@ public final class Settings {
* Whether the device should pulse on pick up gesture.
* @hide
*/
public static final String DOZE_PULSE_ON_PICK_UP = "doze_pulse_on_pick_up";
public static final String DOZE_PICK_UP_GESTURE = "doze_pulse_on_pick_up";
private static final Validator DOZE_PULSE_ON_PICK_UP_VALIDATOR = BOOLEAN_VALIDATOR;
private static final Validator DOZE_PICK_UP_GESTURE_VALIDATOR = BOOLEAN_VALIDATOR;
/**
* Whether the device should pulse on long press gesture.
@@ -7168,9 +7168,9 @@ public final class Settings {
* Whether the device should pulse on double tap gesture.
* @hide
*/
public static final String DOZE_PULSE_ON_DOUBLE_TAP = "doze_pulse_on_double_tap";
public static final String DOZE_DOUBLE_TAP_GESTURE = "doze_pulse_on_double_tap";
private static final Validator DOZE_PULSE_ON_DOUBLE_TAP_VALIDATOR = BOOLEAN_VALIDATOR;
private static final Validator DOZE_DOUBLE_TAP_GESTURE_VALIDATOR = BOOLEAN_VALIDATOR;
/**
* The current night mode that has been selected by the user. Owned
@@ -8064,8 +8064,8 @@ public final class Settings {
QS_TILES,
DOZE_ENABLED,
DOZE_ALWAYS_ON,
DOZE_PULSE_ON_PICK_UP,
DOZE_PULSE_ON_DOUBLE_TAP,
DOZE_PICK_UP_GESTURE,
DOZE_DOUBLE_TAP_GESTURE,
NFC_PAYMENT_DEFAULT_COMPONENT,
AUTOMATIC_STORAGE_MANAGER_DAYS_TO_RETAIN,
FACE_UNLOCK_KEYGUARD_ENABLED,
@@ -8207,8 +8207,8 @@ public final class Settings {
VALIDATORS.put(QS_TILES, QS_TILES_VALIDATOR);
VALIDATORS.put(DOZE_ENABLED, DOZE_ENABLED_VALIDATOR);
VALIDATORS.put(DOZE_ALWAYS_ON, DOZE_ALWAYS_ON_VALIDATOR);
VALIDATORS.put(DOZE_PULSE_ON_PICK_UP, DOZE_PULSE_ON_PICK_UP_VALIDATOR);
VALIDATORS.put(DOZE_PULSE_ON_DOUBLE_TAP, DOZE_PULSE_ON_DOUBLE_TAP_VALIDATOR);
VALIDATORS.put(DOZE_PICK_UP_GESTURE, DOZE_PICK_UP_GESTURE_VALIDATOR);
VALIDATORS.put(DOZE_DOUBLE_TAP_GESTURE, DOZE_DOUBLE_TAP_GESTURE_VALIDATOR);
VALIDATORS.put(NFC_PAYMENT_DEFAULT_COMPONENT, NFC_PAYMENT_DEFAULT_COMPONENT_VALIDATOR);
VALIDATORS.put(AUTOMATIC_STORAGE_MANAGER_DAYS_TO_RETAIN,
AUTOMATIC_STORAGE_MANAGER_DAYS_TO_RETAIN_VALIDATOR);

View File

@@ -36,17 +36,10 @@ public class AmbientDisplayConfiguration {
public boolean enabled(int user) {
return pulseOnNotificationEnabled(user)
|| pulseOnPickupEnabled(user)
|| pulseOnDoubleTapEnabled(user)
|| pulseOnLongPressEnabled(user)
|| alwaysOnEnabled(user);
}
public boolean available() {
return pulseOnNotificationAvailable() || pulseOnPickupAvailable()
|| pulseOnDoubleTapAvailable();
}
public boolean pulseOnNotificationEnabled(int user) {
return boolSettingDefaultOn(Settings.Secure.DOZE_ENABLED, user) && pulseOnNotificationAvailable();
}
@@ -55,30 +48,18 @@ public class AmbientDisplayConfiguration {
return ambientDisplayAvailable();
}
public boolean pulseOnPickupEnabled(int user) {
boolean settingEnabled = boolSettingDefaultOn(Settings.Secure.DOZE_PULSE_ON_PICK_UP, user);
return (settingEnabled || alwaysOnEnabled(user)) && pulseOnPickupAvailable();
public boolean pickupGestureEnabled(int user) {
return boolSettingDefaultOn(Settings.Secure.DOZE_PICK_UP_GESTURE, user)
&& dozePickupSensorAvailable();
}
public boolean pulseOnPickupAvailable() {
return dozePulsePickupSensorAvailable() && ambientDisplayAvailable();
}
public boolean dozePulsePickupSensorAvailable() {
public boolean dozePickupSensorAvailable() {
return mContext.getResources().getBoolean(R.bool.config_dozePulsePickup);
}
public boolean pulseOnPickupCanBeModified(int user) {
return !alwaysOnEnabled(user);
}
public boolean pulseOnDoubleTapEnabled(int user) {
return boolSettingDefaultOn(Settings.Secure.DOZE_PULSE_ON_DOUBLE_TAP, user)
&& pulseOnDoubleTapAvailable();
}
public boolean pulseOnDoubleTapAvailable() {
return doubleTapSensorAvailable() && ambientDisplayAvailable();
public boolean doubleTapGestureEnabled(int user) {
return boolSettingDefaultOn(Settings.Secure.DOZE_DOUBLE_TAP_GESTURE, user)
&& doubleTapSensorAvailable();
}
public boolean doubleTapSensorAvailable() {

View File

@@ -1791,13 +1791,13 @@ class SettingsProtoDumpUtil {
Settings.Secure.DOZE_ALWAYS_ON,
SecureSettingsProto.Doze.ALWAYS_ON);
dumpSetting(s, p,
Settings.Secure.DOZE_PULSE_ON_PICK_UP,
Settings.Secure.DOZE_PICK_UP_GESTURE,
SecureSettingsProto.Doze.PULSE_ON_PICK_UP);
dumpSetting(s, p,
Settings.Secure.DOZE_PULSE_ON_LONG_PRESS,
SecureSettingsProto.Doze.PULSE_ON_LONG_PRESS);
dumpSetting(s, p,
Settings.Secure.DOZE_PULSE_ON_DOUBLE_TAP,
Settings.Secure.DOZE_DOUBLE_TAP_GESTURE,
SecureSettingsProto.Doze.PULSE_ON_DOUBLE_TAP);
p.end(dozeToken);

View File

@@ -3242,9 +3242,9 @@ public class SettingsProvider extends ContentProvider {
getSettingLocked(Settings.Secure.DOZE_ENABLED).getValue());
if (dozeExplicitlyDisabled) {
secureSettings.insertSettingLocked(Settings.Secure.DOZE_PULSE_ON_PICK_UP,
secureSettings.insertSettingLocked(Settings.Secure.DOZE_PICK_UP_GESTURE,
"0", null, true, SettingsState.SYSTEM_PACKAGE_NAME);
secureSettings.insertSettingLocked(Settings.Secure.DOZE_PULSE_ON_DOUBLE_TAP,
secureSettings.insertSettingLocked(Settings.Secure.DOZE_DOUBLE_TAP_GESTURE,
"0", null, true, SettingsState.SYSTEM_PACKAGE_NAME);
}
currentVersion = 131;

View File

@@ -62,10 +62,10 @@ public class DozeLog {
private static SummaryStats sEmergencyCallStats;
private static SummaryStats[][] sProxStats; // [reason][near/far]
public static void tracePickupPulse(Context context, boolean withinVibrationThreshold) {
public static void tracePickupWakeUp(Context context, boolean withinVibrationThreshold) {
if (!ENABLED) return;
init(context);
log("pickupPulse withinVibrationThreshold=" + withinVibrationThreshold);
log("pickupWakeUp withinVibrationThreshold=" + withinVibrationThreshold);
(withinVibrationThreshold ? sPickupPulseNearVibrationStats
: sPickupPulseNotNearVibrationStats).append();
}

View File

@@ -91,13 +91,13 @@ public class DozeSensors {
false /* touchscreen */),
mPickupSensor = new TriggerSensor(
mSensorManager.getDefaultSensor(Sensor.TYPE_PICK_UP_GESTURE),
Settings.Secure.DOZE_PULSE_ON_PICK_UP,
config.pulseOnPickupAvailable(),
Settings.Secure.DOZE_PICK_UP_GESTURE,
config.dozePickupSensorAvailable(),
DozeLog.PULSE_REASON_SENSOR_PICKUP, false /* touchCoords */,
false /* touchscreen */),
new TriggerSensor(
findSensorWithType(config.doubleTapSensorType()),
Settings.Secure.DOZE_PULSE_ON_DOUBLE_TAP,
Settings.Secure.DOZE_DOUBLE_TAP_GESTURE,
true /* configured */,
DozeLog.PULSE_REASON_SENSOR_DOUBLE_TAP,
dozeParameters.doubleTapReportsTouchCoordinates(),

View File

@@ -129,7 +129,9 @@ public class DozeTriggers implements DozeMachine.Part {
boolean isPickup = pulseReason == DozeLog.PULSE_REASON_SENSOR_PICKUP;
boolean isLongPress = pulseReason == DozeLog.PULSE_REASON_SENSOR_LONG_PRESS;
if (mConfig.alwaysOnEnabled(UserHandle.USER_CURRENT) && !isLongPress) {
if (isLongPress) {
requestPulse(pulseReason, sensorPerformedProxCheck);
} else {
proximityCheckThenCall((result) -> {
if (result == ProximityCheck.RESULT_NEAR) {
// In pocket, drop event.
@@ -138,13 +140,13 @@ public class DozeTriggers implements DozeMachine.Part {
if (isDoubleTap) {
mDozeHost.onDoubleTap(screenX, screenY);
mMachine.wakeUp();
} else if (isPickup) {
mMachine.wakeUp();
} else {
mDozeHost.extendPulse();
}
}, sensorPerformedProxCheck, pulseReason);
return;
} else {
requestPulse(pulseReason, sensorPerformedProxCheck);
}
if (isPickup) {
@@ -152,7 +154,7 @@ public class DozeTriggers implements DozeMachine.Part {
SystemClock.elapsedRealtime() - mNotificationPulseTime;
final boolean withinVibrationThreshold =
timeSinceNotification < mDozeParameters.getPickupVibrationThreshold();
DozeLog.tracePickupPulse(mContext, withinVibrationThreshold);
DozeLog.tracePickupWakeUp(mContext, withinVibrationThreshold);
}
}

View File

@@ -45,12 +45,12 @@ public class DozeConfigurationUtil {
boolean[] doneHolder = new boolean[1];
AmbientDisplayConfiguration config = mock(AmbientDisplayConfiguration.class,
noDefaultAnswer(doneHolder));
when(config.pulseOnDoubleTapEnabled(anyInt())).thenReturn(false);
when(config.pulseOnPickupEnabled(anyInt())).thenReturn(false);
when(config.doubleTapGestureEnabled(anyInt())).thenReturn(false);
when(config.pickupGestureEnabled(anyInt())).thenReturn(false);
when(config.pulseOnNotificationEnabled(anyInt())).thenReturn(true);
when(config.doubleTapSensorType()).thenReturn(null);
when(config.pulseOnPickupAvailable()).thenReturn(false);
when(config.dozePickupSensorAvailable()).thenReturn(false);
doneHolder[0] = true;
return config;

View File

@@ -50,7 +50,6 @@ import android.provider.Settings;
import android.service.dreams.DreamManagerInternal;
import android.service.dreams.DreamService;
import android.service.dreams.IDreamManager;
import android.text.TextUtils;
import android.util.Slog;
import android.view.Display;
@@ -124,7 +123,7 @@ public final class DreamManagerService extends SystemService {
}
}, new IntentFilter(Intent.ACTION_USER_SWITCHED), null, mHandler);
mContext.getContentResolver().registerContentObserver(
Settings.Secure.getUriFor(Settings.Secure.DOZE_PULSE_ON_DOUBLE_TAP), false,
Settings.Secure.getUriFor(Settings.Secure.DOZE_DOUBLE_TAP_GESTURE), false,
mDozeEnabledObserver, UserHandle.USER_ALL);
writePulseGestureEnabled();
}

View File

@@ -574,13 +574,13 @@ public class UserRestrictionsUtils {
Settings.Secure.DOZE_ALWAYS_ON, 0, userId);
android.provider.Settings.Secure.putIntForUser(
context.getContentResolver(),
Settings.Secure.DOZE_PULSE_ON_PICK_UP, 0, userId);
Settings.Secure.DOZE_PICK_UP_GESTURE, 0, userId);
android.provider.Settings.Secure.putIntForUser(
context.getContentResolver(),
Settings.Secure.DOZE_PULSE_ON_LONG_PRESS, 0, userId);
android.provider.Settings.Secure.putIntForUser(
context.getContentResolver(),
Settings.Secure.DOZE_PULSE_ON_DOUBLE_TAP, 0, userId);
Settings.Secure.DOZE_DOUBLE_TAP_GESTURE, 0, userId);
}
break;
case UserManager.DISALLOW_CONFIG_LOCATION:
@@ -684,9 +684,9 @@ public class UserRestrictionsUtils {
case android.provider.Settings.Secure.DOZE_ENABLED:
case android.provider.Settings.Secure.DOZE_ALWAYS_ON:
case android.provider.Settings.Secure.DOZE_PULSE_ON_PICK_UP:
case android.provider.Settings.Secure.DOZE_PICK_UP_GESTURE:
case android.provider.Settings.Secure.DOZE_PULSE_ON_LONG_PRESS:
case android.provider.Settings.Secure.DOZE_PULSE_ON_DOUBLE_TAP:
case android.provider.Settings.Secure.DOZE_DOUBLE_TAP_GESTURE:
if ("0".equals(value)) {
return false;
}