summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Gavin Corkery <gavincorkery@google.com> 2020-05-27 13:02:58 +0100
committer Gavin Corkery <gavincorkery@google.com> 2020-05-27 13:16:52 +0100
commit553c94bcabce0fb449a97da502969b20d1cffd16 (patch)
tree807f021b07058970ac2854468fa7141e10bc8691
parentff779f6d8e2588c64173b7087efe81214f9bb167 (diff)
Ensure that health check controller is unbound correctly
Explicitly call into the health check controller if there are no more packages to check. This is due to the fact that the ExplicitHealthCheckController will unbind itself in this case. If this call is not made, the controller will continue running in the foreground and will not be killed by lmkd. Test: atest PackageWatchdogTest Test: check logcat to see that the service is unbound Bug: 156323728 Change-Id: I0044d0832178ee90043d5e64e406df07ee2c36a2
-rw-r--r--services/core/java/com/android/server/PackageWatchdog.java7
-rw-r--r--tests/PackageWatchdog/src/com/android/server/PackageWatchdogTest.java1
2 files changed, 2 insertions, 6 deletions
diff --git a/services/core/java/com/android/server/PackageWatchdog.java b/services/core/java/com/android/server/PackageWatchdog.java
index e77458cc955a..e303f0d00214 100644
--- a/services/core/java/com/android/server/PackageWatchdog.java
+++ b/services/core/java/com/android/server/PackageWatchdog.java
@@ -177,9 +177,6 @@ public class PackageWatchdog {
// 0 if no prune is scheduled.
@GuardedBy("mLock")
private long mUptimeAtLastStateSync;
- // If true, sync explicit health check packages with the ExplicitHealthCheckController.
- @GuardedBy("mLock")
- private boolean mSyncRequired = false;
@FunctionalInterface
@VisibleForTesting
@@ -255,7 +252,6 @@ public class PackageWatchdog {
*/
public void registerHealthObserver(PackageHealthObserver observer) {
synchronized (mLock) {
- mSyncRequired = true;
ObserverInternal internalObserver = mAllObservers.get(observer.getName());
if (internalObserver != null) {
internalObserver.registeredObserver = observer;
@@ -642,7 +638,7 @@ public class PackageWatchdog {
synchronized (mLock) {
if (mIsPackagesReady) {
Set<String> packages = getPackagesPendingHealthChecksLocked();
- if (!packages.equals(mRequestedHealthCheckPackages) || mSyncRequired) {
+ if (!packages.equals(mRequestedHealthCheckPackages) || packages.isEmpty()) {
syncRequired = true;
mRequestedHealthCheckPackages = packages;
}
@@ -654,7 +650,6 @@ public class PackageWatchdog {
Slog.i(TAG, "Syncing health check requests for packages: "
+ mRequestedHealthCheckPackages);
mHealthCheckController.syncRequests(mRequestedHealthCheckPackages);
- mSyncRequired = false;
}
}
diff --git a/tests/PackageWatchdog/src/com/android/server/PackageWatchdogTest.java b/tests/PackageWatchdog/src/com/android/server/PackageWatchdogTest.java
index d011dbbbe5db..ae93a81f274e 100644
--- a/tests/PackageWatchdog/src/com/android/server/PackageWatchdogTest.java
+++ b/tests/PackageWatchdog/src/com/android/server/PackageWatchdogTest.java
@@ -1113,6 +1113,7 @@ public class PackageWatchdogTest {
mTestLooper.dispatchAll();
List<Set> expectedSyncRequests = List.of(
+ Set.of(),
Set.of(APP_A),
Set.of(APP_A, APP_B),
Set.of(APP_A, APP_B, APP_C),