Move SystemServicesModule to Global Scope.
Rename SystemServicesModule to FrameworkServicesModule to make the name less ambiguous. Include the GlobalModule in all the various GobalRootComponents. Include the WMModule in all the various GlobalRootComponents (it is currently empty so its exclusion was not breaking anything, but it should soon!) LocalBluetoothManager has to be moved out of the module as it requires a handler for instantiation. Bug: 162923491 Test: manual Change-Id: Id8498b661759ce0846ee904398dfcfe20ee744e9
This commit is contained in:
@@ -16,7 +16,9 @@
|
||||
|
||||
package com.android.systemui;
|
||||
|
||||
import com.android.systemui.dagger.GlobalModule;
|
||||
import com.android.systemui.dagger.GlobalRootComponent;
|
||||
import com.android.systemui.dagger.WMModule;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
|
||||
@@ -26,7 +28,9 @@ import dagger.Component;
|
||||
@Singleton
|
||||
@Component(
|
||||
modules = {
|
||||
CarSysUIComponentModule.class
|
||||
GlobalModule.class,
|
||||
CarSysUIComponentModule.class,
|
||||
WMModule.class
|
||||
})
|
||||
public interface CarGlobalRootComponent extends GlobalRootComponent {
|
||||
/**
|
||||
|
||||
@@ -20,7 +20,6 @@ import com.android.systemui.dagger.DependencyBinder;
|
||||
import com.android.systemui.dagger.DependencyProvider;
|
||||
import com.android.systemui.dagger.SysUIComponent;
|
||||
import com.android.systemui.dagger.SysUISingleton;
|
||||
import com.android.systemui.dagger.SystemServicesModule;
|
||||
import com.android.systemui.dagger.SystemUIModule;
|
||||
import com.android.systemui.pip.phone.dagger.PipModule;
|
||||
|
||||
@@ -35,7 +34,6 @@ import dagger.Subcomponent;
|
||||
DependencyProvider.class,
|
||||
DependencyBinder.class,
|
||||
PipModule.class,
|
||||
SystemServicesModule.class,
|
||||
SystemUIModule.class,
|
||||
CarSystemUIModule.class,
|
||||
CarSystemUIBinder.class})
|
||||
|
||||
@@ -18,6 +18,8 @@ package com.android.systemui.dagger;
|
||||
|
||||
import static com.android.systemui.Dependency.TIME_TICK_HANDLER_NAME;
|
||||
|
||||
import android.annotation.Nullable;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.INotificationManager;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
@@ -26,6 +28,7 @@ import android.os.Handler;
|
||||
import android.os.HandlerThread;
|
||||
import android.os.Looper;
|
||||
import android.os.ServiceManager;
|
||||
import android.os.UserHandle;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.Choreographer;
|
||||
import android.view.IWindowManager;
|
||||
@@ -39,6 +42,7 @@ import com.android.internal.logging.UiEventLoggerImpl;
|
||||
import com.android.internal.util.NotificationMessagingUtil;
|
||||
import com.android.internal.widget.LockPatternUtils;
|
||||
import com.android.keyguard.ViewMediatorCallback;
|
||||
import com.android.settingslib.bluetooth.LocalBluetoothManager;
|
||||
import com.android.systemui.Prefs;
|
||||
import com.android.systemui.accessibility.ModeSwitchesController;
|
||||
import com.android.systemui.accessibility.SystemActions;
|
||||
@@ -88,7 +92,7 @@ import dagger.Provides;
|
||||
* Provides dependencies for the root component of sysui injection.
|
||||
*
|
||||
* Only SystemUI owned classes and instances should go in here. Other, framework-owned classes
|
||||
* should go in {@link SystemServicesModule}.
|
||||
* should go in {@link FrameworkServicesModule}.
|
||||
*
|
||||
* See SystemUI/docs/dagger.md
|
||||
*/
|
||||
@@ -163,6 +167,15 @@ public class DependencyProvider {
|
||||
|
||||
}
|
||||
|
||||
@SuppressLint("MissingPermission")
|
||||
@SysUISingleton
|
||||
@Provides
|
||||
@Nullable
|
||||
static LocalBluetoothManager provideLocalBluetoothController(Context context,
|
||||
@Background Handler bgHandler) {
|
||||
return LocalBluetoothManager.create(context, bgHandler, UserHandle.ALL);
|
||||
}
|
||||
|
||||
/** */
|
||||
@Provides
|
||||
@SysUISingleton
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package com.android.systemui.dagger;
|
||||
|
||||
import android.annotation.Nullable;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.ActivityManager;
|
||||
import android.app.ActivityTaskManager;
|
||||
import android.app.AlarmManager;
|
||||
@@ -49,10 +48,8 @@ import android.net.ConnectivityManager;
|
||||
import android.net.NetworkScoreManager;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.os.BatteryStats;
|
||||
import android.os.Handler;
|
||||
import android.os.PowerManager;
|
||||
import android.os.ServiceManager;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
import android.os.Vibrator;
|
||||
import android.service.dreams.DreamService;
|
||||
@@ -68,12 +65,12 @@ import android.view.accessibility.AccessibilityManager;
|
||||
import com.android.internal.app.IBatteryStats;
|
||||
import com.android.internal.statusbar.IStatusBarService;
|
||||
import com.android.internal.util.LatencyTracker;
|
||||
import com.android.settingslib.bluetooth.LocalBluetoothManager;
|
||||
import com.android.systemui.dagger.qualifiers.Background;
|
||||
import com.android.systemui.dagger.qualifiers.DisplayId;
|
||||
import com.android.systemui.dagger.qualifiers.Main;
|
||||
import com.android.systemui.shared.system.PackageManagerWrapper;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
|
||||
@@ -81,51 +78,51 @@ import dagger.Provides;
|
||||
* Provides Non-SystemUI, Framework-Owned instances to the dependency graph.
|
||||
*/
|
||||
@Module
|
||||
public class SystemServicesModule {
|
||||
public class FrameworkServicesModule {
|
||||
@Provides
|
||||
@SysUISingleton
|
||||
@Singleton
|
||||
static AccessibilityManager provideAccessibilityManager(Context context) {
|
||||
return context.getSystemService(AccessibilityManager.class);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@SysUISingleton
|
||||
@Singleton
|
||||
static ActivityManager provideActivityManager(Context context) {
|
||||
return context.getSystemService(ActivityManager.class);
|
||||
}
|
||||
|
||||
@SysUISingleton
|
||||
@Provides
|
||||
@Singleton
|
||||
static AlarmManager provideAlarmManager(Context context) {
|
||||
return context.getSystemService(AlarmManager.class);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@SysUISingleton
|
||||
@Singleton
|
||||
static AudioManager provideAudioManager(Context context) {
|
||||
return context.getSystemService(AudioManager.class);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@SysUISingleton
|
||||
@Singleton
|
||||
static ColorDisplayManager provideColorDisplayManager(Context context) {
|
||||
return context.getSystemService(ColorDisplayManager.class);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@SysUISingleton
|
||||
@Singleton
|
||||
static ConnectivityManager provideConnectivityManagager(Context context) {
|
||||
return context.getSystemService(ConnectivityManager.class);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@SysUISingleton
|
||||
@Singleton
|
||||
static ContentResolver provideContentResolver(Context context) {
|
||||
return context.getContentResolver();
|
||||
}
|
||||
|
||||
@Provides
|
||||
@SysUISingleton
|
||||
@Singleton
|
||||
static DevicePolicyManager provideDevicePolicyManager(Context context) {
|
||||
return context.getSystemService(DevicePolicyManager.class);
|
||||
}
|
||||
@@ -137,39 +134,39 @@ public class SystemServicesModule {
|
||||
}
|
||||
|
||||
@Provides
|
||||
@SysUISingleton
|
||||
@Singleton
|
||||
static DisplayManager provideDisplayManager(Context context) {
|
||||
return context.getSystemService(DisplayManager.class);
|
||||
}
|
||||
|
||||
@SysUISingleton
|
||||
@Provides
|
||||
@Singleton
|
||||
static IActivityManager provideIActivityManager() {
|
||||
return ActivityManager.getService();
|
||||
}
|
||||
|
||||
@SysUISingleton
|
||||
@Provides
|
||||
@Singleton
|
||||
static IActivityTaskManager provideIActivityTaskManager() {
|
||||
return ActivityTaskManager.getService();
|
||||
}
|
||||
|
||||
@Provides
|
||||
@SysUISingleton
|
||||
@Singleton
|
||||
static IBatteryStats provideIBatteryStats() {
|
||||
return IBatteryStats.Stub.asInterface(
|
||||
ServiceManager.getService(BatteryStats.SERVICE_NAME));
|
||||
}
|
||||
|
||||
@Provides
|
||||
@SysUISingleton
|
||||
@Singleton
|
||||
static IDreamManager provideIDreamManager() {
|
||||
return IDreamManager.Stub.asInterface(
|
||||
ServiceManager.checkService(DreamService.DREAM_SERVICE));
|
||||
}
|
||||
|
||||
@Provides
|
||||
@SysUISingleton
|
||||
@Singleton
|
||||
@Nullable
|
||||
static FaceManager provideFaceManager(Context context) {
|
||||
return context.getSystemService(FaceManager.class);
|
||||
@@ -177,13 +174,13 @@ public class SystemServicesModule {
|
||||
}
|
||||
|
||||
@Provides
|
||||
@SysUISingleton
|
||||
@Singleton
|
||||
static IPackageManager provideIPackageManager() {
|
||||
return IPackageManager.Stub.asInterface(ServiceManager.getService("package"));
|
||||
}
|
||||
|
||||
@SysUISingleton
|
||||
@Provides
|
||||
@Singleton
|
||||
static IStatusBarService provideIStatusBarService() {
|
||||
return IStatusBarService.Stub.asInterface(
|
||||
ServiceManager.getService(Context.STATUS_BAR_SERVICE));
|
||||
@@ -196,39 +193,30 @@ public class SystemServicesModule {
|
||||
ServiceManager.getService(Context.WALLPAPER_SERVICE));
|
||||
}
|
||||
|
||||
@SysUISingleton
|
||||
@Provides
|
||||
@Singleton
|
||||
static IWindowManager provideIWindowManager() {
|
||||
return WindowManagerGlobal.getWindowManagerService();
|
||||
}
|
||||
|
||||
@SysUISingleton
|
||||
@Provides
|
||||
@Singleton
|
||||
static KeyguardManager provideKeyguardManager(Context context) {
|
||||
return context.getSystemService(KeyguardManager.class);
|
||||
}
|
||||
|
||||
@SysUISingleton
|
||||
@Provides
|
||||
@Singleton
|
||||
static LatencyTracker provideLatencyTracker(Context context) {
|
||||
return LatencyTracker.getInstance(context);
|
||||
}
|
||||
|
||||
@SysUISingleton
|
||||
@Provides
|
||||
@Singleton
|
||||
static LauncherApps provideLauncherApps(Context context) {
|
||||
return context.getSystemService(LauncherApps.class);
|
||||
}
|
||||
|
||||
@SuppressLint("MissingPermission")
|
||||
@SysUISingleton
|
||||
@Provides
|
||||
@Nullable
|
||||
static LocalBluetoothManager provideLocalBluetoothController(Context context,
|
||||
@Background Handler bgHandler) {
|
||||
return LocalBluetoothManager.create(context, bgHandler, UserHandle.ALL);
|
||||
}
|
||||
|
||||
@Provides
|
||||
static MediaRouter2Manager provideMediaRouter2Manager(Context context) {
|
||||
return MediaRouter2Manager.getInstance(context);
|
||||
@@ -240,32 +228,32 @@ public class SystemServicesModule {
|
||||
}
|
||||
|
||||
@Provides
|
||||
@SysUISingleton
|
||||
@Singleton
|
||||
static NetworkScoreManager provideNetworkScoreManager(Context context) {
|
||||
return context.getSystemService(NetworkScoreManager.class);
|
||||
}
|
||||
|
||||
@SysUISingleton
|
||||
@Provides
|
||||
@Singleton
|
||||
static NotificationManager provideNotificationManager(Context context) {
|
||||
return context.getSystemService(NotificationManager.class);
|
||||
}
|
||||
|
||||
@SysUISingleton
|
||||
@Provides
|
||||
@Singleton
|
||||
static PackageManager providePackageManager(Context context) {
|
||||
return context.getPackageManager();
|
||||
}
|
||||
|
||||
@SysUISingleton
|
||||
@Provides
|
||||
@Singleton
|
||||
static PackageManagerWrapper providePackageManagerWrapper() {
|
||||
return PackageManagerWrapper.getInstance();
|
||||
}
|
||||
|
||||
/** */
|
||||
@SysUISingleton
|
||||
@Provides
|
||||
@Singleton
|
||||
static PowerManager providePowerManager(Context context) {
|
||||
return context.getSystemService(PowerManager.class);
|
||||
}
|
||||
@@ -277,57 +265,63 @@ public class SystemServicesModule {
|
||||
}
|
||||
|
||||
@Provides
|
||||
@SysUISingleton
|
||||
@Singleton
|
||||
static RoleManager provideRoleManager(Context context) {
|
||||
return context.getSystemService(RoleManager.class);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
static SensorManager providesSensorManager(Context context) {
|
||||
return context.getSystemService(SensorManager.class);
|
||||
}
|
||||
|
||||
@SysUISingleton
|
||||
@Provides
|
||||
@Singleton
|
||||
static SensorPrivacyManager provideSensorPrivacyManager(Context context) {
|
||||
return context.getSystemService(SensorPrivacyManager.class);
|
||||
}
|
||||
|
||||
@SysUISingleton
|
||||
@Provides
|
||||
@Singleton
|
||||
static ShortcutManager provideShortcutManager(Context context) {
|
||||
return context.getSystemService(ShortcutManager.class);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@SysUISingleton
|
||||
@Singleton
|
||||
@Nullable
|
||||
static TelecomManager provideTelecomManager(Context context) {
|
||||
return context.getSystemService(TelecomManager.class);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@SysUISingleton
|
||||
@Singleton
|
||||
static TelephonyManager provideTelephonyManager(Context context) {
|
||||
return context.getSystemService(TelephonyManager.class);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@SysUISingleton
|
||||
@Singleton
|
||||
static TrustManager provideTrustManager(Context context) {
|
||||
return context.getSystemService(TrustManager.class);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@SysUISingleton
|
||||
@Singleton
|
||||
@Nullable
|
||||
static Vibrator provideVibrator(Context context) {
|
||||
return context.getSystemService(Vibrator.class);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@SysUISingleton
|
||||
@Singleton
|
||||
static ViewConfiguration provideViewConfiguration(Context context) {
|
||||
return ViewConfiguration.get(context);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@SysUISingleton
|
||||
@Singleton
|
||||
static UserManager provideUserManager(Context context) {
|
||||
return context.getSystemService(UserManager.class);
|
||||
}
|
||||
@@ -338,21 +332,15 @@ public class SystemServicesModule {
|
||||
}
|
||||
|
||||
@Provides
|
||||
@SysUISingleton
|
||||
@Singleton
|
||||
@Nullable
|
||||
static WifiManager provideWifiManager(Context context) {
|
||||
return context.getSystemService(WifiManager.class);
|
||||
}
|
||||
|
||||
@SysUISingleton
|
||||
@Provides
|
||||
@Singleton
|
||||
static WindowManager provideWindowManager(Context context) {
|
||||
return context.getSystemService(WindowManager.class);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@SysUISingleton
|
||||
static RoleManager provideRoleManager(Context context) {
|
||||
return context.getSystemService(RoleManager.class);
|
||||
}
|
||||
}
|
||||
@@ -16,63 +16,23 @@
|
||||
|
||||
package com.android.systemui.dagger;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.hardware.display.AmbientDisplayConfiguration;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.Choreographer;
|
||||
|
||||
import com.android.systemui.Prefs;
|
||||
import com.android.systemui.dagger.qualifiers.Main;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
|
||||
/**
|
||||
* Supplies globally scoped instances.
|
||||
* Supplies globally scoped instances that should be available in all versions of SystemUI
|
||||
*
|
||||
* Providers in this module will be accessible to both WMComponent and SysUIComponent scoped
|
||||
* classes. They are in here because they are either needed globally or are inherently universal
|
||||
* to the application.
|
||||
*
|
||||
* Note that just because a class might be used by both WM and SysUI does not necessarily mean that
|
||||
* it should got into this module. If WM and SysUI might need the class for different purposes
|
||||
* it should go into this module. If WM and SysUI might need the class for different purposes
|
||||
* or different semantics, it may make sense to ask them to supply their own. Something like
|
||||
* threading and concurrency provide a good example. Both components need
|
||||
* Threads/Handlers/Executors, but they need separate instances of them in many cases.
|
||||
*
|
||||
* Please use discretion when adding things to the global scope.
|
||||
*/
|
||||
@Module
|
||||
@Module(includes = {FrameworkServicesModule.class})
|
||||
public class GlobalModule {
|
||||
/** */
|
||||
@Provides
|
||||
@Main
|
||||
public SharedPreferences provideSharePreferences(Context context) {
|
||||
return Prefs.get(context);
|
||||
}
|
||||
|
||||
/** */
|
||||
@Provides
|
||||
public AmbientDisplayConfiguration provideAmbientDisplayConfiguration(Context context) {
|
||||
return new AmbientDisplayConfiguration(context);
|
||||
}
|
||||
|
||||
/** */
|
||||
@Provides
|
||||
@Singleton
|
||||
public Choreographer providesChoreographer() {
|
||||
return Choreographer.getInstance();
|
||||
}
|
||||
|
||||
/** */
|
||||
@Provides
|
||||
@Singleton
|
||||
public DisplayMetrics provideDisplayMetrics(Context context) {
|
||||
DisplayMetrics displayMetrics = new DisplayMetrics();
|
||||
context.getDisplay().getMetrics(displayMetrics);
|
||||
return displayMetrics;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ import dagger.Component;
|
||||
*/
|
||||
@Singleton
|
||||
@Component(modules = {
|
||||
GlobalModule.class,
|
||||
SysUISubcomponentModule.class,
|
||||
WMModule.class})
|
||||
public interface GlobalRootComponent {
|
||||
|
||||
@@ -37,7 +37,6 @@ import dagger.Subcomponent;
|
||||
DependencyProvider.class,
|
||||
DependencyBinder.class,
|
||||
PipModule.class,
|
||||
SystemServicesModule.class,
|
||||
SystemUIBinder.class,
|
||||
SystemUIModule.class,
|
||||
SystemUIDefaultModule.class})
|
||||
|
||||
@@ -16,7 +16,9 @@
|
||||
|
||||
package com.android.systemui.tv;
|
||||
|
||||
import com.android.systemui.dagger.GlobalModule;
|
||||
import com.android.systemui.dagger.GlobalRootComponent;
|
||||
import com.android.systemui.dagger.WMModule;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
|
||||
@@ -26,7 +28,11 @@ import dagger.Component;
|
||||
* Root component for Dagger injection.
|
||||
*/
|
||||
@Singleton
|
||||
@Component(modules = {TvSysUIComponentModule.class})
|
||||
@Component(modules = {
|
||||
GlobalModule.class,
|
||||
TvSysUIComponentModule.class,
|
||||
WMModule.class
|
||||
})
|
||||
public interface TvGlobalRootComponent extends GlobalRootComponent {
|
||||
/**
|
||||
* Component Builder interface. This allows to bind Context instance in the component
|
||||
|
||||
@@ -21,7 +21,6 @@ import com.android.systemui.dagger.DependencyBinder;
|
||||
import com.android.systemui.dagger.DependencyProvider;
|
||||
import com.android.systemui.dagger.SysUIComponent;
|
||||
import com.android.systemui.dagger.SysUISingleton;
|
||||
import com.android.systemui.dagger.SystemServicesModule;
|
||||
import com.android.systemui.dagger.SystemUIBinder;
|
||||
import com.android.systemui.dagger.SystemUIModule;
|
||||
|
||||
@@ -35,7 +34,6 @@ import dagger.Subcomponent;
|
||||
DefaultComponentBinder.class,
|
||||
DependencyProvider.class,
|
||||
DependencyBinder.class,
|
||||
SystemServicesModule.class,
|
||||
SystemUIBinder.class,
|
||||
SystemUIModule.class,
|
||||
TvSystemUIModule.class,
|
||||
|
||||
Reference in New Issue
Block a user