Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ca1c886c authored by kwaky's avatar kwaky
Browse files

DO NOT MERGE Refactor StatusBar and CarStatusBar to optimize automotive boot time.

Test: Robolectric -- Robolectric results are identical before and after this change.

Test: Manual -- Hawk is booting successfully and interacting with different
 parts of CarStatusBar is not failing.

Test: Manual -- Pixel 2 is booting successfully and interacting with different
 parts of StatusBar is not failing.

Bug: 142342652
Bug: 140999054
Change-Id: Idf5e152aa661f06b7a041d39d759595636807dce
parent 903cd4ce
Loading
Loading
Loading
Loading
+58 −0
Original line number Diff line number Diff line
@@ -60,26 +60,45 @@ 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.classifier.FalsingLog;
import com.android.systemui.colorextraction.SysuiColorExtractor;
import com.android.systemui.fragments.FragmentHostManager;
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.StatusBarState;
import com.android.systemui.statusbar.car.hvac.HvacController;
import com.android.systemui.statusbar.car.hvac.TemperatureView;
import com.android.systemui.statusbar.notification.NotificationEntryManager;
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.CollapsedStatusBarFragment;
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.policy.BatteryController;
import com.android.systemui.statusbar.policy.DeviceProvisionedController;
import com.android.systemui.statusbar.policy.KeyguardMonitor;
import com.android.systemui.statusbar.policy.UserSwitcherController;
import com.android.systemui.statusbar.policy.ZenModeController;

import java.io.FileDescriptor;
import java.io.PrintWriter;
@@ -292,6 +311,45 @@ public class CarStatusBar extends StatusBar implements CarBatteryController.Batt
        }
    }

    @Override
    protected void getDependencies() {
        // Keyguard
        mKeyguardMonitor = Dependency.get(KeyguardMonitor.class);
        mWakefulnessLifecycle = Dependency.get(WakefulnessLifecycle.class);
        mScreenLifecycle = Dependency.get(ScreenLifecycle.class);

        // Policy
        mZenController = Dependency.get(ZenModeController.class);

        // Icon
        mIconController = Dependency.get(StatusBarIconController.class);
        mLightBarController = Dependency.get(LightBarController.class);

        // Notifications
        mEntryManager = Dependency.get(NotificationEntryManager.class);
        mForegroundServiceController = Dependency.get(ForegroundServiceController.class);
        mGroupAlertTransferHelper = Dependency.get(NotificationGroupAlertTransferHelper.class);
        mGroupManager = Dependency.get(NotificationGroupManager.class);
        mGutsManager = Dependency.get(NotificationGutsManager.class);
        mLockscreenUserManager = Dependency.get(NotificationLockscreenUserManager.class);
        mMediaManager = Dependency.get(NotificationMediaManager.class);
        mNotificationListener = Dependency.get(NotificationListener.class);
        mNotificationLogger = Dependency.get(NotificationLogger.class);
        mRemoteInputManager = Dependency.get(NotificationRemoteInputManager.class);
        mViewHierarchyManager = Dependency.get(NotificationViewHierarchyManager.class);
        mVisualStabilityManager = Dependency.get(VisualStabilityManager.class);

        // Others
        mColorExtractor = Dependency.get(SysuiColorExtractor.class);
        mNavigationBarController = Dependency.get(NavigationBarController.class);
        mUserSwitcherController = Dependency.get(UserSwitcherController.class);
    }

    @Override
    protected void setUpQuickSettingsTilePanel() {
        // ignore.
    }

    /**
     * Remove all content from navbars and rebuild them. Used to allow for different nav bars
     * before and after the device is provisioned. . Also for change of density and font size.
+2 −0
Original line number Diff line number Diff line
@@ -176,9 +176,11 @@ public class SystemUIApplication extends Application implements SysUiServiceProv

        Log.v(TAG, "Starting SystemUI services for user " +
                Process.myUserHandle().getIdentifier() + ".");

        TimingsTraceLog log = new TimingsTraceLog("SystemUIBootTiming",
                Trace.TRACE_TAG_APP);
        log.traceBegin(metricsPrefix);

        final int N = services.length;
        for (int i = 0; i < N; i++) {
            String clsName = services[i];
+130 −90
Original line number Diff line number Diff line
@@ -229,7 +229,6 @@ import com.android.systemui.statusbar.policy.UserInfoController;
import com.android.systemui.statusbar.policy.UserInfoControllerImpl;
import com.android.systemui.statusbar.policy.UserSwitcherController;
import com.android.systemui.statusbar.policy.ZenModeController;
import com.android.systemui.tuner.TunerService;
import com.android.systemui.util.InjectionInflationController;
import com.android.systemui.volume.VolumeComponent;

@@ -344,7 +343,7 @@ public class StatusBar extends SystemUI implements DemoMode,
    private BrightnessMirrorController mBrightnessMirrorController;
    private boolean mBrightnessMirrorVisible;
    protected BiometricUnlockController mBiometricUnlockController;
    private LightBarController mLightBarController;
    protected LightBarController mLightBarController;
    protected LockscreenWallpaper mLockscreenWallpaper;
    @VisibleForTesting
    protected AutoHideController mAutoHideController;
@@ -410,17 +409,17 @@ public class StatusBar extends SystemUI implements DemoMode,
    private final int[] mAbsPos = new int[2];
    private final ArrayList<Runnable> mPostCollapseRunnables = new ArrayList<>();

    private NotificationGutsManager mGutsManager;
    protected NotificationGutsManager mGutsManager;
    protected NotificationLogger mNotificationLogger;
    protected NotificationEntryManager mEntryManager;
    private NotificationListController mNotificationListController;
    private NotificationInterruptionStateProvider mNotificationInterruptionStateProvider;
    protected NotificationListController mNotificationListController;
    protected NotificationInterruptionStateProvider mNotificationInterruptionStateProvider;
    protected NotificationViewHierarchyManager mViewHierarchyManager;
    protected ForegroundServiceController mForegroundServiceController;
    protected AppOpsController mAppOpsController;
    protected KeyguardViewMediator mKeyguardViewMediator;
    private ZenModeController mZenController;
    private final NotificationAlertingManager mNotificationAlertingManager =
    protected ZenModeController mZenController;
    protected final NotificationAlertingManager mNotificationAlertingManager =
            Dependency.get(NotificationAlertingManager.class);

    // for disabling the status bar
@@ -483,7 +482,7 @@ public class StatusBar extends SystemUI implements DemoMode,
    protected boolean mDozing;
    private boolean mDozingRequested;

    private NotificationMediaManager mMediaManager;
    protected NotificationMediaManager mMediaManager;
    protected NotificationLockscreenUserManager mLockscreenUserManager;
    protected NotificationRemoteInputManager mRemoteInputManager;

@@ -555,18 +554,19 @@ public class StatusBar extends SystemUI implements DemoMode,

    private KeyguardUserSwitcher mKeyguardUserSwitcher;
    protected UserSwitcherController mUserSwitcherController;
    private NetworkController mNetworkController;
    private KeyguardMonitor mKeyguardMonitor = Dependency.get(KeyguardMonitor.class);
    private BatteryController mBatteryController;
    protected NetworkController mNetworkController;
    protected KeyguardMonitor mKeyguardMonitor;
    protected BatteryController mBatteryController;
    protected boolean mPanelExpanded;
    private UiModeManager mUiModeManager;
    protected boolean mIsKeyguard;
    private LogMaker mStatusBarStateLog;
    protected NotificationIconAreaController mNotificationIconAreaController;
    @Nullable private View mAmbientIndicationContainer;
    private SysuiColorExtractor mColorExtractor;
    private ScreenLifecycle mScreenLifecycle;
    @VisibleForTesting WakefulnessLifecycle mWakefulnessLifecycle;
    protected SysuiColorExtractor mColorExtractor;
    protected ScreenLifecycle mScreenLifecycle;
    @VisibleForTesting
    protected WakefulnessLifecycle mWakefulnessLifecycle;

    private final View.OnClickListener mGoToLockedShadeListener = v -> {
        if (mState == StatusBarState.KEYGUARD) {
@@ -598,7 +598,7 @@ public class StatusBar extends SystemUI implements DemoMode,

    private HeadsUpAppearanceController mHeadsUpAppearanceController;
    private boolean mVibrateOnOpening;
    private VibratorHelper mVibratorHelper;
    protected VibratorHelper mVibratorHelper;
    private ActivityLaunchAnimator mActivityLaunchAnimator;
    protected StatusBarNotificationPresenter mPresenter;
    private NotificationActivityStarter mNotificationActivityStarter;
@@ -628,40 +628,24 @@ public class StatusBar extends SystemUI implements DemoMode,

    @Override
    public void start() {
        mGroupManager = Dependency.get(NotificationGroupManager.class);
        mGroupAlertTransferHelper = Dependency.get(NotificationGroupAlertTransferHelper.class);
        mVisualStabilityManager = Dependency.get(VisualStabilityManager.class);
        mNotificationLogger = Dependency.get(NotificationLogger.class);
        mRemoteInputManager = Dependency.get(NotificationRemoteInputManager.class);
        mNotificationListener =  Dependency.get(NotificationListener.class);
        mNotificationListener.registerAsSystemService();
        mNetworkController = Dependency.get(NetworkController.class);
        mUserSwitcherController = Dependency.get(UserSwitcherController.class);
        mScreenLifecycle = Dependency.get(ScreenLifecycle.class);
        getDependencies();
        if (mScreenLifecycle != null && mScreenObserver != null) {
            mScreenLifecycle.addObserver(mScreenObserver);
        mWakefulnessLifecycle = Dependency.get(WakefulnessLifecycle.class);
        }

        if (mWakefulnessLifecycle != null && mWakefulnessObserver != null) {
            mWakefulnessLifecycle.addObserver(mWakefulnessObserver);
        mBatteryController = Dependency.get(BatteryController.class);
        mAssistManager = Dependency.get(AssistManager.class);
        }

        mNotificationListener.registerAsSystemService();
        if (mBubbleController != null) {
            mBubbleController.setExpandListener(mBubbleExpandListener);
        }

        mUiModeManager = mContext.getSystemService(UiModeManager.class);
        mLockscreenUserManager = Dependency.get(NotificationLockscreenUserManager.class);
        mGutsManager = Dependency.get(NotificationGutsManager.class);
        mMediaManager = Dependency.get(NotificationMediaManager.class);
        mEntryManager = Dependency.get(NotificationEntryManager.class);
        mBypassHeadsUpNotifier.setUp(mEntryManager);
        mNotificationInterruptionStateProvider =
                Dependency.get(NotificationInterruptionStateProvider.class);
        mViewHierarchyManager = Dependency.get(NotificationViewHierarchyManager.class);
        mForegroundServiceController = Dependency.get(ForegroundServiceController.class);
        mAppOpsController = Dependency.get(AppOpsController.class);
        mZenController = Dependency.get(ZenModeController.class);
        mKeyguardViewMediator = getComponent(KeyguardViewMediator.class);
        mColorExtractor = Dependency.get(SysuiColorExtractor.class);
        mDeviceProvisionedController = Dependency.get(DeviceProvisionedController.class);
        mNavigationBarController = Dependency.get(NavigationBarController.class);
        mBubbleController = Dependency.get(BubbleController.class);
        mBubbleController.setExpandListener(mBubbleExpandListener);
        mActivityIntentHelper = new ActivityIntentHelper(mContext);

        KeyguardSliceProvider sliceProvider = KeyguardSliceProvider.getAttachedInstance();
        if (sliceProvider != null) {
            sliceProvider.initDependencies(mMediaManager, mStatusBarStateController,
@@ -910,6 +894,7 @@ public class StatusBar extends SystemUI implements DemoMode,
                R.id.ambient_indication_container);

        // TODO: Find better place for this callback.
        if (mBatteryController != null) {
            mBatteryController.addCallback(new BatteryStateChangeCallback() {
                @Override
                public void onPowerSaveChanged(boolean isPowerSave) {
@@ -924,6 +909,7 @@ public class StatusBar extends SystemUI implements DemoMode,
                    // noop
                }
            });
        }

        mAutoHideController = Dependency.get(AutoHideController.class);
        mAutoHideController.setStatusBar(this);
@@ -965,28 +951,7 @@ public class StatusBar extends SystemUI implements DemoMode,
                mStatusBarWindow::onShowingLaunchAffordanceChanged);

        // Set up the quick settings tile panel
        View container = mStatusBarWindow.findViewById(R.id.qs_frame);
        if (container != null) {
            FragmentHostManager fragmentHostManager = FragmentHostManager.get(container);
            ExtensionFragmentListener.attachExtensonToFragment(container, QS.TAG, R.id.qs_frame,
                    Dependency.get(ExtensionController.class)
                            .newExtension(QS.class)
                            .withPlugin(QS.class)
                            .withDefault(this::createDefaultQSFragment)
                            .build());
            mBrightnessMirrorController = new BrightnessMirrorController(mStatusBarWindow,
                    (visible) -> {
                        mBrightnessMirrorVisible = visible;
                        updateScrimController();
                    });
            fragmentHostManager.addTagListener(QS.TAG, (tag, f) -> {
                QS qs = (QS) f;
                if (qs instanceof QSFragment) {
                    mQSPanel = ((QSFragment) qs).getQsPanel();
                    mQSPanel.setBrightnessMirror(mBrightnessMirrorController);
                }
            });
        }
        setUpQuickSettingsTilePanel();

        mReportRejectedTouch = mStatusBarWindow.findViewById(R.id.report_rejected_touch);
        if (mReportRejectedTouch != null) {
@@ -1086,7 +1051,9 @@ public class StatusBar extends SystemUI implements DemoMode,
                        mForegroundServiceController,
                        mDeviceProvisionedController);

        if (mAppOpsController != null) {
            mAppOpsController.addCallback(APP_OPS, this);
        }
        mNotificationShelf.setOnActivatedListener(mPresenter);
        mRemoteInputManager.getController().addCallback(mStatusBarWindowController);

@@ -1116,6 +1083,73 @@ public class StatusBar extends SystemUI implements DemoMode,
        mNotificationListController.bind();
    }

    protected void getDependencies() {
        // Icons
        mIconController = Dependency.get(StatusBarIconController.class);
        mLightBarController = Dependency.get(LightBarController.class);

        // Keyguard
        mKeyguardMonitor = Dependency.get(KeyguardMonitor.class);
        mScreenLifecycle = Dependency.get(ScreenLifecycle.class);
        mWakefulnessLifecycle = Dependency.get(WakefulnessLifecycle.class);

        // Notifications
        mEntryManager = Dependency.get(NotificationEntryManager.class);
        mForegroundServiceController = Dependency.get(ForegroundServiceController.class);
        mGroupAlertTransferHelper = Dependency.get(NotificationGroupAlertTransferHelper.class);
        mGroupManager = Dependency.get(NotificationGroupManager.class);
        mGutsManager = Dependency.get(NotificationGutsManager.class);
        mLockscreenUserManager = Dependency.get(NotificationLockscreenUserManager.class);
        mMediaManager = Dependency.get(NotificationMediaManager.class);
        mNotificationInterruptionStateProvider =
                Dependency.get(NotificationInterruptionStateProvider.class);
        mNotificationListener = Dependency.get(NotificationListener.class);
        mNotificationLogger = Dependency.get(NotificationLogger.class);
        mRemoteInputManager = Dependency.get(NotificationRemoteInputManager.class);
        mViewHierarchyManager = Dependency.get(NotificationViewHierarchyManager.class);
        mVisualStabilityManager = Dependency.get(VisualStabilityManager.class);

        // Policy
        mBatteryController = Dependency.get(BatteryController.class);
        mNetworkController = Dependency.get(NetworkController.class);
        mZenController = Dependency.get(ZenModeController.class);

        // Others
        mAppOpsController = Dependency.get(AppOpsController.class);
        mAssistManager = Dependency.get(AssistManager.class);
        mBubbleController = Dependency.get(BubbleController.class);
        mColorExtractor = Dependency.get(SysuiColorExtractor.class);
        mNavigationBarController = Dependency.get(NavigationBarController.class);
        mUserSwitcherController = Dependency.get(UserSwitcherController.class);
        mVibratorHelper = Dependency.get(VibratorHelper.class);
    }

    protected void setUpQuickSettingsTilePanel() {
        View container = mStatusBarWindow.findViewById(R.id.qs_frame);
        if (container != null) {
            FragmentHostManager fragmentHostManager = FragmentHostManager.get(container);
            ExtensionFragmentListener.attachExtensonToFragment(container, QS.TAG, R.id.qs_frame,
                    Dependency.get(ExtensionController.class)
                            .newExtension(QS.class)
                            .withPlugin(QS.class)
                            .withDefault(this::createDefaultQSFragment)
                            .build());
            mBrightnessMirrorController = new BrightnessMirrorController(mStatusBarWindow,
                    (visible) -> {
                        mBrightnessMirrorVisible = visible;
                        updateScrimController();
                    });
            fragmentHostManager.addTagListener(QS.TAG, (tag, f) -> {
                QS qs = (QS) f;
                if (qs instanceof QSFragment) {
                    mQSPanel = ((QSFragment) qs).getQsPanel();
                    mQSPanel.setBrightnessMirror(mBrightnessMirrorController);
                }
            });
        }
    }


    /**
     * Post-init task of {@link #start()}
     * @param state1 disable1 flags
@@ -1936,9 +1970,11 @@ public class StatusBar extends SystemUI implements DemoMode,
            mStatusBarWindow.cancelExpandHelper();
            mStatusBarView.collapsePanel(true /* animate */, delayed, speedUpFactor);
        } else {
            if (mBubbleController != null) {
                mBubbleController.collapseStack();
            }
        }
    }

    private void runPostCollapseRunnables() {
        ArrayList<Runnable> clonedList = new ArrayList<>(mPostCollapseRunnables);
@@ -2984,8 +3020,10 @@ public class StatusBar extends SystemUI implements DemoMode,
        mStatusBarStateController.setLeaveOpenOnKeyguardHide(false);
        mPendingRemoteInputView = null;
        updateIsKeyguard();
        if (mAssistManager != null) {
            mAssistManager.onLockscreenShown();
        }
    }

    public boolean hideKeyguard() {
        mStatusBarStateController.setKeyguardRequested(false);
@@ -3030,7 +3068,7 @@ public class StatusBar extends SystemUI implements DemoMode,

    public void showKeyguardImpl() {
        mIsKeyguard = true;
        if (mKeyguardMonitor.isLaunchTransitionFadingAway()) {
        if (mKeyguardMonitor != null && mKeyguardMonitor.isLaunchTransitionFadingAway()) {
            mNotificationPanel.animate().cancel();
            onLaunchTransitionFadingEnded();
        }
@@ -3495,10 +3533,12 @@ public class StatusBar extends SystemUI implements DemoMode,
    }

    private void updateKeyguardState() {
        if (mKeyguardMonitor != null) {
            mKeyguardMonitor.notifyKeyguardState(mStatusBarKeyguardViewManager.isShowing(),
                    mUnlockMethodCache.isMethodSecure(),
                    mStatusBarKeyguardViewManager.isOccluded());
        }
    }

    public void onActivationReset() {
        mKeyguardIndicationController.hideTransientIndication();
@@ -3886,7 +3926,7 @@ public class StatusBar extends SystemUI implements DemoMode,
        // We don't want to end up in KEYGUARD state when we're unlocking with
        // fingerprint from doze. We should cross fade directly from black.
        boolean unlocking = mBiometricUnlockController.isWakeAndUnlock()
                || mKeyguardMonitor.isKeyguardFadingAway();
                || (mKeyguardMonitor != null && mKeyguardMonitor.isKeyguardFadingAway());

        // Do not animate the scrim expansion when triggered by the fingerprint sensor.
        mScrimController.setExpansionAffectsAlpha(
@@ -3915,7 +3955,7 @@ public class StatusBar extends SystemUI implements DemoMode,
            mScrimController.transitionTo(ScrimState.AOD);
        } else if (mIsKeyguard && !unlocking) {
            mScrimController.transitionTo(ScrimState.KEYGUARD);
        } else if (mBubbleController.isStackExpanded()) {
        } else if (mBubbleController != null && mBubbleController.isStackExpanded()) {
            mScrimController.transitionTo(ScrimState.BUBBLE_EXPANDED);
        } else {
            mScrimController.transitionTo(ScrimState.UNLOCKED, mUnlockScrimCallback);
@@ -4217,8 +4257,8 @@ public class StatusBar extends SystemUI implements DemoMode,
    protected StatusBarKeyguardViewManager mStatusBarKeyguardViewManager;

    protected KeyguardManager mKeyguardManager;
    private DeviceProvisionedController mDeviceProvisionedController
            = Dependency.get(DeviceProvisionedController.class);
    protected DeviceProvisionedController mDeviceProvisionedController =
            Dependency.get(DeviceProvisionedController.class);

    protected NavigationBarController mNavigationBarController;