Separate ambient display triggers
Allows configuring notification and sensor triggers separately. Introduces a helper class that hosts the logic for determining what kinds of triggers a device supports. Bug: 32073185 Change-Id: Ie7e8eb6b895dcc54e6f972e70642c7248b9e223a Test: disable "ambient display", sensor triggers should still work
This commit is contained in:
@@ -209,9 +209,6 @@
|
||||
<!-- Doze: should the significant motion sensor be used as a pulse signal? -->
|
||||
<bool name="doze_pulse_on_significant_motion">false</bool>
|
||||
|
||||
<!-- Doze: should the pickup sensor be used as a pulse signal? -->
|
||||
<bool name="doze_pulse_on_pick_up">false</bool>
|
||||
|
||||
<!-- Doze: check proximity sensor before pulsing? -->
|
||||
<bool name="doze_proximity_check_before_pulse">true</bool>
|
||||
|
||||
@@ -240,9 +237,6 @@
|
||||
-->
|
||||
<string name="doze_pickup_subtype_performs_proximity_check"></string>
|
||||
|
||||
<!-- Type of the double tap sensor. Empty if double tap is not supported. -->
|
||||
<string name="doze_double_tap_sensor_type" translatable="false"></string>
|
||||
|
||||
<!-- Doze: pulse parameter - how long does it take to fade in? -->
|
||||
<integer name="doze_pulse_duration_in">900</integer>
|
||||
|
||||
|
||||
@@ -43,6 +43,7 @@ import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.Display;
|
||||
|
||||
import com.android.internal.hardware.AmbientDisplayConfiguration;
|
||||
import com.android.internal.logging.MetricsLogger;
|
||||
import com.android.internal.logging.MetricsProto.MetricsEvent;
|
||||
import com.android.systemui.SystemUIApplication;
|
||||
@@ -85,6 +86,8 @@ public class DozeService extends DreamService {
|
||||
private boolean mCarMode;
|
||||
private long mNotificationPulseTime;
|
||||
|
||||
private AmbientDisplayConfiguration mConfig;
|
||||
|
||||
public DozeService() {
|
||||
if (DEBUG) Log.d(mTag, "new DozeService()");
|
||||
setDebug(DEBUG);
|
||||
@@ -125,6 +128,7 @@ public class DozeService extends DreamService {
|
||||
setWindowless(true);
|
||||
|
||||
mSensorManager = (SensorManager) mContext.getSystemService(Context.SENSOR_SERVICE);
|
||||
mConfig = new AmbientDisplayConfiguration(mContext);
|
||||
mSensors = new TriggerSensor[] {
|
||||
new TriggerSensor(
|
||||
mSensorManager.getDefaultSensor(Sensor.TYPE_SIGNIFICANT_MOTION),
|
||||
@@ -135,12 +139,12 @@ public class DozeService extends DreamService {
|
||||
mPickupSensor = new TriggerSensor(
|
||||
mSensorManager.getDefaultSensor(Sensor.TYPE_PICK_UP_GESTURE),
|
||||
Settings.Secure.DOZE_PULSE_ON_PICK_UP,
|
||||
mDozeParameters.getPulseOnPickup(), mDozeParameters.getVibrateOnPickup(),
|
||||
mConfig.pulseOnPickupAvailable(), mDozeParameters.getVibrateOnPickup(),
|
||||
DozeLog.PULSE_REASON_SENSOR_PICKUP),
|
||||
new TriggerSensor(
|
||||
findSensorWithType(mDozeParameters.getDoubleTapSensorType()),
|
||||
Settings.Secure.DOZE_PULSE_ON_DOUBLE_TAP,
|
||||
mDozeParameters.getPulseOnPickup(), mDozeParameters.getVibrateOnPickup(),
|
||||
findSensorWithType(mConfig.doubleTapSensorType()),
|
||||
Settings.Secure.DOZE_PULSE_ON_DOUBLE_TAP, true,
|
||||
mDozeParameters.getVibrateOnPickup(),
|
||||
DozeLog.PULSE_REASON_SENSOR_DOUBLE_TAP)
|
||||
};
|
||||
mPowerManager = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
|
||||
@@ -359,7 +363,7 @@ public class DozeService extends DreamService {
|
||||
|
||||
private void requestNotificationPulse() {
|
||||
if (DEBUG) Log.d(mTag, "requestNotificationPulse");
|
||||
if (!mDozeParameters.getPulseOnNotifications()) return;
|
||||
if (!mConfig.pulseOnNotificationEnabled(UserHandle.USER_CURRENT)) return;
|
||||
mNotificationPulseTime = SystemClock.elapsedRealtime();
|
||||
requestPulse(DozeLog.PULSE_REASON_NOTIFICATION);
|
||||
}
|
||||
|
||||
@@ -18,11 +18,13 @@ package com.android.systemui.statusbar.phone;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.SystemProperties;
|
||||
import android.os.UserHandle;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.util.MathUtils;
|
||||
import android.util.SparseBooleanArray;
|
||||
|
||||
import com.android.internal.hardware.AmbientDisplayConfiguration;
|
||||
import com.android.systemui.R;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
@@ -31,9 +33,6 @@ import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class DozeParameters {
|
||||
private static final String TAG = "DozeParameters";
|
||||
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
|
||||
|
||||
private static final int MAX_DURATION = 60 * 1000;
|
||||
|
||||
private final Context mContext;
|
||||
@@ -55,10 +54,8 @@ public class DozeParameters {
|
||||
pw.print(" getPulseOutDuration(): "); pw.println(getPulseOutDuration());
|
||||
pw.print(" getPulseOnSigMotion(): "); pw.println(getPulseOnSigMotion());
|
||||
pw.print(" getVibrateOnSigMotion(): "); pw.println(getVibrateOnSigMotion());
|
||||
pw.print(" getPulseOnPickup(): "); pw.println(getPulseOnPickup());
|
||||
pw.print(" getVibrateOnPickup(): "); pw.println(getVibrateOnPickup());
|
||||
pw.print(" getProxCheckBeforePulse(): "); pw.println(getProxCheckBeforePulse());
|
||||
pw.print(" getPulseOnNotifications(): "); pw.println(getPulseOnNotifications());
|
||||
pw.print(" getPickupVibrationThreshold(): "); pw.println(getPickupVibrationThreshold());
|
||||
pw.print(" getPickupSubtypePerformsProxCheck(): ");pw.println(
|
||||
dumpPickupSubtypePerformsProxCheck());
|
||||
@@ -106,26 +103,14 @@ public class DozeParameters {
|
||||
return SystemProperties.getBoolean("doze.vibrate.sigmotion", false);
|
||||
}
|
||||
|
||||
public boolean getPulseOnPickup() {
|
||||
return getBoolean("doze.pulse.pickup", R.bool.doze_pulse_on_pick_up);
|
||||
}
|
||||
|
||||
public boolean getVibrateOnPickup() {
|
||||
return SystemProperties.getBoolean("doze.vibrate.pickup", false);
|
||||
}
|
||||
|
||||
public String getDoubleTapSensorType() {
|
||||
return mContext.getString(R.string.doze_double_tap_sensor_type);
|
||||
}
|
||||
|
||||
public boolean getProxCheckBeforePulse() {
|
||||
return getBoolean("doze.pulse.proxcheck", R.bool.doze_proximity_check_before_pulse);
|
||||
}
|
||||
|
||||
public boolean getPulseOnNotifications() {
|
||||
return getBoolean("doze.pulse.notifications", R.bool.doze_pulse_on_notifications);
|
||||
}
|
||||
|
||||
public int getPickupVibrationThreshold() {
|
||||
return getInt("doze.pickup.vibration.threshold", R.integer.doze_pickup_vibration_threshold);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user