DozeService: Fix crash if StatusBar not yet initialized

Fixes a bug where a crashing SystemUI may crash again after restarting
if the services restart in an unexpected order.

Bug: 34044765
Test: Crash SystemUI, observe that it doesn't crash again right away.
Change-Id: Id6f781ba29ff11be0850b1883ca2942f15e76324
This commit is contained in:
Adrian Roos
2017-01-03 12:13:49 -08:00
parent 772ff11cb5
commit 0b2e23a427
2 changed files with 9 additions and 2 deletions

View File

@@ -152,7 +152,7 @@ public class DozeFactory {
}
}
private static DozeHost getHost(DozeService service) {
public static DozeHost getHost(DozeService service) {
Application appCandidate = service.getApplication();
final SystemUIApplication app = (SystemUIApplication) appCandidate;
return app.getComponent(DozeHost.class);

View File

@@ -42,6 +42,11 @@ public class DozeService extends DreamService implements DozeMachine.Service {
setWindowless(true);
if (DozeFactory.getHost(this) == null) {
finish();
return;
}
DozeProvider provider = PluginManager.getInstance(this)
.getOneShotPlugin(DozeProvider.ACTION, DozeProvider.VERSION);
mDozeMachine = new DozeFactory(provider).assembleMachine(this);
@@ -62,6 +67,8 @@ public class DozeService extends DreamService implements DozeMachine.Service {
@Override
protected void dumpOnHandler(FileDescriptor fd, PrintWriter pw, String[] args) {
mDozeMachine.dump(pw);
if (mDozeMachine != null) {
mDozeMachine.dump(pw);
}
}
}