Automated import from //branches/master/...@141000,141000
diff --git a/core/java/android/os/LocalPowerManager.java b/core/java/android/os/LocalPowerManager.java
index 55d7972..9e88f5a 100644
--- a/core/java/android/os/LocalPowerManager.java
+++ b/core/java/android/os/LocalPowerManager.java
@@ -20,12 +20,16 @@
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;
diff --git a/services/java/com/android/server/PowerManagerService.java b/services/java/com/android/server/PowerManagerService.java
index 890c58c..2fac5f7 100644
--- a/services/java/com/android/server/PowerManagerService.java
+++ b/services/java/com/android/server/PowerManagerService.java
@@ -843,6 +843,8 @@
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
@@ -1675,13 +1677,23 @@
//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());
diff --git a/services/java/com/android/server/WindowManagerService.java b/services/java/com/android/server/WindowManagerService.java
index 5623b02..dba245a 100644
--- a/services/java/com/android/server/WindowManagerService.java
+++ b/services/java/com/android/server/WindowManagerService.java
@@ -19,6 +19,8 @@
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;
@@ -3678,6 +3680,7 @@
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()) {
@@ -3686,7 +3689,7 @@
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;
@@ -3699,7 +3702,7 @@
if (ev.getEventTime() < ev.getDownTime() + EVENT_IGNORE_DURATION) {
return TOUCH_EVENT;
} else {
- return OTHER_EVENT;
+ return LONG_TOUCH_EVENT;
}
default:
// not good
diff --git a/tests/StatusBar/src/com/android/statusbartest/PowerTest.java b/tests/StatusBar/src/com/android/statusbartest/PowerTest.java
index f236a4b..f778cab 100644
--- a/tests/StatusBar/src/com/android/statusbartest/PowerTest.java
+++ b/tests/StatusBar/src/com/android/statusbartest/PowerTest.java
@@ -62,7 +62,7 @@
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 {
@@ -72,7 +72,7 @@
}
}
},
- new Test("Touch events poke") {
+ new Test("Cheek events poke") {
public void run() {
mPokeState &= ~LocalPowerManager.POKE_LOCK_IGNORE_CHEEK_EVENTS;
try {
@@ -82,6 +82,26 @@
}
}
},
+ 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;