Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1d587e3d authored by Jim Miller's avatar Jim Miller
Browse files

Manual integration of I32a7b5 from froyo

Fix 2662816: Move UI update from async callback to ui thread.

This fixes a bug where the view hierarchy in AccountUnlockScreen was being
modified by the async callback thread from AccountManager.

Change-Id: I5f1b4e04a7e4af68a5705545765f294cdbd0f17b
parent ebad36db
Loading
Loading
Loading
Loading
+32 −32
Original line number Diff line number Diff line
@@ -174,7 +174,10 @@ public class AccountUnlockScreen extends RelativeLayout implements KeyguardScree
        }
    }

    private void onCheckPasswordResult(boolean success) {
    private void postOnCheckPasswordResult(final boolean success) {
        // ensure this runs on UI thread
        mLogin.post(new Runnable() {
            public void run() {
                if (success) {
                    // clear out forgotten password
                    mLockPatternUtils.setPermanentlyLocked(false);
@@ -197,6 +200,8 @@ public class AccountUnlockScreen extends RelativeLayout implements KeyguardScree
                    mCallback.reportFailedUnlockAttempt();
                }
            }
        });
    }

    @Override
    public boolean dispatchKeyEvent(KeyEvent event) {
@@ -270,7 +275,7 @@ public class AccountUnlockScreen extends RelativeLayout implements KeyguardScree
        final String password = mPassword.getText().toString();
        Account account = findIntendedAccount(login);
        if (account == null) {
            onCheckPasswordResult(false);
            postOnCheckPasswordResult(false);
            return;
        }
        getProgressDialog().show();
@@ -283,18 +288,13 @@ public class AccountUnlockScreen extends RelativeLayout implements KeyguardScree
                    mCallback.pokeWakelock(AWAKE_POKE_MILLIS);
                    final Bundle result = future.getResult();
                    final boolean verified = result.getBoolean(AccountManager.KEY_BOOLEAN_RESULT);
                    // ensure on UI thread
                    mLogin.post(new Runnable() {
                        public void run() {
                            onCheckPasswordResult(verified);
                        }
                    });
                    postOnCheckPasswordResult(verified);
                } catch (OperationCanceledException e) {
                    onCheckPasswordResult(false);
                    postOnCheckPasswordResult(false);
                } catch (IOException e) {
                    onCheckPasswordResult(false);
                    postOnCheckPasswordResult(false);
                } catch (AuthenticatorException e) {
                    onCheckPasswordResult(false);
                    postOnCheckPasswordResult(false);
                } finally {
                    mLogin.post(new Runnable() {
                        public void run() {