Skip to content

Commit c6f2b3b

Browse files
Jeff BrownAndroid (Google) Code Review
authored andcommitted
Merge "Fix policy issues when screen is off. (DO NOT MERGE)" into gingerbread
2 parents 2dda21b + eb9f7a0 commit c6f2b3b

File tree

8 files changed

+256
-257
lines changed

8 files changed

+256
-257
lines changed

core/java/android/view/WindowManagerPolicy.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -544,16 +544,18 @@ public int prepareAddWindowLw(WindowState win,
544544
* Generally, it's best to keep as little as possible in the queue thread
545545
* because it's the most fragile.
546546
* @param whenNanos The event time in uptime nanoseconds.
547+
* @param action The key event action.
548+
* @param flags The key event flags.
547549
* @param keyCode The key code.
548-
* @param down True if the key is down.
550+
* @param scanCode The key's scan code.
549551
* @param policyFlags The policy flags associated with the key.
550552
* @param isScreenOn True if the screen is already on
551553
*
552554
* @return The bitwise or of the {@link #ACTION_PASS_TO_USER},
553555
* {@link #ACTION_POKE_USER_ACTIVITY} and {@link #ACTION_GO_TO_SLEEP} flags.
554556
*/
555-
public int interceptKeyBeforeQueueing(long whenNanos, int keyCode, boolean down, int policyFlags,
556-
boolean isScreenOn);
557+
public int interceptKeyBeforeQueueing(long whenNanos, int action, int flags,
558+
int keyCode, int scanCode, int policyFlags, boolean isScreenOn);
557559

558560
/**
559561
* Called from the input dispatcher thread before a key is dispatched to a window.
@@ -571,14 +573,15 @@ public int interceptKeyBeforeQueueing(long whenNanos, int keyCode, boolean down,
571573
* @param action The key event action.
572574
* @param flags The key event flags.
573575
* @param keyCode The key code.
576+
* @param scanCode The key's scan code.
574577
* @param metaState bit mask of meta keys that are held.
575578
* @param repeatCount Number of times a key down has repeated.
576579
* @param policyFlags The policy flags associated with the key.
577580
* @return Returns true if the policy consumed the event and it should
578581
* not be further dispatched.
579582
*/
580583
public boolean interceptKeyBeforeDispatching(WindowState win, int action, int flags,
581-
int keyCode, int metaState, int repeatCount, int policyFlags);
584+
int keyCode, int scanCode, int metaState, int repeatCount, int policyFlags);
582585

583586
/**
584587
* Called when layout of the windows is about to start.

libs/ui/InputDispatcher.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1405,8 +1405,13 @@ String8 InputDispatcher::getApplicationWindowLabelLocked(const InputApplication*
14051405

14061406
void InputDispatcher::pokeUserActivityLocked(const EventEntry* eventEntry) {
14071407
int32_t eventType = POWER_MANAGER_BUTTON_EVENT;
1408-
if (eventEntry->type == EventEntry::TYPE_MOTION) {
1408+
switch (eventEntry->type) {
1409+
case EventEntry::TYPE_MOTION: {
14091410
const MotionEntry* motionEntry = static_cast<const MotionEntry*>(eventEntry);
1411+
if (motionEntry->action == AMOTION_EVENT_ACTION_CANCEL) {
1412+
return;
1413+
}
1414+
14101415
if (motionEntry->source & AINPUT_SOURCE_CLASS_POINTER) {
14111416
switch (motionEntry->action) {
14121417
case AMOTION_EVENT_ACTION_DOWN:
@@ -1424,6 +1429,15 @@ void InputDispatcher::pokeUserActivityLocked(const EventEntry* eventEntry) {
14241429
break;
14251430
}
14261431
}
1432+
break;
1433+
}
1434+
case EventEntry::TYPE_KEY: {
1435+
const KeyEntry* keyEntry = static_cast<const KeyEntry*>(eventEntry);
1436+
if (keyEntry->flags & AKEY_EVENT_FLAG_CANCELED) {
1437+
return;
1438+
}
1439+
break;
1440+
}
14271441
}
14281442

14291443
CommandEntry* commandEntry = postCommandLocked(

policy/src/com/android/internal/policy/impl/LockScreen.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,12 @@ public void onGrabbedStateChange(View v, int grabbedState) {
333333
mSelector.setRightHintText(mSilentMode ? R.string.lockscreen_sound_on_label
334334
: R.string.lockscreen_sound_off_label);
335335
}
336-
mCallback.pokeWakelock();
336+
// Don't poke the wake lock when returning to a state where the handle is
337+
// not grabbed since that can happen when the system (instead of the user)
338+
// cancels the grab.
339+
if (grabbedState != SlidingTab.OnTriggerListener.NO_HANDLE) {
340+
mCallback.pokeWakelock();
341+
}
337342
}
338343

339344
/**

0 commit comments

Comments
 (0)