private KeyguardUserSwitcher mKeyguardUserSwitcher;
@VisibleForTesting
protected KeyguardStatusBarView mKeyguardStatusBar;
- private ViewGroup mBigClockContainer;
+ @VisibleForTesting
+ protected ViewGroup mBigClockContainer;
private QS mQs;
- private FrameLayout mQsFrame;
+ @VisibleForTesting
+ protected FrameLayout mQsFrame;
@VisibleForTesting
protected KeyguardStatusView mKeyguardStatusView;
private View mQsNavbarScrim;
private int mIndicationBottomPadding;
private int mAmbientIndicationBottomPadding;
private boolean mIsFullWidth;
+ private boolean mBlockingExpansionForCurrentTouch;
/**
* Current dark amount that follows regular interpolation curve of animation.
return false;
}
initDownStates(event);
+ // Make sure the next touch won't the blocked after the current ends.
+ if (event.getAction() == MotionEvent.ACTION_UP
+ || event.getAction() == MotionEvent.ACTION_CANCEL) {
+ mBlockingExpansionForCurrentTouch = false;
+ }
if (!mIsExpanding && mPulseExpansionHandler.onTouchEvent(event)) {
// We're expanding all the other ones shouldn't get this anymore
return true;
if (!mQsExpansionEnabled || mCollapsedOnDown) {
return false;
}
- View header = mKeyguardShowing ? mKeyguardStatusBar : mQs.getHeader();
+ View header = mKeyguardShowing || mQs == null ? mKeyguardStatusBar : mQs.getHeader();
final boolean onHeader = x >= mQsFrame.getX()
&& x <= mQsFrame.getX() + mQsFrame.getWidth()
&& y >= header.getTop() && y <= header.getBottom();
@Override
protected boolean isTrackingBlocked() {
- return mConflictingQsExpansionGesture && mQsExpanded;
+ return mConflictingQsExpansionGesture && mQsExpanded || mBlockingExpansionForCurrentTouch;
}
public boolean isQsExpanded() {
updateLockIcon();
}
+ /**
+ * Do not let the user drag the shade up and down for the current touch session.
+ * This is necessary to avoid shade expansion while/after the bouncer is dismissed.
+ */
+ public void blockExpansionForCurrentTouch() {
+ mBlockingExpansionForCurrentTouch = mTracking;
+ }
+
@Override
public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
super.dump(fd, pw, args);
package com.android.systemui.statusbar.phone;
+import static com.google.common.truth.Truth.assertThat;
+
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.verify;
import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
+import android.view.MotionEvent;
+import android.view.ViewGroup;
import androidx.test.filters.SmallTest;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.statusbar.AmbientPulseManager;
import com.android.systemui.statusbar.NotificationLockscreenUserManager;
+import com.android.systemui.statusbar.NotificationShelf;
import com.android.systemui.statusbar.PulseExpansionHandler;
import com.android.systemui.statusbar.StatusBarStateControllerImpl;
import com.android.systemui.statusbar.SysuiStatusBarStateController;
public class NotificationPanelViewTest extends SysuiTestCase {
@Mock
+ private StatusBar mStatusBar;
+ @Mock
private SysuiStatusBarStateController mStatusBarStateController;
@Mock
private NotificationStackScrollLayout mNotificationStackScrollLayout;
@Mock
private KeyguardBottomAreaView mKeyguardBottomArea;
@Mock
+ private KeyguardBottomAreaView mQsFrame;
+ @Mock
+ private ViewGroup mBigClockContainer;
+ @Mock
+ private ScrimController mScrimController;
+ @Mock
+ private NotificationIconAreaController mNotificationAreaController;
+ @Mock
+ private HeadsUpManagerPhone mHeadsUpManager;
+ @Mock
+ private NotificationShelf mNotificationShelf;
+ @Mock
+ private NotificationGroupManager mGroupManager;
+ @Mock
private KeyguardStatusBarView mKeyguardStatusBar;
+ @Mock
+ private HeadsUpTouchHelper.Callback mHeadsUpCallback;
+ @Mock
+ private PanelBar mPanelBar;
private NotificationPanelView mNotificationPanelView;
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
+ when(mNotificationStackScrollLayout.getHeight()).thenReturn(1000);
+ when(mNotificationStackScrollLayout.getHeadsUpCallback()).thenReturn(mHeadsUpCallback);
+ when(mHeadsUpCallback.getContext()).thenReturn(mContext);
mDependency.injectTestDependency(StatusBarStateController.class,
mStatusBarStateController);
mDependency.injectMockDependency(ShadeController.class);
new StatusBarStateControllerImpl());
PulseExpansionHandler expansionHandler = new PulseExpansionHandler(mContext, coordinator);
mNotificationPanelView = new TestableNotificationPanelView(coordinator, expansionHandler);
+ mNotificationPanelView.setHeadsUpManager(mHeadsUpManager);
+ mNotificationPanelView.setBar(mPanelBar);
}
@Test
verify(mNotificationStackScrollLayout).setShowDarkShelf(eq(false));
}
+ @Test
+ public void testSetExpandedHeight() {
+ mNotificationPanelView.setExpandedHeight(200);
+ assertThat((int) mNotificationPanelView.getExpandedHeight()).isEqualTo(200);
+ }
+
+ @Test
+ public void testOnTouchEvent_expansionCanBeBlocked() {
+ mNotificationPanelView.onTouchEvent(MotionEvent.obtain(0L /* downTime */,
+ 0L /* eventTime */, MotionEvent.ACTION_DOWN, 0f /* x */, 0f /* y */,
+ 0 /* metaState */));
+ mNotificationPanelView.onTouchEvent(MotionEvent.obtain(0L /* downTime */,
+ 0L /* eventTime */, MotionEvent.ACTION_MOVE, 0f /* x */, 200f /* y */,
+ 0 /* metaState */));
+ assertThat((int) mNotificationPanelView.getExpandedHeight()).isEqualTo(200);
+ assertThat(mNotificationPanelView.isTrackingBlocked()).isFalse();
+
+ mNotificationPanelView.blockExpansionForCurrentTouch();
+ mNotificationPanelView.onTouchEvent(MotionEvent.obtain(0L /* downTime */,
+ 0L /* eventTime */, MotionEvent.ACTION_MOVE, 0f /* x */, 300f /* y */,
+ 0 /* metaState */));
+ // Expansion should not have changed because it was blocked
+ assertThat((int) mNotificationPanelView.getExpandedHeight()).isEqualTo(200);
+ assertThat(mNotificationPanelView.isTrackingBlocked()).isTrue();
+
+ mNotificationPanelView.onTouchEvent(MotionEvent.obtain(0L /* downTime */,
+ 0L /* eventTime */, MotionEvent.ACTION_UP, 0f /* x */, 300f /* y */,
+ 0 /* metaState */));
+ assertThat(mNotificationPanelView.isTrackingBlocked()).isFalse();
+ }
+
private class TestableNotificationPanelView extends NotificationPanelView {
TestableNotificationPanelView(NotificationWakeUpCoordinator coordinator,
PulseExpansionHandler expansionHandler) {
mKeyguardStatusView = NotificationPanelViewTest.this.mKeyguardStatusView;
mKeyguardStatusBar = NotificationPanelViewTest.this.mKeyguardStatusBar;
mKeyguardBottomArea = NotificationPanelViewTest.this.mKeyguardBottomArea;
+ mBigClockContainer = NotificationPanelViewTest.this.mBigClockContainer;
+ mQsFrame = NotificationPanelViewTest.this.mQsFrame;
+ initDependencies(NotificationPanelViewTest.this.mStatusBar,
+ NotificationPanelViewTest.this.mGroupManager,
+ NotificationPanelViewTest.this.mNotificationShelf,
+ NotificationPanelViewTest.this.mHeadsUpManager,
+ NotificationPanelViewTest.this.mNotificationAreaController,
+ NotificationPanelViewTest.this.mScrimController);
}
}
}