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

Commit 043ceb9a authored by Justin Weir's avatar Justin Weir
Browse files

Create an empty ShadeViewController implementation

Variants that have no shade can bind this new empty implementation
to avoid bringing in all of the dependencies of NPVC. This is not
an ideal fix to the problem, but it's a good intermediate step as
the dagger graph gets cleaned up to eliminate the need to bind it
at all.

Bug: 288868098
Test: Updated and ran affected tests
Change-Id: I88154864d008dd55d361d80a3bc7d751cbb8d365
parent f9105bab
Loading
Loading
Loading
Loading
+2 −22
Original line number Diff line number Diff line
@@ -168,7 +168,6 @@ import com.android.systemui.statusbar.NotificationShadeDepthController;
import com.android.systemui.statusbar.NotificationShadeWindowController;
import com.android.systemui.statusbar.NotificationShelfController;
import com.android.systemui.statusbar.PulseExpansionHandler;
import com.android.systemui.statusbar.RemoteInputController;
import com.android.systemui.statusbar.StatusBarState;
import com.android.systemui.statusbar.SysuiStatusBarStateController;
import com.android.systemui.statusbar.VibratorHelper;
@@ -224,6 +223,8 @@ import com.android.systemui.util.Utils;
import com.android.systemui.util.time.SystemClock;
import com.android.wm.shell.animation.FlingAnimationUtils;

import kotlin.Unit;

import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
@@ -234,8 +235,6 @@ import java.util.function.Consumer;
import javax.inject.Inject;
import javax.inject.Provider;

import kotlin.Unit;

import kotlinx.coroutines.CoroutineDispatcher;

@SysUISingleton
@@ -440,8 +439,6 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump
    private final FalsingCollector mFalsingCollector;
    private final ShadeHeadsUpTrackerImpl mShadeHeadsUpTracker = new ShadeHeadsUpTrackerImpl();
    private final ShadeFoldAnimator mShadeFoldAnimator = new ShadeFoldAnimatorImpl();
    private final ShadeNotificationPresenterImpl mShadeNotificationPresenter =
            new ShadeNotificationPresenterImpl();

    private boolean mShowIconsWhenExpanded;
    private int mIndicationBottomPadding;
@@ -3323,23 +3320,6 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump
        ).printTableData(ipw);
    }

    private final class ShadeNotificationPresenterImpl implements ShadeNotificationPresenter{
        @Override
        public RemoteInputController.Delegate createRemoteInputDelegate() {
            return mNotificationStackScrollLayoutController.createDelegate();
        }

        @Override
        public boolean hasPulsingNotifications() {
            return mNotificationListContainer.hasPulsingNotifications();
        }
    }

    @Override
    public ShadeNotificationPresenter getShadeNotificationPresenter() {
        return mShadeNotificationPresenter;
    }

    @Override
    public void initDependencies(
            CentralSurfaces centralSurfaces,
+4 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.systemui.shade
import android.view.ViewPropertyAnimator
import com.android.systemui.statusbar.GestureRecorder
import com.android.systemui.statusbar.NotificationShelfController
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayoutController
import com.android.systemui.statusbar.phone.CentralSurfaces
import com.android.systemui.statusbar.phone.HeadsUpManagerPhone

@@ -63,6 +64,9 @@ interface ShadeSurface : ShadeViewController {
    /** Animates the view from its current alpha to zero then runs the runnable. */
    fun fadeOut(startDelayMs: Long, durationMs: Long, endAction: Runnable): ViewPropertyAnimator

    /** Returns the NSSL controller. */
    val notificationStackScrollLayoutController: NotificationStackScrollLayoutController

    /** Set whether the bouncer is showing. */
    fun setBouncerShowing(bouncerShowing: Boolean)

+1 −18
Original line number Diff line number Diff line
@@ -19,9 +19,7 @@ import android.view.MotionEvent
import android.view.ViewGroup
import android.view.ViewTreeObserver
import com.android.systemui.keyguard.shared.model.WakefulnessModel
import com.android.systemui.statusbar.RemoteInputController
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayoutController
import com.android.systemui.statusbar.phone.HeadsUpAppearanceController
import com.android.systemui.statusbar.phone.KeyguardStatusBarView
import com.android.systemui.statusbar.phone.KeyguardStatusBarViewController
@@ -141,9 +139,6 @@ interface ShadeViewController {
    /** Returns the StatusBarState. */
    val barState: Int

    /** Returns the NSSL controller. */
    val notificationStackScrollLayoutController: NotificationStackScrollLayoutController

    /** Sets the amount of progress in the status bar launch animation. */
    fun applyLaunchAnimationProgress(linearProgress: Float)

@@ -261,9 +256,6 @@ interface ShadeViewController {
    /** Returns the ShadeFoldAnimator. */
    val shadeFoldAnimator: ShadeFoldAnimator

    /** Returns the ShadeNotificationPresenter. */
    val shadeNotificationPresenter: ShadeNotificationPresenter

    companion object {
        /**
         * Returns a multiplicative factor to use when determining the falsing threshold for touches
@@ -325,16 +317,7 @@ interface ShadeFoldAnimator {
    fun cancelFoldToAodAnimation()

    /** Returns the main view of the shade. */
    val view: ViewGroup
}

/** Handles the shade's interactions with StatusBarNotificationPresenter. */
interface ShadeNotificationPresenter {
    /** Returns a new delegate for some view controller pieces of the remote input process. */
    fun createRemoteInputDelegate(): RemoteInputController.Delegate

    /** Returns whether the screen has temporarily woken up to display notifications. */
    fun hasPulsingNotifications(): Boolean
    val view: ViewGroup?
}

/**
+111 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2023 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.shade

import android.view.MotionEvent
import android.view.ViewGroup
import android.view.ViewTreeObserver
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow
import com.android.systemui.statusbar.phone.HeadsUpAppearanceController
import java.util.function.Consumer
import javax.inject.Inject

/** Empty implementation of ShadeViewController for variants with no shade. */
class ShadeViewControllerEmptyImpl @Inject constructor() : ShadeViewController {
    override fun expand(animate: Boolean) {}
    override fun expandToQs() {}
    override fun expandToNotifications() {}
    override val isExpandingOrCollapsing: Boolean = false
    override val isExpanded: Boolean = false
    override val isPanelExpanded: Boolean = false
    override val isShadeFullyExpanded: Boolean = false
    override fun collapse(delayed: Boolean, speedUpFactor: Float) {}
    override fun collapse(animate: Boolean, delayed: Boolean, speedUpFactor: Float) {}
    override fun collapseWithDuration(animationDuration: Int) {}
    override fun instantCollapse() {}
    override fun animateCollapseQs(fullyCollapse: Boolean) {}
    override fun canBeCollapsed(): Boolean = false
    override val isCollapsing: Boolean = false
    override val isFullyCollapsed: Boolean = false
    override val isTracking: Boolean = false
    override val isViewEnabled: Boolean = false
    override fun setOpenCloseListener(openCloseListener: OpenCloseListener) {}
    override fun shouldHideStatusBarIconsWhenExpanded() = false
    override fun blockExpansionForCurrentTouch() {}
    override fun setTrackingStartedListener(trackingStartedListener: TrackingStartedListener) {}
    override fun disableHeader(state1: Int, state2: Int, animated: Boolean) {}
    override fun startExpandLatencyTracking() {}
    override fun startBouncerPreHideAnimation() {}
    override fun dozeTimeTick() {}
    override fun resetViews(animate: Boolean) {}
    override val barState: Int = 0
    override fun applyLaunchAnimationProgress(linearProgress: Float) {}
    override fun closeUserSwitcherIfOpen(): Boolean {
        return false
    }
    override fun onBackPressed() {}
    override fun setIsLaunchAnimationRunning(running: Boolean) {}
    override fun setAlpha(alpha: Int, animate: Boolean) {}
    override fun setAlphaChangeAnimationEndAction(r: Runnable) {}
    override fun setPulsing(pulsing: Boolean) {}
    override fun setQsScrimEnabled(qsScrimEnabled: Boolean) {}
    override fun setAmbientIndicationTop(ambientIndicationTop: Int, ambientTextVisible: Boolean) {}
    override fun updateSystemUiStateFlags() {}
    override fun updateTouchableRegion() {}
    override fun addOnGlobalLayoutListener(listener: ViewTreeObserver.OnGlobalLayoutListener) {}
    override fun removeOnGlobalLayoutListener(listener: ViewTreeObserver.OnGlobalLayoutListener) {}
    override fun postToView(action: Runnable): Boolean {
        return false
    }
    override fun transitionToExpandedShade(delay: Long) {}
    override val isUnlockHintRunning: Boolean = false

    override fun resetViewGroupFade() {}
    override fun setKeyguardTransitionProgress(keyguardAlpha: Float, keyguardTranslationY: Int) {}
    override fun setOverStretchAmount(amount: Float) {}
    override fun setKeyguardStatusBarAlpha(alpha: Float) {}
    override fun showAodUi() {}
    override fun isFullyExpanded(): Boolean {
        return false
    }
    override fun handleExternalTouch(event: MotionEvent): Boolean {
        return false
    }
    override fun startTrackingExpansionFromStatusBar() {}
    override val shadeHeadsUpTracker = ShadeHeadsUpTrackerEmptyImpl()
    override val shadeFoldAnimator = ShadeFoldAnimatorEmptyImpl()
}

class ShadeHeadsUpTrackerEmptyImpl : ShadeHeadsUpTracker {
    override fun addTrackingHeadsUpListener(listener: Consumer<ExpandableNotificationRow>) {}
    override fun removeTrackingHeadsUpListener(listener: Consumer<ExpandableNotificationRow>) {}
    override fun setHeadsUpAppearanceController(
        headsUpAppearanceController: HeadsUpAppearanceController?
    ) {}
    override val trackedHeadsUpNotification: ExpandableNotificationRow? = null
}

class ShadeFoldAnimatorEmptyImpl : ShadeFoldAnimator {
    override fun prepareFoldToAodAnimation() {}
    override fun startFoldToAodAnimation(
        startAction: Runnable,
        endAction: Runnable,
        cancelAction: Runnable,
    ) {}
    override fun cancelFoldToAodAnimation() {}
    override val view: ViewGroup? = null
}
+5 −3
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import com.android.systemui.shade.ShadeViewController;
import com.android.systemui.statusbar.NotificationRemoteInputManager;
import com.android.systemui.statusbar.NotificationShadeWindowController;
import com.android.systemui.statusbar.StatusBarState;
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayoutController;
import com.android.systemui.statusbar.phone.dagger.CentralSurfacesComponent;
import com.android.systemui.statusbar.policy.OnHeadsUpChangedListener;
import com.android.systemui.statusbar.window.StatusBarWindowController;
@@ -35,6 +36,7 @@ public class StatusBarHeadsUpChangeListener implements OnHeadsUpChangedListener
    private final NotificationShadeWindowController mNotificationShadeWindowController;
    private final StatusBarWindowController mStatusBarWindowController;
    private final ShadeViewController mShadeViewController;
    private final NotificationStackScrollLayoutController mNsslController;
    private final KeyguardBypassController mKeyguardBypassController;
    private final HeadsUpManagerPhone mHeadsUpManager;
    private final StatusBarStateController mStatusBarStateController;
@@ -45,14 +47,15 @@ public class StatusBarHeadsUpChangeListener implements OnHeadsUpChangedListener
            NotificationShadeWindowController notificationShadeWindowController,
            StatusBarWindowController statusBarWindowController,
            ShadeViewController shadeViewController,
            NotificationStackScrollLayoutController nsslController,
            KeyguardBypassController keyguardBypassController,
            HeadsUpManagerPhone headsUpManager,
            StatusBarStateController statusBarStateController,
            NotificationRemoteInputManager notificationRemoteInputManager) {

        mNotificationShadeWindowController = notificationShadeWindowController;
        mStatusBarWindowController = statusBarWindowController;
        mShadeViewController = shadeViewController;
        mNsslController = nsslController;
        mKeyguardBypassController = keyguardBypassController;
        mHeadsUpManager = headsUpManager;
        mStatusBarStateController = statusBarStateController;
@@ -85,8 +88,7 @@ public class StatusBarHeadsUpChangeListener implements OnHeadsUpChangedListener
                //animation
                // is finished.
                mHeadsUpManager.setHeadsUpGoingAway(true);
                mShadeViewController.getNotificationStackScrollLayoutController()
                        .runAfterAnimationFinished(() -> {
                mNsslController.runAfterAnimationFinished(() -> {
                    if (!mHeadsUpManager.hasPinnedHeadsUp()) {
                        mNotificationShadeWindowController.setHeadsUpShowing(false);
                        mHeadsUpManager.setHeadsUpGoingAway(false);
Loading