@@ -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