Skip to content

Commit f0fd172

Browse files
committed
lock out clicks while switching.
Bug: 7416992 Change-Id: Ic0fcf809c4d9bb3515dd1168d427f8b22d5f76b6 Proto-Id: I0ea871fb012feb2e17249e37a9253861f2ef5011
1 parent 47cde77 commit f0fd172

File tree

2 files changed

+43
-27
lines changed

2 files changed

+43
-27
lines changed

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,9 +207,11 @@ public void onAnimationEnd(Animator animation) {
207207

208208
@Override
209209
public void setPressed(boolean pressed) {
210-
super.setPressed(pressed);
211-
mFramed.setPressed(pressed);
212-
mUserImage.invalidate();
210+
if (!pressed || isClickable()) {
211+
super.setPressed(pressed);
212+
mFramed.setPressed(pressed);
213+
mUserImage.invalidate();
214+
}
213215
}
214216

215217
public UserInfo getUserInfo() {

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

Lines changed: 38 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -110,36 +110,50 @@ public boolean onInterceptTouchEvent(MotionEvent event) {
110110
return false;
111111
}
112112

113+
private void setAllClickable(boolean clickable)
114+
{
115+
for(int i = 0; i < mUsersGrid.getChildCount(); i++) {
116+
View v = mUsersGrid.getChildAt(i);
117+
v.setClickable(clickable);
118+
v.setPressed(false);
119+
}
120+
}
121+
113122
@Override
114123
public void onClick(View v) {
115124
if (!(v instanceof KeyguardMultiUserAvatar)) return;
116125
final KeyguardMultiUserAvatar avatar = (KeyguardMultiUserAvatar) v;
117-
if (mActiveUserAvatar == avatar) {
118-
// If they click the currently active user, show the unlock hint
119-
mCallback.showUnlockHint();
120-
return;
121-
} else {
122-
// Reset the previously active user to appear inactive
123-
mCallback.hideSecurityView(FADE_OUT_ANIMATION_DURATION);
124-
mActiveUserAvatar.setActive(false, true, new Runnable() {
125-
@Override
126-
public void run() {
127-
mActiveUserAvatar = avatar;
128-
mActiveUserAvatar.setActive(true, true, new Runnable() {
129-
@Override
130-
public void run() {
131-
if (this.getClass().getName().contains("internal")) {
132-
try {
133-
ActivityManagerNative.getDefault()
134-
.switchUser(avatar.getUserInfo().id);
135-
} catch (RemoteException re) {
136-
Log.e(TAG, "Couldn't switch user " + re);
126+
if (avatar.isClickable()) { // catch race conditions
127+
if (mActiveUserAvatar == avatar) {
128+
// If they click the currently active user, show the unlock hint
129+
mCallback.showUnlockHint();
130+
return;
131+
} else {
132+
// Reset the previously active user to appear inactive
133+
mCallback.hideSecurityView(FADE_OUT_ANIMATION_DURATION);
134+
setAllClickable(false);
135+
mActiveUserAvatar.setActive(false, true, new Runnable() {
136+
@Override
137+
public void run() {
138+
mActiveUserAvatar = avatar;
139+
mActiveUserAvatar.setActive(true, true, new Runnable() {
140+
@Override
141+
public void run() {
142+
if (this.getClass().getName().contains("internal")) {
143+
try {
144+
ActivityManagerNative.getDefault()
145+
.switchUser(avatar.getUserInfo().id);
146+
} catch (RemoteException re) {
147+
Log.e(TAG, "Couldn't switch user " + re);
148+
}
149+
} else {
150+
setAllClickable(true);
137151
}
138152
}
139-
}
140-
});
141-
}
142-
});
153+
});
154+
}
155+
});
156+
}
143157
}
144158
}
145159
}

0 commit comments

Comments
 (0)