From 883ff1a65daf54d925f21daabcf5a0830f650796 Mon Sep 17 00:00:00 2001 From: "Philip P. Moltmann" Date: Mon, 7 Jan 2019 14:34:47 -0800 Subject: [PATCH] Automatically unbind for AbstractRemoteService No need for services to think about unbinding anymore. Now the AbstractRemoteService counts how many requests are not yet finished and once the number of unfinished requests drops to zero, schedules an unbind. Bug: 117779333 Test: - Started settings which makes many calls to PermissionControllerManager. Saw the automatic unbind to eventually happen. - atest CtsContentCaptureServiceTestCases (with content capture enabled and with content capture disabled) - atest CtsAutoFillServiceTestCases (4 tests out of WebViewActivityTest fail without and with this change) Change-Id: Ief2f3512df5a1c55694c0c6b449079a49089bcde --- .../internal/infra/AbstractRemoteService.java | 38 +++++++++++++++++-- .../server/autofill/RemoteFillService.java | 3 -- 2 files changed, 34 insertions(+), 7 deletions(-) diff --git a/core/java/com/android/internal/infra/AbstractRemoteService.java b/core/java/com/android/internal/infra/AbstractRemoteService.java index c94c64a879b31..e8ac2239c3fde 100644 --- a/core/java/com/android/internal/infra/AbstractRemoteService.java +++ b/core/java/com/android/internal/infra/AbstractRemoteService.java @@ -39,6 +39,7 @@ import com.android.internal.annotations.GuardedBy; import java.io.PrintWriter; import java.lang.ref.WeakReference; +import java.util.ArrayList; /** * Base class representing a remote service. @@ -93,6 +94,9 @@ public abstract class AbstractRemoteService> mUnfinishedRequests = new ArrayList<>(); + /** * Callback called when the service dies. * @@ -229,6 +233,8 @@ public abstract class AbstractRemoteService asyncRequest = new MyAsyncPendingRequest(this, request); @@ -341,6 +361,10 @@ public abstract class AbstractRemoteService