Merge "AOD: Use double tap coordinates to trigger Ambient Indication" into oc-dr1-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
2402522553
@@ -262,6 +262,9 @@
|
|||||||
<!-- Doze: alpha to apply to small icons when dozing -->
|
<!-- Doze: alpha to apply to small icons when dozing -->
|
||||||
<integer name="doze_small_icon_alpha">222</integer><!-- 87% of 0xff -->
|
<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. -->
|
<!-- Hotspot tile: number of days to show after feature is used. -->
|
||||||
<integer name="days_to_show_hotspot_tile">30</integer>
|
<integer name="days_to_show_hotspot_tile">30</integer>
|
||||||
|
|
||||||
|
|||||||
@@ -38,6 +38,8 @@ public interface DozeHost {
|
|||||||
|
|
||||||
void setAnimateWakeup(boolean animateWakeup);
|
void setAnimateWakeup(boolean animateWakeup);
|
||||||
|
|
||||||
|
void onDoubleTap(float x, float y);
|
||||||
|
|
||||||
interface Callback {
|
interface Callback {
|
||||||
default void onNotificationHeadsUp() {}
|
default void onNotificationHeadsUp() {}
|
||||||
default void onPowerSaveChanged(boolean active) {}
|
default void onPowerSaveChanged(boolean active) {}
|
||||||
|
|||||||
@@ -81,17 +81,18 @@ public class DozeSensors {
|
|||||||
mSensorManager.getDefaultSensor(Sensor.TYPE_SIGNIFICANT_MOTION),
|
mSensorManager.getDefaultSensor(Sensor.TYPE_SIGNIFICANT_MOTION),
|
||||||
null /* setting */,
|
null /* setting */,
|
||||||
dozeParameters.getPulseOnSigMotion(),
|
dozeParameters.getPulseOnSigMotion(),
|
||||||
DozeLog.PULSE_REASON_SENSOR_SIGMOTION),
|
DozeLog.PULSE_REASON_SENSOR_SIGMOTION, false /* touchCoords */),
|
||||||
mPickupSensor = new TriggerSensor(
|
mPickupSensor = new TriggerSensor(
|
||||||
mSensorManager.getDefaultSensor(Sensor.TYPE_PICK_UP_GESTURE),
|
mSensorManager.getDefaultSensor(Sensor.TYPE_PICK_UP_GESTURE),
|
||||||
Settings.Secure.DOZE_PULSE_ON_PICK_UP,
|
Settings.Secure.DOZE_PULSE_ON_PICK_UP,
|
||||||
config.pulseOnPickupAvailable(),
|
config.pulseOnPickupAvailable(),
|
||||||
DozeLog.PULSE_REASON_SENSOR_PICKUP),
|
DozeLog.PULSE_REASON_SENSOR_PICKUP, false /* touchCoords */),
|
||||||
new TriggerSensor(
|
new TriggerSensor(
|
||||||
findSensorWithType(config.doubleTapSensorType()),
|
findSensorWithType(config.doubleTapSensorType()),
|
||||||
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())
|
||||||
};
|
};
|
||||||
|
|
||||||
mProxSensor = new ProxSensor();
|
mProxSensor = new ProxSensor();
|
||||||
@@ -207,16 +208,19 @@ public class DozeSensors {
|
|||||||
final boolean mConfigured;
|
final boolean mConfigured;
|
||||||
final int mPulseReason;
|
final int mPulseReason;
|
||||||
final String mSetting;
|
final String mSetting;
|
||||||
|
final boolean mReportsTouchCoordinates;
|
||||||
|
|
||||||
private boolean mRequested;
|
private boolean mRequested;
|
||||||
private boolean mRegistered;
|
private boolean mRegistered;
|
||||||
private boolean mDisabled;
|
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;
|
mSensor = sensor;
|
||||||
mSetting = setting;
|
mSetting = setting;
|
||||||
mConfigured = configured;
|
mConfigured = configured;
|
||||||
mPulseReason = pulseReason;
|
mPulseReason = pulseReason;
|
||||||
|
mReportsTouchCoordinates = reportsTouchCoordinates;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setListening(boolean listen) {
|
public void setListening(boolean listen) {
|
||||||
@@ -276,7 +280,13 @@ public class DozeSensors {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mRegistered = false;
|
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
|
updateListener(); // reregister, this sensor only fires once
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
@@ -309,7 +319,12 @@ public class DozeSensors {
|
|||||||
* Called when a sensor requests a pulse
|
* Called when a sensor requests a pulse
|
||||||
* @param pulseReason Requesting sensor, e.g. {@link DozeLog#PULSE_REASON_SENSOR_PICKUP}
|
* @param pulseReason Requesting sensor, e.g. {@link DozeLog#PULSE_REASON_SENSOR_PICKUP}
|
||||||
* @param sensorPerformedProxCheck true if the sensor already checked for FAR proximity.
|
* @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 */);
|
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 isDoubleTap = pulseReason == DozeLog.PULSE_REASON_SENSOR_DOUBLE_TAP;
|
||||||
boolean isPickup = pulseReason == DozeLog.PULSE_REASON_SENSOR_PICKUP;
|
boolean isPickup = pulseReason == DozeLog.PULSE_REASON_SENSOR_PICKUP;
|
||||||
|
|
||||||
if (mConfig.alwaysOnEnabled(UserHandle.USER_CURRENT)) {
|
if (mConfig.alwaysOnEnabled(UserHandle.USER_CURRENT)) {
|
||||||
if (isDoubleTap) {
|
if (isDoubleTap) {
|
||||||
|
mDozeHost.onDoubleTap(screenX, screenY);
|
||||||
mMachine.wakeUp();
|
mMachine.wakeUp();
|
||||||
} else {
|
} else {
|
||||||
mDozeHost.extendPulse();
|
mDozeHost.extendPulse();
|
||||||
|
|||||||
@@ -157,6 +157,10 @@ public class DozeParameters {
|
|||||||
return 2 * getPulseVisibleDuration();
|
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
|
* 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_TRANSPARENT;
|
||||||
import static com.android.systemui.statusbar.phone.BarTransitions.MODE_WARNING;
|
import static com.android.systemui.statusbar.phone.BarTransitions.MODE_WARNING;
|
||||||
|
|
||||||
import android.R.style;
|
|
||||||
import android.animation.Animator;
|
import android.animation.Animator;
|
||||||
import android.animation.AnimatorListenerAdapter;
|
import android.animation.AnimatorListenerAdapter;
|
||||||
import android.annotation.NonNull;
|
import android.annotation.NonNull;
|
||||||
@@ -5325,6 +5324,37 @@ public class StatusBar extends SystemUI implements DemoMode,
|
|||||||
mAnimateWakeup = animateWakeup;
|
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() {
|
private boolean shouldAnimateWakeup() {
|
||||||
return mAnimateWakeup;
|
return mAnimateWakeup;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ class DozeHostFake implements DozeHost {
|
|||||||
boolean pulseExtended;
|
boolean pulseExtended;
|
||||||
boolean animateWakeup;
|
boolean animateWakeup;
|
||||||
boolean dozing;
|
boolean dozing;
|
||||||
|
float doubleTapX;
|
||||||
|
float doubleTapY;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addCallback(@NonNull Callback callback) {
|
public void addCallback(@NonNull Callback callback) {
|
||||||
@@ -88,4 +90,10 @@ class DozeHostFake implements DozeHost {
|
|||||||
public void setAnimateWakeup(boolean animateWakeup) {
|
public void setAnimateWakeup(boolean animateWakeup) {
|
||||||
this.animateWakeup = animateWakeup;
|
this.animateWakeup = animateWakeup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDoubleTap(float x, float y) {
|
||||||
|
doubleTapX = y;
|
||||||
|
doubleTapY = y;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user