public interface LocalPowerManager {
public static final int OTHER_EVENT = 0;
public static final int CHEEK_EVENT = 1;
- public static final int TOUCH_EVENT = 2;
- public static final int BUTTON_EVENT = 3; // Button and trackball events.
+ public static final int TOUCH_EVENT = 2; // touch events are TOUCH for 300ms, and then either
+ // up events or LONG_TOUCH events.
+ public static final int LONG_TOUCH_EVENT = 3;
+ public static final int TOUCH_UP_EVENT = 4;
+ public static final int BUTTON_EVENT = 5; // Button and trackball events.
public static final int POKE_LOCK_IGNORE_CHEEK_EVENTS = 0x1;
public static final int POKE_LOCK_SHORT_TIMEOUT = 0x2;
public static final int POKE_LOCK_MEDIUM_TIMEOUT = 0x4;
+ public static final int POKE_LOCK_IGNORE_TOUCH_AND_CHEEK_EVENTS = 0x8;
public static final int POKE_LOCK_TIMEOUT_MASK = 0x6;
pw.println(" poke lock '" + p.tag + "':"
+ ((p.pokey & POKE_LOCK_IGNORE_CHEEK_EVENTS) != 0
? " POKE_LOCK_IGNORE_CHEEK_EVENTS" : "")
+ + ((p.pokey & POKE_LOCK_IGNORE_TOUCH_AND_CHEEK_EVENTS) != 0
+ ? " POKE_LOCK_IGNORE_TOUCH_AND_CHEEK_EVENTS" : "")
+ ((p.pokey & POKE_LOCK_SHORT_TIMEOUT) != 0
? " POKE_LOCK_SHORT_TIMEOUT" : "")
+ ((p.pokey & POKE_LOCK_MEDIUM_TIMEOUT) != 0
//mContext.enforceCallingOrSelfPermission(android.Manifest.permission.DEVICE_POWER, null);
if (((mPokey & POKE_LOCK_IGNORE_CHEEK_EVENTS) != 0)
- && !((eventType == OTHER_EVENT) || (eventType == BUTTON_EVENT))) {
+ && (eventType == CHEEK_EVENT || eventType == TOUCH_EVENT)) {
if (false) {
- Log.d(TAG, "dropping mPokey=0x" + Integer.toHexString(mPokey));
+ Log.d(TAG, "dropping cheek or short event mPokey=0x" + Integer.toHexString(mPokey));
}
return;
}
+ if (((mPokey & POKE_LOCK_IGNORE_TOUCH_AND_CHEEK_EVENTS) != 0)
+ && (eventType == TOUCH_EVENT || eventType == TOUCH_UP_EVENT
+ || eventType == LONG_TOUCH_EVENT || eventType == CHEEK_EVENT)) {
+ if (false) {
+ Log.d(TAG, "dropping touch mPokey=0x" + Integer.toHexString(mPokey));
+ }
+ return;
+ }
+
+
if (false) {
if (((mPokey & POKE_LOCK_IGNORE_CHEEK_EVENTS) != 0)) {
Log.d(TAG, "userActivity !!!");//, new RuntimeException());
import static android.os.LocalPowerManager.CHEEK_EVENT;
import static android.os.LocalPowerManager.OTHER_EVENT;
import static android.os.LocalPowerManager.TOUCH_EVENT;
+import static android.os.LocalPowerManager.LONG_TOUCH_EVENT;
+import static android.os.LocalPowerManager.TOUCH_UP_EVENT;
import static android.view.WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW;
import static android.view.WindowManager.LayoutParams.FIRST_SUB_WINDOW;
import static android.view.WindowManager.LayoutParams.FLAG_BLUR_BEHIND;
private static final float CHEEK_THRESHOLD = 0.6f;
private int mEventState = EVENT_NONE;
private float mEventSize;
+
private int eventType(MotionEvent ev) {
float size = ev.getSize();
switch (ev.getAction()) {
return (mEventSize > CHEEK_THRESHOLD) ? CHEEK_EVENT : TOUCH_EVENT;
case MotionEvent.ACTION_UP:
if (size > mEventSize) mEventSize = size;
- return (mEventSize > CHEEK_THRESHOLD) ? CHEEK_EVENT : OTHER_EVENT;
+ return (mEventSize > CHEEK_THRESHOLD) ? CHEEK_EVENT : TOUCH_UP_EVENT;
case MotionEvent.ACTION_MOVE:
final int N = ev.getHistorySize();
if (size > mEventSize) mEventSize = size;
if (ev.getEventTime() < ev.getDownTime() + EVENT_IGNORE_DURATION) {
return TOUCH_EVENT;
} else {
- return OTHER_EVENT;
+ return LONG_TOUCH_EVENT;
}
default:
// not good
return mTests;
}
private Test[] mTests = new Test[] {
- new Test("Touch events don't poke") {
+ new Test("Cheek events don't poke") {
public void run() {
mPokeState |= LocalPowerManager.POKE_LOCK_IGNORE_CHEEK_EVENTS;
try {
}
}
},
- new Test("Touch events poke") {
+ new Test("Cheek events poke") {
public void run() {
mPokeState &= ~LocalPowerManager.POKE_LOCK_IGNORE_CHEEK_EVENTS;
try {
}
}
},
+ new Test("Touch and Cheek events don't poke") {
+ public void run() {
+ mPokeState |= LocalPowerManager.POKE_LOCK_IGNORE_TOUCH_AND_CHEEK_EVENTS;
+ try {
+ mPowerManager.setPokeLock(mPokeState, mPokeToken, TAG);
+ } catch (RemoteException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ },
+ new Test("Touch and Cheek events poke") {
+ public void run() {
+ mPokeState &= ~LocalPowerManager.POKE_LOCK_IGNORE_TOUCH_AND_CHEEK_EVENTS;
+ try {
+ mPowerManager.setPokeLock(mPokeState, mPokeToken, TAG);
+ } catch (RemoteException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ },
new Test("Short timeout") {
public void run() {
mPokeState &= ~LocalPowerManager.POKE_LOCK_TIMEOUT_MASK;