Merge "AOD: Use double tap coordinates to trigger Ambient Indication" into oc-dr1-dev
am: 2402522553
Change-Id: I22486ede65b6a07683cea4b8f5c48de94ae7a148
This commit is contained in:
@@ -262,6 +262,9 @@
|
||||
<!-- Doze: alpha to apply to small icons when dozing -->
|
||||
<integer name="doze_small_icon_alpha">222</integer><!-- 87% of 0xff -->
|
||||
|
||||
<!-- Doze: whether the double tap sensor reports 2D touch coordinates -->
|
||||
<bool name="doze_double_tap_reports_touch_coordinates">false</bool>
|
||||
|
||||
<!-- Hotspot tile: number of days to show after feature is used. -->
|
||||
<integer name="days_to_show_hotspot_tile">30</integer>
|
||||
|
||||
|
||||
@@ -38,6 +38,8 @@ public interface DozeHost {
|
||||
|
||||
void setAnimateWakeup(boolean animateWakeup);
|
||||
|
||||
void onDoubleTap(float x, float y);
|
||||
|
||||
interface Callback {
|
||||
default void onNotificationHeadsUp() {}
|
||||
default void onPowerSaveChanged(boolean active) {}
|
||||
|
||||
@@ -81,17 +81,18 @@ public class DozeSensors {
|
||||
mSensorManager.getDefaultSensor(Sensor.TYPE_SIGNIFICANT_MOTION),
|
||||
null /* setting */,
|
||||
dozeParameters.getPulseOnSigMotion(),
|
||||
DozeLog.PULSE_REASON_SENSOR_SIGMOTION),
|
||||
DozeLog.PULSE_REASON_SENSOR_SIGMOTION, false /* touchCoords */),
|
||||
mPickupSensor = new TriggerSensor(
|
||||
mSensorManager.getDefaultSensor(Sensor.TYPE_PICK_UP_GESTURE),
|
||||
Settings.Secure.DOZE_PULSE_ON_PICK_UP,
|
||||
config.pulseOnPickupAvailable(),
|
||||
DozeLog.PULSE_REASON_SENSOR_PICKUP),
|
||||
DozeLog.PULSE_REASON_SENSOR_PICKUP, false /* touchCoords */),
|
||||
new TriggerSensor(
|
||||
findSensorWithType(config.doubleTapSensorType()),
|
||||
Settings.Secure.DOZE_PULSE_ON_DOUBLE_TAP,
|
||||
true /* configured */,
|
||||
DozeLog.PULSE_REASON_SENSOR_DOUBLE_TAP)
|
||||
DozeLog.PULSE_REASON_SENSOR_DOUBLE_TAP,
|
||||
dozeParameters.doubleTapReportsTouchCoordinates())
|
||||
};
|
||||
|
||||
mProxSensor = new ProxSensor();
|
||||
@@ -207,16 +208,19 @@ public class DozeSensors {
|
||||
final boolean mConfigured;
|
||||
final int mPulseReason;
|
||||
final String mSetting;
|
||||
final boolean mReportsTouchCoordinates;
|
||||
|
||||
private boolean mRequested;
|
||||
private boolean mRegistered;
|
||||
private boolean mDisabled;
|
||||
|
||||
public TriggerSensor(Sensor sensor, String setting, boolean configured, int pulseReason) {
|
||||
public TriggerSensor(Sensor sensor, String setting, boolean configured, int pulseReason,
|
||||
boolean reportsTouchCoordinates) {
|
||||
mSensor = sensor;
|
||||
mSetting = setting;
|
||||
mConfigured = configured;
|
||||
mPulseReason = pulseReason;
|
||||
mReportsTouchCoordinates = reportsTouchCoordinates;
|
||||
}
|
||||
|
||||
public void setListening(boolean listen) {
|
||||
@@ -276,7 +280,13 @@ public class DozeSensors {
|
||||
}
|
||||
|
||||
mRegistered = false;
|
||||
mCallback.onSensorPulse(mPulseReason, sensorPerformsProxCheck);
|
||||
float screenX = -1;
|
||||
float screenY = -1;
|
||||
if (mReportsTouchCoordinates && event.values.length >= 2) {
|
||||
screenX = event.values[0];
|
||||
screenY = event.values[1];
|
||||
}
|
||||
mCallback.onSensorPulse(mPulseReason, sensorPerformsProxCheck, screenX, screenY);
|
||||
updateListener(); // reregister, this sensor only fires once
|
||||
}));
|
||||
}
|
||||
@@ -309,7 +319,12 @@ public class DozeSensors {
|
||||
* Called when a sensor requests a pulse
|
||||
* @param pulseReason Requesting sensor, e.g. {@link DozeLog#PULSE_REASON_SENSOR_PICKUP}
|
||||
* @param sensorPerformedProxCheck true if the sensor already checked for FAR proximity.
|
||||
* @param screenX the location on the screen where the sensor fired or -1
|
||||
* if the sensor doesn't support reporting screen locations.
|
||||
* @param screenY the location on the screen where the sensor fired or -1
|
||||
* if the sensor doesn't support reporting screen locations.
|
||||
*/
|
||||
void onSensorPulse(int pulseReason, boolean sensorPerformedProxCheck);
|
||||
void onSensorPulse(int pulseReason, boolean sensorPerformedProxCheck,
|
||||
float screenX, float screenY);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,12 +98,14 @@ public class DozeTriggers implements DozeMachine.Part {
|
||||
requestPulse(DozeLog.PULSE_REASON_NOTIFICATION, false /* performedProxCheck */);
|
||||
}
|
||||
|
||||
private void onSensor(int pulseReason, boolean sensorPerformedProxCheck) {
|
||||
private void onSensor(int pulseReason, boolean sensorPerformedProxCheck,
|
||||
float screenX, float screenY) {
|
||||
boolean isDoubleTap = pulseReason == DozeLog.PULSE_REASON_SENSOR_DOUBLE_TAP;
|
||||
boolean isPickup = pulseReason == DozeLog.PULSE_REASON_SENSOR_PICKUP;
|
||||
|
||||
if (mConfig.alwaysOnEnabled(UserHandle.USER_CURRENT)) {
|
||||
if (isDoubleTap) {
|
||||
mDozeHost.onDoubleTap(screenX, screenY);
|
||||
mMachine.wakeUp();
|
||||
} else {
|
||||
mDozeHost.extendPulse();
|
||||
|
||||
@@ -157,6 +157,10 @@ public class DozeParameters {
|
||||
return 2 * getPulseVisibleDuration();
|
||||
}
|
||||
|
||||
public boolean doubleTapReportsTouchCoordinates() {
|
||||
return mContext.getResources().getBoolean(R.bool.doze_double_tap_reports_touch_coordinates);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Parses a spec of the form `1,2,3,!5,*`. The resulting object will match numbers that are
|
||||
|
||||
@@ -32,7 +32,6 @@ import static com.android.systemui.statusbar.phone.BarTransitions.MODE_TRANSLUCE
|
||||
import static com.android.systemui.statusbar.phone.BarTransitions.MODE_TRANSPARENT;
|
||||
import static com.android.systemui.statusbar.phone.BarTransitions.MODE_WARNING;
|
||||
|
||||
import android.R.style;
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
import android.annotation.NonNull;
|
||||
@@ -5325,6 +5324,37 @@ public class StatusBar extends SystemUI implements DemoMode,
|
||||
mAnimateWakeup = animateWakeup;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDoubleTap(float screenX, float screenY) {
|
||||
if (screenX > 0 && screenY > 0 && mAmbientIndicationContainer != null
|
||||
&& mAmbientIndicationContainer.getVisibility() == View.VISIBLE) {
|
||||
mAmbientIndicationContainer.getLocationOnScreen(mTmpInt2);
|
||||
float viewX = screenX - mTmpInt2[0];
|
||||
float viewY = screenY - mTmpInt2[1];
|
||||
if (0 <= viewX && viewX <= mAmbientIndicationContainer.getWidth()
|
||||
&& 0 <= viewY && viewY <= mAmbientIndicationContainer.getHeight()) {
|
||||
dispatchDoubleTap(viewX, viewY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void dispatchDoubleTap(float viewX, float viewY) {
|
||||
dispatchTap(mAmbientIndicationContainer, viewX, viewY);
|
||||
dispatchTap(mAmbientIndicationContainer, viewX, viewY);
|
||||
}
|
||||
|
||||
private void dispatchTap(View view, float x, float y) {
|
||||
long now = SystemClock.elapsedRealtime();
|
||||
dispatchTouchEvent(view, x, y, now, MotionEvent.ACTION_DOWN);
|
||||
dispatchTouchEvent(view, x, y, now, MotionEvent.ACTION_UP);
|
||||
}
|
||||
|
||||
private void dispatchTouchEvent(View view, float x, float y, long now, int action) {
|
||||
MotionEvent ev = MotionEvent.obtain(now, now, action, x, y, 0 /* meta */);
|
||||
view.dispatchTouchEvent(ev);
|
||||
ev.recycle();
|
||||
}
|
||||
|
||||
private boolean shouldAnimateWakeup() {
|
||||
return mAnimateWakeup;
|
||||
}
|
||||
|
||||
@@ -28,6 +28,8 @@ class DozeHostFake implements DozeHost {
|
||||
boolean pulseExtended;
|
||||
boolean animateWakeup;
|
||||
boolean dozing;
|
||||
float doubleTapX;
|
||||
float doubleTapY;
|
||||
|
||||
@Override
|
||||
public void addCallback(@NonNull Callback callback) {
|
||||
@@ -88,4 +90,10 @@ class DozeHostFake implements DozeHost {
|
||||
public void setAnimateWakeup(boolean animateWakeup) {
|
||||
this.animateWakeup = animateWakeup;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDoubleTap(float x, float y) {
|
||||
doubleTapX = y;
|
||||
doubleTapY = y;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user