Merge "Move StatusBar to constructor injection."

This commit is contained in:
Dave Mankoff
2019-10-04 14:24:55 +00:00
committed by Android (Google) Code Review
13 changed files with 506 additions and 399 deletions

View File

@@ -29,6 +29,7 @@ import com.android.systemui.power.EnhancedEstimates;
import com.android.systemui.power.EnhancedEstimatesImpl;
import com.android.systemui.statusbar.NotificationLockscreenUserManager;
import com.android.systemui.statusbar.NotificationLockscreenUserManagerImpl;
import com.android.systemui.statusbar.car.CarStatusBar;
import com.android.systemui.statusbar.notification.NotificationEntryManager;
import com.android.systemui.statusbar.notification.NotificationInterruptionStateProvider;
import com.android.systemui.statusbar.notification.collection.NotificationData;
@@ -42,6 +43,8 @@ import javax.inject.Singleton;
import dagger.Binds;
import dagger.Module;
import dagger.Provides;
import dagger.multibindings.ClassKey;
import dagger.multibindings.IntoMap;
@Module
abstract class CarSystemUIModule {
@@ -94,4 +97,9 @@ abstract class CarSystemUIModule {
@Binds
abstract SystemUIRootComponent bindSystemUIRootComponent(
CarSystemUIRootComponent systemUIRootComponent);
@Binds
@IntoMap
@ClassKey(StatusBar.class)
public abstract SystemUI providesStatusBar(CarStatusBar statusBar);
}

View File

@@ -16,6 +16,8 @@
package com.android.systemui.statusbar.car;
import static com.android.systemui.Dependency.ALLOW_NOTIFICATION_LONG_PRESS_NAME;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ValueAnimator;
@@ -34,6 +36,7 @@ import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.inputmethodservice.InputMethodService;
import android.os.IBinder;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.Display;
import android.view.GestureDetector;
@@ -57,36 +60,83 @@ import com.android.car.notification.NotificationClickHandlerFactory;
import com.android.car.notification.NotificationDataManager;
import com.android.car.notification.NotificationViewController;
import com.android.car.notification.PreprocessingManager;
import com.android.internal.logging.MetricsLogger;
import com.android.internal.statusbar.RegisterStatusBarResult;
import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.systemui.BatteryMeterView;
import com.android.systemui.CarSystemUIFactory;
import com.android.systemui.Dependency;
import com.android.systemui.ForegroundServiceController;
import com.android.systemui.Prefs;
import com.android.systemui.R;
import com.android.systemui.SystemUIFactory;
import com.android.systemui.UiOffloadThread;
import com.android.systemui.appops.AppOpsController;
import com.android.systemui.assist.AssistManager;
import com.android.systemui.broadcast.BroadcastDispatcher;
import com.android.systemui.bubbles.BubbleController;
import com.android.systemui.classifier.FalsingLog;
import com.android.systemui.colorextraction.SysuiColorExtractor;
import com.android.systemui.doze.DozeLog;
import com.android.systemui.fragments.FragmentHostManager;
import com.android.systemui.keyguard.KeyguardViewMediator;
import com.android.systemui.keyguard.ScreenLifecycle;
import com.android.systemui.keyguard.WakefulnessLifecycle;
import com.android.systemui.plugins.FalsingManager;
import com.android.systemui.plugins.qs.QS;
import com.android.systemui.qs.car.CarQSFragment;
import com.android.systemui.shared.system.ActivityManagerWrapper;
import com.android.systemui.shared.system.TaskStackChangeListener;
import com.android.systemui.statusbar.FlingAnimationUtils;
import com.android.systemui.statusbar.NavigationBarController;
import com.android.systemui.statusbar.NotificationListener;
import com.android.systemui.statusbar.NotificationLockscreenUserManager;
import com.android.systemui.statusbar.NotificationMediaManager;
import com.android.systemui.statusbar.NotificationRemoteInputManager;
import com.android.systemui.statusbar.NotificationViewHierarchyManager;
import com.android.systemui.statusbar.PulseExpansionHandler;
import com.android.systemui.statusbar.StatusBarState;
import com.android.systemui.statusbar.SysuiStatusBarStateController;
import com.android.systemui.statusbar.VibratorHelper;
import com.android.systemui.statusbar.car.hvac.HvacController;
import com.android.systemui.statusbar.car.hvac.TemperatureView;
import com.android.systemui.statusbar.notification.BypassHeadsUpNotifier;
import com.android.systemui.statusbar.notification.DynamicPrivacyController;
import com.android.systemui.statusbar.notification.NotifPipelineInitializer;
import com.android.systemui.statusbar.notification.NotificationAlertingManager;
import com.android.systemui.statusbar.notification.NotificationEntryManager;
import com.android.systemui.statusbar.notification.NotificationInterruptionStateProvider;
import com.android.systemui.statusbar.notification.NotificationWakeUpCoordinator;
import com.android.systemui.statusbar.notification.VisualStabilityManager;
import com.android.systemui.statusbar.notification.logging.NotificationLogger;
import com.android.systemui.statusbar.notification.row.NotificationGutsManager;
import com.android.systemui.statusbar.phone.AutoHideController;
import com.android.systemui.statusbar.phone.CollapsedStatusBarFragment;
import com.android.systemui.statusbar.phone.HeadsUpManagerPhone;
import com.android.systemui.statusbar.phone.KeyguardBypassController;
import com.android.systemui.statusbar.phone.LightBarController;
import com.android.systemui.statusbar.phone.NotificationGroupAlertTransferHelper;
import com.android.systemui.statusbar.phone.NotificationGroupManager;
import com.android.systemui.statusbar.phone.StatusBar;
import com.android.systemui.statusbar.phone.StatusBarIconController;
import com.android.systemui.statusbar.phone.StatusBarWindowController;
import com.android.systemui.statusbar.policy.BatteryController;
import com.android.systemui.statusbar.policy.ConfigurationController;
import com.android.systemui.statusbar.policy.DeviceProvisionedController;
import com.android.systemui.statusbar.policy.KeyguardStateController;
import com.android.systemui.statusbar.policy.NetworkController;
import com.android.systemui.statusbar.policy.RemoteInputQuickSettingsDisabler;
import com.android.systemui.statusbar.policy.UserSwitcherController;
import com.android.systemui.statusbar.policy.ZenModeController;
import com.android.systemui.util.InjectionInflationController;
import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.util.Map;
import javax.inject.Inject;
import javax.inject.Named;
/**
* A status bar (and navigation bar) tailored for the automotive use case.
*/
@@ -175,6 +225,8 @@ public class CarStatusBar extends StatusBar implements CarBatteryController.Batt
private boolean mHideNavBarForKeyboard;
private boolean mBottomNavBarVisible;
private final NavigationBarController mNavigationBarController;
private final CarPowerStateListener mCarPowerStateListener =
(int state) -> {
// When the car powers on, clear all notifications and mute/unread states.
@@ -189,6 +241,116 @@ public class CarStatusBar extends StatusBar implements CarBatteryController.Batt
}
};
@Inject
public CarStatusBar(
LightBarController lightBarController,
AutoHideController autoHideController,
KeyguardUpdateMonitor keyguardUpdateMonitor,
StatusBarIconController statusBarIconController,
DozeLog dozeLog,
InjectionInflationController injectionInflationController,
PulseExpansionHandler pulseExpansionHandler,
NotificationWakeUpCoordinator notificationWakeUpCoordinator,
KeyguardBypassController keyguardBypassController,
KeyguardStateController keyguardStateController,
HeadsUpManagerPhone headsUpManagerPhone,
DynamicPrivacyController dynamicPrivacyController,
BypassHeadsUpNotifier bypassHeadsUpNotifier,
@Named(ALLOW_NOTIFICATION_LONG_PRESS_NAME) boolean allowNotificationLongPress,
NotifPipelineInitializer notifPipelineInitializer,
FalsingManager falsingManager,
BroadcastDispatcher broadcastDispatcher,
RemoteInputQuickSettingsDisabler remoteInputQuickSettingsDisabler,
NotificationGutsManager notificationGutsManager,
NotificationLogger notificationLogger,
NotificationEntryManager notificationEntryManager,
NotificationInterruptionStateProvider notificationInterruptionStateProvider,
NotificationViewHierarchyManager notificationViewHierarchyManager,
ForegroundServiceController foregroundServiceController,
AppOpsController appOpsController,
KeyguardViewMediator keyguardViewMediator,
ZenModeController zenModeController,
NotificationAlertingManager notificationAlertingManager,
DisplayMetrics displayMetrics,
MetricsLogger metricsLogger,
UiOffloadThread uiOffloadThread,
NotificationMediaManager notificationMediaManager,
NotificationLockscreenUserManager lockScreenUserManager,
NotificationRemoteInputManager remoteInputManager,
UserSwitcherController userSwitcherController,
NetworkController networkController,
BatteryController batteryController,
SysuiColorExtractor colorExtractor,
ScreenLifecycle screenLifecycle,
WakefulnessLifecycle wakefulnessLifecycle,
SysuiStatusBarStateController statusBarStateController,
VibratorHelper vibratorHelper,
BubbleController bubbleController,
NotificationGroupManager groupManager,
NotificationGroupAlertTransferHelper groupAlertTransferHelper,
VisualStabilityManager visualStabilityManager,
DeviceProvisionedController deviceProvisionedController,
NavigationBarController navigationBarController,
AssistManager assistManager,
NotificationListener notificationListener,
ConfigurationController configurationController,
StatusBarWindowController statusBarWindowController) {
super(
lightBarController,
autoHideController,
keyguardUpdateMonitor,
statusBarIconController,
dozeLog,
injectionInflationController,
pulseExpansionHandler,
notificationWakeUpCoordinator,
keyguardBypassController,
keyguardStateController,
headsUpManagerPhone,
dynamicPrivacyController,
bypassHeadsUpNotifier,
allowNotificationLongPress,
notifPipelineInitializer,
falsingManager,
broadcastDispatcher,
remoteInputQuickSettingsDisabler,
notificationGutsManager,
notificationLogger,
notificationEntryManager,
notificationInterruptionStateProvider,
notificationViewHierarchyManager,
foregroundServiceController,
appOpsController,
keyguardViewMediator,
zenModeController,
notificationAlertingManager,
displayMetrics,
metricsLogger,
uiOffloadThread,
notificationMediaManager,
lockScreenUserManager,
remoteInputManager,
userSwitcherController,
networkController,
batteryController,
colorExtractor,
screenLifecycle,
wakefulnessLifecycle,
statusBarStateController,
vibratorHelper,
bubbleController,
groupManager,
groupAlertTransferHelper,
visualStabilityManager,
deviceProvisionedController,
navigationBarController,
assistManager,
notificationListener,
configurationController,
statusBarWindowController);
mNavigationBarController = navigationBarController;
}
@Override
public void start() {
// get the provisioned state before calling the parent class since it's that flow that

View File

@@ -104,12 +104,6 @@ it should be shown.
Shows the drag handle for the divider between two apps when in split screen
mode.
### [com.android.systemui.SystemBars](/packages/SystemUI/src/com/android/systemui/SystemBars.java)
This is a proxy to the actual SystemUI for the status bar. This loads from
config_statusBarComponent which defaults to StatusBar. (maybe this should be
removed and copy how config_systemUiVendorServiceComponent works)
### [com.android.systemui.status.phone.StatusBar](/packages/SystemUI/src/com/android/systemui/status/phone/StatusBar.java)
This shows the UI for the status bar and the notification shade it contains.

View File

@@ -279,7 +279,7 @@
<item>com.android.systemui.recents.Recents</item>
<item>com.android.systemui.volume.VolumeUI</item>
<item>com.android.systemui.stackdivider.Divider</item>
<item>com.android.systemui.SystemBars</item>
<item>com.android.systemui.statusbar.phone.StatusBar</item>
<item>com.android.systemui.usb.StorageNotification</item>
<item>com.android.systemui.power.PowerUI</item>
<item>com.android.systemui.media.RingtonePlayer</item>

View File

@@ -197,6 +197,12 @@ public abstract class DependencyBinder {
public abstract StatusBarStateController provideStatusBarStateController(
StatusBarStateControllerImpl controllerImpl);
/**
*/
@Binds
public abstract SysuiStatusBarStateController providesSysuiStatusBarStateController(
StatusBarStateControllerImpl statusBarStateControllerImpl);
/**
*/
@Binds
@@ -235,10 +241,4 @@ public abstract class DependencyBinder {
*/
@Binds
public abstract FalsingManager provideFalsingmanager(FalsingManagerProxy falsingManagerImpl);
/**
*/
@Binds
public abstract SysuiStatusBarStateController providesSysuiStatusBarStateController(
StatusBarStateControllerImpl statusBarStateControllerImpl);
}

View File

@@ -40,6 +40,7 @@ import android.view.WindowManagerGlobal;
import com.android.internal.logging.MetricsLogger;
import com.android.internal.statusbar.IStatusBarService;
import com.android.internal.widget.LockPatternUtils;
import com.android.settingslib.bluetooth.LocalBluetoothManager;
import com.android.systemui.plugins.PluginInitializerImpl;
import com.android.systemui.shared.plugins.PluginManager;
@@ -238,4 +239,10 @@ public class DependencyProvider {
public AlarmManager provideAlarmManager(Context context) {
return context.getSystemService(AlarmManager.class);
}
/** */
@Provides
public LockPatternUtils provideLockPatternUtils(Context context) {
return new LockPatternUtils(context);
}
}

View File

@@ -1,88 +0,0 @@
/*
* Copyright (C) 2017 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.util.Log;
import com.android.systemui.statusbar.phone.StatusBar;
import java.io.FileDescriptor;
import java.io.PrintWriter;
/**
* Ensure a single status bar service implementation is running at all times, using the in-process
* implementation according to the product config.
*/
public class SystemBars extends SystemUI {
private static final String TAG = "SystemBars";
private static final boolean DEBUG = false;
private static final int WAIT_FOR_BARS_TO_DIE = 500;
// in-process fallback implementation, per the product config
private SystemUI mStatusBar;
@Override
public void start() {
if (DEBUG) Log.d(TAG, "start");
createStatusBarFromConfig();
}
@Override
public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
if (mStatusBar != null) {
mStatusBar.dump(fd, pw, args);
}
}
@Override
public void onBootCompleted() {
if (mStatusBar != null) {
mStatusBar.onBootCompleted();
}
}
private void createStatusBarFromConfig() {
if (DEBUG) Log.d(TAG, "createStatusBarFromConfig");
final String clsName = mContext.getString(R.string.config_statusBarComponent);
if (clsName == null || clsName.length() == 0) {
throw andLog("No status bar component configured", null);
}
Class<?> cls = null;
try {
cls = mContext.getClassLoader().loadClass(clsName);
} catch (Throwable t) {
throw andLog("Error loading status bar component: " + clsName, t);
}
try {
mStatusBar = (SystemUI) cls.newInstance();
} catch (Throwable t) {
throw andLog("Error creating status bar component: " + clsName, t);
}
mStatusBar.mContext = mContext;
mStatusBar.mComponents = mComponents;
if (mStatusBar instanceof StatusBar) {
SystemUIFactory.getInstance().getRootComponent()
.getStatusBarInjector()
.createStatusBar((StatusBar) mStatusBar);
}
mStatusBar.start();
if (DEBUG) Log.d(TAG, "started " + mStatusBar.getClass().getSimpleName());
}
private RuntimeException andLog(String msg, Throwable t) {
Log.w(TAG, msg, t);
throw new RuntimeException(msg, t);
}
}

View File

@@ -44,7 +44,7 @@ public abstract class SystemUIBinder {
@ClassKey(PowerUI.class)
public abstract SystemUI bindPowerUI(PowerUI sysui);
/** Inject into StatusBar. */
/** Inject into Recents. */
@Binds
@IntoMap
@ClassKey(Recents.class)

View File

@@ -40,6 +40,8 @@ import javax.inject.Singleton;
import dagger.Binds;
import dagger.Module;
import dagger.Provides;
import dagger.multibindings.ClassKey;
import dagger.multibindings.IntoMap;
/**
* A dagger module for injecting default implementations of components of System UI that may be
@@ -76,6 +78,11 @@ abstract class SystemUIDefaultModule {
return SysUiServiceProvider.getComponent(context, StatusBar.class);
}
@Binds
@IntoMap
@ClassKey(StatusBar.class)
public abstract SystemUI providesStatusBar(StatusBar statusBar);
@Singleton
@Provides
@Named(ALLOW_NOTIFICATION_LONG_PRESS_NAME)

View File

@@ -37,7 +37,7 @@ import java.util.Locale;
* adb shell setprop debug.falsing_log true
*
* The log gets dumped as part of the SystemUI services. To dump on demand:
* adb shell dumpsys activity service com.android.systemui SystemBars | grep -A 999 FALSING | less
* adb shell dumpsys activity service com.android.systemui StatusBar | grep -A 999 FALSING | less
*
* To dump into logcat:
* adb shell setprop debug.falsing_logcat true

View File

@@ -234,7 +234,7 @@ public class KeyguardViewMediator extends SystemUI {
*/
private PowerManager.WakeLock mShowKeyguardWakeLock;
private StatusBarKeyguardViewManager mStatusBarKeyguardViewManager;
private final StatusBarKeyguardViewManager mStatusBarKeyguardViewManager;
// these are protected by synchronized (this)
@@ -317,7 +317,7 @@ public class KeyguardViewMediator extends SystemUI {
* the keyguard.
*/
private boolean mWaitingUntilKeyguardVisible = false;
private LockPatternUtils mLockPatternUtils;
private final LockPatternUtils mLockPatternUtils;
private boolean mKeyguardDonePending = false;
private boolean mHideAnimationRun = false;
private boolean mHideAnimationRunning = false;
@@ -681,10 +681,21 @@ public class KeyguardViewMediator extends SystemUI {
};
@Inject
public KeyguardViewMediator(FalsingManager falsingManager) {
public KeyguardViewMediator(
Context context,
FalsingManager falsingManager,
LockPatternUtils lockPatternUtils) {
super();
mContext = context;
mFalsingManager = falsingManager;
mLockPatternUtils = lockPatternUtils;
mStatusBarKeyguardViewManager =
SystemUIFactory.getInstance().createStatusBarKeyguardViewManager(
mContext,
mViewMediatorCallback,
mLockPatternUtils);
}
public void userActivity() {
@@ -722,7 +733,6 @@ public class KeyguardViewMediator extends SystemUI {
mUpdateMonitor = Dependency.get(KeyguardUpdateMonitor.class);
mLockPatternUtils = new LockPatternUtils(mContext);
KeyguardUpdateMonitor.setCurrentUser(ActivityManager.getCurrentUser());
// Assume keyguard is showing (unless it's disabled) until we know for sure, unless Keyguard
@@ -736,9 +746,6 @@ public class KeyguardViewMediator extends SystemUI {
setShowingLocked(false /* showing */, true /* forceCallbacks */);
}
mStatusBarKeyguardViewManager =
SystemUIFactory.getInstance().createStatusBarKeyguardViewManager(mContext,
mViewMediatorCallback, mLockPatternUtils);
final ContentResolver cr = mContext.getContentResolver();
mDeviceInteractive = mPM.isInteractive();

View File

@@ -347,10 +347,9 @@ public class StatusBar extends SystemUI implements DemoMode,
private BrightnessMirrorController mBrightnessMirrorController;
private boolean mBrightnessMirrorVisible;
protected BiometricUnlockController mBiometricUnlockController;
@Inject LightBarController mLightBarController;
private final LightBarController mLightBarController;
protected LockscreenWallpaper mLockscreenWallpaper;
@VisibleForTesting
@Inject AutoHideController mAutoHideController;
private final AutoHideController mAutoHideController;
private int mNaturalBarHeight = -1;
@@ -360,8 +359,7 @@ public class StatusBar extends SystemUI implements DemoMode,
protected PhoneStatusBarView mStatusBarView;
private int mStatusBarWindowState = WINDOW_STATE_SHOWING;
protected StatusBarWindowController mStatusBarWindowController;
@VisibleForTesting
@Inject KeyguardUpdateMonitor mKeyguardUpdateMonitor;
private final KeyguardUpdateMonitor mKeyguardUpdateMonitor;
@VisibleForTesting
DozeServiceHost mDozeServiceHost = new DozeServiceHost();
private boolean mWakeUpComingFromTouch;
@@ -369,38 +367,21 @@ public class StatusBar extends SystemUI implements DemoMode,
private final Object mQueueLock = new Object();
@Inject StatusBarIconController mIconController;
@Inject
DozeLog mDozeLog;
@Inject
InjectionInflationController mInjectionInflater;
@Inject
PulseExpansionHandler mPulseExpansionHandler;
@Inject
NotificationWakeUpCoordinator mWakeUpCoordinator;
@Inject
KeyguardBypassController mKeyguardBypassController;
@Inject
KeyguardStateController mKeyguardStateController;
@Inject
protected HeadsUpManagerPhone mHeadsUpManager;
@Inject
DynamicPrivacyController mDynamicPrivacyController;
@Inject
BypassHeadsUpNotifier mBypassHeadsUpNotifier;
@Nullable
@Inject
protected KeyguardLiftController mKeyguardLiftController;
@Inject
@Named(ALLOW_NOTIFICATION_LONG_PRESS_NAME)
boolean mAllowNotificationLongPress;
@Inject
protected NotifPipelineInitializer mNotifPipelineInitializer;
@Inject
protected FalsingManager mFalsingManager;
@VisibleForTesting
@Inject BroadcastDispatcher mBroadcastDispatcher;
private final StatusBarIconController mIconController;
private final DozeLog mDozeLog;
private final InjectionInflationController mInjectionInflater;
private final PulseExpansionHandler mPulseExpansionHandler;
private final NotificationWakeUpCoordinator mWakeUpCoordinator;
private final KeyguardBypassController mKeyguardBypassController;
private final KeyguardStateController mKeyguardStateController;
private final HeadsUpManagerPhone mHeadsUpManager;
private final DynamicPrivacyController mDynamicPrivacyController;
private final BypassHeadsUpNotifier mBypassHeadsUpNotifier;
private final boolean mAllowNotificationLongPress;
private final NotifPipelineInitializer mNotifPipelineInitializer;
private final FalsingManager mFalsingManager;
private final BroadcastDispatcher mBroadcastDispatcher;
private final ConfigurationController mConfigurationController;
// expanded notifications
protected NotificationPanelView mNotificationPanel; // the sliding/resizing panel within the notification window
@@ -413,7 +394,7 @@ public class StatusBar extends SystemUI implements DemoMode,
// RemoteInputView to be activated after unlock
private View mPendingRemoteInputView;
@Inject RemoteInputQuickSettingsDisabler mRemoteInputQuickSettingsDisabler;
private final RemoteInputQuickSettingsDisabler mRemoteInputQuickSettingsDisabler;
private View mReportRejectedTouch;
@@ -422,17 +403,17 @@ public class StatusBar extends SystemUI implements DemoMode,
private final int[] mAbsPos = new int[2];
private final ArrayList<Runnable> mPostCollapseRunnables = new ArrayList<>();
@Inject NotificationGutsManager mGutsManager;
@Inject NotificationLogger mNotificationLogger;
@Inject NotificationEntryManager mEntryManager;
private final NotificationGutsManager mGutsManager;
private final NotificationLogger mNotificationLogger;
private final NotificationEntryManager mEntryManager;
private NotificationListController mNotificationListController;
@Inject NotificationInterruptionStateProvider mNotificationInterruptionStateProvider;
@Inject NotificationViewHierarchyManager mViewHierarchyManager;
@Inject ForegroundServiceController mForegroundServiceController;
@Inject AppOpsController mAppOpsController;
@Inject KeyguardViewMediator mKeyguardViewMediator;
@Inject ZenModeController mZenController;
@Inject NotificationAlertingManager mNotificationAlertingManager;
private final NotificationInterruptionStateProvider mNotificationInterruptionStateProvider;
private final NotificationViewHierarchyManager mViewHierarchyManager;
private final ForegroundServiceController mForegroundServiceController;
private final AppOpsController mAppOpsController;
private final KeyguardViewMediator mKeyguardViewMediator;
private final ZenModeController mZenController;
private final NotificationAlertingManager mNotificationAlertingManager;
// for disabling the status bar
private int mDisabled1 = 0;
@@ -443,7 +424,7 @@ public class StatusBar extends SystemUI implements DemoMode,
private final Rect mLastFullscreenStackBounds = new Rect();
private final Rect mLastDockedStackBounds = new Rect();
@Inject DisplayMetrics mDisplayMetrics;
private final DisplayMetrics mDisplayMetrics;
// XXX: gesture research
private final GestureRecorder mGestureRec = DEBUG_GESTURES
@@ -452,7 +433,7 @@ public class StatusBar extends SystemUI implements DemoMode,
private ScreenPinningRequest mScreenPinningRequest;
@Inject MetricsLogger mMetricsLogger;
private final MetricsLogger mMetricsLogger;
// ensure quick settings is disabled until the current user makes it through the setup wizard
@VisibleForTesting
@@ -489,14 +470,14 @@ public class StatusBar extends SystemUI implements DemoMode,
private ViewMediatorCallback mKeyguardViewMediatorCallback;
protected ScrimController mScrimController;
protected DozeScrimController mDozeScrimController;
@Inject UiOffloadThread mUiOffloadThread;
private final UiOffloadThread mUiOffloadThread;
protected boolean mDozing;
private boolean mDozingRequested;
@Inject NotificationMediaManager mMediaManager;
@Inject NotificationLockscreenUserManager mLockscreenUserManager;
@Inject NotificationRemoteInputManager mRemoteInputManager;
private final NotificationMediaManager mMediaManager;
private final NotificationLockscreenUserManager mLockscreenUserManager;
private final NotificationRemoteInputManager mRemoteInputManager;
private boolean mWallpaperSupported;
private final BroadcastReceiver mWallpaperChangedReceiver = new BroadcastReceiver() {
@@ -567,18 +548,18 @@ public class StatusBar extends SystemUI implements DemoMode,
};
private KeyguardUserSwitcher mKeyguardUserSwitcher;
@Inject UserSwitcherController mUserSwitcherController;
@Inject NetworkController mNetworkController;
@Inject BatteryController mBatteryController;
private final UserSwitcherController mUserSwitcherController;
private final NetworkController mNetworkController;
private final BatteryController mBatteryController;
protected boolean mPanelExpanded;
private UiModeManager mUiModeManager;
protected boolean mIsKeyguard;
private LogMaker mStatusBarStateLog;
protected NotificationIconAreaController mNotificationIconAreaController;
@Nullable private View mAmbientIndicationContainer;
@Inject SysuiColorExtractor mColorExtractor;
@Inject ScreenLifecycle mScreenLifecycle;
@Inject @VisibleForTesting WakefulnessLifecycle mWakefulnessLifecycle;
private final SysuiColorExtractor mColorExtractor;
private final ScreenLifecycle mScreenLifecycle;
private final WakefulnessLifecycle mWakefulnessLifecycle;
private final View.OnClickListener mGoToLockedShadeListener = v -> {
if (mState == StatusBarState.KEYGUARD) {
@@ -587,7 +568,7 @@ public class StatusBar extends SystemUI implements DemoMode,
}
};
private boolean mNoAnimationOnNextBarModeChange;
@Inject SysuiStatusBarStateController mStatusBarStateController;
private final SysuiStatusBarStateController mStatusBarStateController;
private final KeyguardUpdateMonitorCallback mUpdateCallback =
new KeyguardUpdateMonitorCallback() {
@@ -608,17 +589,13 @@ public class StatusBar extends SystemUI implements DemoMode,
private HeadsUpAppearanceController mHeadsUpAppearanceController;
private boolean mVibrateOnOpening;
@Inject VibratorHelper mVibratorHelper;
private final VibratorHelper mVibratorHelper;
private ActivityLaunchAnimator mActivityLaunchAnimator;
protected StatusBarNotificationPresenter mPresenter;
private NotificationActivityStarter mNotificationActivityStarter;
private boolean mPulsing;
@Inject BubbleController mBubbleController;
private final BubbleController.BubbleExpandListener mBubbleExpandListener =
(isExpanding, key) -> {
mEntryManager.updateNotifications();
updateScrimController();
};
private final BubbleController mBubbleController;
private final BubbleController.BubbleExpandListener mBubbleExpandListener;
private ActivityIntentHelper mActivityIntentHelper;
@Override
@@ -635,6 +612,120 @@ public class StatusBar extends SystemUI implements DemoMode,
AppOpsManager.OP_COARSE_LOCATION,
AppOpsManager.OP_FINE_LOCATION};
@Inject
public StatusBar(
LightBarController lightBarController,
AutoHideController autoHideController,
KeyguardUpdateMonitor keyguardUpdateMonitor,
StatusBarIconController statusBarIconController,
DozeLog dozeLog,
InjectionInflationController injectionInflationController,
PulseExpansionHandler pulseExpansionHandler,
NotificationWakeUpCoordinator notificationWakeUpCoordinator,
KeyguardBypassController keyguardBypassController,
KeyguardStateController keyguardStateController,
HeadsUpManagerPhone headsUpManagerPhone,
DynamicPrivacyController dynamicPrivacyController,
BypassHeadsUpNotifier bypassHeadsUpNotifier,
@Named(ALLOW_NOTIFICATION_LONG_PRESS_NAME) boolean allowNotificationLongPress,
NotifPipelineInitializer notifPipelineInitializer,
FalsingManager falsingManager,
BroadcastDispatcher broadcastDispatcher,
RemoteInputQuickSettingsDisabler remoteInputQuickSettingsDisabler,
NotificationGutsManager notificationGutsManager,
NotificationLogger notificationLogger,
NotificationEntryManager notificationEntryManager,
NotificationInterruptionStateProvider notificationInterruptionStateProvider,
NotificationViewHierarchyManager notificationViewHierarchyManager,
ForegroundServiceController foregroundServiceController,
AppOpsController appOpsController,
KeyguardViewMediator keyguardViewMediator,
ZenModeController zenModeController,
NotificationAlertingManager notificationAlertingManager,
DisplayMetrics displayMetrics,
MetricsLogger metricsLogger,
UiOffloadThread uiOffloadThread,
NotificationMediaManager notificationMediaManager,
NotificationLockscreenUserManager lockScreenUserManager,
NotificationRemoteInputManager remoteInputManager,
UserSwitcherController userSwitcherController,
NetworkController networkController,
BatteryController batteryController,
SysuiColorExtractor colorExtractor,
ScreenLifecycle screenLifecycle,
WakefulnessLifecycle wakefulnessLifecycle,
SysuiStatusBarStateController statusBarStateController,
VibratorHelper vibratorHelper,
BubbleController bubbleController,
NotificationGroupManager groupManager,
NotificationGroupAlertTransferHelper groupAlertTransferHelper,
VisualStabilityManager visualStabilityManager,
DeviceProvisionedController deviceProvisionedController,
NavigationBarController navigationBarController,
AssistManager assistManager,
NotificationListener notificationListener,
ConfigurationController configurationController,
StatusBarWindowController statusBarWindowController) {
mLightBarController = lightBarController;
mAutoHideController = autoHideController;
mKeyguardUpdateMonitor = keyguardUpdateMonitor;
mIconController = statusBarIconController;
mDozeLog = dozeLog;
mInjectionInflater = injectionInflationController;
mPulseExpansionHandler = pulseExpansionHandler;
mWakeUpCoordinator = notificationWakeUpCoordinator;
mKeyguardBypassController = keyguardBypassController;
mKeyguardStateController = keyguardStateController;
mHeadsUpManager = headsUpManagerPhone;
mDynamicPrivacyController = dynamicPrivacyController;
mBypassHeadsUpNotifier = bypassHeadsUpNotifier;
mAllowNotificationLongPress = allowNotificationLongPress;
mNotifPipelineInitializer = notifPipelineInitializer;
mFalsingManager = falsingManager;
mBroadcastDispatcher = broadcastDispatcher;
mRemoteInputQuickSettingsDisabler = remoteInputQuickSettingsDisabler;
mGutsManager = notificationGutsManager;
mNotificationLogger = notificationLogger;
mEntryManager = notificationEntryManager;
mNotificationInterruptionStateProvider = notificationInterruptionStateProvider;
mViewHierarchyManager = notificationViewHierarchyManager;
mForegroundServiceController = foregroundServiceController;
mAppOpsController = appOpsController;
mKeyguardViewMediator = keyguardViewMediator;
mZenController = zenModeController;
mNotificationAlertingManager = notificationAlertingManager;
mDisplayMetrics = displayMetrics;
mMetricsLogger = metricsLogger;
mUiOffloadThread = uiOffloadThread;
mMediaManager = notificationMediaManager;
mLockscreenUserManager = lockScreenUserManager;
mRemoteInputManager = remoteInputManager;
mUserSwitcherController = userSwitcherController;
mNetworkController = networkController;
mBatteryController = batteryController;
mColorExtractor = colorExtractor;
mScreenLifecycle = screenLifecycle;
mWakefulnessLifecycle = wakefulnessLifecycle;
mStatusBarStateController = statusBarStateController;
mVibratorHelper = vibratorHelper;
mBubbleController = bubbleController;
mGroupManager = groupManager;
mGroupAlertTransferHelper = groupAlertTransferHelper;
mVisualStabilityManager = visualStabilityManager;
mDeviceProvisionedController = deviceProvisionedController;
mNavigationBarController = navigationBarController;
mAssistManager = assistManager;
mNotificationListener = notificationListener;
mConfigurationController = configurationController;
mStatusBarWindowController = statusBarWindowController;
mBubbleExpandListener =
(isExpanding, key) -> {
mEntryManager.updateNotifications();
updateScrimController();
};
}
@Override
public void start() {
mNotificationListener.registerAsSystemService();
@@ -772,7 +863,7 @@ public class StatusBar extends SystemUI implements DemoMode,
Dependency.get(ActivityStarterDelegate.class).setActivityStarterImpl(this);
Dependency.get(ConfigurationController.class).addCallback(this);
mConfigurationController.addCallback(this);
// set the initial view visibility
Dependency.get(InitController.class).addPostInitTask(this::updateAreThereNotifications);
@@ -805,6 +896,8 @@ public class StatusBar extends SystemUI implements DemoMode,
NotificationListContainer notifListContainer = (NotificationListContainer) mStackScroller;
mNotificationLogger.setUpWithContainer(notifListContainer);
// TODO: make this injectable. Currently that would create a circular dependency between
// NotificationIconAreaController and StatusBar.
mNotificationIconAreaController = SystemUIFactory.getInstance()
.createNotificationIconAreaController(context, this,
mWakeUpCoordinator, mKeyguardBypassController,
@@ -869,7 +962,7 @@ public class StatusBar extends SystemUI implements DemoMode,
.commit();
mHeadsUpManager.setUp(mStatusBarWindow, mGroupManager, this, mVisualStabilityManager);
Dependency.get(ConfigurationController.class).addCallback(mHeadsUpManager);
mConfigurationController.addCallback(mHeadsUpManager);
mHeadsUpManager.addListener(this);
mHeadsUpManager.addListener(mNotificationPanel);
mHeadsUpManager.addListener(mGroupManager);
@@ -1004,11 +1097,10 @@ public class StatusBar extends SystemUI implements DemoMode,
});
}
PowerManager pm = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
if (!pm.isScreenOn()) {
if (!mPowerManager.isScreenOn()) {
mBroadcastReceiver.onReceive(mContext, new Intent(Intent.ACTION_SCREEN_OFF));
}
mGestureWakeLock = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK,
mGestureWakeLock = mPowerManager.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK,
"GestureWakeLock");
mVibrator = mContext.getSystemService(Vibrator.class);
int[] pattern = mContext.getResources().getIntArray(
@@ -1131,8 +1223,8 @@ public class StatusBar extends SystemUI implements DemoMode,
@Override
public void wakeUpIfDozing(long time, View where, String why) {
if (mDozing) {
PowerManager pm = mContext.getSystemService(PowerManager.class);
pm.wakeUp(time, PowerManager.WAKE_REASON_GESTURE, "com.android.systemui:" + why);
mPowerManager.wakeUp(
time, PowerManager.WAKE_REASON_GESTURE, "com.android.systemui:" + why);
mWakeUpComingFromTouch = true;
where.getLocationInWindow(mTmpInt2);
mWakeUpTouchLocation = new PointF(mTmpInt2[0] + where.getWidth() / 2,
@@ -1232,13 +1324,12 @@ public class StatusBar extends SystemUI implements DemoMode,
protected void startKeyguard() {
Trace.beginSection("StatusBar#startKeyguard");
KeyguardViewMediator keyguardViewMediator = getComponent(KeyguardViewMediator.class);
mBiometricUnlockController = new BiometricUnlockController(mContext,
mDozeScrimController, keyguardViewMediator,
mDozeScrimController, mKeyguardViewMediator,
mScrimController, this, mKeyguardStateController, new Handler(),
mKeyguardUpdateMonitor, mKeyguardBypassController);
putComponent(BiometricUnlockController.class, mBiometricUnlockController);
mStatusBarKeyguardViewManager = keyguardViewMediator.registerStatusBar(this,
mStatusBarKeyguardViewManager = mKeyguardViewMediator.registerStatusBar(this,
getBouncerContainer(), mNotificationPanel, mBiometricUnlockController,
mStatusBarWindow.findViewById(R.id.lock_icon_container), mStackScroller,
mKeyguardBypassController);
@@ -1248,7 +1339,7 @@ public class StatusBar extends SystemUI implements DemoMode,
mRemoteInputManager.getController().addCallback(mStatusBarKeyguardViewManager);
mDynamicPrivacyController.setStatusBarKeyguardViewManager(mStatusBarKeyguardViewManager);
mKeyguardViewMediatorCallback = keyguardViewMediator.getViewMediatorCallback();
mKeyguardViewMediatorCallback = mKeyguardViewMediator.getViewMediatorCallback();
mLightBarController.setBiometricUnlockController(mBiometricUnlockController);
mMediaManager.setBiometricUnlockController(mBiometricUnlockController);
Dependency.get(KeyguardDismissUtil.class).setDismissHandler(this::executeWhenUnlocked);
@@ -1734,6 +1825,16 @@ public class StatusBar extends SystemUI implements DemoMode,
return mPresenter;
}
@VisibleForTesting
void setBarStateForTest(int state) {
mState = state;
}
@VisibleForTesting
void setUserSetupForTest(boolean userSetup) {
mUserSetup = userSetup;
}
/**
* All changes to the status bar and notifications funnel through here and are batched.
*/
@@ -2425,7 +2526,6 @@ public class StatusBar extends SystemUI implements DemoMode,
public void createAndAddWindows(@Nullable RegisterStatusBarResult result) {
makeStatusBarView(result);
mStatusBarWindowController = Dependency.get(StatusBarWindowController.class);
mStatusBarWindowController.add(mStatusBarWindow, getStatusBarHeight());
}
@@ -2669,7 +2769,6 @@ public class StatusBar extends SystemUI implements DemoMode,
}
}
// SystemUIService notifies SystemBars of configuration changes, which then calls down here
@Override
public void onConfigChanged(Configuration newConfig) {
updateResources();
@@ -3251,7 +3350,7 @@ public class StatusBar extends SystemUI implements DemoMode,
final int themeResId = lockDarkText ? R.style.Theme_SystemUI_Light : R.style.Theme_SystemUI;
if (mContext.getThemeResId() != themeResId) {
mContext.setTheme(themeResId);
Dependency.get(ConfigurationController.class).notifyThemeChanged();
mConfigurationController.notifyThemeChanged();
}
}
@@ -3798,8 +3897,7 @@ public class StatusBar extends SystemUI implements DemoMode,
return;
}
if (!mDeviceInteractive) {
PowerManager pm = mContext.getSystemService(PowerManager.class);
pm.wakeUp(SystemClock.uptimeMillis(), PowerManager.WAKE_REASON_CAMERA_LAUNCH,
mPowerManager.wakeUp(SystemClock.uptimeMillis(), PowerManager.WAKE_REASON_CAMERA_LAUNCH,
"com.android.systemui:CAMERA_GESTURE");
}
vibrateForCameraGesture();
@@ -4188,11 +4286,11 @@ public class StatusBar extends SystemUI implements DemoMode,
// all notifications
protected ViewGroup mStackScroller;
@Inject NotificationGroupManager mGroupManager;
@Inject NotificationGroupAlertTransferHelper mGroupAlertTransferHelper;
private final NotificationGroupManager mGroupManager;
private final NotificationGroupAlertTransferHelper mGroupAlertTransferHelper;
// handling reordering
@Inject VisualStabilityManager mVisualStabilityManager;
private final VisualStabilityManager mVisualStabilityManager;
protected AccessibilityManager mAccessibilityManager;
@@ -4208,9 +4306,9 @@ public class StatusBar extends SystemUI implements DemoMode,
protected StatusBarKeyguardViewManager mStatusBarKeyguardViewManager;
protected KeyguardManager mKeyguardManager;
@Inject DeviceProvisionedController mDeviceProvisionedController;
private final DeviceProvisionedController mDeviceProvisionedController;
@Inject protected NavigationBarController mNavigationBarController;
private final NavigationBarController mNavigationBarController;
// UI-specific methods
@@ -4226,7 +4324,7 @@ public class StatusBar extends SystemUI implements DemoMode,
protected NotificationShelf mNotificationShelf;
protected EmptyShadeView mEmptyShadeView;
@Inject AssistManager mAssistManager;
private final AssistManager mAssistManager;
public boolean isDeviceInteractive() {
return mDeviceInteractive;
@@ -4285,7 +4383,7 @@ public class StatusBar extends SystemUI implements DemoMode,
}
}
@Inject NotificationListener mNotificationListener;
private final NotificationListener mNotificationListener;
public void setNotificationSnoozed(StatusBarNotification sbn, SnoozeOption snoozeOption) {
if (snoozeOption.getSnoozeCriterion() != null) {

View File

@@ -65,7 +65,7 @@ import android.view.ViewGroup.LayoutParams;
import androidx.test.filters.SmallTest;
import com.android.internal.logging.MetricsLogger;
import com.android.internal.colorextraction.ColorExtractor;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.internal.logging.testing.FakeMetricsLogger;
import com.android.internal.statusbar.IStatusBarService;
@@ -89,7 +89,6 @@ import com.android.systemui.keyguard.KeyguardViewMediator;
import com.android.systemui.keyguard.ScreenLifecycle;
import com.android.systemui.keyguard.WakefulnessLifecycle;
import com.android.systemui.plugins.ActivityStarter.OnDismissAction;
import com.android.systemui.plugins.FalsingManager;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.statusbar.CommandQueue;
import com.android.systemui.statusbar.KeyguardIndicationController;
@@ -100,14 +99,15 @@ import com.android.systemui.statusbar.NotificationLockscreenUserManager;
import com.android.systemui.statusbar.NotificationMediaManager;
import com.android.systemui.statusbar.NotificationPresenter;
import com.android.systemui.statusbar.NotificationRemoteInputManager;
import com.android.systemui.statusbar.NotificationShelf;
import com.android.systemui.statusbar.NotificationViewHierarchyManager;
import com.android.systemui.statusbar.PulseExpansionHandler;
import com.android.systemui.statusbar.RemoteInputController;
import com.android.systemui.statusbar.StatusBarState;
import com.android.systemui.statusbar.StatusBarStateControllerImpl;
import com.android.systemui.statusbar.SysuiStatusBarStateController;
import com.android.systemui.statusbar.VibratorHelper;
import com.android.systemui.statusbar.notification.BypassHeadsUpNotifier;
import com.android.systemui.statusbar.notification.DynamicPrivacyController;
import com.android.systemui.statusbar.notification.NotifPipelineInitializer;
import com.android.systemui.statusbar.notification.NotificationAlertingManager;
import com.android.systemui.statusbar.notification.NotificationEntryListener;
import com.android.systemui.statusbar.notification.NotificationEntryManager;
@@ -122,10 +122,14 @@ import com.android.systemui.statusbar.notification.row.NotificationGutsManager;
import com.android.systemui.statusbar.notification.stack.NotificationListContainer;
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout;
import com.android.systemui.statusbar.policy.BatteryController;
import com.android.systemui.statusbar.policy.ConfigurationController;
import com.android.systemui.statusbar.policy.DeviceProvisionedController;
import com.android.systemui.statusbar.policy.KeyguardStateController;
import com.android.systemui.statusbar.policy.NetworkController;
import com.android.systemui.statusbar.policy.RemoteInputQuickSettingsDisabler;
import com.android.systemui.statusbar.policy.UserSwitcherController;
import com.android.systemui.statusbar.policy.ZenModeController;
import com.android.systemui.util.InjectionInflationController;
import org.junit.Before;
import org.junit.Test;
@@ -144,6 +148,15 @@ import java.util.HashSet;
@RunWith(AndroidTestingRunner.class)
@RunWithLooper(setAsMainLooper = true)
public class StatusBarTest extends SysuiTestCase {
private StatusBar mStatusBar;
private FakeMetricsLogger mMetricsLogger;
private PowerManager mPowerManager;
private TestableNotificationInterruptionStateProvider mNotificationInterruptionStateProvider;
private CommandQueue mCommandQueue;
@Mock private LightBarController mLightBarController;
@Mock private StatusBarIconController mStatusBarIconController;
@Mock private StatusBarKeyguardViewManager mStatusBarKeyguardViewManager;
@Mock private KeyguardStateController mKeyguardStateController;
@Mock private KeyguardIndicationController mKeyguardIndicationController;
@@ -158,7 +171,6 @@ public class StatusBarTest extends SysuiTestCase {
@Mock private BiometricUnlockController mBiometricUnlockController;
@Mock private NotificationData mNotificationData;
@Mock private NotificationInterruptionStateProvider.HeadsUpSuppressor mHeadsUpSuppressor;
@Mock private NotificationViewHierarchyManager mViewHierarchyManager;
@Mock private VisualStabilityManager mVisualStabilityManager;
@Mock private NotificationListener mNotificationListener;
@Mock private KeyguardViewMediator mKeyguardViewMediator;
@@ -185,17 +197,25 @@ public class StatusBarTest extends SysuiTestCase {
@Mock private NavigationBarController mNavigationBarController;
@Mock private BypassHeadsUpNotifier mBypassHeadsUpNotifier;
@Mock private SysuiColorExtractor mColorExtractor;
@Mock private ColorExtractor.GradientColors mGradientColors;
@Mock private DozeLog mDozeLog;
@Mock private PulseExpansionHandler mPulseExpansionHandler;
@Mock private RemoteInputQuickSettingsDisabler mRemoteInputQuickSettingsDisabler;
@Mock private NotificationWakeUpCoordinator mNotificationWakeUpCoordinator;
@Mock private KeyguardBypassController mKeyguardBypassController;
private TestableStatusBar mStatusBar;
private FakeMetricsLogger mMetricsLogger;
private PowerManager mPowerManager;
private TestableNotificationInterruptionStateProvider mNotificationInterruptionStateProvider;
private CommandQueue mCommandQueue;
@Mock private InjectionInflationController mInjectionInflationController;
@Mock private DynamicPrivacyController mDynamicPrivacyController;
@Mock private NotifPipelineInitializer mNotifPipelineInitializer;
@Mock private ZenModeController mZenModeController;
@Mock private AutoHideController mAutoHideController;
@Mock private NotificationViewHierarchyManager mNotificationViewHierarchyManager;
@Mock private UserSwitcherController mUserSwitcherController;
@Mock private NetworkController mNetworkController;
@Mock private VibratorHelper mVibratorHelper;
@Mock private BubbleController mBubbleController;
@Mock private NotificationGroupManager mGroupManager;
@Mock private NotificationGroupAlertTransferHelper mGroupAlertTransferHelper;
@Mock private StatusBarWindowController mStatusBarWindowController;
@Mock private NotificationIconAreaController mNotificationIconAreaController;
@Before
public void setup() throws Exception {
@@ -249,65 +269,88 @@ public class StatusBarTest extends SysuiTestCase {
mHeadsUpManager, mHeadsUpSuppressor);
when(mRemoteInputManager.getController()).thenReturn(mRemoteInputController);
mStatusBar = new TestableStatusBar(
mStatusBarKeyguardViewManager,
mKeyguardIndicationController,
mStackScroller,
mPowerManager,
mNotificationPanelView,
mBarService,
mNotificationListener,
notificationLogger,
mVisualStabilityManager,
mViewHierarchyManager,
entryManager,
mScrimController,
mBiometricUnlockController,
mKeyguardViewMediator,
mRemoteInputManager,
mock(NotificationGroupManager.class),
mock(NotificationGroupAlertTransferHelper.class),
new FalsingManagerFake(),
mock(StatusBarWindowController.class),
mock(NotificationIconAreaController.class),
mDozeScrimController,
mock(NotificationShelf.class),
mLockscreenUserManager,
mCommandQueue,
mNotificationPresenter,
mock(BubbleController.class),
mNavigationBarController,
mock(AutoHideController.class),
WakefulnessLifecycle wakefulnessLifecycle = new WakefulnessLifecycle();
wakefulnessLifecycle.dispatchStartedWakingUp();
wakefulnessLifecycle.dispatchFinishedWakingUp();
when(mGradientColors.supportsDarkText()).thenReturn(true);
when(mColorExtractor.getNeutralColors()).thenReturn(mGradientColors);
ConfigurationController configurationController = new ConfigurationControllerImpl(mContext);
mStatusBar = new StatusBar(
mLightBarController,
mAutoHideController,
mKeyguardUpdateMonitor,
mStatusBarWindowView,
mBroadcastDispatcher,
mAssistManager,
mNotificationGutsManager,
mNotificationMediaManager,
mForegroundServiceController,
mAppOpsController,
mStatusBarStateController,
mDeviceProvisionedController,
mNotificationAlertingManager,
mNotificationInterruptionStateProvider,
mMetricsLogger,
mHeadsUpManager,
mKeyguardStateController,
new ScreenLifecycle(),
mBypassHeadsUpNotifier,
mColorExtractor,
new DisplayMetrics(),
Dependency.get(UiOffloadThread.class),
mStatusBarIconController,
mDozeLog,
mInjectionInflationController,
mPulseExpansionHandler,
mNotificationWakeUpCoordinator,
mKeyguardBypassController,
mKeyguardStateController,
mHeadsUpManager,
mDynamicPrivacyController,
mBypassHeadsUpNotifier,
true,
mNotifPipelineInitializer,
new FalsingManagerFake(),
mBroadcastDispatcher,
new RemoteInputQuickSettingsDisabler(
mContext,
new ConfigurationControllerImpl(mContext)
configurationController
),
mNotificationWakeUpCoordinator,
mKeyguardBypassController);
mNotificationGutsManager,
notificationLogger,
entryManager,
mNotificationInterruptionStateProvider,
mNotificationViewHierarchyManager,
mForegroundServiceController,
mAppOpsController,
mKeyguardViewMediator,
mZenModeController,
mNotificationAlertingManager,
new DisplayMetrics(),
mMetricsLogger,
Dependency.get(UiOffloadThread.class),
mNotificationMediaManager,
mLockscreenUserManager,
mRemoteInputManager,
mUserSwitcherController,
mNetworkController,
mBatteryController,
mColorExtractor,
new ScreenLifecycle(),
wakefulnessLifecycle,
mStatusBarStateController,
mVibratorHelper,
mBubbleController,
mGroupManager,
mGroupAlertTransferHelper,
mVisualStabilityManager,
mDeviceProvisionedController,
mNavigationBarController,
mAssistManager,
mNotificationListener,
configurationController,
mStatusBarWindowController);
// TODO: we should be able to call mStatusBar.start() and have all the below values
// initialized automatically.
mStatusBar.mContext = mContext;
mStatusBar.mComponents = mContext.getComponents();
mStatusBar.mStatusBarKeyguardViewManager = mStatusBarKeyguardViewManager;
mStatusBar.mStatusBarWindow = mStatusBarWindowView;
mStatusBar.mBiometricUnlockController = mBiometricUnlockController;
mStatusBar.mScrimController = mScrimController;
mStatusBar.mNotificationPanel = mNotificationPanelView;
mStatusBar.mCommandQueue = mCommandQueue;
mStatusBar.mDozeScrimController = mDozeScrimController;
mStatusBar.mNotificationIconAreaController = mNotificationIconAreaController;
mStatusBar.mPresenter = mNotificationPresenter;
mStatusBar.mKeyguardIndicationController = mKeyguardIndicationController;
mStatusBar.mPowerManager = mPowerManager;
mStatusBar.mBarService = mBarService;
mStatusBar.mStackScroller = mStackScroller;
mStatusBar.putComponent(StatusBar.class, mStatusBar);
Dependency.get(InitController.class).executePostInitTasks();
entryManager.setUpForTest(mock(NotificationPresenter.class), mStackScroller,
@@ -636,8 +679,8 @@ public class StatusBarTest extends SysuiTestCase {
@Test
@RunWithLooper(setAsMainLooper = true)
public void testUpdateKeyguardState_DoesNotCrash() {
mStatusBar.mState = StatusBarState.KEYGUARD;
when(mStatusBar.mLockscreenUserManager.getCurrentProfiles()).thenReturn(
mStatusBar.setBarStateForTest(StatusBarState.KEYGUARD);
when(mLockscreenUserManager.getCurrentProfiles()).thenReturn(
new SparseArray<>());
mStatusBar.onStateChanged(StatusBarState.SHADE);
}
@@ -768,8 +811,7 @@ public class StatusBarTest extends SysuiTestCase {
verify(mStatusBarStateController).setState(eq(StatusBarState.KEYGUARD));
// If useFullscreenUserSwitcher is true, state is set to FULLSCREEN_USER_SWITCHER.
mStatusBar.mUserSwitcherController = mock(UserSwitcherController.class);
when(mStatusBar.mUserSwitcherController.useFullscreenUserSwitcher()).thenReturn(true);
when(mUserSwitcherController.useFullscreenUserSwitcher()).thenReturn(true);
mStatusBar.showKeyguardImpl();
verify(mStatusBarStateController).setState(eq(StatusBarState.FULLSCREEN_USER_SWITCHER));
}
@@ -821,136 +863,6 @@ public class StatusBarTest extends SysuiTestCase {
any(UserHandle.class));
}
static class TestableStatusBar extends StatusBar {
public TestableStatusBar(StatusBarKeyguardViewManager man,
KeyguardIndicationController key,
NotificationStackScrollLayout stack,
PowerManager pm, NotificationPanelView panelView,
IStatusBarService barService, NotificationListener notificationListener,
NotificationLogger notificationLogger,
VisualStabilityManager visualStabilityManager,
NotificationViewHierarchyManager viewHierarchyManager,
TestableNotificationEntryManager entryManager, ScrimController scrimController,
BiometricUnlockController biometricUnlockController,
KeyguardViewMediator keyguardViewMediator,
NotificationRemoteInputManager notificationRemoteInputManager,
NotificationGroupManager notificationGroupManager,
NotificationGroupAlertTransferHelper notificationGroupAlertTransferHelper,
FalsingManager falsingManager,
StatusBarWindowController statusBarWindowController,
NotificationIconAreaController notificationIconAreaController,
DozeScrimController dozeScrimController,
NotificationShelf notificationShelf,
NotificationLockscreenUserManager notificationLockscreenUserManager,
CommandQueue commandQueue,
StatusBarNotificationPresenter notificationPresenter,
BubbleController bubbleController,
NavigationBarController navBarController,
AutoHideController autoHideController,
KeyguardUpdateMonitor keyguardUpdateMonitor,
StatusBarWindowView statusBarWindow,
BroadcastDispatcher broadcastDispatcher,
AssistManager assistManager,
NotificationGutsManager notificationGutsManager,
NotificationMediaManager notificationMediaManager,
ForegroundServiceController foregroundServiceController,
AppOpsController appOpsController,
SysuiStatusBarStateController statusBarStateController,
DeviceProvisionedController deviceProvisionedController,
NotificationAlertingManager notificationAlertingManager,
NotificationInterruptionStateProvider notificationInterruptionStateProvider,
MetricsLogger metricsLogger,
HeadsUpManagerPhone headsUpManager,
KeyguardStateController keyguardStateController,
ScreenLifecycle screenLifecycle,
BypassHeadsUpNotifier bypassHeadsUpNotifier,
SysuiColorExtractor colorExtractor, DisplayMetrics displayMetrics,
UiOffloadThread uiOffloadThread,
DozeLog dozeLog,
PulseExpansionHandler pulseExpansionHandler,
RemoteInputQuickSettingsDisabler remoteInputQuickSettingsDisabler,
NotificationWakeUpCoordinator notificationWakeUpCoordinator,
KeyguardBypassController keyguardBypassController) {
mStatusBarKeyguardViewManager = man;
mKeyguardIndicationController = key;
mStackScroller = stack;
mPowerManager = pm;
mNotificationPanel = panelView;
mBarService = barService;
mNotificationListener = notificationListener;
mNotificationLogger = notificationLogger;
mWakefulnessLifecycle = createAwakeWakefulnessLifecycle();
mVisualStabilityManager = visualStabilityManager;
mViewHierarchyManager = viewHierarchyManager;
mEntryManager = entryManager;
mScrimController = scrimController;
mBiometricUnlockController = biometricUnlockController;
mKeyguardViewMediator = keyguardViewMediator;
mRemoteInputManager = notificationRemoteInputManager;
mGroupManager = notificationGroupManager;
mGroupAlertTransferHelper = notificationGroupAlertTransferHelper;
mFalsingManager = falsingManager;
mStatusBarWindowController = statusBarWindowController;
mNotificationIconAreaController = notificationIconAreaController;
mDozeScrimController = dozeScrimController;
mNotificationShelf = notificationShelf;
mLockscreenUserManager = notificationLockscreenUserManager;
mCommandQueue = commandQueue;
mPresenter = notificationPresenter;
mGestureWakeLock = mock(PowerManager.WakeLock.class);
mBubbleController = bubbleController;
mNavigationBarController = navBarController;
mAutoHideController = autoHideController;
mKeyguardUpdateMonitor = keyguardUpdateMonitor;
mStatusBarWindow = statusBarWindow;
mDozeServiceHost.mWakeLockScreenPerformsAuth = false;
mBroadcastDispatcher = broadcastDispatcher;
mAssistManager = assistManager;
mGutsManager = notificationGutsManager;
mMediaManager = notificationMediaManager;
mForegroundServiceController = foregroundServiceController;
mAppOpsController = appOpsController;
mStatusBarStateController = statusBarStateController;
mDeviceProvisionedController = deviceProvisionedController;
mNotificationAlertingManager = notificationAlertingManager;
mNotificationInterruptionStateProvider = notificationInterruptionStateProvider;
mMetricsLogger = metricsLogger;
mHeadsUpManager = headsUpManager;
mKeyguardStateController = keyguardStateController;
mScreenLifecycle = screenLifecycle;
mBypassHeadsUpNotifier = bypassHeadsUpNotifier;
mColorExtractor = colorExtractor;
mDisplayMetrics = displayMetrics;
mUiOffloadThread = uiOffloadThread;
mDozeLog = dozeLog;
mPulseExpansionHandler = pulseExpansionHandler;
mRemoteInputQuickSettingsDisabler = remoteInputQuickSettingsDisabler;
mWakeUpCoordinator = notificationWakeUpCoordinator;
mKeyguardBypassController = keyguardBypassController;
}
private WakefulnessLifecycle createAwakeWakefulnessLifecycle() {
WakefulnessLifecycle wakefulnessLifecycle = new WakefulnessLifecycle();
wakefulnessLifecycle.dispatchStartedWakingUp();
wakefulnessLifecycle.dispatchFinishedWakingUp();
return wakefulnessLifecycle;
}
@Override
protected void updateTheme() {
// Do nothing for now, until we have more mocking and StatusBar is smaller.
}
public void setBarStateForTest(int state) {
mState = state;
}
public void setUserSetupForTest(boolean userSetup) {
mUserSetup = userSetup;
}
}
public static class TestableNotificationEntryManager extends NotificationEntryManager {
public TestableNotificationEntryManager(Context context) {
@@ -969,7 +881,7 @@ public class StatusBarTest extends SysuiTestCase {
public static class TestableNotificationInterruptionStateProvider extends
NotificationInterruptionStateProvider {
public TestableNotificationInterruptionStateProvider(
TestableNotificationInterruptionStateProvider(
Context context,
PowerManager powerManager,
IDreamManager dreamManager,