Merge "Remove contents of DependencyProvider." into tm-dev

This commit is contained in:
Dave Mankoff
2022-04-18 14:48:20 +00:00
committed by Android (Google) Code Review
26 changed files with 460 additions and 297 deletions

View File

@@ -28,6 +28,8 @@ import android.view.Display;
import com.android.internal.annotations.VisibleForTesting;
import com.android.systemui.dagger.SysUISingleton;
import javax.inject.Inject;
/**
* A class to control {@link MagnificationModeSwitch}. It shows the button UI with following
* conditions:
@@ -44,6 +46,7 @@ public class ModeSwitchesController implements SwitchListener {
private final DisplayIdIndexSupplier<MagnificationModeSwitch> mSwitchSupplier;
private SwitchListener mSwitchListenerDelegate;
@Inject
public ModeSwitchesController(Context context) {
mSwitchSupplier = new SwitchSupplier(context,
context.getSystemService(DisplayManager.class), this::onSwitch);

View File

@@ -31,10 +31,13 @@ import android.util.SparseArray
import com.android.internal.annotations.VisibleForTesting
import com.android.systemui.Dumpable
import com.android.systemui.broadcast.logging.BroadcastDispatcherLogger
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Background
import com.android.systemui.dump.DumpManager
import com.android.systemui.settings.UserTracker
import java.io.PrintWriter
import java.util.concurrent.Executor
import javax.inject.Inject
data class ReceiverData(
val receiver: BroadcastReceiver,
@@ -63,14 +66,15 @@ private const val DEBUG = true
* Broadcast handling may be asynchronous *without* calling goAsync(), as it's running within sysui
* and doesn't need to worry about being killed.
*/
open class BroadcastDispatcher @JvmOverloads constructor (
@SysUISingleton
open class BroadcastDispatcher @Inject constructor(
private val context: Context,
private val bgLooper: Looper,
private val bgExecutor: Executor,
@Background private val bgLooper: Looper,
@Background private val bgExecutor: Executor,
private val dumpManager: DumpManager,
private val logger: BroadcastDispatcherLogger,
private val userTracker: UserTracker,
private val removalPendingStore: PendingRemovalStore = PendingRemovalStore(logger)
private val removalPendingStore: PendingRemovalStore
) : Dumpable {
// Only modify in BG thread

View File

@@ -0,0 +1,34 @@
/*
* 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.broadcast;
import com.android.systemui.CoreStartable;
import dagger.Binds;
import dagger.Module;
import dagger.multibindings.ClassKey;
import dagger.multibindings.IntoMap;
/** */
@Module
public abstract class BroadcastDispatcherModule {
/** Ensures BroadcastDispatcher is initialized. */
@Binds
@IntoMap
@ClassKey(BroadcastDispatcherStartable.class)
abstract CoreStartable bindsBroadastDispatcherStartable(BroadcastDispatcherStartable s);
}

View File

@@ -0,0 +1,31 @@
/*
* 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.broadcast
import android.content.Context
import com.android.systemui.CoreStartable
import javax.inject.Inject
class BroadcastDispatcherStartable @Inject constructor(
context: Context,
val broadcastDispatcher: BroadcastDispatcher
) : CoreStartable(context) {
override fun start() {
broadcastDispatcher.initialize()
}
}

View File

@@ -8,6 +8,7 @@ import com.android.systemui.Dumpable
import com.android.systemui.broadcast.logging.BroadcastDispatcherLogger
import com.android.systemui.util.indentIfPossible
import java.io.PrintWriter
import javax.inject.Inject
/**
* Store information about requests for unregistering receivers from [BroadcastDispatcher], before
@@ -15,7 +16,7 @@ import java.io.PrintWriter
*
* This helps make unregistering a receiver a *sync* operation.
*/
class PendingRemovalStore(
class PendingRemovalStore @Inject constructor(
private val logger: BroadcastDispatcherLogger
) : Dumpable {
@GuardedBy("pendingRemoval")

View File

@@ -0,0 +1,53 @@
/*
* 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.dagger;
import android.content.Context;
import com.android.internal.logging.MetricsLogger;
import com.android.internal.util.NotificationMessagingUtil;
import com.android.internal.widget.LockPatternUtils;
import dagger.Module;
import dagger.Provides;
/**
* Provides items imported from com.android.internal.
*/
@Module
public class AndroidInternalsModule {
/** */
@Provides
@SysUISingleton
public LockPatternUtils provideLockPatternUtils(Context context) {
return new LockPatternUtils(context);
}
/** */
@Provides
@SysUISingleton
public MetricsLogger provideMetricsLogger() {
return new MetricsLogger();
}
/** */
@Provides
public NotificationMessagingUtil provideNotificationMessagingUtil(Context context) {
return new NotificationMessagingUtil(context);
}
}

View File

@@ -16,279 +16,24 @@
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;
import android.content.om.OverlayManager;
import android.hardware.display.AmbientDisplayConfiguration;
import android.hardware.display.ColorDisplayManager;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.Looper;
import android.os.ServiceManager;
import android.os.UserHandle;
import android.view.Choreographer;
import android.view.IWindowManager;
import android.view.LayoutInflater;
import com.android.internal.logging.MetricsLogger;
import com.android.internal.util.NotificationMessagingUtil;
import com.android.internal.widget.LockPatternUtils;
import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.keyguard.ViewMediatorCallback;
import com.android.settingslib.bluetooth.LocalBluetoothManager;
import com.android.systemui.Prefs;
import com.android.systemui.R;
import com.android.systemui.accessibility.AccessibilityButtonModeObserver;
import com.android.systemui.accessibility.AccessibilityButtonTargetsObserver;
import com.android.systemui.accessibility.ModeSwitchesController;
import com.android.systemui.accessibility.floatingmenu.AccessibilityFloatingMenuController;
import com.android.systemui.broadcast.BroadcastDispatcher;
import com.android.systemui.broadcast.logging.BroadcastDispatcherLogger;
import com.android.systemui.dagger.qualifiers.Background;
import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.doze.AlwaysOnDisplayPolicy;
import com.android.systemui.dump.DumpManager;
import com.android.systemui.keyguard.KeyguardViewMediator;
import com.android.systemui.qs.ReduceBrightColorsController;
import com.android.systemui.settings.UserTracker;
import com.android.systemui.shared.system.ActivityManagerWrapper;
import com.android.systemui.shared.system.DevicePolicyManagerWrapper;
import com.android.systemui.shared.system.TaskStackChangeListeners;
import com.android.systemui.shared.system.WindowManagerWrapper;
import com.android.systemui.statusbar.connectivity.NetworkController;
import com.android.systemui.statusbar.phone.AutoHideController;
import com.android.systemui.statusbar.phone.ConfigurationControllerImpl;
import com.android.systemui.statusbar.policy.ConfigurationController;
import com.android.systemui.statusbar.policy.DataSaverController;
import com.android.systemui.theme.ThemeOverlayApplier;
import com.android.systemui.util.leak.LeakDetector;
import com.android.systemui.util.settings.SecureSettings;
import java.util.concurrent.Executor;
import javax.inject.Named;
import com.android.systemui.broadcast.BroadcastDispatcherModule;
import com.android.systemui.theme.ThemeModule;
import com.android.systemui.util.leak.LeakModule;
import dagger.Module;
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 FrameworkServicesModule}.
*
* See SystemUI/docs/dagger.md
* @deprecated This module is going away. Don't put anything in here.
*/
@Module(includes = {NightDisplayListenerModule.class})
@Deprecated
@Module(includes = {
AndroidInternalsModule.class,
BroadcastDispatcherModule.class,
LeakModule.class,
NightDisplayListenerModule.class,
SharedLibraryModule.class,
SettingsLibraryModule.class,
ThemeModule.class
})
public class DependencyProvider {
/** */
@Provides
@SysUISingleton
@Named(TIME_TICK_HANDLER_NAME)
public Handler provideTimeTickHandler() {
HandlerThread thread = new HandlerThread("TimeTick");
thread.start();
return new Handler(thread.getLooper());
}
/** */
@Provides
@Main
public SharedPreferences provideSharePreferences(Context context) {
return Prefs.get(context);
}
/** */
@Provides
public AmbientDisplayConfiguration provideAmbientDisplayConfiguration(Context context) {
return new AmbientDisplayConfiguration(context);
}
/** */
@Provides
public Handler provideHandler() {
return new Handler();
}
/** */
@Provides
@SysUISingleton
public DataSaverController provideDataSaverController(NetworkController networkController) {
return networkController.getDataSaverController();
}
@Provides
@SysUISingleton
public INotificationManager provideINotificationManager() {
return INotificationManager.Stub.asInterface(
ServiceManager.getService(Context.NOTIFICATION_SERVICE));
}
/** */
@Provides
@SysUISingleton
public LayoutInflater providerLayoutInflater(Context context) {
return LayoutInflater.from(context);
}
/** */
@Provides
@SysUISingleton
public LeakDetector provideLeakDetector(DumpManager dumpManager) {
return LeakDetector.create(dumpManager);
}
@SuppressLint("MissingPermission")
@SysUISingleton
@Provides
@Nullable
static LocalBluetoothManager provideLocalBluetoothController(Context context,
@Background Handler bgHandler) {
return LocalBluetoothManager.create(context, bgHandler, UserHandle.ALL);
}
/** */
@Provides
@SysUISingleton
public MetricsLogger provideMetricsLogger() {
return new MetricsLogger();
}
/** */
@SysUISingleton
@Provides
static ThemeOverlayApplier provideThemeOverlayManager(Context context,
@Background Executor bgExecutor,
@Main Executor mainExecutor,
OverlayManager overlayManager,
DumpManager dumpManager) {
return new ThemeOverlayApplier(overlayManager, bgExecutor, mainExecutor,
context.getString(R.string.launcher_overlayable_package),
context.getString(R.string.themepicker_overlayable_package), dumpManager);
}
/** */
@Provides
@SysUISingleton
public AccessibilityFloatingMenuController provideAccessibilityFloatingMenuController(
Context context, AccessibilityButtonTargetsObserver accessibilityButtonTargetsObserver,
AccessibilityButtonModeObserver accessibilityButtonModeObserver,
KeyguardUpdateMonitor keyguardUpdateMonitor) {
return new AccessibilityFloatingMenuController(context, accessibilityButtonTargetsObserver,
accessibilityButtonModeObserver, keyguardUpdateMonitor);
}
/** */
@Provides
@SysUISingleton
public ConfigurationController provideConfigurationController(Context context) {
return new ConfigurationControllerImpl(context);
}
/** */
@SysUISingleton
@Provides
public AutoHideController provideAutoHideController(Context context,
@Main Handler mainHandler, IWindowManager iWindowManager) {
return new AutoHideController(context, mainHandler, iWindowManager);
}
/** */
@SysUISingleton
@Provides
public ReduceBrightColorsController provideReduceBrightColorsListener(
@Background Handler bgHandler, UserTracker userTracker,
ColorDisplayManager colorDisplayManager, SecureSettings secureSettings) {
return new ReduceBrightColorsController(userTracker, bgHandler,
colorDisplayManager, secureSettings);
}
@Provides
@SysUISingleton
public ActivityManagerWrapper provideActivityManagerWrapper() {
return ActivityManagerWrapper.getInstance();
}
/** */
@Provides
@SysUISingleton
public TaskStackChangeListeners provideTaskStackChangeListeners() {
return TaskStackChangeListeners.getInstance();
}
/** Provides and initializes the {#link BroadcastDispatcher} for SystemUI */
@Provides
@SysUISingleton
public BroadcastDispatcher providesBroadcastDispatcher(
Context context,
@Background Looper backgroundLooper,
@Background Executor backgroundExecutor,
DumpManager dumpManager,
BroadcastDispatcherLogger logger,
UserTracker userTracker
) {
BroadcastDispatcher bD = new BroadcastDispatcher(context, backgroundLooper,
backgroundExecutor, dumpManager, logger, userTracker);
bD.initialize();
return bD;
}
/** */
@Provides
@SysUISingleton
public DevicePolicyManagerWrapper provideDevicePolicyManagerWrapper() {
return DevicePolicyManagerWrapper.getInstance();
}
/** */
@Provides
@SysUISingleton
public LockPatternUtils provideLockPatternUtils(Context context) {
return new LockPatternUtils(context);
}
/** */
@Provides
@SysUISingleton
public AlwaysOnDisplayPolicy provideAlwaysOnDisplayPolicy(Context context) {
return new AlwaysOnDisplayPolicy(context);
}
/***/
@Provides
public NotificationMessagingUtil provideNotificationMessagingUtil(Context context) {
return new NotificationMessagingUtil(context);
}
/** */
@Provides
public ViewMediatorCallback providesViewMediatorCallback(KeyguardViewMediator viewMediator) {
return viewMediator.getViewMediatorCallback();
}
/** */
@Provides
public WindowManagerWrapper providesWindowManagerWrapper() {
return WindowManagerWrapper.getInstance();
}
/** */
@Provides
@SysUISingleton
public Choreographer providesChoreographer() {
return Choreographer.getInstance();
}
/** */
@Provides
@SysUISingleton
public ModeSwitchesController providesModeSwitchesController(Context context) {
return new ModeSwitchesController(context);
}
}

View File

@@ -22,6 +22,7 @@ import android.app.ActivityTaskManager;
import android.app.AlarmManager;
import android.app.IActivityManager;
import android.app.IActivityTaskManager;
import android.app.INotificationManager;
import android.app.IWallpaperManager;
import android.app.KeyguardManager;
import android.app.NotificationManager;
@@ -35,6 +36,7 @@ import android.app.trust.TrustManager;
import android.content.ClipboardManager;
import android.content.ContentResolver;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.om.OverlayManager;
import android.content.pm.IPackageManager;
import android.content.pm.LauncherApps;
@@ -44,6 +46,7 @@ import android.content.res.Resources;
import android.hardware.SensorManager;
import android.hardware.SensorPrivacyManager;
import android.hardware.devicestate.DeviceStateManager;
import android.hardware.display.AmbientDisplayConfiguration;
import android.hardware.display.ColorDisplayManager;
import android.hardware.display.DisplayManager;
import android.hardware.face.FaceManager;
@@ -68,8 +71,10 @@ import android.telecom.TelecomManager;
import android.telephony.CarrierConfigManager;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.view.Choreographer;
import android.view.CrossWindowBlurListeners;
import android.view.IWindowManager;
import android.view.LayoutInflater;
import android.view.ViewConfiguration;
import android.view.WindowManager;
import android.view.WindowManagerGlobal;
@@ -82,6 +87,7 @@ import com.android.internal.appwidget.IAppWidgetService;
import com.android.internal.jank.InteractionJankMonitor;
import com.android.internal.statusbar.IStatusBarService;
import com.android.internal.util.LatencyTracker;
import com.android.systemui.Prefs;
import com.android.systemui.dagger.qualifiers.DisplayId;
import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.shared.system.PackageManagerWrapper;
@@ -116,6 +122,12 @@ public class FrameworkServicesModule {
return context.getSystemService(AlarmManager.class);
}
/** */
@Provides
public AmbientDisplayConfiguration provideAmbientDisplayConfiguration(Context context) {
return new AmbientDisplayConfiguration(context);
}
@Provides
@Singleton
static AudioManager provideAudioManager(Context context) {
@@ -128,6 +140,13 @@ public class FrameworkServicesModule {
return context.getSystemService(CaptioningManager.class);
}
/** */
@Provides
@Singleton
public Choreographer providesChoreographer() {
return Choreographer.getInstance();
}
@Provides
@Singleton
static ColorDisplayManager provideColorDisplayManager(Context context) {
@@ -293,6 +312,13 @@ public class FrameworkServicesModule {
return context.getSystemService(LauncherApps.class);
}
/** */
@Provides
@Singleton
public LayoutInflater providerLayoutInflater(Context context) {
return LayoutInflater.from(context);
}
@Provides
static MediaRouter2Manager provideMediaRouter2Manager(Context context) {
return MediaRouter2Manager.getInstance(context);
@@ -315,6 +341,14 @@ public class FrameworkServicesModule {
return context.getSystemService(NotificationManager.class);
}
/** */
@Provides
@Singleton
public INotificationManager provideINotificationManager() {
return INotificationManager.Stub.asInterface(
ServiceManager.getService(Context.NOTIFICATION_SERVICE));
}
@Provides
@Singleton
static PackageManager providePackageManager(Context context) {
@@ -334,6 +368,13 @@ public class FrameworkServicesModule {
return context.getSystemService(PowerManager.class);
}
/** */
@Provides
@Main
public SharedPreferences provideSharePreferences(Context context) {
return Prefs.get(context);
}
/** */
@Provides
@Singleton

View File

@@ -0,0 +1,44 @@
/*
* 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.dagger;
import android.annotation.Nullable;
import android.annotation.SuppressLint;
import android.content.Context;
import android.os.Handler;
import android.os.UserHandle;
import com.android.settingslib.bluetooth.LocalBluetoothManager;
import com.android.systemui.dagger.qualifiers.Background;
import dagger.Module;
import dagger.Provides;
/** */
@Module
public class SettingsLibraryModule {
/** */
@SuppressLint("MissingPermission")
@SysUISingleton
@Provides
@Nullable
static LocalBluetoothManager provideLocalBluetoothController(Context context,
@Background Handler bgHandler) {
return LocalBluetoothManager.create(context, bgHandler, UserHandle.ALL);
}
}

View File

@@ -0,0 +1,58 @@
/*
* 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.dagger;
import com.android.systemui.shared.system.ActivityManagerWrapper;
import com.android.systemui.shared.system.DevicePolicyManagerWrapper;
import com.android.systemui.shared.system.TaskStackChangeListeners;
import com.android.systemui.shared.system.WindowManagerWrapper;
import dagger.Module;
import dagger.Provides;
/** */
@Module
public class SharedLibraryModule {
/** */
@Provides
@SysUISingleton
public ActivityManagerWrapper provideActivityManagerWrapper() {
return ActivityManagerWrapper.getInstance();
}
/** */
@Provides
@SysUISingleton
public DevicePolicyManagerWrapper provideDevicePolicyManagerWrapper() {
return DevicePolicyManagerWrapper.getInstance();
}
/** */
@Provides
@SysUISingleton
public TaskStackChangeListeners provideTaskStackChangeListeners() {
return TaskStackChangeListeners.getInstance();
}
/** */
@Provides
public WindowManagerWrapper providesWindowManagerWrapper() {
return WindowManagerWrapper.getInstance();
}
}

View File

@@ -29,11 +29,15 @@ import android.util.KeyValueListParser;
import android.util.Log;
import com.android.systemui.R;
import com.android.systemui.dagger.SysUISingleton;
import javax.inject.Inject;
/**
* Class to store the policy for AOD, which comes from
* {@link android.provider.Settings.Global}
*/
@SysUISingleton
public class AlwaysOnDisplayPolicy {
public static final String TAG = "AlwaysOnDisplayPolicy";
@@ -130,6 +134,7 @@ public class AlwaysOnDisplayPolicy {
private final Context mContext;
private SettingsObserver mSettingsObserver;
@Inject
public AlwaysOnDisplayPolicy(Context context) {
context = context.getApplicationContext();
mContext = context;

View File

@@ -25,6 +25,7 @@ import com.android.internal.widget.LockPatternUtils;
import com.android.keyguard.KeyguardDisplayManager;
import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.keyguard.KeyguardViewController;
import com.android.keyguard.ViewMediatorCallback;
import com.android.keyguard.dagger.KeyguardQsUserSwitchComponent;
import com.android.keyguard.dagger.KeyguardStatusBarViewComponent;
import com.android.keyguard.dagger.KeyguardStatusViewComponent;
@@ -127,4 +128,10 @@ public class KeyguardModule {
notificationShadeWindowController,
activityLaunchAnimator);
}
/** */
@Provides
public ViewMediatorCallback providesViewMediatorCallback(KeyguardViewMediator viewMediator) {
return viewMediator.getViewMediatorCallback();
}
}

View File

@@ -26,6 +26,7 @@ import android.provider.Settings;
import androidx.annotation.NonNull;
import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.dagger.qualifiers.Background;
import com.android.systemui.settings.UserTracker;
import com.android.systemui.statusbar.policy.CallbackController;
@@ -38,6 +39,7 @@ import javax.inject.Inject;
/**
* @hide
*/
@SysUISingleton
public class ReduceBrightColorsController implements
CallbackController<ReduceBrightColorsController.Listener> {
private final ColorDisplayManager mManager;

View File

@@ -23,12 +23,14 @@ import android.util.Log;
import android.view.IWindowManager;
import android.view.MotionEvent;
import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.statusbar.AutoHideUiElement;
import javax.inject.Inject;
/** A controller to control all auto-hide things. Also see {@link AutoHideUiElement}. */
@SysUISingleton
public class AutoHideController {
private static final String TAG = "AutoHideController";
private static final long AUTO_HIDE_TIMEOUT_MS = 2250;

View File

@@ -20,11 +20,14 @@ import android.content.res.Configuration
import android.graphics.Rect
import android.os.LocaleList
import android.view.View.LAYOUT_DIRECTION_RTL
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.statusbar.policy.ConfigurationController
import java.util.ArrayList
import javax.inject.Inject
class ConfigurationControllerImpl(context: Context) : ConfigurationController {
@SysUISingleton
class ConfigurationControllerImpl @Inject constructor(context: Context) : ConfigurationController {
private val listeners: MutableList<ConfigurationController.ConfigurationListener> = ArrayList()
private val lastConfig = Configuration()

View File

@@ -29,10 +29,13 @@ import com.android.systemui.statusbar.connectivity.AccessPointController;
import com.android.systemui.statusbar.connectivity.AccessPointControllerImpl;
import com.android.systemui.statusbar.connectivity.NetworkController;
import com.android.systemui.statusbar.connectivity.NetworkControllerImpl;
import com.android.systemui.statusbar.phone.ConfigurationControllerImpl;
import com.android.systemui.statusbar.policy.BluetoothController;
import com.android.systemui.statusbar.policy.BluetoothControllerImpl;
import com.android.systemui.statusbar.policy.CastController;
import com.android.systemui.statusbar.policy.CastControllerImpl;
import com.android.systemui.statusbar.policy.ConfigurationController;
import com.android.systemui.statusbar.policy.DataSaverController;
import com.android.systemui.statusbar.policy.DeviceControlsController;
import com.android.systemui.statusbar.policy.DeviceControlsControllerImpl;
import com.android.systemui.statusbar.policy.DevicePostureController;
@@ -83,6 +86,10 @@ public interface StatusBarPolicyModule {
@Binds
CastController provideCastController(CastControllerImpl controllerImpl);
/** */
@Binds
ConfigurationController bindConfigurationController(ConfigurationControllerImpl impl);
/** */
@Binds
ExtensionController provideExtensionController(ExtensionControllerImpl controllerImpl);
@@ -182,4 +189,11 @@ public interface StatusBarPolicyModule {
return resources.getStringArray(
R.array.config_perDeviceStateRotationLockDefaults);
}
/** */
@Provides
@SysUISingleton
static DataSaverController provideDataSaverController(NetworkController networkController) {
return networkController.getDataSaverController();
}
}

View File

@@ -0,0 +1,49 @@
/*
* 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.theme;
import android.content.res.Resources;
import com.android.systemui.R;
import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.util.concurrency.SysUIConcurrencyModule;
import javax.inject.Named;
import dagger.Module;
import dagger.Provides;
/** */
@Module(includes = {SysUIConcurrencyModule.class})
public class ThemeModule {
static final String LAUNCHER_PACKAGE = "theme_launcher_package";
static final String THEME_PICKER_PACKAGE = "theme_picker_package";
/** */
@Provides
@Named(LAUNCHER_PACKAGE)
static String provideLauncherPackage(@Main Resources resources) {
return resources.getString(R.string.launcher_overlayable_package);
}
/** */
@Provides
@Named(THEME_PICKER_PACKAGE)
static String provideThemePickerPackage(@Main Resources resources) {
return resources.getString(R.string.themepicker_overlayable_package);
}
}

View File

@@ -31,6 +31,7 @@ import androidx.annotation.VisibleForTesting;
import com.android.systemui.Dumpable;
import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.dagger.qualifiers.Background;
import com.android.systemui.dump.DumpManager;
import com.google.android.collect.Lists;
@@ -45,6 +46,9 @@ import java.util.Set;
import java.util.concurrent.Executor;
import java.util.stream.Collectors;
import javax.inject.Inject;
import javax.inject.Named;
/**
* Responsible for orchestrating overlays, based on user preferences and other inputs from
* {@link ThemeOverlayController}.
@@ -134,17 +138,17 @@ public class ThemeOverlayApplier implements Dumpable {
private final Map<String, String> mCategoryToTargetPackage = new ArrayMap<>();
private final OverlayManager mOverlayManager;
private final Executor mBgExecutor;
private final Executor mMainExecutor;
private final String mLauncherPackage;
private final String mThemePickerPackage;
@Inject
public ThemeOverlayApplier(OverlayManager overlayManager,
Executor bgExecutor,
Executor mainExecutor,
String launcherPackage, String themePickerPackage, DumpManager dumpManager) {
@Background Executor bgExecutor,
@Named(ThemeModule.LAUNCHER_PACKAGE) String launcherPackage,
@Named(ThemeModule.THEME_PICKER_PACKAGE) String themePickerPackage,
DumpManager dumpManager) {
mOverlayManager = overlayManager;
mBgExecutor = bgExecutor;
mMainExecutor = mainExecutor;
mLauncherPackage = launcherPackage;
mThemePickerPackage = themePickerPackage;
mTargetPackageToCategories.put(ANDROID_PACKAGE, Sets.newHashSet(

View File

@@ -63,6 +63,15 @@ public abstract class GlobalConcurrencyModule {
return new Handler(mainLooper);
}
/**
* @deprecated Use @Main Handler.
*/
@Deprecated
@Provides
public static Handler provideHandler() {
return new Handler();
}
/**
* Provide a Main-Thread Executor.
*/

View File

@@ -16,6 +16,8 @@
package com.android.systemui.util.concurrency;
import static com.android.systemui.Dependency.TIME_TICK_HANDLER_NAME;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.Looper;
@@ -28,6 +30,8 @@ import com.android.systemui.dagger.qualifiers.Main;
import java.util.concurrent.Executor;
import javax.inject.Named;
import dagger.Module;
import dagger.Provides;
@@ -162,4 +166,14 @@ public abstract class SysUIConcurrencyModule {
@Background DelayableExecutor executor) {
return new MessageRouterImpl(executor);
}
/** */
@Provides
@SysUISingleton
@Named(TIME_TICK_HANDLER_NAME)
public static Handler provideTimeTickHandler() {
HandlerThread thread = new HandlerThread("TimeTick");
thread.start();
return new Handler(thread.getLooper());
}
}

View File

@@ -17,9 +17,9 @@
package com.android.systemui.util.leak;
import android.os.Build;
import android.util.IndentingPrintWriter;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.util.IndentingPrintWriter;
import com.android.systemui.Dumpable;
import com.android.systemui.dump.DumpManager;
@@ -133,17 +133,4 @@ public class LeakDetector implements Dumpable {
pw.decreaseIndent();
pw.println();
}
public static LeakDetector create(DumpManager dumpManager) {
if (ENABLED) {
TrackedCollections collections = new TrackedCollections();
return new LeakDetector(
collections,
new TrackedGarbage(collections),
new TrackedObjects(collections),
dumpManager);
} else {
return new LeakDetector(null, null, null, dumpManager);
}
}
}

View File

@@ -0,0 +1,42 @@
/*
* 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.util.leak;
import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.dump.DumpManager;
import com.android.systemui.util.Compile;
import dagger.Module;
import dagger.Provides;
/** */
@Module
public class LeakModule {
@Provides
@SysUISingleton
LeakDetector providesLeakDetector(DumpManager dumpManager, TrackedCollections collections) {
if (Compile.IS_DEBUG) {
return new LeakDetector(
collections,
new TrackedGarbage(collections),
new TrackedObjects(collections),
dumpManager);
} else {
return new LeakDetector(null, null, null, dumpManager);
}
}
}

View File

@@ -24,6 +24,8 @@ import java.util.Collection;
import java.util.Map;
import java.util.function.Predicate;
import javax.inject.Inject;
/**
* Tracks the size of collections.
*/
@@ -34,6 +36,10 @@ public class TrackedCollections {
private final WeakIdentityHashMap<Collection<?>, CollectionState> mCollections
= new WeakIdentityHashMap<>();
@Inject
TrackedCollections() {
}
/**
* @see LeakDetector#trackCollection(Collection, String)
*/

View File

@@ -37,7 +37,8 @@ class FakeBroadcastDispatcher(
dumpManager: DumpManager,
logger: BroadcastDispatcherLogger,
userTracker: UserTracker
) : BroadcastDispatcher(context, looper, executor, dumpManager, logger, userTracker) {
) : BroadcastDispatcher(
context, looper, executor, dumpManager, logger, userTracker, PendingRemovalStore(logger)) {
private val registeredReceivers = ArraySet<BroadcastReceiver>()

View File

@@ -104,7 +104,7 @@ public class ThemeOverlayApplierTest extends SysuiTestCase {
public void setup() throws Exception {
MockitoAnnotations.initMocks(this);
mManager = new ThemeOverlayApplier(mOverlayManager,
MoreExecutors.directExecutor(), MoreExecutors.directExecutor(),
MoreExecutors.directExecutor(),
LAUNCHER_PACKAGE, THEMEPICKER_PACKAGE, mDumpManager) {
@Override
protected OverlayManagerTransaction.Builder getTransactionBuilder() {

View File

@@ -52,6 +52,8 @@ public class LeakDetectorTest extends SysuiTestCase {
private Object mObject;
private Collection<?> mCollection;
private CollectionWaiter trackObjectWith(Consumer<Object> tracker) {
mObject = new Object();
CollectionWaiter collectionWaiter = ReferenceTestUtils.createCollectionWaiter(mObject);
@@ -69,7 +71,9 @@ public class LeakDetectorTest extends SysuiTestCase {
@Before
public void setup() {
mLeakDetector = LeakDetector.create(Mockito.mock(DumpManager.class));
TrackedCollections collections = new TrackedCollections();
mLeakDetector = new LeakDetector(collections, new TrackedGarbage(collections),
new TrackedObjects(collections), Mockito.mock(DumpManager.class));
// Note: Do not try to factor out object / collection waiter creation. The optimizer will
// try and cache accesses to fields and thus create a GC root for the duration of the test