From c07743a00d4846af77511804fd4f01dbb67e3884 Mon Sep 17 00:00:00 2001 From: Robert Horvath Date: Thu, 16 Sep 2021 17:02:56 +0200 Subject: [PATCH] Pass Binder token to ISuspendControlServiceInternal#enableAutosuspend The Binder token signals system_server's death to the suspend HAL, so that autosuspend is disabled in case the framework stops or crashes and cannot hold suspend blockers anymore. Bug: 193776617 Test: atest SystemSuspendV1_0UnitTest SystemSuspendV1_0AidlTest Test: Put device to sleep, observe "automatic system suspend enabled". On `adb shell stop`, observe "automatic system suspend disabled". Change-Id: I918e7d2180eb47f078ef57732ae0e2dcd5e1f2c3 Merged-In: I918e7d2180eb47f078ef57732ae0e2dcd5e1f2c3 --- .../core/jni/com_android_server_power_PowerManagerService.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/services/core/jni/com_android_server_power_PowerManagerService.cpp b/services/core/jni/com_android_server_power_PowerManagerService.cpp index 4922b2cc9a801..55117aec997ba 100644 --- a/services/core/jni/com_android_server_power_PowerManagerService.cpp +++ b/services/core/jni/com_android_server_power_PowerManagerService.cpp @@ -397,9 +397,10 @@ sp getSuspendControlI void enableAutoSuspend() { static bool enabled = false; if (!enabled) { + static sp autosuspendClientToken = new BBinder(); sp suspendControl = getSuspendControlInternal(); - suspendControl->enableAutosuspend(&enabled); + suspendControl->enableAutosuspend(autosuspendClientToken, &enabled); } {