Loading packages/CarSystemUI/Android.bp +1 −1 Original line number Diff line number Diff line Loading @@ -26,8 +26,8 @@ android_app { ], static_libs: [ "CarNotificationLib", "SystemUI-core", "CarNotificationLib", "SystemUIPluginLib", "SystemUISharedLib", "SettingsLib", Loading packages/SystemUI/AndroidManifest.xml +3 −1 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ xmlns:androidprv="http://schemas.android.com/apk/prv/res/android" package="com.android.systemui" android:sharedUserId="android.uid.systemui" xmlns:tools="http://schemas.android.com/tools" coreApp="true"> <!-- Using OpenGL ES 2.0 --> Loading Loading @@ -259,7 +260,8 @@ android:theme="@style/Theme.SystemUI" android:defaultToDeviceProtectedStorage="true" android:directBootAware="true" android:appComponentFactory="androidx.core.app.CoreComponentFactory"> tools:replace="android:appComponentFactory" android:appComponentFactory=".SystemUIAppComponentFactory"> <!-- Keep theme in sync with SystemUIApplication.onCreate(). Setting the theme on the application does not affect views inflated by services. The application theme is set again from onCreate to take effect for those views. --> Loading packages/SystemUI/docs/dagger.md +8 −1 Original line number Diff line number Diff line Loading @@ -53,7 +53,7 @@ variants (like other form factors e.g. Car). ### Adding injection to a new SystemUI object Anything that depends on any `@Singleton` provider from SystemUIRootComponent should be declared as an `@Subcomponent` of the root component, this requires should be declared as a `@Subcomponent` of the root component. This requires declaring your own interface for generating your own modules or just the object you need injected. The subcomponent also needs to be added to SystemUIRootComponent in SystemUIFactory so it can be acquired. Loading Loading @@ -204,6 +204,13 @@ public CustomView(@Named(VIEW_CONTEXT) Context themedViewContext, AttributeSet a } ``` ## Updating Dagger2 Binaries can be downloaded from https://repo1.maven.org/maven2/com/google/dagger/ and then loaded into [/prebuilts/tools/common/m2/repository/com/google/dagger/](http://cs/android/prebuilts/tools/common/m2/repository/com/google/dagger/) ## TODO List - Eliminate usages of Dependency#get Loading packages/SystemUI/src/com/android/systemui/ContextComponentHelper.java 0 → 100644 +25 −0 Original line number Diff line number Diff line /* * Copyright (C) 2019 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.systemui; /** * Interface necessary to make Dagger happy. See {@link ContextComponentResolver}. */ public interface ContextComponentHelper { /** Turns a classname into an instance of the class or returns null. */ <T> T resolve(String className); } packages/SystemUI/src/com/android/systemui/ContextComponentResolver.java 0 → 100644 +48 −0 Original line number Diff line number Diff line /* * Copyright (C) 2019 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.systemui; import java.util.Map; import javax.inject.Inject; import javax.inject.Provider; /** * Used during Service and Activity instantiation to make them injectable. */ public class ContextComponentResolver implements ContextComponentHelper { private final Map<Class<?>, Provider<Object>> mCreators; @Inject ContextComponentResolver(Map<Class<?>, Provider<Object>> creators) { mCreators = creators; } /** * Looks up the class name to see if Dagger has an instance of it. */ @Override public <T> T resolve(String className) { for (Map.Entry<Class<?>, Provider<Object>> p : mCreators.entrySet()) { if (p.getKey().getName().equals(className)) { return (T) p.getValue().get(); } } return null; } } Loading
packages/CarSystemUI/Android.bp +1 −1 Original line number Diff line number Diff line Loading @@ -26,8 +26,8 @@ android_app { ], static_libs: [ "CarNotificationLib", "SystemUI-core", "CarNotificationLib", "SystemUIPluginLib", "SystemUISharedLib", "SettingsLib", Loading
packages/SystemUI/AndroidManifest.xml +3 −1 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ xmlns:androidprv="http://schemas.android.com/apk/prv/res/android" package="com.android.systemui" android:sharedUserId="android.uid.systemui" xmlns:tools="http://schemas.android.com/tools" coreApp="true"> <!-- Using OpenGL ES 2.0 --> Loading Loading @@ -259,7 +260,8 @@ android:theme="@style/Theme.SystemUI" android:defaultToDeviceProtectedStorage="true" android:directBootAware="true" android:appComponentFactory="androidx.core.app.CoreComponentFactory"> tools:replace="android:appComponentFactory" android:appComponentFactory=".SystemUIAppComponentFactory"> <!-- Keep theme in sync with SystemUIApplication.onCreate(). Setting the theme on the application does not affect views inflated by services. The application theme is set again from onCreate to take effect for those views. --> Loading
packages/SystemUI/docs/dagger.md +8 −1 Original line number Diff line number Diff line Loading @@ -53,7 +53,7 @@ variants (like other form factors e.g. Car). ### Adding injection to a new SystemUI object Anything that depends on any `@Singleton` provider from SystemUIRootComponent should be declared as an `@Subcomponent` of the root component, this requires should be declared as a `@Subcomponent` of the root component. This requires declaring your own interface for generating your own modules or just the object you need injected. The subcomponent also needs to be added to SystemUIRootComponent in SystemUIFactory so it can be acquired. Loading Loading @@ -204,6 +204,13 @@ public CustomView(@Named(VIEW_CONTEXT) Context themedViewContext, AttributeSet a } ``` ## Updating Dagger2 Binaries can be downloaded from https://repo1.maven.org/maven2/com/google/dagger/ and then loaded into [/prebuilts/tools/common/m2/repository/com/google/dagger/](http://cs/android/prebuilts/tools/common/m2/repository/com/google/dagger/) ## TODO List - Eliminate usages of Dependency#get Loading
packages/SystemUI/src/com/android/systemui/ContextComponentHelper.java 0 → 100644 +25 −0 Original line number Diff line number Diff line /* * Copyright (C) 2019 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.systemui; /** * Interface necessary to make Dagger happy. See {@link ContextComponentResolver}. */ public interface ContextComponentHelper { /** Turns a classname into an instance of the class or returns null. */ <T> T resolve(String className); }
packages/SystemUI/src/com/android/systemui/ContextComponentResolver.java 0 → 100644 +48 −0 Original line number Diff line number Diff line /* * Copyright (C) 2019 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.systemui; import java.util.Map; import javax.inject.Inject; import javax.inject.Provider; /** * Used during Service and Activity instantiation to make them injectable. */ public class ContextComponentResolver implements ContextComponentHelper { private final Map<Class<?>, Provider<Object>> mCreators; @Inject ContextComponentResolver(Map<Class<?>, Provider<Object>> creators) { mCreators = creators; } /** * Looks up the class name to see if Dagger has an instance of it. */ @Override public <T> T resolve(String className) { for (Map.Entry<Class<?>, Provider<Object>> p : mCreators.entrySet()) { if (p.getKey().getName().equals(className)) { return (T) p.getValue().get(); } } return null; } }