OSDN Git Service

NetworkCapabilities needs UID to be satisfied.
authorJeff Sharkey <jsharkey@android.com>
Thu, 22 Feb 2018 03:27:48 +0000 (20:27 -0700)
committerJeff Sharkey <jsharkey@android.com>
Thu, 22 Feb 2018 03:27:50 +0000 (20:27 -0700)
A recently added NetworkCapabilities feature expects that a
NetworkRequest defines a real UID in order for it to be satisfied
by a VPN-based network.

So when creating our JobStatus inside the system (either from a new
external request, or from a persisted job on disk), splice in the
source UID of the job, so that VPNs start matching.

Test: bit CtsJobSchedulerTestCases:*
Bug: 7276571873418534
Change-Id: Id611a98fee8f53cea92f7a22ec02f7f6d8a4c534

services/core/java/com/android/server/job/controllers/JobStatus.java

index 3867306..d1bb63a 100644 (file)
@@ -302,7 +302,6 @@ public final class JobStatus {
         this.numFailures = numFailures;
 
         int requiredConstraints = job.getConstraintFlags();
-
         if (job.getRequiredNetwork() != null) {
             requiredConstraints |= CONSTRAINT_CONNECTIVITY;
         }
@@ -323,6 +322,13 @@ public final class JobStatus {
         mInternalFlags = internalFlags;
 
         updateEstimatedNetworkBytesLocked();
+
+        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.
+            job.getRequiredNetwork().networkCapabilities.setSingleUid(this.sourceUid);
+        }
     }
 
     /** Copy constructor: used specifically when cloning JobStatus objects for persistence,