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

Commit 748a0ebf authored by Matthew Williams's avatar Matthew Williams Committed by Android Git Automerger
Browse files

am 00768c4d: Merge "JobScheduler blocking main thread." into lmp-preview-dev

* commit '00768c4dc67aed2f156184e9544b869cb80cdd50':
  JobScheduler blocking main thread.
parents bd2d97f2 78b96543
Loading
Loading
Loading
Loading
+1 −2
Original line number Original line Diff line number Diff line
@@ -481,11 +481,10 @@ public class JobServiceContext extends IJobCallback.Stub implements ServiceConne
         */
         */
        private void closeAndCleanupJobH(boolean reschedule) {
        private void closeAndCleanupJobH(boolean reschedule) {
            removeMessages(MSG_TIMEOUT);
            removeMessages(MSG_TIMEOUT);
            mCompletedListener.onJobCompleted(mRunningJob, reschedule);
            synchronized (mLock) {
            synchronized (mLock) {
                mWakeLock.release();
                mWakeLock.release();
                mContext.unbindService(JobServiceContext.this);
                mContext.unbindService(JobServiceContext.this);
                mCompletedListener.onJobCompleted(mRunningJob, reschedule);

                mWakeLock = null;
                mWakeLock = null;
                mRunningJob = null;
                mRunningJob = null;
                mParams = null;
                mParams = null;
+10 −4
Original line number Original line Diff line number Diff line
@@ -262,16 +262,23 @@ public class JobStore {
        @Override
        @Override
        public void run() {
        public void run() {
            final long startElapsed = SystemClock.elapsedRealtime();
            final long startElapsed = SystemClock.elapsedRealtime();
            List<JobStatus> mStoreCopy = new ArrayList<JobStatus>();
            synchronized (JobStore.this) {
            synchronized (JobStore.this) {
                writeJobsMapImpl();
                // Copy over the jobs so we can release the lock before writing.
                for (JobStatus jobStatus : mJobSet) {
                    JobStatus copy = new JobStatus(jobStatus.getJob(), jobStatus.getUid(),
                            jobStatus.getEarliestRunTime(), jobStatus.getLatestRunTimeElapsed());
                    mStoreCopy.add(copy);
                }
                }
            }
            writeJobsMapImpl(mStoreCopy);
            if (JobSchedulerService.DEBUG) {
            if (JobSchedulerService.DEBUG) {
                Slog.v(TAG, "Finished writing, took " + (SystemClock.elapsedRealtime()
                Slog.v(TAG, "Finished writing, took " + (SystemClock.elapsedRealtime()
                        - startElapsed) + "ms");
                        - startElapsed) + "ms");
            }
            }
        }
        }


        private void writeJobsMapImpl() {
        private void writeJobsMapImpl(List<JobStatus> jobList) {
            try {
            try {
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                XmlSerializer out = new FastXmlSerializer();
                XmlSerializer out = new FastXmlSerializer();
@@ -281,8 +288,7 @@ public class JobStore {


                out.startTag(null, "job-info");
                out.startTag(null, "job-info");
                out.attribute(null, "version", Integer.toString(JOBS_FILE_VERSION));
                out.attribute(null, "version", Integer.toString(JOBS_FILE_VERSION));
                for (int i = 0; i < mJobSet.size(); i++) {
                for (JobStatus jobStatus : jobList) {
                    final JobStatus jobStatus = mJobSet.valueAt(i);
                    if (DEBUG) {
                    if (DEBUG) {
                        Slog.d(TAG, "Saving job " + jobStatus.getJobId());
                        Slog.d(TAG, "Saving job " + jobStatus.getJobId());
                    }
                    }