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

Commit 3c55195e authored by Justin Weir's avatar Justin Weir Committed by Android (Google) Code Review
Browse files

Merge "First pass code cleanup of NotificationPanelViewController" into tm-qpr-dev

parents 58936f28 c9444cc2
Loading
Loading
Loading
Loading
+97 −157
Original line number Original line Diff line number Diff line
@@ -40,8 +40,6 @@ import static com.android.systemui.statusbar.phone.panelstate.PanelExpansionStat
import static com.android.systemui.statusbar.phone.panelstate.PanelExpansionStateManagerKt.STATE_OPENING;
import static com.android.systemui.statusbar.phone.panelstate.PanelExpansionStateManagerKt.STATE_OPENING;
import static com.android.systemui.util.DumpUtilsKt.asIndenting;
import static com.android.systemui.util.DumpUtilsKt.asIndenting;


import static java.lang.Float.isNaN;

import android.animation.Animator;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorListenerAdapter;
import android.animation.ValueAnimator;
import android.animation.ValueAnimator;
@@ -50,13 +48,13 @@ import android.app.ActivityManager;
import android.app.Fragment;
import android.app.Fragment;
import android.app.StatusBarManager;
import android.app.StatusBarManager;
import android.content.ContentResolver;
import android.content.ContentResolver;
import android.content.res.Resources;
import android.database.ContentObserver;
import android.database.ContentObserver;
import android.graphics.Canvas;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Color;
import android.graphics.ColorFilter;
import android.graphics.ColorFilter;
import android.graphics.Insets;
import android.graphics.Insets;
import android.graphics.Paint;
import android.graphics.Paint;
import android.graphics.PixelFormat;
import android.graphics.PointF;
import android.graphics.PointF;
import android.graphics.Rect;
import android.graphics.Rect;
import android.graphics.Region;
import android.graphics.Region;
@@ -79,6 +77,7 @@ import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.MotionEvent;
import android.view.VelocityTracker;
import android.view.VelocityTracker;
import android.view.View;
import android.view.View;
import android.view.View.AccessibilityDelegate;
import android.view.ViewGroup;
import android.view.ViewGroup;
import android.view.ViewPropertyAnimator;
import android.view.ViewPropertyAnimator;
import android.view.ViewStub;
import android.view.ViewStub;
@@ -195,7 +194,6 @@ import com.android.systemui.util.Compile;
import com.android.systemui.util.LargeScreenUtils;
import com.android.systemui.util.LargeScreenUtils;
import com.android.systemui.util.ListenerSet;
import com.android.systemui.util.ListenerSet;
import com.android.systemui.util.Utils;
import com.android.systemui.util.Utils;
import com.android.systemui.util.settings.SecureSettings;
import com.android.systemui.util.time.SystemClock;
import com.android.systemui.util.time.SystemClock;
import com.android.systemui.wallet.controller.QuickAccessWalletController;
import com.android.systemui.wallet.controller.QuickAccessWalletController;
import com.android.wm.shell.animation.FlingAnimationUtils;
import com.android.wm.shell.animation.FlingAnimationUtils;
@@ -207,14 +205,13 @@ import java.util.HashSet;
import java.util.List;
import java.util.List;
import java.util.Optional;
import java.util.Optional;
import java.util.Set;
import java.util.Set;
import java.util.concurrent.Executor;
import java.util.function.Consumer;
import java.util.function.Consumer;


import javax.inject.Inject;
import javax.inject.Inject;
import javax.inject.Provider;
import javax.inject.Provider;


@CentralSurfacesComponent.CentralSurfacesScope
@CentralSurfacesComponent.CentralSurfacesScope
public class NotificationPanelViewController extends PanelViewController {
public final class NotificationPanelViewController extends PanelViewController {


    private static final boolean DEBUG_LOGCAT = Compile.IS_DEBUG && Log.isLoggable(TAG, Log.DEBUG);
    private static final boolean DEBUG_LOGCAT = Compile.IS_DEBUG && Log.isLoggable(TAG, Log.DEBUG);
    private static final boolean SPEW_LOGCAT = Compile.IS_DEBUG && Log.isLoggable(TAG, Log.VERBOSE);
    private static final boolean SPEW_LOGCAT = Compile.IS_DEBUG && Log.isLoggable(TAG, Log.VERBOSE);
@@ -260,7 +257,8 @@ public class NotificationPanelViewController extends PanelViewController {
    private final ConfigurationListener mConfigurationListener = new ConfigurationListener();
    private final ConfigurationListener mConfigurationListener = new ConfigurationListener();
    private final SettingsChangeObserver mSettingsChangeObserver;
    private final SettingsChangeObserver mSettingsChangeObserver;


    @VisibleForTesting final StatusBarStateListener mStatusBarStateListener =
    @VisibleForTesting
    final StatusBarStateListener mStatusBarStateListener =
            new StatusBarStateListener();
            new StatusBarStateListener();
    private final NotificationPanelView mView;
    private final NotificationPanelView mView;
    private final VibratorHelper mVibratorHelper;
    private final VibratorHelper mVibratorHelper;
@@ -337,17 +335,18 @@ public class NotificationPanelViewController extends PanelViewController {
    private KeyguardUserSwitcherController mKeyguardUserSwitcherController;
    private KeyguardUserSwitcherController mKeyguardUserSwitcherController;
    private KeyguardStatusBarView mKeyguardStatusBar;
    private KeyguardStatusBarView mKeyguardStatusBar;
    private KeyguardStatusBarViewController mKeyguardStatusBarViewController;
    private KeyguardStatusBarViewController mKeyguardStatusBarViewController;
    @VisibleForTesting QS mQs;
    @VisibleForTesting
    QS mQs;
    private FrameLayout mQsFrame;
    private FrameLayout mQsFrame;
    private QsFrameTranslateController mQsFrameTranslateController;
    private final QsFrameTranslateController mQsFrameTranslateController;
    private KeyguardStatusViewController mKeyguardStatusViewController;
    private KeyguardStatusViewController mKeyguardStatusViewController;
    private LockIconViewController mLockIconViewController;
    private final LockIconViewController mLockIconViewController;
    private NotificationsQuickSettingsContainer mNotificationContainerParent;
    private NotificationsQuickSettingsContainer mNotificationContainerParent;
    private NotificationsQSContainerController mNotificationsQSContainerController;
    private final NotificationsQSContainerController mNotificationsQSContainerController;
    private boolean mAnimateNextPositionUpdate;
    private boolean mAnimateNextPositionUpdate;
    private float mQuickQsHeaderHeight;
    private float mQuickQsHeaderHeight;
    private ScreenOffAnimationController mScreenOffAnimationController;
    private final ScreenOffAnimationController mScreenOffAnimationController;
    private UnlockedScreenOffAnimationController mUnlockedScreenOffAnimationController;
    private final UnlockedScreenOffAnimationController mUnlockedScreenOffAnimationController;


    private int mTrackingPointer;
    private int mTrackingPointer;
    private VelocityTracker mQsVelocityTracker;
    private VelocityTracker mQsVelocityTracker;
@@ -400,12 +399,6 @@ public class NotificationPanelViewController extends PanelViewController {
    private int mLargeScreenShadeHeaderHeight;
    private int mLargeScreenShadeHeaderHeight;
    private int mSplitShadeNotificationsScrimMarginBottom;
    private int mSplitShadeNotificationsScrimMarginBottom;


    /**
     * Vertical overlap allowed between the bottom of the notification shelf and
     * the top of the lock icon or the under-display fingerprint sensor background.
     */
    private int mShelfAndLockIconOverlap;

    private final KeyguardClockPositionAlgorithm
    private final KeyguardClockPositionAlgorithm
            mClockPositionAlgorithm =
            mClockPositionAlgorithm =
            new KeyguardClockPositionAlgorithm();
            new KeyguardClockPositionAlgorithm();
@@ -420,7 +413,8 @@ public class NotificationPanelViewController extends PanelViewController {
     * Determines if QS should be already expanded when expanding shade.
     * Determines if QS should be already expanded when expanding shade.
     * Used for split shade, two finger gesture as well as accessibility shortcut to QS.
     * Used for split shade, two finger gesture as well as accessibility shortcut to QS.
     */
     */
    @VisibleForTesting boolean mQsExpandImmediate;
    @VisibleForTesting
    boolean mQsExpandImmediate;
    private boolean mTwoFingerQsExpandPossible;
    private boolean mTwoFingerQsExpandPossible;
    private String mHeaderDebugInfo;
    private String mHeaderDebugInfo;


@@ -442,14 +436,13 @@ public class NotificationPanelViewController extends PanelViewController {
    private int mNavigationBarBottomHeight;
    private int mNavigationBarBottomHeight;
    private boolean mExpandingFromHeadsUp;
    private boolean mExpandingFromHeadsUp;
    private boolean mCollapsedOnDown;
    private boolean mCollapsedOnDown;
    private int mPositionMinSideMargin;
    private boolean mClosingWithAlphaFadeOut;
    private boolean mClosingWithAlphaFadeOut;
    private boolean mHeadsUpAnimatingAway;
    private boolean mHeadsUpAnimatingAway;
    private boolean mLaunchingAffordance;
    private boolean mLaunchingAffordance;
    private final FalsingManager mFalsingManager;
    private final FalsingManager mFalsingManager;
    private final FalsingCollector mFalsingCollector;
    private final FalsingCollector mFalsingCollector;


    private Runnable mHeadsUpExistenceChangedRunnable = () -> {
    private final Runnable mHeadsUpExistenceChangedRunnable = () -> {
        setHeadsUpAnimatingAway(false);
        setHeadsUpAnimatingAway(false);
        updatePanelExpansionAndVisibility();
        updatePanelExpansionAndVisibility();
    };
    };
@@ -459,9 +452,6 @@ public class NotificationPanelViewController extends PanelViewController {
    private boolean mIsFullWidth;
    private boolean mIsFullWidth;
    private boolean mBlockingExpansionForCurrentTouch;
    private boolean mBlockingExpansionForCurrentTouch;


    // TODO (b/204204226): no longer needed once refactor is complete
    private final boolean mUseCombinedQSHeaders;

    /**
    /**
     * Following variables maintain state of events when input focus transfer may occur.
     * Following variables maintain state of events when input focus transfer may occur.
     */
     */
@@ -517,19 +507,10 @@ public class NotificationPanelViewController extends PanelViewController {
    private final MediaDataManager mMediaDataManager;
    private final MediaDataManager mMediaDataManager;
    private final SysUiState mSysUiState;
    private final SysUiState mSysUiState;


    private NotificationShadeDepthController mDepthController;
    private final NotificationShadeDepthController mDepthController;
    private int mDisplayId;
    private final int mDisplayId;


    /**
     * Cache the resource id of the theme to avoid unnecessary work in onThemeChanged.
     *
     * onThemeChanged is forced when the theme might not have changed. So, to avoid unncessary
     * work, check the current id with the cached id.
     */
    private int mThemeResId;
    private KeyguardIndicationController mKeyguardIndicationController;
    private KeyguardIndicationController mKeyguardIndicationController;
    private int mShelfHeight;
    private int mDarkIconSize;
    private int mHeadsUpInset;
    private int mHeadsUpInset;
    private boolean mHeadsUpPinnedMode;
    private boolean mHeadsUpPinnedMode;
    private boolean mAllowExpandForSmallExpansion;
    private boolean mAllowExpandForSmallExpansion;
@@ -643,15 +624,12 @@ public class NotificationPanelViewController extends PanelViewController {
    private final ContentResolver mContentResolver;
    private final ContentResolver mContentResolver;
    private float mMinFraction;
    private float mMinFraction;


    private final Executor mUiExecutor;
    private final KeyguardMediaController mKeyguardMediaController;
    private final SecureSettings mSecureSettings;

    private KeyguardMediaController mKeyguardMediaController;


    private boolean mStatusViewCentered = true;
    private boolean mStatusViewCentered = true;


    private Optional<KeyguardUnfoldTransition> mKeyguardUnfoldTransition;
    private final Optional<KeyguardUnfoldTransition> mKeyguardUnfoldTransition;
    private Optional<NotificationPanelUnfoldAnimationController>
    private final Optional<NotificationPanelUnfoldAnimationController>
            mNotificationPanelUnfoldAnimationController;
            mNotificationPanelUnfoldAnimationController;


    /** The drag distance required to fully expand the split shade. */
    /** The drag distance required to fully expand the split shade. */
@@ -662,9 +640,13 @@ public class NotificationPanelViewController extends PanelViewController {


    private final NPVCDownEventState.Buffer mLastDownEvents;
    private final NPVCDownEventState.Buffer mLastDownEvents;


    private View.AccessibilityDelegate mAccessibilityDelegate = new View.AccessibilityDelegate() {
    private final Runnable mAnimateKeyguardBottomAreaInvisibleEndRunnable =
            () -> mKeyguardBottomArea.setVisibility(View.GONE);

    private final AccessibilityDelegate mAccessibilityDelegate = new AccessibilityDelegate() {
        @Override
        @Override
        public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfo info) {
        public void onInitializeAccessibilityNodeInfo(View host,
                AccessibilityNodeInfo info) {
            super.onInitializeAccessibilityNodeInfo(host, info);
            super.onInitializeAccessibilityNodeInfo(host, info);
            info.addAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_SCROLL_FORWARD);
            info.addAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_SCROLL_FORWARD);
            info.addAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_SCROLL_UP);
            info.addAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_SCROLL_UP);
@@ -672,7 +654,8 @@ public class NotificationPanelViewController extends PanelViewController {


        @Override
        @Override
        public boolean performAccessibilityAction(View host, int action, Bundle args) {
        public boolean performAccessibilityAction(View host, int action, Bundle args) {
            if (action == AccessibilityNodeInfo.AccessibilityAction.ACTION_SCROLL_FORWARD.getId()
            if (action
                    == AccessibilityNodeInfo.AccessibilityAction.ACTION_SCROLL_FORWARD.getId()
                    || action
                    || action
                    == AccessibilityNodeInfo.AccessibilityAction.ACTION_SCROLL_UP.getId()) {
                    == AccessibilityNodeInfo.AccessibilityAction.ACTION_SCROLL_UP.getId()) {
                mStatusBarKeyguardViewManager.showBouncer(true);
                mStatusBarKeyguardViewManager.showBouncer(true);
@@ -699,7 +682,6 @@ public class NotificationPanelViewController extends PanelViewController {


    @Inject
    @Inject
    public NotificationPanelViewController(NotificationPanelView view,
    public NotificationPanelViewController(NotificationPanelView view,
            @Main Resources resources,
            @Main Handler handler,
            @Main Handler handler,
            LayoutInflater layoutInflater,
            LayoutInflater layoutInflater,
            FeatureFlags featureFlags,
            FeatureFlags featureFlags,
@@ -749,8 +731,6 @@ public class NotificationPanelViewController extends PanelViewController {
            QuickAccessWalletController quickAccessWalletController,
            QuickAccessWalletController quickAccessWalletController,
            QRCodeScannerController qrCodeScannerController,
            QRCodeScannerController qrCodeScannerController,
            RecordingController recordingController,
            RecordingController recordingController,
            @Main Executor uiExecutor,
            SecureSettings secureSettings,
            LargeScreenShadeHeaderController largeScreenShadeHeaderController,
            LargeScreenShadeHeaderController largeScreenShadeHeaderController,
            ScreenOffAnimationController screenOffAnimationController,
            ScreenOffAnimationController screenOffAnimationController,
            LockscreenGestureLogger lockscreenGestureLogger,
            LockscreenGestureLogger lockscreenGestureLogger,
@@ -835,8 +815,6 @@ public class NotificationPanelViewController extends PanelViewController {
        mUserManager = userManager;
        mUserManager = userManager;
        mMediaDataManager = mediaDataManager;
        mMediaDataManager = mediaDataManager;
        mTapAgainViewController = tapAgainViewController;
        mTapAgainViewController = tapAgainViewController;
        mUiExecutor = uiExecutor;
        mSecureSettings = secureSettings;
        mInteractionJankMonitor = interactionJankMonitor;
        mInteractionJankMonitor = interactionJankMonitor;
        mSysUiState = sysUiState;
        mSysUiState = sysUiState;
        mPanelEventsEmitter = panelEventsEmitter;
        mPanelEventsEmitter = panelEventsEmitter;
@@ -846,7 +824,6 @@ public class NotificationPanelViewController extends PanelViewController {
            }
            }
        });
        });
        statusBarWindowStateController.addListener(this::onStatusBarWindowStateChanged);
        statusBarWindowStateController.addListener(this::onStatusBarWindowStateChanged);
        mThemeResId = mView.getContext().getThemeResId();
        mKeyguardBypassController = bypassController;
        mKeyguardBypassController = bypassController;
        mUpdateMonitor = keyguardUpdateMonitor;
        mUpdateMonitor = keyguardUpdateMonitor;
        mLockscreenShadeTransitionController = lockscreenShadeTransitionController;
        mLockscreenShadeTransitionController = lockscreenShadeTransitionController;
@@ -893,14 +870,14 @@ public class NotificationPanelViewController extends PanelViewController {
            mView.getOverlay().add(new DebugDrawable());
            mView.getOverlay().add(new DebugDrawable());
        }
        }


        mKeyguardUnfoldTransition = unfoldComponent.map(c -> c.getKeyguardUnfoldTransition());
        mKeyguardUnfoldTransition = unfoldComponent.map(
                SysUIUnfoldComponent::getKeyguardUnfoldTransition);
        mNotificationPanelUnfoldAnimationController = unfoldComponent.map(
        mNotificationPanelUnfoldAnimationController = unfoldComponent.map(
                SysUIUnfoldComponent::getNotificationPanelUnfoldAnimationController);
                SysUIUnfoldComponent::getNotificationPanelUnfoldAnimationController);


        mQsFrameTranslateController = qsFrameTranslateController;
        mQsFrameTranslateController = qsFrameTranslateController;
        updateUserSwitcherFlags();
        updateUserSwitcherFlags();
        onFinishInflate();
        onFinishInflate();
        mUseCombinedQSHeaders = featureFlags.isEnabled(Flags.COMBINED_QS_HEADERS);
        keyguardUnlockAnimationController.addKeyguardUnlockAnimationListener(
        keyguardUnlockAnimationController.addKeyguardUnlockAnimationListener(
                new KeyguardUnlockAnimationController.KeyguardUnlockAnimationListener() {
                new KeyguardUnlockAnimationController.KeyguardUnlockAnimationListener() {
                    @Override
                    @Override
@@ -1048,12 +1025,8 @@ public class NotificationPanelViewController extends PanelViewController {
        mQsPeekHeight = mResources.getDimensionPixelSize(R.dimen.qs_peek_height);
        mQsPeekHeight = mResources.getDimensionPixelSize(R.dimen.qs_peek_height);
        mClockPositionAlgorithm.loadDimens(mResources);
        mClockPositionAlgorithm.loadDimens(mResources);
        mQsFalsingThreshold = mResources.getDimensionPixelSize(R.dimen.qs_falsing_threshold);
        mQsFalsingThreshold = mResources.getDimensionPixelSize(R.dimen.qs_falsing_threshold);
        mPositionMinSideMargin = mResources.getDimensionPixelSize(
                R.dimen.notification_panel_min_side_margin);
        mIndicationBottomPadding = mResources.getDimensionPixelSize(
        mIndicationBottomPadding = mResources.getDimensionPixelSize(
                R.dimen.keyguard_indication_bottom_padding);
                R.dimen.keyguard_indication_bottom_padding);
        mShelfHeight = mResources.getDimensionPixelSize(R.dimen.notification_shelf_height);
        mDarkIconSize = mResources.getDimensionPixelSize(R.dimen.status_bar_icon_drawing_size_dark);
        int statusbarHeight = SystemBarUtils.getStatusBarHeight(mView.getContext());
        int statusbarHeight = SystemBarUtils.getStatusBarHeight(mView.getContext());
        mHeadsUpInset = statusbarHeight + mResources.getDimensionPixelSize(
        mHeadsUpInset = statusbarHeight + mResources.getDimensionPixelSize(
                R.dimen.heads_up_status_bar_padding);
                R.dimen.heads_up_status_bar_padding);
@@ -1124,9 +1097,6 @@ public class NotificationPanelViewController extends PanelViewController {
        mSplitShadeNotificationsScrimMarginBottom =
        mSplitShadeNotificationsScrimMarginBottom =
                mResources.getDimensionPixelSize(
                mResources.getDimensionPixelSize(
                        R.dimen.split_shade_notifications_scrim_margin_bottom);
                        R.dimen.split_shade_notifications_scrim_margin_bottom);
        mShelfAndLockIconOverlap =
                mResources.getDimensionPixelSize(R.dimen.shelf_and_lock_icon_overlap);

        final boolean newSplitShadeEnabled =
        final boolean newSplitShadeEnabled =
                LargeScreenUtils.shouldUseSplitNotificationShade(mResources);
                LargeScreenUtils.shouldUseSplitNotificationShade(mResources);
        final boolean splitShadeChanged = mSplitShadeEnabled != newSplitShadeEnabled;
        final boolean splitShadeChanged = mSplitShadeEnabled != newSplitShadeEnabled;
@@ -1305,7 +1275,7 @@ public class NotificationPanelViewController extends PanelViewController {


    private void updateMaxDisplayedNotifications(boolean recompute) {
    private void updateMaxDisplayedNotifications(boolean recompute) {
        if (recompute) {
        if (recompute) {
            mMaxAllowedKeyguardNotifications = Math.max(computeMaxKeyguardNotifications(), 1);
            setMaxDisplayedNotifications(Math.max(computeMaxKeyguardNotifications(), 1));
        } else {
        } else {
            if (SPEW_LOGCAT) Log.d(TAG, "Skipping computeMaxKeyguardNotifications() by request");
            if (SPEW_LOGCAT) Log.d(TAG, "Skipping computeMaxKeyguardNotifications() by request");
        }
        }
@@ -1333,7 +1303,7 @@ public class NotificationPanelViewController extends PanelViewController {


    private void updateGestureExclusionRect() {
    private void updateGestureExclusionRect() {
        Rect exclusionRect = calculateGestureExclusionRect();
        Rect exclusionRect = calculateGestureExclusionRect();
        mView.setSystemGestureExclusionRects(exclusionRect.isEmpty() ? Collections.EMPTY_LIST
        mView.setSystemGestureExclusionRects(exclusionRect.isEmpty() ? Collections.emptyList()
                : Collections.singletonList(exclusionRect));
                : Collections.singletonList(exclusionRect));
    }
    }


@@ -1361,14 +1331,11 @@ public class NotificationPanelViewController extends PanelViewController {
        mQsSizeChangeAnimator = ValueAnimator.ofInt(oldHeight, newHeight);
        mQsSizeChangeAnimator = ValueAnimator.ofInt(oldHeight, newHeight);
        mQsSizeChangeAnimator.setDuration(300);
        mQsSizeChangeAnimator.setDuration(300);
        mQsSizeChangeAnimator.setInterpolator(Interpolators.FAST_OUT_SLOW_IN);
        mQsSizeChangeAnimator.setInterpolator(Interpolators.FAST_OUT_SLOW_IN);
        mQsSizeChangeAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        mQsSizeChangeAnimator.addUpdateListener(animation -> {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
            requestScrollerTopPaddingUpdate(false /* animate */);
            requestScrollerTopPaddingUpdate(false /* animate */);
            requestPanelHeightUpdate();
            requestPanelHeightUpdate();
            int height = (int) mQsSizeChangeAnimator.getAnimatedValue();
            int height = (int) mQsSizeChangeAnimator.getAnimatedValue();
            mQs.setHeightOverride(height);
            mQs.setHeightOverride(height);
            }
        });
        });
        mQsSizeChangeAnimator.addListener(new AnimatorListenerAdapter() {
        mQsSizeChangeAnimator.addListener(new AnimatorListenerAdapter() {
            @Override
            @Override
@@ -1913,12 +1880,8 @@ public class NotificationPanelViewController extends PanelViewController {
            mListenForHeadsUp = mCollapsedOnDown && mHeadsUpManager.hasPinnedHeadsUp();
            mListenForHeadsUp = mCollapsedOnDown && mHeadsUpManager.hasPinnedHeadsUp();
            mAllowExpandForSmallExpansion = mExpectingSynthesizedDown;
            mAllowExpandForSmallExpansion = mExpectingSynthesizedDown;
            mTouchSlopExceededBeforeDown = mExpectingSynthesizedDown;
            mTouchSlopExceededBeforeDown = mExpectingSynthesizedDown;
            if (mExpectingSynthesizedDown) {
            // When false, down but not synthesized motion event.
                mLastEventSynthesizedDown = true;
            mLastEventSynthesizedDown = mExpectingSynthesizedDown;
            } else {
                // down but not synthesized motion event.
                mLastEventSynthesizedDown = false;
            }
            mLastDownEvents.insert(
            mLastDownEvents.insert(
                    mSystemClock.currentTimeMillis(),
                    mSystemClock.currentTimeMillis(),
                    mDownX,
                    mDownX,
@@ -1943,7 +1906,6 @@ public class NotificationPanelViewController extends PanelViewController {
     *
     *
     * @param downX the x location where the touch started
     * @param downX the x location where the touch started
     * @param downY the y location where the touch started
     * @param downY the y location where the touch started
     *
     * @return true if the panel could be collapsed because it stared on QQS
     * @return true if the panel could be collapsed because it stared on QQS
     */
     */
    private boolean canPanelCollapseOnQQS(float downX, float downY) {
    private boolean canPanelCollapseOnQQS(float downX, float downY) {
@@ -2276,15 +2238,11 @@ public class NotificationPanelViewController extends PanelViewController {
    }
    }


    private void onQsExpansionStarted() {
    private void onQsExpansionStarted() {
        onQsExpansionStarted(0);
    }

    protected void onQsExpansionStarted(int overscrollAmount) {
        cancelQsAnimation();
        cancelQsAnimation();
        cancelHeightAnimator();
        cancelHeightAnimator();


        // Reset scroll position and apply that position to the expanded height.
        // Reset scroll position and apply that position to the expanded height.
        float height = mQsExpansionHeight - overscrollAmount;
        float height = mQsExpansionHeight;
        setQsExpansion(height);
        setQsExpansion(height);
        requestPanelHeightUpdate();
        requestPanelHeightUpdate();
        mNotificationStackScrollLayoutController.checkSnoozeLeavebehind();
        mNotificationStackScrollLayoutController.checkSnoozeLeavebehind();
@@ -2296,7 +2254,8 @@ public class NotificationPanelViewController extends PanelViewController {
        }
        }
    }
    }


    @VisibleForTesting void setQsExpanded(boolean expanded) {
    @VisibleForTesting
    void setQsExpanded(boolean expanded) {
        boolean changed = mQsExpanded != expanded;
        boolean changed = mQsExpanded != expanded;
        if (changed) {
        if (changed) {
            mQsExpanded = expanded;
            mQsExpanded = expanded;
@@ -2321,13 +2280,6 @@ public class NotificationPanelViewController extends PanelViewController {
        }
        }
    }
    }


    private final Runnable mAnimateKeyguardBottomAreaInvisibleEndRunnable = new Runnable() {
        @Override
        public void run() {
            mKeyguardBottomArea.setVisibility(View.GONE);
        }
    };

    private void setKeyguardBottomAreaVisibility(int statusBarState, boolean goingToFullShade) {
    private void setKeyguardBottomAreaVisibility(int statusBarState, boolean goingToFullShade) {
        mKeyguardBottomArea.animate().cancel();
        mKeyguardBottomArea.animate().cancel();
        if (goingToFullShade) {
        if (goingToFullShade) {
@@ -2445,7 +2397,7 @@ public class NotificationPanelViewController extends PanelViewController {
            }
            }
            setQSClippingBounds();
            setQSClippingBounds();
        }
        }
    };
    }


    private void onNotificationScrolled(int newScrollPosition) {
    private void onNotificationScrolled(int newScrollPosition) {
        updateQSExpansionEnabledAmbient();
        updateQSExpansionEnabledAmbient();
@@ -2629,8 +2581,8 @@ public class NotificationPanelViewController extends PanelViewController {
            mQs.setFancyClipping(
            mQs.setFancyClipping(
                    mQsClipTop,
                    mQsClipTop,
                    mQsClipBottom,
                    mQsClipBottom,
                    radius, qsVisible
                    radius,
                    && !mSplitShadeEnabled);
                    qsVisible && !mSplitShadeEnabled);
        }
        }
        mKeyguardStatusViewController.setClipBounds(
        mKeyguardStatusViewController.setClipBounds(
                clipStatusView ? mKeyguardStatusAreaClipBounds : null);
                clipStatusView ? mKeyguardStatusAreaClipBounds : null);
@@ -2754,8 +2706,7 @@ public class NotificationPanelViewController extends PanelViewController {
        }
        }
    }
    }



    private void requestScrollerTopPaddingUpdate(boolean animate) {
    protected void requestScrollerTopPaddingUpdate(boolean animate) {
        mNotificationStackScrollLayoutController.updateTopPadding(
        mNotificationStackScrollLayoutController.updateTopPadding(
                calculateNotificationsTopPadding(), animate);
                calculateNotificationsTopPadding(), animate);
        if (mKeyguardShowing && mKeyguardBypassController.getBypassEnabled()) {
        if (mKeyguardShowing && mKeyguardBypassController.getBypassEnabled()) {
@@ -2903,7 +2854,7 @@ public class NotificationPanelViewController extends PanelViewController {
     * @param onFinishRunnable Runnable to be executed at the end of animation.
     * @param onFinishRunnable Runnable to be executed at the end of animation.
     * @param isClick          If originated by click (different interpolator and duration.)
     * @param isClick          If originated by click (different interpolator and duration.)
     */
     */
    protected void flingSettings(float vel, int type, final Runnable onFinishRunnable,
    private void flingSettings(float vel, int type, final Runnable onFinishRunnable,
            boolean isClick) {
            boolean isClick) {
        float target;
        float target;
        switch (type) {
        switch (type) {
@@ -2945,11 +2896,11 @@ public class NotificationPanelViewController extends PanelViewController {
        if (oppositeDirection) {
        if (oppositeDirection) {
            animator.setDuration(350);
            animator.setDuration(350);
        }
        }
        animator.addUpdateListener(animation -> {
        animator.addUpdateListener(
            setQsExpansion((Float) animation.getAnimatedValue());
                animation -> setQsExpansion((Float) animation.getAnimatedValue()));
        });
        animator.addListener(new AnimatorListenerAdapter() {
        animator.addListener(new AnimatorListenerAdapter() {
            private boolean mIsCanceled;
            private boolean mIsCanceled;

            @Override
            @Override
            public void onAnimationStart(Animator animation) {
            public void onAnimationStart(Animator animation) {
                notifyExpandingStarted();
                notifyExpandingStarted();
@@ -3047,7 +2998,7 @@ public class NotificationPanelViewController extends PanelViewController {
            maxHeight = calculatePanelHeightShade();
            maxHeight = calculatePanelHeightShade();
        }
        }
        maxHeight = Math.max(min, maxHeight);
        maxHeight = Math.max(min, maxHeight);
        if (maxHeight == 0 || isNaN(maxHeight)) {
        if (maxHeight == 0) {
            Log.wtf(TAG, "maxPanelHeight is invalid. mOverExpansion: "
            Log.wtf(TAG, "maxPanelHeight is invalid. mOverExpansion: "
                    + mOverExpansion + ", calculatePanelHeightQsExpanded: "
                    + mOverExpansion + ", calculatePanelHeightQsExpanded: "
                    + calculatePanelHeightQsExpanded() + ", calculatePanelHeightShade: "
                    + calculatePanelHeightQsExpanded() + ", calculatePanelHeightShade: "
@@ -3212,7 +3163,7 @@ public class NotificationPanelViewController extends PanelViewController {
        updateQsExpansion();
        updateQsExpansion();
    }
    }


    protected float getHeaderTranslation() {
    private float getHeaderTranslation() {
        if (mBarState == KEYGUARD && !mKeyguardBypassController.getBypassEnabled()) {
        if (mBarState == KEYGUARD && !mKeyguardBypassController.getBypassEnabled()) {
            return -mQs.getQsMinExpansionHeight();
            return -mQs.getQsMinExpansionHeight();
        }
        }
@@ -3282,22 +3233,13 @@ public class NotificationPanelViewController extends PanelViewController {
        mMediaHierarchyManager.setCollapsingShadeFromQS(false);
        mMediaHierarchyManager.setCollapsingShadeFromQS(false);
        mMediaHierarchyManager.setQsExpanded(mQsExpanded);
        mMediaHierarchyManager.setQsExpanded(mQsExpanded);
        if (isFullyCollapsed()) {
        if (isFullyCollapsed()) {
            DejankUtils.postAfterTraversal(new Runnable() {
            DejankUtils.postAfterTraversal(() -> setListening(false));
                @Override
                public void run() {
                    setListening(false);
                }
            });


            // Workaround b/22639032: Make sure we invalidate something because else RenderThread
            // Workaround b/22639032: Make sure we invalidate something because else RenderThread
            // thinks we are actually drawing a frame put in reality we don't, so RT doesn't go
            // thinks we are actually drawing a frame put in reality we don't, so RT doesn't go
            // ahead with rendering and we jank.
            // ahead with rendering and we jank.
            mView.postOnAnimation(new Runnable() {
            mView.postOnAnimation(
                @Override
                    () -> mView.getParent().invalidateChild(mView, M_DUMMY_DIRTY_RECT));
                public void run() {
                    mView.getParent().invalidateChild(mView, M_DUMMY_DIRTY_RECT);
                }
            });
        } else {
        } else {
            setListening(true);
            setListening(true);
        }
        }
@@ -3582,7 +3524,7 @@ public class NotificationPanelViewController extends PanelViewController {
        mNotificationStackScrollLayoutController.forceNoOverlappingRendering(closing);
        mNotificationStackScrollLayoutController.forceNoOverlappingRendering(closing);
    }
    }


    protected void updateExpandedHeight(float expandedHeight) {
    private void updateExpandedHeight(float expandedHeight) {
        if (mTracking) {
        if (mTracking) {
            mNotificationStackScrollLayoutController
            mNotificationStackScrollLayoutController
                    .setExpandingVelocity(getCurrentExpandVelocity());
                    .setExpandingVelocity(getCurrentExpandVelocity());
@@ -3605,12 +3547,10 @@ public class NotificationPanelViewController extends PanelViewController {
    }
    }


    private void updateStatusBarIcons() {
    private void updateStatusBarIcons() {
        boolean
        boolean showIconsWhenExpanded =
                showIconsWhenExpanded =
                (isPanelVisibleBecauseOfHeadsUp() || isFullWidth())
                (isPanelVisibleBecauseOfHeadsUp() || isFullWidth())
                        && getExpandedHeight() < getOpeningHeight();
                        && getExpandedHeight() < getOpeningHeight();
        boolean noVisibleNotifications = true;
        if (showIconsWhenExpanded && isOnKeyguard()) {
        if (showIconsWhenExpanded && noVisibleNotifications && isOnKeyguard()) {
            showIconsWhenExpanded = false;
            showIconsWhenExpanded = false;
        }
        }
        if (showIconsWhenExpanded != mShowIconsWhenExpanded) {
        if (showIconsWhenExpanded != mShowIconsWhenExpanded) {
@@ -3911,6 +3851,7 @@ public class NotificationPanelViewController extends PanelViewController {
                    public void onAnimationCancel(Animator animation) {
                    public void onAnimationCancel(Animator animation) {
                        endAction.run();
                        endAction.run();
                    }
                    }

                    @Override
                    @Override
                    public void onAnimationEnd(Animator animation) {
                    public void onAnimationEnd(Animator animation) {
                        endAction.run();
                        endAction.run();
@@ -3930,7 +3871,6 @@ public class NotificationPanelViewController extends PanelViewController {
        resetTranslation();
        resetTranslation();
    }
    }


    /** */
    public void setImportantForAccessibility(int mode) {
    public void setImportantForAccessibility(int mode) {
        mView.setImportantForAccessibility(mode);
        mView.setImportantForAccessibility(mode);
    }
    }
@@ -4265,8 +4205,7 @@ public class NotificationPanelViewController extends PanelViewController {
            };
            };


    @Override
    @Override
    protected PanelViewController.OnConfigurationChangedListener
    protected OnConfigurationChangedListener createOnConfigurationChangedListener() {
            createOnConfigurationChangedListener() {
        return new OnConfigurationChangedListener();
        return new OnConfigurationChangedListener();
    }
    }


@@ -4499,7 +4438,6 @@ public class NotificationPanelViewController extends PanelViewController {
        @Override
        @Override
        public void onThemeChanged() {
        public void onThemeChanged() {
            if (DEBUG_LOGCAT) Log.d(TAG, "onThemeChanged");
            if (DEBUG_LOGCAT) Log.d(TAG, "onThemeChanged");
            mThemeResId = mView.getContext().getThemeResId();
            reInflateViews();
            reInflateViews();
        }
        }


@@ -4649,6 +4587,7 @@ public class NotificationPanelViewController extends PanelViewController {
    public interface NotificationPanelViewStateProvider {
    public interface NotificationPanelViewStateProvider {
        /** Returns the expanded height of the panel view. */
        /** Returns the expanded height of the panel view. */
        float getPanelViewExpandedHeight();
        float getPanelViewExpandedHeight();

        /**
        /**
         * Returns true if heads up should be visible.
         * Returns true if heads up should be visible.
         *
         *
@@ -4745,7 +4684,7 @@ public class NotificationPanelViewController extends PanelViewController {
            setIsFullWidth(mNotificationStackScrollLayoutController.getWidth() == mView.getWidth());
            setIsFullWidth(mNotificationStackScrollLayoutController.getWidth() == mView.getWidth());


            // Update Clock Pivot
            // Update Clock Pivot
            mKeyguardStatusViewController.setPivotX(mView.getWidth() / 2);
            mKeyguardStatusViewController.setPivotX(((float) mView.getWidth()) / 2f);
            mKeyguardStatusViewController.setPivotY(
            mKeyguardStatusViewController.setPivotY(
                    (FONT_HEIGHT - CAP_HEIGHT) / 2048f
                    (FONT_HEIGHT - CAP_HEIGHT) / 2048f
                            * mKeyguardStatusViewController.getClockTextSize());
                            * mKeyguardStatusViewController.getClockTextSize());
@@ -4812,7 +4751,7 @@ public class NotificationPanelViewController extends PanelViewController {
        private final Paint mDebugPaint = new Paint();
        private final Paint mDebugPaint = new Paint();


        @Override
        @Override
        public void draw(@NonNull Canvas canvas) {
        public void draw(@androidx.annotation.NonNull @NonNull Canvas canvas) {
            mDebugTextUsedYPositions.clear();
            mDebugTextUsedYPositions.clear();


            mDebugPaint.setColor(Color.RED);
            mDebugPaint.setColor(Color.RED);
@@ -4886,7 +4825,7 @@ public class NotificationPanelViewController extends PanelViewController {


        @Override
        @Override
        public int getOpacity() {
        public int getOpacity() {
            return 0;
            return PixelFormat.UNKNOWN;
        }
        }
    }
    }


@@ -4956,15 +4895,16 @@ public class NotificationPanelViewController extends PanelViewController {
        private final ListenerSet<Listener> mListeners = new ListenerSet<>();
        private final ListenerSet<Listener> mListeners = new ListenerSet<>();


        @Inject
        @Inject
        PanelEventsEmitter() {}
        PanelEventsEmitter() {
        }


        @Override
        @Override
        public void registerListener(@NonNull Listener listener) {
        public void registerListener(@androidx.annotation.NonNull @NonNull Listener listener) {
            mListeners.addIfAbsent(listener);
            mListeners.addIfAbsent(listener);
        }
        }


        @Override
        @Override
        public void unregisterListener(@NonNull Listener listener) {
        public void unregisterListener(@androidx.annotation.NonNull @NonNull Listener listener) {
            mListeners.remove(listener);
            mListeners.remove(listener);
        }
        }


+0 −3
Original line number Original line Diff line number Diff line
@@ -483,7 +483,6 @@ public class NotificationPanelViewControllerTest extends SysuiTestCase {
        mPanelEventsEmitter = new NotificationPanelViewController.PanelEventsEmitter();
        mPanelEventsEmitter = new NotificationPanelViewController.PanelEventsEmitter();


        mNotificationPanelViewController = new NotificationPanelViewController(mView,
        mNotificationPanelViewController = new NotificationPanelViewController(mView,
                mResources,
                mMainHandler,
                mMainHandler,
                mLayoutInflater,
                mLayoutInflater,
                mFeatureFlags,
                mFeatureFlags,
@@ -524,8 +523,6 @@ public class NotificationPanelViewControllerTest extends SysuiTestCase {
                mQuickAccessWalletController,
                mQuickAccessWalletController,
                mQrCodeScannerController,
                mQrCodeScannerController,
                mRecordingController,
                mRecordingController,
                mExecutor,
                mSecureSettings,
                mLargeScreenShadeHeaderController,
                mLargeScreenShadeHeaderController,
                mScreenOffAnimationController,
                mScreenOffAnimationController,
                mLockscreenGestureLogger,
                mLockscreenGestureLogger,