Watch all networks for job invalidation signals.
Until now, ConnectivityController was only watching for the
system-wide "default" network to change. Since the "default" network
can change on a per-UID basis, we could end up with jobs not being
rematched correctly.
To resolve this, we start watching for the firehose of all network
changes across the device. Since this results in increased noise,
we add a local cache of per-UID answers, and only re-evaluate jobs
when the changing network is the "default" network for that UID.
For NetworkPolicyManager.Listener, we only need to listen to
onUidRulesChanged(), since the other events always boil down into
specific rule changes.
Extends unit tests to verify all this logic behaves correctly.
Test: atest com.android.server.job.controllers.ConnectivityControllerTest
Bug: 73553301
Change-Id: I5b23ecd1facb6de723c5a6a7ddf9769a032d439e
diff --git a/services/core/java/com/android/server/job/JobSchedulerService.java b/services/core/java/com/android/server/job/JobSchedulerService.java
index 66817fa..736aa46 100644
--- a/services/core/java/com/android/server/job/JobSchedulerService.java
+++ b/services/core/java/com/android/server/job/JobSchedulerService.java
@@ -127,7 +127,7 @@
* Any function with the suffix 'Locked' also needs to lock on {@link #mJobs}.
* @hide
*/
-public final class JobSchedulerService extends com.android.server.SystemService
+public class JobSchedulerService extends com.android.server.SystemService
implements StateChangedListener, JobCompletedListener {
public static final String TAG = "JobScheduler";
public static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
@@ -781,6 +781,10 @@
}
};
+ public Context getTestableContext() {
+ return getContext();
+ }
+
public Object getLock() {
return mLock;
}