diff --git a/packages/SystemUI/AndroidManifest.xml b/packages/SystemUI/AndroidManifest.xml index 379af1bc9506c..2c0d73a3b6825 100644 --- a/packages/SystemUI/AndroidManifest.xml +++ b/packages/SystemUI/AndroidManifest.xml @@ -370,7 +370,7 @@ android:defaultToDeviceProtectedStorage="true" android:directBootAware="true" tools:replace="android:appComponentFactory" - android:appComponentFactory=".SystemUIAppComponentFactory"> + android:appComponentFactory=".PhoneSystemUIAppComponentFactory"> diff --git a/packages/SystemUI/proguard.flags b/packages/SystemUI/proguard.flags index a8ed84393cfba..b534fcec2a856 100644 --- a/packages/SystemUI/proguard.flags +++ b/packages/SystemUI/proguard.flags @@ -1,13 +1,7 @@ -include proguard_common.flags --keep class com.android.systemui.statusbar.tv.TvStatusBar -keep class com.android.systemui.SystemUIInitializerImpl { *; } --keep class com.android.systemui.tv.TvSystemUIInitializer { - *; -} - --keep,allowoptimization,allowaccessmodification class com.android.systemui.dagger.DaggerReferenceGlobalRootComponent** { !synthetic *; } --keep,allowoptimization,allowaccessmodification class com.android.systemui.tv.DaggerTvGlobalRootComponent** { !synthetic *; } \ No newline at end of file +-keep,allowoptimization,allowaccessmodification class com.android.systemui.dagger.DaggerReferenceGlobalRootComponent** { !synthetic *; } \ No newline at end of file diff --git a/packages/SystemUI/res/values-television/config.xml b/packages/SystemUI/res/values-television/config.xml index 0ca154e06787c..2ace86f919aaa 100644 --- a/packages/SystemUI/res/values-television/config.xml +++ b/packages/SystemUI/res/values-television/config.xml @@ -20,11 +20,6 @@ - - - com.android.systemui.tv.TvSystemUIInitializer - - 3 diff --git a/packages/SystemUI/res/values/config.xml b/packages/SystemUI/res/values/config.xml index 166bd2ac4439f..421f41f60d85a 100644 --- a/packages/SystemUI/res/values/config.xml +++ b/packages/SystemUI/res/values/config.xml @@ -302,9 +302,6 @@ true - - com.android.systemui.SystemUIInitializerImpl - -1dp -1dp diff --git a/packages/SystemUI/src/com/android/systemui/PhoneSystemUIAppComponentFactory.kt b/packages/SystemUI/src/com/android/systemui/PhoneSystemUIAppComponentFactory.kt new file mode 100644 index 0000000000000..f06cb4104e1c8 --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/PhoneSystemUIAppComponentFactory.kt @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2023 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 android.content.Context + +class PhoneSystemUIAppComponentFactory : SystemUIAppComponentFactoryBase() { + override fun createSystemUIInitializer(context: Context) = SystemUIInitializerImpl(context) +} diff --git a/packages/SystemUI/src/com/android/systemui/SystemUIAppComponentFactory.java b/packages/SystemUI/src/com/android/systemui/SystemUIAppComponentFactory.java deleted file mode 100644 index 527ce127820e8..0000000000000 --- a/packages/SystemUI/src/com/android/systemui/SystemUIAppComponentFactory.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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 android.content.Context; - -/** - * Starts up SystemUI using the AOSP {@link SystemUIInitializerImpl}. - * - * This initializer relies on reflection to start everything up and should be considered deprecated. - * Instead, create your own {@link SystemUIAppComponentFactoryBase}, specify it in your - * AndroidManifest.xml and construct your own {@link SystemUIInitializer} directly. - * - * @deprecated Define your own SystemUIAppComponentFactoryBase implementation and use that. This - * implementation may be changed or removed in future releases. - */ -@Deprecated -public class SystemUIAppComponentFactory extends SystemUIAppComponentFactoryBase { - @Override - protected SystemUIInitializer createSystemUIInitializer(Context context) { - return SystemUIInitializerFactory.createWithContext(context); - } -} diff --git a/packages/SystemUI/src/com/android/systemui/SystemUIApplication.java b/packages/SystemUI/src/com/android/systemui/SystemUIApplication.java index 70c39df2a610c..453d1d117d0d7 100644 --- a/packages/SystemUI/src/com/android/systemui/SystemUIApplication.java +++ b/packages/SystemUI/src/com/android/systemui/SystemUIApplication.java @@ -54,7 +54,7 @@ import javax.inject.Provider; * Application class for SystemUI. */ public class SystemUIApplication extends Application implements - SystemUIAppComponentFactory.ContextInitializer { + SystemUIAppComponentFactoryBase.ContextInitializer { public static final String TAG = "SystemUIService"; private static final boolean DEBUG = false; @@ -66,7 +66,7 @@ public class SystemUIApplication extends Application implements */ private CoreStartable[] mServices; private boolean mServicesStarted; - private SystemUIAppComponentFactory.ContextAvailableCallback mContextAvailableCallback; + private SystemUIAppComponentFactoryBase.ContextAvailableCallback mContextAvailableCallback; private SysUIComponent mSysUIComponent; private SystemUIInitializer mInitializer; @@ -366,7 +366,7 @@ public class SystemUIApplication extends Application implements @Override public void setContextAvailableCallback( - SystemUIAppComponentFactory.ContextAvailableCallback callback) { + SystemUIAppComponentFactoryBase.ContextAvailableCallback callback) { mContextAvailableCallback = callback; } diff --git a/packages/SystemUI/src/com/android/systemui/SystemUIInitializerFactory.kt b/packages/SystemUI/src/com/android/systemui/SystemUIInitializerFactory.kt deleted file mode 100644 index b9454e8c3be86..0000000000000 --- a/packages/SystemUI/src/com/android/systemui/SystemUIInitializerFactory.kt +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (C) 2022 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 android.annotation.SuppressLint -import android.content.Context -import android.util.Log -import com.android.internal.annotations.VisibleForTesting -import com.android.systemui.util.Assert - -/** - * Factory to reflectively lookup a [SystemUIInitializer] to start SystemUI with. - */ -@Deprecated("Provide your own {@link SystemUIAppComponentFactoryBase} that doesn't need this.") -object SystemUIInitializerFactory { - private const val TAG = "SysUIInitializerFactory" - @SuppressLint("StaticFieldLeak") - private var initializer: SystemUIInitializer? = null - - /** - * Instantiate a [SystemUIInitializer] reflectively. - */ - @JvmStatic - fun createWithContext(context: Context): SystemUIInitializer { - return createFromConfig(context) - } - - /** - * Instantiate a [SystemUIInitializer] reflectively. - */ - @JvmStatic - private fun createFromConfig(context: Context): SystemUIInitializer { - Assert.isMainThread() - - return createFromConfigNoAssert(context) - } - - @JvmStatic - @VisibleForTesting - fun createFromConfigNoAssert(context: Context): SystemUIInitializer { - - return initializer ?: run { - val className = context.getString(R.string.config_systemUIFactoryComponent) - if (className.isEmpty()) { - throw RuntimeException("No SystemUIFactory component configured") - } - try { - val cls = context.classLoader.loadClass(className) - val constructor = cls.getConstructor(Context::class.java) - (constructor.newInstance(context) as SystemUIInitializer).apply { - initializer = this - } - } catch (t: Throwable) { - Log.w(TAG, "Error creating SystemUIInitializer component: $className", t) - throw t - } - } - } -} diff --git a/packages/SystemUI/src/com/android/systemui/dagger/WMComponent.java b/packages/SystemUI/src/com/android/systemui/dagger/WMComponent.java index b71871ebdb55e..d70c57fda2e11 100644 --- a/packages/SystemUI/src/com/android/systemui/dagger/WMComponent.java +++ b/packages/SystemUI/src/com/android/systemui/dagger/WMComponent.java @@ -16,12 +16,11 @@ package com.android.systemui.dagger; -import android.content.Context; import android.os.HandlerThread; import androidx.annotation.Nullable; -import com.android.systemui.SystemUIInitializerFactory; +import com.android.systemui.SystemUIInitializer; import com.android.systemui.tv.TvWMComponent; import com.android.wm.shell.back.BackAnimation; import com.android.wm.shell.bubbles.Bubbles; @@ -49,7 +48,7 @@ import java.util.Optional; /** * Dagger Subcomponent for WindowManager. This class explicitly describes the interfaces exported * from the WM component into the SysUI component (in - * {@link SystemUIInitializerFactory#init(Context, boolean)}), and references the specific dependencies + * {@link SystemUIInitializer#init(boolean)}), and references the specific dependencies * provided by its particular device/form-factor SystemUI implementation. * * ie. {@link WMComponent} includes {@link WMShellModule} diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardSliceProvider.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardSliceProvider.java index 573de9737eb8b..0511314331431 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardSliceProvider.java +++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardSliceProvider.java @@ -49,7 +49,7 @@ import com.android.internal.annotations.VisibleForTesting; import com.android.keyguard.KeyguardUpdateMonitor; import com.android.keyguard.KeyguardUpdateMonitorCallback; import com.android.systemui.R; -import com.android.systemui.SystemUIAppComponentFactory; +import com.android.systemui.SystemUIAppComponentFactoryBase; import com.android.systemui.plugins.statusbar.StatusBarStateController; import com.android.systemui.settings.UserTracker; import com.android.systemui.statusbar.NotificationMediaManager; @@ -72,13 +72,13 @@ import javax.inject.Inject; /** * Simple Slice provider that shows the current date. * - * Injection is handled by {@link SystemUIAppComponentFactory} + + * Injection is handled by {@link SystemUIAppComponentFactoryBase} + * {@link com.android.systemui.dagger.GlobalRootComponent#inject(KeyguardSliceProvider)}. */ public class KeyguardSliceProvider extends SliceProvider implements NextAlarmController.NextAlarmChangeCallback, ZenModeController.Callback, NotificationMediaManager.MediaListener, StatusBarStateController.StateListener, - SystemUIAppComponentFactory.ContextInitializer { + SystemUIAppComponentFactoryBase.ContextInitializer { private static final String TAG = "KgdSliceProvider"; @@ -148,7 +148,7 @@ public class KeyguardSliceProvider extends SliceProvider implements protected boolean mDozing; private int mStatusBarState; private boolean mMediaIsVisible; - private SystemUIAppComponentFactory.ContextAvailableCallback mContextAvailableCallback; + private SystemUIAppComponentFactoryBase.ContextAvailableCallback mContextAvailableCallback; @Inject WakeLockLogger mWakeLockLogger; @@ -533,7 +533,7 @@ public class KeyguardSliceProvider extends SliceProvider implements @Override public void setContextAvailableCallback( - SystemUIAppComponentFactory.ContextAvailableCallback callback) { + SystemUIAppComponentFactoryBase.ContextAvailableCallback callback) { mContextAvailableCallback = callback; } } diff --git a/packages/SystemUI/tests/src/com/android/systemui/DependencyTest.java b/packages/SystemUI/tests/src/com/android/systemui/DependencyTest.java index a0fdc8f1555e3..24a5e80727963 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/DependencyTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/DependencyTest.java @@ -48,8 +48,7 @@ public class DependencyTest extends SysuiTestCase { @Test public void testInitDependency() throws ExecutionException, InterruptedException { Dependency.clearDependencies(); - SystemUIInitializer initializer = - SystemUIInitializerFactory.createFromConfigNoAssert(mContext); + SystemUIInitializer initializer = new SystemUIInitializerImpl(mContext); initializer.init(true); Dependency dependency = initializer.getSysUIComponent().createDependency(); dependency.start(); diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/SysuiBaseFragmentTest.java b/packages/SystemUI/tests/utils/src/com/android/systemui/SysuiBaseFragmentTest.java index 9179efc9f39f5..e470406499b63 100644 --- a/packages/SystemUI/tests/utils/src/com/android/systemui/SysuiBaseFragmentTest.java +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/SysuiBaseFragmentTest.java @@ -57,8 +57,7 @@ public abstract class SysuiBaseFragmentTest extends BaseFragmentTest { @Before public void sysuiSetup() throws ExecutionException, InterruptedException { - SystemUIInitializer initializer = - SystemUIInitializerFactory.createFromConfigNoAssert(mContext); + SystemUIInitializer initializer = new SystemUIInitializerImpl(mContext); initializer.init(true); mDependency = new TestableDependency(initializer.getSysUIComponent().createDependency()); Dependency.setInstance(mDependency); diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/SysuiTestCase.java b/packages/SystemUI/tests/utils/src/com/android/systemui/SysuiTestCase.java index 8bbd58dc8fe12..de177168e20f0 100644 --- a/packages/SystemUI/tests/utils/src/com/android/systemui/SysuiTestCase.java +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/SysuiTestCase.java @@ -90,8 +90,7 @@ public abstract class SysuiTestCase { if (isRobolectricTest()) { mContext = mContext.createDefaultDisplayContext(); } - SystemUIInitializer initializer = - SystemUIInitializerFactory.createFromConfigNoAssert(mContext); + SystemUIInitializer initializer = new SystemUIInitializerImpl(mContext); initializer.init(true); mDependency = new TestableDependency(initializer.getSysUIComponent().createDependency()); Dependency.setInstance(mDependency);