From fadf6eaee1c3a32391adb78fe7eaab755fc5bcdf Mon Sep 17 00:00:00 2001 From: Rashed Abdel-Tawab Date: Tue, 3 Oct 2017 17:17:37 -0400 Subject: SystemUI: Add double tap to sleep gesture Author: Roman Birg Date: Sun Nov 23 06:54:06 2014 -0800 SystemUI: double tap to sleep improvements * Make it more reliable * Add it to keyguard * Add a content observer to not always query Settings.System on every touch event Change-Id: I292c4d9d9f810843590b7a9ec6e15b99ac44009d Signed-off-by: Roman Birg Author: Adnan Begovic Date: Wed Nov 11 12:05:59 2015 -0800 fw: Move DOUBLE_TAP_SLEEP_GESTURE to CMSettings. Change-Id: I8274b7c241cef6835a1114a702e68c95b6d2e036 Author: Zhao Wei Liew Date: Fri Oct 7 08:56:25 2016 +0800 SystemUI: Use Tuner API for CM settings Get rid of all the excess code by implementing TunerService.Tunable and observing any changes made to the settings through it. Remove UserContentObserver as the Tuner API handles user switches. Also remove some unused imports that were introduced in earlier CM commits, but were never removed since. Change-Id: Iecafafabdaec82b3b3c72293bea865de48f0e90a Author: Altaf-Mahdi Date: Wed Nov 11 16:07:49 2015 -0500 Double tap to sleep anywhere on the lock screen [1/3] Change-Id: I7dd46f3fafeb2e629974c0f32083d4d9774fb1de [neo: Using Tuner API.] Signed-off-by: Pranav Vashi Author: dianlujitao Date: Thu Feb 27 12:57:07 2020 +0800 SystemUI: Don't sleep on double tap below status bar Change-Id: Ic64c29eae63e96f34dc37cda355401b7e2cd2d39 [Pig]: Forward port to R [bgcngm]: Forward port to S POSP edit: keep the lockscreen part only also add dozing and ambient pulsing checks Change-Id: I0281d23cb3ad5f8f2b67d08ae431e8a962a60927 --- core/java/android/provider/Settings.java | 6 ++++ .../phone/NotificationPanelViewController.java | 36 +++++++++++++++++++++- 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index 5753e0481b0f..fb59ae9a26e8 100644 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -10158,6 +10158,12 @@ public final class Settings { @Readable public static final String GAME_DASHBOARD_ALWAYS_ON = "game_dashboard_always_on"; + /** + * Double tap on lockscreen to sleep + * @hide + */ + public static final String DOUBLE_TAP_SLEEP_GESTURE = "double_tap_sleep_gesture"; + /** * These entries are considered common between the personal and the managed profile, * since the managed profile doesn't get to change them. diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java index 7af289fb4094..4eeb96888415 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java @@ -61,6 +61,7 @@ import android.os.VibrationEffect; import android.provider.Settings; import android.util.Log; import android.util.MathUtils; +import android.view.GestureDetector; import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.VelocityTracker; @@ -163,6 +164,7 @@ import com.android.systemui.statusbar.policy.KeyguardStateController; import com.android.systemui.statusbar.policy.KeyguardUserSwitcherController; import com.android.systemui.statusbar.policy.KeyguardUserSwitcherView; import com.android.systemui.statusbar.policy.OnHeadsUpChangedListener; +import com.android.systemui.tuner.TunerService; import com.android.systemui.util.Utils; import com.android.systemui.util.settings.SecureSettings; import com.android.systemui.wallet.controller.QuickAccessWalletController; @@ -254,6 +256,9 @@ public class NotificationPanelViewController extends PanelViewController { private static final String COUNTER_PANEL_OPEN_QS = "panel_open_qs"; private static final String COUNTER_PANEL_OPEN_PEEK = "panel_open_peek"; + private static final String DOUBLE_TAP_SLEEP_GESTURE = + Settings.Secure.DOUBLE_TAP_SLEEP_GESTURE; + private static final Rect M_DUMMY_DIRTY_RECT = new Rect(0, 0, 1, 1); private static final Rect EMPTY_RECT = new Rect(); @@ -315,6 +320,7 @@ public class NotificationPanelViewController extends PanelViewController { private final AuthController mAuthController; private final MediaHierarchyManager mMediaHierarchyManager; private final StatusBarKeyguardViewManager mStatusBarKeyguardViewManager; + private final TunerService mTunerService; private final KeyguardStatusViewComponent.Factory mKeyguardStatusViewComponentFactory; private final KeyguardQsUserSwitchComponent.Factory mKeyguardQsUserSwitchComponentFactory; private final KeyguardUserSwitcherComponent.Factory mKeyguardUserSwitcherComponentFactory; @@ -514,6 +520,8 @@ public class NotificationPanelViewController extends PanelViewController { private final MediaDataManager mMediaDataManager; private NotificationShadeDepthController mDepthController; private int mDisplayId; + private boolean mDoubleTapToSleepEnabled; + private GestureDetector mDoubleTapGesture; /** * Cache the resource id of the theme to avoid unnecessary work in onThemeChanged. @@ -708,6 +716,7 @@ public class NotificationPanelViewController extends PanelViewController { MediaHierarchyManager mediaHierarchyManager, BiometricUnlockController biometricUnlockController, StatusBarKeyguardViewManager statusBarKeyguardViewManager, + TunerService tunerService, NotificationStackScrollLayoutController notificationStackScrollLayoutController, KeyguardStatusViewComponent.Factory keyguardStatusViewComponentFactory, KeyguardQsUserSwitchComponent.Factory keyguardQsUserSwitchComponentFactory, @@ -755,6 +764,7 @@ public class NotificationPanelViewController extends PanelViewController { mFlingAnimationUtilsBuilder = flingAnimationUtilsBuilder; mMediaHierarchyManager = mediaHierarchyManager; mStatusBarKeyguardViewManager = statusBarKeyguardViewManager; + mTunerService = tunerService; mNotificationStackScrollLayoutController = notificationStackScrollLayoutController; mGroupManager = groupManager; mNotificationIconAreaController = notificationIconAreaController; @@ -828,6 +838,16 @@ public class NotificationPanelViewController extends PanelViewController { }); mBottomAreaShadeAlphaAnimator.setDuration(160); mBottomAreaShadeAlphaAnimator.setInterpolator(Interpolators.ALPHA_OUT); + mDoubleTapGesture = new GestureDetector(mView.getContext(), + new GestureDetector.SimpleOnGestureListener() { + @Override + public boolean onDoubleTap(MotionEvent e) { + if (mPowerManager != null) { + mPowerManager.goToSleep(e.getEventTime()); + } + return true; + } + }); mLockscreenUserManager = notificationLockscreenUserManager; mEntryManager = notificationEntryManager; mConversationNotificationManager = conversationNotificationManager; @@ -3968,6 +3988,10 @@ public class NotificationPanelViewController extends PanelViewController { return false; } + if (mDoubleTapToSleepEnabled && !mPulsing && !mDozing && mBarState == StatusBarState.KEYGUARD) { + mDoubleTapGesture.onTouchEvent(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) { @@ -4531,13 +4555,15 @@ public class NotificationPanelViewController extends PanelViewController { positionClockAndNotifications(true /* forceUpdate */); } - private class OnAttachStateChangeListener implements View.OnAttachStateChangeListener { + private class OnAttachStateChangeListener implements View.OnAttachStateChangeListener, + TunerService.Tunable { @Override public void onViewAttachedToWindow(View v) { mFragmentService.getFragmentHostManager(mView) .addTagListener(QS.TAG, mFragmentListener); mStatusBarStateController.addCallback(mStatusBarStateListener); mConfigurationController.addCallback(mConfigurationListener); + mTunerService.addTunable(this, DOUBLE_TAP_SLEEP_GESTURE); mUpdateMonitor.registerCallback(mKeyguardUpdateCallback); // Theme might have changed between inflating this view and attaching it to the // window, so @@ -4557,6 +4583,14 @@ public class NotificationPanelViewController extends PanelViewController { mConfigurationController.removeCallback(mConfigurationListener); mUpdateMonitor.removeCallback(mKeyguardUpdateCallback); mFalsingManager.removeTapListener(mFalsingTapListener); + mTunerService.removeTunable(this); + } + + @Override + public void onTuningChanged(String key, String newValue) { + if (DOUBLE_TAP_SLEEP_GESTURE.equals(key)) { + mDoubleTapToSleepEnabled = TunerService.parseIntegerSwitch(newValue, true); + } } } -- cgit v1.2.3