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

Commit e61cf512 authored by Kweku Adams's avatar Kweku Adams
Browse files

Wait for unlock to start jobs.

We don't tell apps that a user is unlocked until the user is fully
unlocked (not just unlocking) so some apps may think that storage is
still encrypted even when it's not (during user unlocking). Wait until
the user is fully unlocked to run any jobs for a user to avoid potential
problems.

Bug: 162076852
Test: atest frameworks/base/services/tests/servicestests/src/com/android/server/job
Test: atest frameworks/base/services/tests/mockingservicestests/src/com/android/server/job
Test: atest CtsJobSchedulerTestCases
Change-Id: I4c7e2e2e4f86162c59685295417e02eb554c1cb0
parent baba0836
Loading
Loading
Loading
Loading
+3 −7
Original line number Diff line number Diff line
@@ -881,20 +881,16 @@ public class JobSchedulerService extends com.android.server.SystemService
    }

    @Override
    public void onUserStarting(@NonNull TargetUser user) {
    public void onUserUnlocked(@NonNull TargetUser user) {
        synchronized (mLock) {
            // Note that the user has started after its unlocked instead of when the user
            // actually starts because the storage won't be decrypted until unlock.
            mStartedUsers = ArrayUtils.appendInt(mStartedUsers, user.getUserIdentifier());
        }
        // Let's kick any outstanding jobs for this user.
        mHandler.obtainMessage(MSG_CHECK_JOB).sendToTarget();
    }

    @Override
    public void onUserUnlocking(@NonNull TargetUser user) {
        // Let's kick any outstanding jobs for this user.
        mHandler.obtainMessage(MSG_CHECK_JOB).sendToTarget();
    }

    @Override
    public void onUserStopping(@NonNull TargetUser user) {
        synchronized (mLock) {