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

Commit cf5a9530 authored by Jason Monk's avatar Jason Monk
Browse files

Fix crash from USER_PRESENT broadcast in sysui

Since sending the USER_PRESENT broadcast too early in the boot
process can result in a SecurityException, don't do auto-unlock
until after the boot has completed.

Bug: 17464800
Change-Id: Iee3d0b9723ed38abddf0bdde009f95331881008b
parent 2911b204
Loading
Loading
Loading
Loading
+16 −2
Original line number Original line Diff line number Diff line
@@ -170,6 +170,8 @@ public class KeyguardViewMediator extends SystemUI {
    private boolean mSwitchingUser;
    private boolean mSwitchingUser;


    private boolean mSystemReady;
    private boolean mSystemReady;
    private boolean mBootCompleted;
    private boolean mBootSendUserPresent;


    // Whether the next call to playSounds() should be skipped.  Defaults to
    // Whether the next call to playSounds() should be skipped.  Defaults to
    // true because the first lock (on boot) should be silent.
    // true because the first lock (on boot) should be silent.
@@ -1146,8 +1148,14 @@ public class KeyguardViewMediator extends SystemUI {
    }
    }


    private void sendUserPresentBroadcast() {
    private void sendUserPresentBroadcast() {
        synchronized (this) {
            if (mBootCompleted) {
                final UserHandle currentUser = new UserHandle(mLockPatternUtils.getCurrentUser());
                final UserHandle currentUser = new UserHandle(mLockPatternUtils.getCurrentUser());
                mContext.sendBroadcastAsUser(USER_PRESENT_INTENT, currentUser);
                mContext.sendBroadcastAsUser(USER_PRESENT_INTENT, currentUser);
            } else {
                mBootSendUserPresent = true;
            }
        }
    }
    }


    /**
    /**
@@ -1407,6 +1415,12 @@ public class KeyguardViewMediator extends SystemUI {


    public void onBootCompleted() {
    public void onBootCompleted() {
        mUpdateMonitor.dispatchBootCompleted();
        mUpdateMonitor.dispatchBootCompleted();
        synchronized (this) {
            mBootCompleted = true;
            if (mBootSendUserPresent) {
                sendUserPresentBroadcast();
            }
        }
    }
    }


    public StatusBarKeyguardViewManager registerStatusBar(PhoneStatusBar phoneStatusBar,
    public StatusBarKeyguardViewManager registerStatusBar(PhoneStatusBar phoneStatusBar,