Allow Services to be created through Dagger.
This is a significant change that allows Services to have their constructed injected into. The DozeService is now labeled as injectable (thought it takes no arguments). At least one Service has to be marked as injectable for Dagger to be happy compiling this code. Bug: 138787339 Test: atest SystemUITests Change-Id: I0ec92e01dd236bcee3083c8f8744c53b7ccc92d3 Merged-In: Ib58f8763c996fbc2aea07ead56493d2d9e936f5b
This commit is contained in:
@@ -60,16 +60,20 @@ public class SystemUIApplication extends Application implements SysUiServiceProv
|
||||
private boolean mServicesStarted;
|
||||
private boolean mBootCompleted;
|
||||
private final Map<Class<?>, Object> mComponents = new HashMap<>();
|
||||
private ContextAvailableCallback mContextAvailableCallback;
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
// This line is used to setup Dagger's dependency injection and should be kept at the
|
||||
// top of this method.
|
||||
mContextAvailableCallback.onContextAvailable(this);
|
||||
|
||||
// Set the application theme that is inherited by all services. Note that setting the
|
||||
// application theme in the manifest does only work for activities. Keep this in sync with
|
||||
// the theme set there.
|
||||
setTheme(R.style.Theme_SystemUI);
|
||||
|
||||
SystemUIFactory.createFromConfig(this);
|
||||
|
||||
if (Process.myUserHandle().equals(UserHandle.SYSTEM)) {
|
||||
IntentFilter bootCompletedFilter = new IntentFilter(Intent.ACTION_BOOT_COMPLETED);
|
||||
@@ -286,4 +290,12 @@ public class SystemUIApplication extends Application implements SysUiServiceProv
|
||||
public SystemUI[] getServices() {
|
||||
return mServices;
|
||||
}
|
||||
|
||||
void setContextAvailableCallback(ContextAvailableCallback callback) {
|
||||
mContextAvailableCallback = callback;
|
||||
}
|
||||
|
||||
interface ContextAvailableCallback {
|
||||
void onContextAvailable(Context context);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user