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

Commit 34f6d96f authored by Lucas Dupin's avatar Lucas Dupin
Browse files

Respond to tap interrupts when pulsing

Tap interrupts are not sent from SLPI when pulsing because the display
is already on. We need a gesture recognizer and callbacks to do so.

Fixes: 125773800
Test: manually toggle settings and tap on screen
Test: atest ScreenDecorationsTest
Change-Id: I1a5f70ba161209c40d8de9033d09182132f2c8ca
parent 623a9c6d
Loading
Loading
Loading
Loading
+49 −8
Original line number Diff line number Diff line
@@ -34,9 +34,12 @@ import android.media.session.MediaSessionLegacyHelper;
import android.net.Uri;
import android.os.Bundle;
import android.os.SystemClock;
import android.os.UserHandle;
import android.provider.Settings;
import android.util.AttributeSet;
import android.view.ActionMode;
import android.view.DisplayCutout;
import android.view.GestureDetector;
import android.view.InputDevice;
import android.view.InputQueue;
import android.view.KeyEvent;
@@ -53,6 +56,7 @@ import android.view.WindowInsetsController;
import android.widget.FrameLayout;

import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.hardware.AmbientDisplayConfiguration;
import com.android.internal.view.FloatingActionMode;
import com.android.internal.widget.FloatingToolbar;
import com.android.systemui.Dependency;
@@ -63,16 +67,23 @@ import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.statusbar.DragDownHelper;
import com.android.systemui.statusbar.StatusBarState;
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout;
import com.android.systemui.tuner.TunerService;

import java.io.FileDescriptor;
import java.io.PrintWriter;

/**
 * Combined status bar and notification panel view. Also holding backdrop and scrims.
 */
public class StatusBarWindowView extends FrameLayout {
    public static final String TAG = "StatusBarWindowView";
    public static final boolean DEBUG = StatusBar.DEBUG;

    private final GestureDetector mGestureDetector;
    private final StatusBarStateController mStatusBarStateController;
    private boolean mDoubleTapEnabled;
    private boolean mSingleTapEnabled;
    private DragDownHelper mDragDownHelper;
    private DoubleTapHelper mDoubleTapHelper;
    private NotificationStackScrollLayout mStackScrollLayout;
    private NotificationPanelView mNotificationPanel;
    private View mBrightnessMirror;
@@ -95,8 +106,37 @@ public class StatusBarWindowView extends FrameLayout {
    private boolean mTouchActive;
    private boolean mExpandAnimationRunning;
    private boolean mExpandAnimationPending;
    private final StatusBarStateController
            mStatusBarStateController = Dependency.get(StatusBarStateController.class);

    private final GestureDetector.SimpleOnGestureListener mGestureListener =
            new GestureDetector.SimpleOnGestureListener() {
        @Override
        public boolean onSingleTapConfirmed(MotionEvent e) {
            if (mSingleTapEnabled) {
                mService.wakeUpIfDozing(SystemClock.uptimeMillis(), StatusBarWindowView.this,
                        "SINGLE_TAP");
            }
            return mSingleTapEnabled;
        }

        @Override
        public boolean onDoubleTap(MotionEvent e) {
            if (mDoubleTapEnabled) {
                mService.wakeUpIfDozing(SystemClock.uptimeMillis(), StatusBarWindowView.this,
                        "DOUBLE_TAP");
            }
            return mDoubleTapEnabled;
        }
    };
    private final TunerService.Tunable mTunable = (key, newValue) -> {
        AmbientDisplayConfiguration configuration = new AmbientDisplayConfiguration(mContext);
        switch (key) {
            case Settings.Secure.DOZE_DOUBLE_TAP_GESTURE:
                mDoubleTapEnabled = configuration.doubleTapGestureEnabled(UserHandle.USER_CURRENT);
                break;
            case Settings.Secure.DOZE_TAP_SCREEN_GESTURE:
                mSingleTapEnabled = configuration.tapGestureEnabled(UserHandle.USER_CURRENT);
        }
    };

    /**
     * If set to true, the current gesture started below the notch and we need to dispatch touch
@@ -110,10 +150,11 @@ public class StatusBarWindowView extends FrameLayout {
        mTransparentSrcPaint.setColor(0);
        mTransparentSrcPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC));
        mFalsingManager = FalsingManager.getInstance(context);
        mDoubleTapHelper = new DoubleTapHelper(this, active -> {}, () -> {
            mService.wakeUpIfDozing(SystemClock.uptimeMillis(), this, "DOUBLE_TAP");
            return true;
        }, null, null);
        mGestureDetector = new GestureDetector(context, mGestureListener);
        mStatusBarStateController = Dependency.get(StatusBarStateController.class);
        Dependency.get(TunerService.class).addTunable(mTunable,
                Settings.Secure.DOZE_DOUBLE_TAP_GESTURE,
                Settings.Secure.DOZE_TAP_SCREEN_GESTURE);
    }

    @Override
@@ -306,6 +347,7 @@ public class StatusBarWindowView extends FrameLayout {
            return false;
        }
        mFalsingManager.onTouchEvent(ev, getWidth(), getHeight());
        mGestureDetector.onTouchEvent(ev);
        if (mBrightnessMirror != null && mBrightnessMirror.getVisibility() == VISIBLE) {
            // Disallow new pointers while the brightness mirror is visible. This is so that you
            // can't touch anything other than the brightness slider while the mirror is showing
@@ -366,7 +408,6 @@ public class StatusBarWindowView extends FrameLayout {
    public boolean onTouchEvent(MotionEvent ev) {
        boolean handled = false;
        if (mService.isDozing()) {
            mDoubleTapHelper.onTouchEvent(ev);
            handled = !mService.isPulsing();
        }
        if ((mStatusBarStateController.getState() == StatusBarState.KEYGUARD && !handled)
+5 −5
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
@@ -82,6 +83,9 @@ public class ScreenDecorationsTest extends SysuiTestCase {
        mTestableLooper = TestableLooper.get(this);
        mDependency.injectTestDependency(Dependency.MAIN_HANDLER,
                new Handler(mTestableLooper.getLooper()));
        mTunablePaddingService = mDependency.injectMockDependency(TunablePaddingService.class);
        mTunerService = mDependency.injectMockDependency(TunerService.class);
        mFragmentService = mDependency.injectMockDependency(FragmentService.class);

        mStatusBar = mock(StatusBar.class);
        mWindowManager = mock(WindowManager.class);
@@ -93,12 +97,9 @@ public class ScreenDecorationsTest extends SysuiTestCase {
        when(mWindowManager.getDefaultDisplay()).thenReturn(display);
        mContext.addMockSystemService(WindowManager.class, mWindowManager);

        mFragmentService = mDependency.injectMockDependency(FragmentService.class);
        mFragmentHostManager = mock(FragmentHostManager.class);
        when(mFragmentService.getFragmentHostManager(any())).thenReturn(mFragmentHostManager);

        mTunerService = mDependency.injectMockDependency(TunerService.class);


        mScreenDecorations = new ScreenDecorations() {
            @Override
@@ -126,8 +127,7 @@ public class ScreenDecorationsTest extends SysuiTestCase {
        };
        mScreenDecorations.mContext = mContext;
        mScreenDecorations.mComponents = mContext.getComponents();

        mTunablePaddingService = mDependency.injectMockDependency(TunablePaddingService.class);
        reset(mTunerService);
    }

    @Test