Merge "Touch handling and other tiny cleanups in NPVC" into tm-qpr-dev am: 07b420686a

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/21767439

Change-Id: I0c07948cc0cfacc5cd33814210fb5ef3a8d8ea6a
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Justin Weir
2023-03-10 23:23:05 +00:00
committed by Automerger Merge Worker
7 changed files with 49 additions and 87 deletions

View File

@@ -119,6 +119,7 @@ import com.android.keyguard.dagger.KeyguardStatusViewComponent;
import com.android.keyguard.dagger.KeyguardUserSwitcherComponent;
import com.android.systemui.DejankUtils;
import com.android.systemui.Dumpable;
import com.android.systemui.Gefingerpoken;
import com.android.systemui.R;
import com.android.systemui.animation.ActivityLaunchAnimator;
import com.android.systemui.animation.Interpolators;
@@ -162,14 +163,12 @@ import com.android.systemui.plugins.FalsingManager.FalsingTapListener;
import com.android.systemui.plugins.qs.QS;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.plugins.statusbar.StatusBarStateController.StateListener;
import com.android.systemui.screenrecord.RecordingController;
import com.android.systemui.shade.transition.ShadeTransitionController;
import com.android.systemui.shared.system.QuickStepContract;
import com.android.systemui.statusbar.CommandQueue;
import com.android.systemui.statusbar.GestureRecorder;
import com.android.systemui.statusbar.KeyguardIndicationController;
import com.android.systemui.statusbar.LockscreenShadeTransitionController;
import com.android.systemui.statusbar.NotificationRemoteInputManager;
import com.android.systemui.statusbar.NotificationShadeDepthController;
import com.android.systemui.statusbar.NotificationShadeWindowController;
import com.android.systemui.statusbar.NotificationShelfController;
@@ -357,6 +356,7 @@ public final class NotificationPanelViewController implements Dumpable {
private final AlternateBouncerInteractor mAlternateBouncerInteractor;
private final QuickSettingsController mQsController;
private final InteractionJankMonitor mInteractionJankMonitor;
private final TouchHandler mTouchHandler = new TouchHandler();
private long mDownTime;
private boolean mTouchSlopExceededBeforeDown;
@@ -541,7 +541,7 @@ public final class NotificationPanelViewController implements Dumpable {
private final KeyguardBottomAreaViewModel mKeyguardBottomAreaViewModel;
private final KeyguardBottomAreaInteractor mKeyguardBottomAreaInteractor;
private float mMinExpandHeight;
private ShadeHeightLogger mShadeHeightLogger;
private final ShadeHeightLogger mShadeHeightLogger;
private boolean mPanelUpdateWhenAnimatorEnds;
private boolean mHasVibratedOnOpen = false;
private int mFixedDuration = NO_FIXED_DURATION;
@@ -586,15 +586,15 @@ public final class NotificationPanelViewController implements Dumpable {
private boolean mGestureWaitForTouchSlop;
private boolean mIgnoreXTouchSlop;
private boolean mExpandLatencyTracking;
private DreamingToLockscreenTransitionViewModel mDreamingToLockscreenTransitionViewModel;
private OccludedToLockscreenTransitionViewModel mOccludedToLockscreenTransitionViewModel;
private LockscreenToDreamingTransitionViewModel mLockscreenToDreamingTransitionViewModel;
private GoneToDreamingTransitionViewModel mGoneToDreamingTransitionViewModel;
private LockscreenToOccludedTransitionViewModel mLockscreenToOccludedTransitionViewModel;
private final DreamingToLockscreenTransitionViewModel mDreamingToLockscreenTransitionViewModel;
private final OccludedToLockscreenTransitionViewModel mOccludedToLockscreenTransitionViewModel;
private final LockscreenToDreamingTransitionViewModel mLockscreenToDreamingTransitionViewModel;
private final GoneToDreamingTransitionViewModel mGoneToDreamingTransitionViewModel;
private final LockscreenToOccludedTransitionViewModel mLockscreenToOccludedTransitionViewModel;
private KeyguardTransitionInteractor mKeyguardTransitionInteractor;
private final KeyguardTransitionInteractor mKeyguardTransitionInteractor;
private final KeyguardInteractor mKeyguardInteractor;
private CoroutineDispatcher mMainDispatcher;
private final CoroutineDispatcher mMainDispatcher;
private boolean mIsOcclusionTransitionRunning = false;
private int mDreamingToLockscreenTransitionTranslationY;
private int mOccludedToLockscreenTransitionTranslationY;
@@ -708,12 +708,10 @@ public final class NotificationPanelViewController implements Dumpable {
QuickSettingsController quickSettingsController,
FragmentService fragmentService,
ContentResolver contentResolver,
RecordingController recordingController,
ShadeHeaderController shadeHeaderController,
ScreenOffAnimationController screenOffAnimationController,
LockscreenGestureLogger lockscreenGestureLogger,
ShadeExpansionStateManager shadeExpansionStateManager,
NotificationRemoteInputManager remoteInputManager,
Optional<SysUIUnfoldComponent> unfoldComponent,
SysUiState sysUiState,
Provider<KeyguardBottomAreaViewController> keyguardBottomAreaViewControllerProvider,
@@ -771,7 +769,7 @@ public final class NotificationPanelViewController implements Dumpable {
});
mView.addOnLayoutChangeListener(new ShadeLayoutChangeListener());
mView.setOnTouchListener(createTouchHandler());
mView.setOnTouchListener(getTouchHandler());
mView.setOnConfigurationChangedListener(config -> loadDimens());
mResources = mView.getResources();
@@ -1643,10 +1641,6 @@ public final class NotificationPanelViewController implements Dumpable {
return mDozing && mDozeParameters.getAlwaysOn();
}
boolean isDozing() {
return mDozing;
}
private boolean hasVisibleNotifications() {
return mNotificationStackScrollLayoutController
.getVisibleNotificationCount() != 0
@@ -3336,8 +3330,8 @@ public final class NotificationPanelViewController implements Dumpable {
}
@VisibleForTesting
TouchHandler createTouchHandler() {
return new TouchHandler();
TouchHandler getTouchHandler() {
return mTouchHandler;
}
public NotificationStackScrollLayoutController getNotificationStackScrollLayoutController() {
@@ -3985,14 +3979,14 @@ public final class NotificationPanelViewController implements Dumpable {
return mView.post(action);
}
/** */
public boolean sendInterceptTouchEventToView(MotionEvent event) {
return mView.onInterceptTouchEvent(event);
/** Sends an external (e.g. Status Bar) intercept touch event to the Shade touch handler. */
public boolean handleExternalInterceptTouch(MotionEvent event) {
return mTouchHandler.onInterceptTouchEvent(event);
}
/** */
public boolean sendTouchEventToView(MotionEvent event) {
return mView.dispatchTouchEvent(event);
/** Sends an external (e.g. Status Bar) touch event to the Shade touch handler. */
public boolean handleExternalTouch(MotionEvent event) {
return mTouchHandler.onTouchEvent(event);
}
/** */
@@ -4010,14 +4004,6 @@ public final class NotificationPanelViewController implements Dumpable {
return mView.isEnabled();
}
int getDisplayRightInset() {
return mDisplayRightInset;
}
int getDisplayLeftInset() {
return mDisplayLeftInset;
}
float getOverStretchAmount() {
return mOverStretchAmount;
}
@@ -4026,10 +4012,6 @@ public final class NotificationPanelViewController implements Dumpable {
return mMinFraction;
}
boolean getCollapsedOnDown() {
return mCollapsedOnDown;
}
int getNavigationBarBottomHeight() {
return mNavigationBarBottomHeight;
}
@@ -4593,7 +4575,7 @@ public final class NotificationPanelViewController implements Dumpable {
}
/** Handles MotionEvents for the Shade. */
public final class TouchHandler implements View.OnTouchListener {
public final class TouchHandler implements View.OnTouchListener, Gefingerpoken {
private long mLastTouchDownTime = -1L;
/** @see ViewGroup#onInterceptTouchEvent(MotionEvent) */
@@ -4739,6 +4721,11 @@ public final class NotificationPanelViewController implements Dumpable {
@Override
public boolean onTouch(View v, MotionEvent event) {
return onTouchEvent(event);
}
@Override
public boolean onTouchEvent(MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
if (event.getDownTime() == mLastTouchDownTime) {
// An issue can occur when swiping down after unlock, where multiple down

View File

@@ -342,7 +342,7 @@ public class NotificationShadeWindowViewController {
MotionEvent cancellation = MotionEvent.obtain(ev);
cancellation.setAction(MotionEvent.ACTION_CANCEL);
mStackScrollLayout.onInterceptTouchEvent(cancellation);
mNotificationPanelViewController.sendInterceptTouchEventToView(cancellation);
mNotificationPanelViewController.handleExternalInterceptTouch(cancellation);
cancellation.recycle();
}

View File

@@ -35,6 +35,7 @@ import android.widget.LinearLayout;
import com.android.internal.policy.SystemBarUtils;
import com.android.systemui.Dependency;
import com.android.systemui.Gefingerpoken;
import com.android.systemui.R;
import com.android.systemui.plugins.DarkIconDispatcher;
import com.android.systemui.plugins.DarkIconDispatcher.DarkReceiver;
@@ -60,7 +61,7 @@ public class PhoneStatusBarView extends FrameLayout {
private Rect mDisplaySize;
private int mStatusBarHeight;
@Nullable
private TouchEventHandler mTouchEventHandler;
private Gefingerpoken mTouchEventHandler;
/**
* Draw this many pixels into the left/right side of the cutout to optimally use the space
@@ -72,7 +73,7 @@ public class PhoneStatusBarView extends FrameLayout {
mContentInsetsProvider = Dependency.get(StatusBarContentInsetsProvider.class);
}
void setTouchEventHandler(TouchEventHandler handler) {
void setTouchEventHandler(Gefingerpoken handler) {
mTouchEventHandler = handler;
}
@@ -185,7 +186,7 @@ public class PhoneStatusBarView extends FrameLayout {
);
return true;
}
return mTouchEventHandler.handleTouchEvent(event);
return mTouchEventHandler.onTouchEvent(event);
}
@Override
@@ -267,28 +268,4 @@ public class PhoneStatusBarView extends FrameLayout {
insets.second,
getPaddingBottom());
}
/**
* A handler responsible for all touch event handling on the status bar.
*
* Touches that occur on the status bar view may have ramifications for the notification
* panel (e.g. a touch that pulls down the shade could start on the status bar), so this
* interface provides a way to notify the panel controller when these touches occur.
*
* The handler will be notified each time {@link PhoneStatusBarView#onTouchEvent} and
* {@link PhoneStatusBarView#onInterceptTouchEvent} are called.
**/
public interface TouchEventHandler {
/** Called each time {@link PhoneStatusBarView#onInterceptTouchEvent} is called. */
void onInterceptTouchEvent(MotionEvent event);
/**
* Called each time {@link PhoneStatusBarView#onTouchEvent} is called.
*
* Should return true if the touch was handled by this handler and false otherwise. The
* return value from the handler will be returned from
* {@link PhoneStatusBarView#onTouchEvent}.
*/
boolean handleTouchEvent(MotionEvent event);
}
}

View File

@@ -24,11 +24,11 @@ import android.view.MotionEvent
import android.view.View
import android.view.ViewGroup
import android.view.ViewTreeObserver
import com.android.systemui.Gefingerpoken
import com.android.systemui.R
import com.android.systemui.shade.ShadeController
import com.android.systemui.shade.ShadeLogger
import com.android.systemui.shared.animation.UnfoldMoveFromCenterAnimator
import com.android.systemui.statusbar.phone.PhoneStatusBarView.TouchEventHandler
import com.android.systemui.statusbar.policy.ConfigurationController
import com.android.systemui.unfold.SysUIUnfoldComponent
import com.android.systemui.unfold.UNFOLD_STATUS_BAR
@@ -131,7 +131,7 @@ class PhoneStatusBarViewController private constructor(
}
/** Called when a touch event occurred on {@link PhoneStatusBarView}. */
fun onTouchEvent(event: MotionEvent) {
fun onTouch(event: MotionEvent) {
if (centralSurfaces.statusBarWindowState == WINDOW_STATE_SHOWING) {
val upOrCancel =
event.action == MotionEvent.ACTION_UP ||
@@ -141,13 +141,14 @@ class PhoneStatusBarViewController private constructor(
}
}
inner class PhoneStatusBarViewTouchHandler : TouchEventHandler {
override fun onInterceptTouchEvent(event: MotionEvent) {
onTouchEvent(event)
inner class PhoneStatusBarViewTouchHandler : Gefingerpoken {
override fun onInterceptTouchEvent(event: MotionEvent): Boolean {
onTouch(event)
return false
}
override fun handleTouchEvent(event: MotionEvent): Boolean {
onTouchEvent(event)
override fun onTouchEvent(event: MotionEvent): Boolean {
onTouch(event)
// If panels aren't enabled, ignore the gesture and don't pass it down to the
// panel view.
@@ -174,7 +175,7 @@ class PhoneStatusBarViewController private constructor(
return true
}
}
return centralSurfaces.notificationPanelViewController.sendTouchEventToView(event)
return centralSurfaces.notificationPanelViewController.handleExternalTouch(event)
}
}

View File

@@ -536,12 +536,10 @@ public class NotificationPanelViewControllerBaseTest extends SysuiTestCase {
mQsController,
mFragmentService,
mContentResolver,
mRecordingController,
mShadeHeaderController,
mScreenOffAnimationController,
mLockscreenGestureLogger,
mShadeExpansionStateManager,
mNotificationRemoteInputManager,
mSysUIUnfoldComponent,
mSysUiState,
() -> mKeyguardBottomAreaViewController,

View File

@@ -18,7 +18,6 @@ package com.android.systemui.statusbar.phone
import android.view.LayoutInflater
import android.view.MotionEvent
import android.view.ViewGroup
import android.view.ViewTreeObserver
import android.view.ViewTreeObserver.OnPreDrawListener
import android.widget.FrameLayout
@@ -55,8 +54,6 @@ class PhoneStatusBarViewControllerTest : SysuiTestCase() {
@Mock
private lateinit var notificationPanelViewController: NotificationPanelViewController
@Mock
private lateinit var panelView: ViewGroup
@Mock
private lateinit var moveFromCenterAnimation: StatusBarMoveFromCenterAnimationController
@Mock
private lateinit var sysuiUnfoldComponent: SysUIUnfoldComponent
@@ -116,7 +113,7 @@ class PhoneStatusBarViewControllerTest : SysuiTestCase() {
val returnVal = view.onTouchEvent(
MotionEvent.obtain(0L, 0L, MotionEvent.ACTION_DOWN, 0f, 0f, 0))
assertThat(returnVal).isFalse()
verify(notificationPanelViewController, never()).sendTouchEventToView(any())
verify(notificationPanelViewController, never()).handleExternalTouch(any())
}
@Test
@@ -128,7 +125,7 @@ class PhoneStatusBarViewControllerTest : SysuiTestCase() {
val returnVal = view.onTouchEvent(
MotionEvent.obtain(0L, 0L, MotionEvent.ACTION_DOWN, 0f, 0f, 0))
assertThat(returnVal).isTrue()
verify(notificationPanelViewController, never()).sendTouchEventToView(any())
verify(notificationPanelViewController, never()).handleExternalTouch(any())
}
@Test
@@ -141,7 +138,7 @@ class PhoneStatusBarViewControllerTest : SysuiTestCase() {
view.onTouchEvent(event)
verify(notificationPanelViewController).sendTouchEventToView(event)
verify(notificationPanelViewController).handleExternalTouch(event)
}
@Test
@@ -154,7 +151,7 @@ class PhoneStatusBarViewControllerTest : SysuiTestCase() {
view.onTouchEvent(event)
verify(notificationPanelViewController).sendTouchEventToView(event)
verify(notificationPanelViewController).handleExternalTouch(event)
}
@Test
@@ -167,7 +164,7 @@ class PhoneStatusBarViewControllerTest : SysuiTestCase() {
view.onTouchEvent(event)
verify(notificationPanelViewController, never()).sendTouchEventToView(any())
verify(notificationPanelViewController, never()).handleExternalTouch(any())
}
private fun createViewMock(): PhoneStatusBarView {

View File

@@ -19,6 +19,7 @@ package com.android.systemui.statusbar.phone
import android.view.MotionEvent
import android.view.ViewGroup
import androidx.test.filters.SmallTest
import com.android.systemui.Gefingerpoken
import com.android.systemui.SysuiTestCase
import com.android.systemui.shade.NotificationPanelViewController
import com.google.common.truth.Truth.assertThat
@@ -94,16 +95,17 @@ class PhoneStatusBarViewTest : SysuiTestCase() {
// No assert needed, just testing no crash
}
private class TestTouchEventHandler : PhoneStatusBarView.TouchEventHandler {
private class TestTouchEventHandler : Gefingerpoken {
var lastInterceptEvent: MotionEvent? = null
var lastEvent: MotionEvent? = null
var handleTouchReturnValue: Boolean = false
override fun onInterceptTouchEvent(event: MotionEvent?) {
override fun onInterceptTouchEvent(event: MotionEvent?): Boolean {
lastInterceptEvent = event
return handleTouchReturnValue
}
override fun handleTouchEvent(event: MotionEvent?): Boolean {
override fun onTouchEvent(event: MotionEvent?): Boolean {
lastEvent = event
return handleTouchReturnValue
}