summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Kweku Adams <kwekua@google.com> 2023-11-17 19:52:26 +0000
committer Kweku Adams <kwekua@google.com> 2023-11-17 20:04:11 +0000
commit054fcdf7aaed8e53ecefc1cbd0e5ef382429b8fb (patch)
tree73a73fdc21c41da0786969a121deec10589dd990
parent57ea02322e889177f886e2e61bef646353cf60a8 (diff)
Properly set the NetworkRequest singleUid.
A job's NetworkRequest should have the source app's UID as the UID. The previous code attempted to set the UID, but didn't modify the stored job, leading to potentially unexpected behavior of proxied jobs. Rearranging code to ensure we properly set the NetworkRequest UID. Bug: 311727153 Test: N/A Change-Id: I8fb49b74ff861ea82d89ab8d2791e4b917fd6ef2
-rw-r--r--apex/jobscheduler/service/java/com/android/server/job/controllers/JobStatus.java32
1 files changed, 16 insertions, 16 deletions
diff --git a/apex/jobscheduler/service/java/com/android/server/job/controllers/JobStatus.java b/apex/jobscheduler/service/java/com/android/server/job/controllers/JobStatus.java
index d6ada4cd7fdc..c8cadb3c7a58 100644
--- a/apex/jobscheduler/service/java/com/android/server/job/controllers/JobStatus.java
+++ b/apex/jobscheduler/service/java/com/android/server/job/controllers/JobStatus.java
@@ -598,7 +598,6 @@ public final class JobStatus {
long lastSuccessfulRunTime, long lastFailedRunTime, long cumulativeExecutionTimeMs,
int internalFlags,
int dynamicConstraints) {
- this.job = job;
this.callingUid = callingUid;
this.standbyBucket = standbyBucket;
mNamespace = namespace;
@@ -626,6 +625,22 @@ public final class JobStatus {
this.sourceTag = tag;
}
+ // This needs to be done before setting the field variable.
+ if (job.getRequiredNetwork() != null) {
+ // Later, when we check if a given network satisfies the required
+ // network, we need to know the UID that is requesting it, so push
+ // the source UID into place.
+ final JobInfo.Builder builder = new JobInfo.Builder(job);
+ builder.setRequiredNetwork(new NetworkRequest.Builder(job.getRequiredNetwork())
+ .setUids(Collections.singleton(new Range<>(this.sourceUid, this.sourceUid)))
+ .build());
+ // Don't perform validation checks at this point since we've already passed the
+ // initial validation check.
+ job = builder.build(false, false);
+ }
+
+ this.job = job;
+
final String bnNamespace = namespace == null ? "" : "@" + namespace + "@";
this.batteryName = this.sourceTag != null
? bnNamespace + this.sourceTag + ":" + job.getService().getPackageName()
@@ -708,21 +723,6 @@ public final class JobStatus {
updateNetworkBytesLocked();
- if (job.getRequiredNetwork() != null) {
- // Later, when we check if a given network satisfies the required
- // network, we need to know the UID that is requesting it, so push
- // our source UID into place.
- final JobInfo.Builder builder = new JobInfo.Builder(job);
- final NetworkRequest.Builder requestBuilder =
- new NetworkRequest.Builder(job.getRequiredNetwork());
- requestBuilder.setUids(
- Collections.singleton(new Range<Integer>(this.sourceUid, this.sourceUid)));
- builder.setRequiredNetwork(requestBuilder.build());
- // Don't perform validation checks at this point since we've already passed the
- // initial validation check.
- job = builder.build(false, false);
- }
-
updateMediaBackupExemptionStatus();
}