From a98efadb48aafaed3314740c6a2ac92bbca0fc55 Mon Sep 17 00:00:00 2001 From: Eugene Susla Date: Wed, 7 Apr 2021 08:53:02 -0700 Subject: [PATCH] Re-connect to the CDM service if process gets killed If an app gets force stopped, we want to revive it Bug: 181344542 Test: presubmit Change-Id: If89fe8e8302b3f7566a8f38c2622790e68140cb3 --- .../companion/CompanionDeviceManagerService.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/services/companion/java/com/android/server/companion/CompanionDeviceManagerService.java b/services/companion/java/com/android/server/companion/CompanionDeviceManagerService.java index e9b2ed30aa099..55490ce6825b7 100644 --- a/services/companion/java/com/android/server/companion/CompanionDeviceManagerService.java +++ b/services/companion/java/com/android/server/companion/CompanionDeviceManagerService.java @@ -154,6 +154,8 @@ public class CompanionDeviceManagerService extends SystemService implements Bind private static final long DEVICE_DISAPPEARED_TIMEOUT_MS = 10 * 1000; private static final long DEVICE_DISAPPEARED_UNBIND_TIMEOUT_MS = 10 * 60 * 1000; + private static final long DEVICE_LISTENER_DIED_REBIND_TIMEOUT_MS = 10 * 1000; + private static final boolean DEBUG = false; private static final String LOG_TAG = "CompanionDeviceManagerService"; @@ -1131,6 +1133,14 @@ public class CompanionDeviceManagerService extends SystemService implements Bind // Service binding is managed manually based on corresponding device being nearby return Long.MAX_VALUE; } + + @Override + public void binderDied() { + super.binderDied(); + + // Re-connect to the service if process gets killed + mMainHandler.postDelayed(this::connect, DEVICE_LISTENER_DIED_REBIND_TIMEOUT_MS); + } }; }