From e0d25ed36f65175a39d459ff65b67dbc5db42749 Mon Sep 17 00:00:00 2001 From: Alex Salo Date: Fri, 10 Apr 2020 18:13:03 -0700 Subject: [PATCH] Fix adaptive_sleep resetting after reboot When device is locked after reboot - packageManager cannot resolve the service. Instead, rely on the configuration that is provided at the sign time. SystemServer relies on this as well, so it is consistent. Bug: 151176054 Test: manually Change-Id: Ifc1c078e3d774d63b8aeec2fe6b332305e47847b --- .../android/server/attention/AttentionManagerService.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/attention/AttentionManagerService.java b/services/core/java/com/android/server/attention/AttentionManagerService.java index 50ec0400a729f..e8acbd4931805 100644 --- a/services/core/java/com/android/server/attention/AttentionManagerService.java +++ b/services/core/java/com/android/server/attention/AttentionManagerService.java @@ -165,7 +165,7 @@ public class AttentionManagerService extends SystemService { * Returns {@code true} if attention service is supported on this device. */ private boolean isAttentionServiceSupported() { - return isServiceEnabled() && isServiceAvailable(); + return isServiceEnabled() && isServiceConfigured(mContext); } @VisibleForTesting @@ -210,6 +210,11 @@ public class AttentionManagerService extends SystemService { return false; } + if (!isServiceAvailable()) { + Slog.w(LOG_TAG, "Service is not available at this moment."); + return false; + } + // don't allow attention check in screen off state if (!mPowerManager.isInteractive()) { return false;