Fixes for JobScheduler sourcePackage fields

Source fields now copied as part of copy constructor.
Wakelocks acquired with sourceUid as the worksource.

Change-Id: I93217730c6b1215ea048aa6f54636c5f3215ce8e
This commit is contained in:
Shreyas Basarge
2016-01-20 16:32:20 +00:00
parent a0b16caf88
commit 325956df08
2 changed files with 5 additions and 1 deletions

View File

@@ -289,7 +289,7 @@ public class JobServiceContext extends IJobCallback.Stub implements ServiceConne
final PowerManager pm =
(PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, runningJob.getTag());
mWakeLock.setWorkSource(new WorkSource(runningJob.getUid()));
mWakeLock.setWorkSource(new WorkSource(runningJob.getSourceUid()));
mWakeLock.setReferenceCounted(false);
mWakeLock.acquire();
mCallbackHandler.obtainMessage(MSG_SERVICE_BOUND).sendToTarget();

View File

@@ -92,6 +92,8 @@ public class JobStatus {
/** Copy constructor. */
public JobStatus(JobStatus jobStatus) {
this(jobStatus.getJob(), jobStatus.getUid(), jobStatus.getNumFailures());
this.sourceUserId = jobStatus.sourceUserId;
this.sourcePackageName = jobStatus.sourcePackageName;
this.earliestRunTimeElapsedMillis = jobStatus.getEarliestRunTime();
this.latestRunTimeElapsedMillis = jobStatus.getLatestRunTimeElapsed();
}
@@ -132,6 +134,8 @@ public class JobStatus {
public JobStatus(JobStatus rescheduling, long newEarliestRuntimeElapsedMillis,
long newLatestRuntimeElapsedMillis, int backoffAttempt) {
this(rescheduling.job, rescheduling.getUid(), backoffAttempt);
this.sourceUserId = rescheduling.sourceUserId;
this.sourcePackageName = rescheduling.sourcePackageName;
earliestRunTimeElapsedMillis = newEarliestRuntimeElapsedMillis;
latestRunTimeElapsedMillis = newLatestRuntimeElapsedMillis;