Automated import from //branches/master/...@141000,141000
This commit is contained in:
committed by
The Android Open Source Project
parent
df940486a4
commit
36197e77c3
@@ -20,12 +20,16 @@ package android.os;
|
||||
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;
|
||||
|
||||
|
||||
@@ -843,6 +843,8 @@ class PowerManagerService extends IPowerManager.Stub implements LocalPowerManage
|
||||
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 @@ class PowerManagerService extends IPowerManager.Stub implements LocalPowerManage
|
||||
//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());
|
||||
|
||||
@@ -19,6 +19,8 @@ package com.android.server;
|
||||
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 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo
|
||||
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 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo
|
||||
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 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo
|
||||
if (ev.getEventTime() < ev.getDownTime() + EVENT_IGNORE_DURATION) {
|
||||
return TOUCH_EVENT;
|
||||
} else {
|
||||
return OTHER_EVENT;
|
||||
return LONG_TOUCH_EVENT;
|
||||
}
|
||||
default:
|
||||
// not good
|
||||
|
||||
@@ -62,7 +62,7 @@ public class PowerTest extends TestActivity
|
||||
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 @@ public class PowerTest extends TestActivity
|
||||
}
|
||||
}
|
||||
},
|
||||
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 @@ public class PowerTest extends TestActivity
|
||||
}
|
||||
}
|
||||
},
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user