SystemService post-completed user event: jobs

Use the new onUser completed event for JobSchedulerService.

This delays handling aspects of the user starting/unlock events
(which are important, but not urgent) until a little later.
In particular, it delays the intial job scheduling until a little after
the user has started, instead of immediately.

Test: manual
Bug: 197344658
Change-Id: I78ea7f7822ee466ce34dfc0b9f602fa1a4ceb7c3
This commit is contained in:
Adam Bookatz
2022-01-20 13:34:16 -08:00
parent 12091ce823
commit d6e625de2e

View File

@@ -1209,18 +1209,16 @@ public class JobSchedulerService extends com.android.server.SystemService
synchronized (mLock) {
mStartedUsers = ArrayUtils.appendInt(mStartedUsers, user.getUserIdentifier());
}
// The user is starting but credential encrypted storage is still locked.
// Only direct-boot-aware jobs can safely run.
// Let's kick off any eligible jobs for this user.
mHandler.obtainMessage(MSG_CHECK_JOB).sendToTarget();
}
/** Start jobs after user is available, delayed by a few seconds since non-urgent. */
@Override
public void onUserUnlocked(@NonNull TargetUser user) {
// The user is fully unlocked and credential encrypted storage is now decrypted.
// Direct-boot-UNaware jobs can now safely run.
// Let's kick off any outstanding jobs for this user.
mHandler.obtainMessage(MSG_CHECK_JOB).sendToTarget();
public void onUserCompletedEvent(@NonNull TargetUser user, UserCompletedEventType eventType) {
if (eventType.includesOnUserStarting() || eventType.includesOnUserUnlocked()) {
// onUserStarting: direct-boot-aware jobs can safely run
// onUserUnlocked: direct-boot-UNaware jobs can safely run.
mHandler.obtainMessage(MSG_CHECK_JOB).sendToTarget();
}
}
@Override