Skip to content

Commit d2b82f7

Browse files
author
Jim Miller
committed
Fix wrong pattern count in keyguard pattern security view.
This fixes a bug introduced in I085c5ec8 where keyguard attempts to emulate slippery windows with views. In order to do so, the code was overloading dispatchTouchEvent(). It would allow the super (a ViewGroup) to dispatch the events and then would dispatch them itself to sub views. In the case where an event overlaps an actual child view, it would result in 2 copies of the event per window layer (there are 2). This results in 2 events per layer for the top two views in the hierarchy. So each actual pattern attempt would count as 4 attempts to the system. The solution is to overload onTouchEvent() at each level in the view hierarchy, which means that we ignore events that were already handled by a child window of the parent. This change also disables slippery windows for keyguard because it causes vertical patterns to be ignored. Fixes bug 7191277 Change-Id: I4df217f2bf382134d93113b8d55b0d71e0e23677
1 parent 1e5aeec commit d2b82f7

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ public KeyguardHostView(Context context, AttributeSet attrs) {
109109
}
110110

111111
@Override
112-
public boolean dispatchTouchEvent(MotionEvent ev) {
113-
boolean result = super.dispatchTouchEvent(ev);
112+
public boolean onTouchEvent(MotionEvent ev) {
113+
boolean result = super.onTouchEvent(ev);
114114
mTempRect.set(0, 0, 0, 0);
115115
offsetRectIntoDescendantCoords(mSecurityViewContainer, mTempRect);
116116
ev.offsetLocation(mTempRect.left, mTempRect.top);

policy/src/com/android/internal/policy/impl/keyguard/KeyguardPatternView.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,8 @@ private void updateFooter(FooterMode mode) {
157157
}
158158

159159
@Override
160-
public boolean dispatchTouchEvent(MotionEvent ev) {
161-
boolean result = super.dispatchTouchEvent(ev);
160+
public boolean onTouchEvent(MotionEvent ev) {
161+
boolean result = super.onTouchEvent(ev);
162162
// as long as the user is entering a pattern (i.e sending a touch event that was handled
163163
// by this screen), keep poking the wake lock so that the screen will stay on.
164164
final long elapsed = SystemClock.elapsedRealtime() - mLastPokeTime;
@@ -237,10 +237,11 @@ public void onPatternCellAdded(List<LockPatternView.Cell> pattern) {
237237

238238
public void onPatternDetected(List<LockPatternView.Cell> pattern) {
239239
if (mLockPatternUtils.checkPattern(pattern)) {
240+
mCallback.reportSuccessfulUnlockAttempt();
240241
mLockPatternView.setDisplayMode(LockPatternView.DisplayMode.Correct);
241-
mCallback.dismiss(true); // keyguardDone(true)
242242
KeyStore.getInstance().password(LockPatternUtils.patternToString(pattern));
243243
mTotalFailedPatternAttempts = 0;
244+
mCallback.dismiss(true);
244245
} else {
245246
if (pattern.size() > MIN_PATTERN_BEFORE_POKE_WAKELOCK) {
246247
mCallback.userActivity(UNLOCK_PATTERN_WAKE_INTERVAL_MS);

policy/src/com/android/internal/policy/impl/keyguard/KeyguardSecurityViewFlipper.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ public KeyguardSecurityViewFlipper(Context context, AttributeSet attr) {
4040
}
4141

4242
@Override
43-
public boolean dispatchTouchEvent(MotionEvent ev) {
44-
boolean result = super.dispatchTouchEvent(ev);
43+
public boolean onTouchEvent(MotionEvent ev) {
44+
boolean result = super.onTouchEvent(ev);
4545
mTempRect.set(0, 0, 0, 0);
4646
for (int i = 0; i < getChildCount(); i++) {
4747
View child = getChildAt(i);

policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewManager.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,7 @@ private void maybeCreateKeyguardLocked(boolean enableScreenRotation) {
131131
mKeyguardHost = new ViewManagerHost(mContext);
132132

133133
int flags = WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN
134-
| WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER
135-
| WindowManager.LayoutParams.FLAG_SLIPPERY;
134+
| WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER;
136135

137136
if (!mNeedsInput) {
138137
flags |= WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM;

0 commit comments

Comments
 (0)