Prevent deadlock in AttentionManagerService

Bug: 133077390
Test: manually verified
Change-Id: I5548760fe8003c15612bebe275fd902fdafa21af
This commit is contained in:
Alex Salo
2019-05-20 15:59:48 -07:00
parent 1cc5f3175f
commit 207e92db2d

View File

@@ -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;
}