Move dagger modules into shell library for reuse

- Certain system ui implementations which use the shell don't depend on
  SystemUI-core, which means that the dagger modules for providing the
  core Shell components need to be copied (which makes it more cumbersome
  to make changes). Instead, move these modules back into the shell lib
  for any SysUI app to reference.

Bug: 205019015
Test: make SystemUIGoogle
Test: make CarSystemUI
Test: make ArcSystemUI
Change-Id: I8dc938a7695972f9d7b3d7ea8e3ce65a7b454b13
This commit is contained in:
Winson Chung
2021-11-04 19:22:25 -07:00
parent 7c1c6a691c
commit ca5598dd10
13 changed files with 92 additions and 34 deletions

View File

@@ -132,11 +132,12 @@ android_library {
"kotlinx-coroutines-android",
"kotlinx-coroutines-core",
"iconloader_base",
"jsr330",
"protolog-lib",
"WindowManager-Shell-proto",
"dagger2",
"jsr330",
],
kotlincflags: ["-Xjvm-default=enable"],
manifest: "AndroidManifest.xml",
plugins: ["dagger2-compiler"],
}

View File

@@ -15,6 +15,10 @@
limitations under the License.
-->
<resources>
<!-- Determines whether the shell features all run on another thread. This is to be overrided
by the resources of the app using the Shell library. -->
<bool name="config_enableShellMainThread">false</bool>
<!-- Animation duration for PIP when entering. -->
<integer name="config_pipEnterAnimationDuration">425</integer>

View File

@@ -0,0 +1,34 @@
/*
* Copyright (C) 2021 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.wm.shell.common.annotations;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import javax.inject.Qualifier;
/**
* Annotates a method or qualifies a provider that runs on the main-thread of the process using
* this library.
*/
@Qualifier
@Documented
@Retention(RUNTIME)
public @interface ExternalMainThread {
}

View File

@@ -0,0 +1,13 @@
The dagger modules in this directory can be included by the host SysUI using the Shell library for
explicity injection of Shell components. Apps using this library are not required to use these
dagger modules for setup, but it is recommended for them to include them as needed.
The modules are currently inherited as such:
+- WMShellBaseModule (common shell features across SysUI)
|
+- WMShellModule (handheld)
|
+- TvPipModule (tv pip)
|
+- TvWMShellModule (tv)

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2019 The Android Open Source Project
* Copyright (C) 2021 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.
@@ -14,12 +14,11 @@
* limitations under the License.
*/
package com.android.systemui.wmshell;
package com.android.wm.shell.dagger;
import android.content.Context;
import android.os.Handler;
import com.android.systemui.dagger.WMSingleton;
import com.android.wm.shell.ShellTaskOrganizer;
import com.android.wm.shell.WindowManagerShellWrapper;
import com.android.wm.shell.common.DisplayController;

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020 The Android Open Source Project
* Copyright (C) 2021 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.
@@ -14,14 +14,12 @@
* limitations under the License.
*/
package com.android.systemui.wmshell;
package com.android.wm.shell.dagger;
import android.animation.AnimationHandler;
import android.content.Context;
import android.view.IWindowManager;
import com.android.systemui.dagger.WMComponent;
import com.android.systemui.dagger.WMSingleton;
import com.android.wm.shell.ShellTaskOrganizer;
import com.android.wm.shell.common.DisplayController;
import com.android.wm.shell.common.DisplayImeController;

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020 The Android Open Source Project
* Copyright (C) 2021 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.
@@ -14,7 +14,7 @@
* limitations under the License.
*/
package com.android.systemui.wmshell;
package com.android.wm.shell.dagger;
import android.app.ActivityTaskManager;
import android.content.Context;
@@ -27,8 +27,6 @@ import android.view.WindowManager;
import com.android.internal.logging.UiEventLogger;
import com.android.internal.statusbar.IStatusBarService;
import com.android.launcher3.icons.IconProvider;
import com.android.systemui.dagger.WMComponent;
import com.android.systemui.dagger.WMSingleton;
import com.android.wm.shell.RootDisplayAreaOrganizer;
import com.android.wm.shell.RootTaskDisplayAreaOrganizer;
import com.android.wm.shell.ShellCommandHandler;

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020 The Android Open Source Project
* Copyright (C) 2021 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.
@@ -14,7 +14,7 @@
* limitations under the License.
*/
package com.android.systemui.wmshell;
package com.android.wm.shell.dagger;
import static android.os.Process.THREAD_PRIORITY_DISPLAY;
import static android.os.Process.THREAD_PRIORITY_TOP_APP_BOOST;
@@ -24,18 +24,18 @@ import android.content.Context;
import android.os.Build;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.Looper;
import android.os.Trace;
import com.android.internal.graphics.SfVsyncFrameCallbackProvider;
import com.android.systemui.R;
import com.android.systemui.dagger.WMSingleton;
import com.android.systemui.dagger.qualifiers.Main;
import com.android.wm.shell.common.HandlerExecutor;
import com.android.wm.shell.common.ShellExecutor;
import com.android.wm.shell.common.annotations.ChoreographerSfVsync;
import com.android.wm.shell.common.annotations.ExternalMainThread;
import com.android.wm.shell.common.annotations.ShellAnimationThread;
import com.android.wm.shell.common.annotations.ShellMainThread;
import com.android.wm.shell.common.annotations.ShellSplashscreenThread;
import com.android.wm.shell.R;
import dagger.Module;
import dagger.Provides;
@@ -61,13 +61,26 @@ public abstract class WMShellConcurrencyModule {
// Shell Concurrency - Components used for managing threading in the Shell and SysUI
//
/**
* Provide a SysUI main-thread Handler.
*
* Prefer the Main Executor when possible.
*/
@Provides
@ExternalMainThread
public static Handler provideMainHandler() {
return new Handler(Looper.getMainLooper());
}
/**
* Provide a SysUI main-thread Executor.
*/
@WMSingleton
@Provides
@Main
public static ShellExecutor provideSysUIMainExecutor(@Main Handler sysuiMainHandler) {
@ExternalMainThread
public static ShellExecutor provideSysUIMainExecutor(
@ExternalMainThread Handler sysuiMainHandler) {
return new HandlerExecutor(sysuiMainHandler);
}
@@ -78,7 +91,8 @@ public abstract class WMShellConcurrencyModule {
@WMSingleton
@Provides
@ShellMainThread
public static Handler provideShellMainHandler(Context context, @Main Handler sysuiMainHandler) {
public static Handler provideShellMainHandler(Context context,
@ExternalMainThread Handler sysuiMainHandler) {
if (enableShellMainThread(context)) {
HandlerThread mainThread = new HandlerThread("wmshell.main", THREAD_PRIORITY_DISPLAY);
mainThread.start();
@@ -99,7 +113,8 @@ public abstract class WMShellConcurrencyModule {
@Provides
@ShellMainThread
public static ShellExecutor provideShellMainExecutor(Context context,
@ShellMainThread Handler mainHandler, @Main ShellExecutor sysuiMainExecutor) {
@ShellMainThread Handler mainHandler,
@ExternalMainThread ShellExecutor sysuiMainExecutor) {
if (enableShellMainThread(context)) {
return new HandlerExecutor(mainHandler);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020 The Android Open Source Project
* Copyright (C) 2021 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.
@@ -14,15 +14,13 @@
* limitations under the License.
*/
package com.android.systemui.wmshell;
package com.android.wm.shell.dagger;
import android.animation.AnimationHandler;
import android.content.Context;
import android.os.Handler;
import android.view.IWindowManager;
import com.android.systemui.dagger.WMComponent;
import com.android.systemui.dagger.WMSingleton;
import com.android.wm.shell.ShellTaskOrganizer;
import com.android.wm.shell.WindowManagerShellWrapper;
import com.android.wm.shell.apppairs.AppPairsController;

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020 The Android Open Source Project
* Copyright (C) 2021 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.
@@ -14,7 +14,7 @@
* limitations under the License.
*/
package com.android.systemui.dagger;
package com.android.wm.shell.dagger;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

View File

@@ -654,9 +654,6 @@
<!-- Whether to use the split 2-column notification shade -->
<bool name="config_use_split_notification_shade">false</bool>
<!-- Determines whether the shell features all run on another thread. -->
<bool name="config_enableShellMainThread">false</bool>
<!-- Default udfps icon. Same path as ic_fingerprint.xml -->
<string name="config_udfpsIcon" translatable="false">
M25.5,16.3283C28.47,14.8433 31.9167,14 35.5834,14C39.2501,14 42.6968,14.8433 45.6668,16.3283

View File

@@ -20,13 +20,14 @@ import android.content.Context;
import com.android.systemui.SystemUIFactory;
import com.android.systemui.tv.TvWMComponent;
import com.android.systemui.wmshell.TvWMShellModule;
import com.android.systemui.wmshell.WMShellModule;
import com.android.wm.shell.dagger.TvWMShellModule;
import com.android.wm.shell.dagger.WMShellModule;
import com.android.wm.shell.ShellCommandHandler;
import com.android.wm.shell.ShellInit;
import com.android.wm.shell.TaskViewFactory;
import com.android.wm.shell.apppairs.AppPairs;
import com.android.wm.shell.bubbles.Bubbles;
import com.android.wm.shell.dagger.WMSingleton;
import com.android.wm.shell.displayareahelper.DisplayAreaHelper;
import com.android.wm.shell.hidedisplaycutout.HideDisplayCutout;
import com.android.wm.shell.legacysplitscreen.LegacySplitScreen;

View File

@@ -17,8 +17,8 @@
package com.android.systemui.tv;
import com.android.systemui.dagger.WMComponent;
import com.android.systemui.dagger.WMSingleton;
import com.android.systemui.wmshell.TvWMShellModule;
import com.android.wm.shell.dagger.WMSingleton;
import com.android.wm.shell.dagger.TvWMShellModule;
import dagger.Subcomponent;