Loading packages/CarSystemUI/src/com/android/systemui/CarSystemUIRootComponent.java +1 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ import dagger.Component; DependencyProvider.class, DependencyBinder.class, ServiceBinder.class, SystemUIBinder.class, SystemUIFactory.ContextHolder.class, SystemUIModule.class, CarSystemUIModule.class Loading packages/SystemUI/src/com/android/systemui/ContextComponentHelper.java +3 −0 Original line number Diff line number Diff line Loading @@ -24,4 +24,7 @@ import android.app.Service; public interface ContextComponentHelper { /** Turns a classname into an instance of the class or returns null. */ Service resolveService(String className); /** Turns a classname into an instance of the class or returns null. */ SystemUI resolveSystemUI(String className); } packages/SystemUI/src/com/android/systemui/ContextComponentResolver.java +14 −1 Original line number Diff line number Diff line Loading @@ -22,17 +22,22 @@ import java.util.Map; import javax.inject.Inject; import javax.inject.Provider; import javax.inject.Singleton; /** * Used during Service and Activity instantiation to make them injectable. */ @Singleton public class ContextComponentResolver implements ContextComponentHelper { private final Map<Class<?>, Provider<Service>> mServiceCreators; private final Map<Class<?>, Provider<SystemUI>> mSystemUICreators; @Inject ContextComponentResolver( Map<Class<?>, Provider<Service>> serviceCreators) { Map<Class<?>, Provider<Service>> serviceCreators, Map<Class<?>, Provider<SystemUI>> systemUICreators) { mServiceCreators = serviceCreators; mSystemUICreators = systemUICreators; } /** Loading @@ -43,6 +48,14 @@ public class ContextComponentResolver implements ContextComponentHelper { return resolve(className, mServiceCreators); } /** * Looks up the SystemUI class name to see if Dagger has an instance of it. */ @Override public SystemUI resolveSystemUI(String className) { return resolve(className, mSystemUICreators); } private <T> T resolve(String className, Map<Class<?>, Provider<T>> creators) { for (Map.Entry<Class<?>, Provider<T>> p : creators.entrySet()) { if (p.getKey().getName().equals(className)) { Loading packages/SystemUI/src/com/android/systemui/SystemUI.java +0 −4 Original line number Diff line number Diff line Loading @@ -24,7 +24,6 @@ import android.os.Bundle; import java.io.FileDescriptor; import java.io.PrintWriter; import java.util.Map; import java.util.function.Function; public abstract class SystemUI implements SysUiServiceProvider { public Context mContext; Loading Loading @@ -62,7 +61,4 @@ public abstract class SystemUI implements SysUiServiceProvider { n.addExtras(extras); } public interface Injector extends Function<Context, SystemUI> { } } packages/SystemUI/src/com/android/systemui/SystemUIApplication.java +9 −7 Original line number Diff line number Diff line Loading @@ -54,6 +54,8 @@ public class SystemUIApplication extends Application implements SysUiServiceProv public static final String TAG = "SystemUIService"; private static final boolean DEBUG = false; private ContextComponentHelper mComponentHelper; /** * Hold a reference on the stuff we start. */ Loading @@ -78,6 +80,8 @@ public class SystemUIApplication extends Application implements SysUiServiceProv Trace.TRACE_TAG_APP); log.traceBegin("DependencyInjection"); mContextAvailableCallback.onContextAvailable(this); mComponentHelper = SystemUIFactory .getInstance().getRootComponent().getContextComponentHelper(); log.traceEnd(); // Set the application theme that is inherited by all services. Note that setting the Loading Loading @@ -186,14 +190,12 @@ public class SystemUIApplication extends Application implements SysUiServiceProv if (DEBUG) Log.d(TAG, "loading: " + clsName); log.traceBegin("StartServices" + clsName); long ti = System.currentTimeMillis(); Class cls; try { cls = Class.forName(clsName); Object o = cls.newInstance(); if (o instanceof SystemUI.Injector) { o = ((SystemUI.Injector) o).apply(this); SystemUI obj = mComponentHelper.resolveSystemUI(clsName); if (obj == null) { obj = (SystemUI) Class.forName(clsName).newInstance(); } mServices[i] = (SystemUI) o; mServices[i] = obj; } catch (ClassNotFoundException ex) { throw new RuntimeException(ex); } catch (IllegalAccessException ex) { Loading @@ -211,7 +213,7 @@ public class SystemUIApplication extends Application implements SysUiServiceProv // Warn if initialization of component takes too long ti = System.currentTimeMillis() - ti; if (ti > 1000) { Log.w(TAG, "Initialization of " + cls.getName() + " took " + ti + " ms"); Log.w(TAG, "Initialization of " + clsName + " took " + ti + " ms"); } if (mBootCompleted) { mServices[i].onBootCompleted(); Loading Loading
packages/CarSystemUI/src/com/android/systemui/CarSystemUIRootComponent.java +1 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ import dagger.Component; DependencyProvider.class, DependencyBinder.class, ServiceBinder.class, SystemUIBinder.class, SystemUIFactory.ContextHolder.class, SystemUIModule.class, CarSystemUIModule.class Loading
packages/SystemUI/src/com/android/systemui/ContextComponentHelper.java +3 −0 Original line number Diff line number Diff line Loading @@ -24,4 +24,7 @@ import android.app.Service; public interface ContextComponentHelper { /** Turns a classname into an instance of the class or returns null. */ Service resolveService(String className); /** Turns a classname into an instance of the class or returns null. */ SystemUI resolveSystemUI(String className); }
packages/SystemUI/src/com/android/systemui/ContextComponentResolver.java +14 −1 Original line number Diff line number Diff line Loading @@ -22,17 +22,22 @@ import java.util.Map; import javax.inject.Inject; import javax.inject.Provider; import javax.inject.Singleton; /** * Used during Service and Activity instantiation to make them injectable. */ @Singleton public class ContextComponentResolver implements ContextComponentHelper { private final Map<Class<?>, Provider<Service>> mServiceCreators; private final Map<Class<?>, Provider<SystemUI>> mSystemUICreators; @Inject ContextComponentResolver( Map<Class<?>, Provider<Service>> serviceCreators) { Map<Class<?>, Provider<Service>> serviceCreators, Map<Class<?>, Provider<SystemUI>> systemUICreators) { mServiceCreators = serviceCreators; mSystemUICreators = systemUICreators; } /** Loading @@ -43,6 +48,14 @@ public class ContextComponentResolver implements ContextComponentHelper { return resolve(className, mServiceCreators); } /** * Looks up the SystemUI class name to see if Dagger has an instance of it. */ @Override public SystemUI resolveSystemUI(String className) { return resolve(className, mSystemUICreators); } private <T> T resolve(String className, Map<Class<?>, Provider<T>> creators) { for (Map.Entry<Class<?>, Provider<T>> p : creators.entrySet()) { if (p.getKey().getName().equals(className)) { Loading
packages/SystemUI/src/com/android/systemui/SystemUI.java +0 −4 Original line number Diff line number Diff line Loading @@ -24,7 +24,6 @@ import android.os.Bundle; import java.io.FileDescriptor; import java.io.PrintWriter; import java.util.Map; import java.util.function.Function; public abstract class SystemUI implements SysUiServiceProvider { public Context mContext; Loading Loading @@ -62,7 +61,4 @@ public abstract class SystemUI implements SysUiServiceProvider { n.addExtras(extras); } public interface Injector extends Function<Context, SystemUI> { } }
packages/SystemUI/src/com/android/systemui/SystemUIApplication.java +9 −7 Original line number Diff line number Diff line Loading @@ -54,6 +54,8 @@ public class SystemUIApplication extends Application implements SysUiServiceProv public static final String TAG = "SystemUIService"; private static final boolean DEBUG = false; private ContextComponentHelper mComponentHelper; /** * Hold a reference on the stuff we start. */ Loading @@ -78,6 +80,8 @@ public class SystemUIApplication extends Application implements SysUiServiceProv Trace.TRACE_TAG_APP); log.traceBegin("DependencyInjection"); mContextAvailableCallback.onContextAvailable(this); mComponentHelper = SystemUIFactory .getInstance().getRootComponent().getContextComponentHelper(); log.traceEnd(); // Set the application theme that is inherited by all services. Note that setting the Loading Loading @@ -186,14 +190,12 @@ public class SystemUIApplication extends Application implements SysUiServiceProv if (DEBUG) Log.d(TAG, "loading: " + clsName); log.traceBegin("StartServices" + clsName); long ti = System.currentTimeMillis(); Class cls; try { cls = Class.forName(clsName); Object o = cls.newInstance(); if (o instanceof SystemUI.Injector) { o = ((SystemUI.Injector) o).apply(this); SystemUI obj = mComponentHelper.resolveSystemUI(clsName); if (obj == null) { obj = (SystemUI) Class.forName(clsName).newInstance(); } mServices[i] = (SystemUI) o; mServices[i] = obj; } catch (ClassNotFoundException ex) { throw new RuntimeException(ex); } catch (IllegalAccessException ex) { Loading @@ -211,7 +213,7 @@ public class SystemUIApplication extends Application implements SysUiServiceProv // Warn if initialization of component takes too long ti = System.currentTimeMillis() - ti; if (ti > 1000) { Log.w(TAG, "Initialization of " + cls.getName() + " took " + ti + " ms"); Log.w(TAG, "Initialization of " + clsName + " took " + ti + " ms"); } if (mBootCompleted) { mServices[i].onBootCompleted(); Loading