SyncManager: detect suspicious periodic sync removal.
- Also disallow and detect JobScheduler.cancelAll() for the system UID.
- Also wtf() if jobs.xml can't be read.
Bug: 64536115
Test: boot, add & remove google accounts
Change-Id: I953c12f70b479cf5f71a81a3787c103599f243c8
diff --git a/services/core/java/com/android/server/job/JobSchedulerService.java b/services/core/java/com/android/server/job/JobSchedulerService.java
index e25f3e6..12087b0 100644
--- a/services/core/java/com/android/server/job/JobSchedulerService.java
+++ b/services/core/java/com/android/server/job/JobSchedulerService.java
@@ -1835,6 +1835,13 @@
}
}
}
+
+ @Override
+ public int countJobs() {
+ synchronized (mLock) {
+ return mJobs.size();
+ }
+ }
}
/**
@@ -2015,6 +2022,12 @@
@Override
public void cancelAll() throws RemoteException {
final int uid = Binder.getCallingUid();
+ switch (uid) {
+ case Process.SYSTEM_UID:
+ // This really shouldn't happen.
+ Slog.wtf(TAG, "JobScheduler.cancelAll() called for uid=" + uid);
+ return;
+ }
long ident = Binder.clearCallingIdentity();
try {