From 207e92db2df844e537101de761416635747ccf8e Mon Sep 17 00:00:00 2001 From: Alex Salo Date: Mon, 20 May 2019 15:59:48 -0700 Subject: Prevent deadlock in AttentionManagerService Bug: 133077390 Test: manually verified Change-Id: I5548760fe8003c15612bebe275fd902fdafa21af --- .../android/server/attention/AttentionManagerService.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/services/core/java/com/android/server/attention/AttentionManagerService.java b/services/core/java/com/android/server/attention/AttentionManagerService.java index e14846863946..3b19d0875f5f 100644 --- a/services/core/java/com/android/server/attention/AttentionManagerService.java +++ b/services/core/java/com/android/server/attention/AttentionManagerService.java @@ -115,6 +115,14 @@ public class AttentionManagerService extends SystemService { mAttentionHandler = handler; } + @Override + public void onBootPhase(int phase) { + if (phase == SystemService.PHASE_SYSTEM_SERVICES_READY) { + mContext.registerReceiver(new ScreenStateReceiver(), + new IntentFilter(Intent.ACTION_SCREEN_OFF)); + } + } + @Override public void onStart() { publishBinderService(Context.ATTENTION_SERVICE, new BinderService()); @@ -135,10 +143,6 @@ public class AttentionManagerService extends SystemService { private boolean isServiceAvailable() { if (mComponentName == null) { mComponentName = resolveAttentionService(mContext); - if (mComponentName != null) { - mContext.registerReceiver(new ScreenStateReceiver(), - new IntentFilter(Intent.ACTION_SCREEN_OFF)); - } } return mComponentName != null; } -- cgit v1.2.3-59-g8ed1b