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:
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user