SystemUI: Add double tap to sleep gesture

Author: Roman Birg <roman@cyngn.com>
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 <roman@cyngn.com>

Author: Adnan Begovic <adnan@cyngn.com>
Date:   Wed Nov 11 12:05:59 2015 -0800

    fw: Move DOUBLE_TAP_SLEEP_GESTURE to CMSettings.

    Change-Id: I8274b7c241cef6835a1114a702e68c95b6d2e036

Author: Zhao Wei Liew <zhaoweiliew@gmail.com>
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 <altaf.mahdi@gmail.com>
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 <neobuddy89@gmail.com>

Author: dianlujitao <dianlujitao@lineageos.org>
Date:   Thu Feb 27 12:57:07 2020 +0800

    SystemUI: Don't sleep on double tap below status bar

    Change-Id: Ic64c29eae63e96f34dc37cda355401b7e2cd2d39

Author: Arian <arian.kulmer@web.de>
Date:   2020-12-27 14:35:33 +0100

    NotificationPanelViewController: Fix DT2S gesture handling

    Change-Id: I9f2d3c63d397c998bea5137f747a9ad95ae2c746

Author:     maxwen <max.weninger@gmail.com>
AuthorDate: Mon Nov 18 00:29:15 2019 +0100

    SystemUI: use DOUBLE_TAP_TO_WAKE setting also for wake from aod

    Co-authored-by: Michael W <baddaemon87@gmail.com>
    Change-Id: Ib51fdeaaa9a1b18b79f4f311c65565352d909a72

Author:     Dhina17 <dhinalogu@gmail.com>
AuthorDate: Tue Sep 12 11:08:28 2023 +0530

    SystemUI: Move DT2S from PulsingGestureListener

    PulsingGestureListener should handle the touch events in the
    dozing state (AOD/ambient).
    Our DT2S should work in non-dozing mode so move out from here.

    Test:
    Double tap to sleep on QQS status bar works fine as before.

    Change-Id: Ia79df2eb73e54d8b0dcb1d10b18539f4e88a0a18

Author:     Dhina17 <dhinalogu@gmail.com>
AuthorDate: Mon Sep 11 16:24:24 2023 +0530

    SystemUI: Pass touch events to pulsing gesture listener only if dozing

    PulsingGestureListener should handle touch events only in the
    dozing state (AOD/ambient).

    Otherwise lockscreen DT2S and AOD DT2W will be in conflict.

    Explanation:
    Enable AOD, DT2W and DT2S in the display settings.

    In the scenerio, touch events are passed to
    first NotificationPanelView then NotificationShadeWindowView.

    So first NotificationPanelView(Controller) detects the double tap
    and put the screen to sleep (hence dozing = true).
    Then as the NotificationShadeWindowView(Controller) detects the double tap at dozing,
    it wakes up from the AOD immediately [from PulsingGestureListener].

    so it won't let the screen to sleep on double tap the lockscreen
    when AOD and DT2W are available.

    PulsingGestureListener is supposed to receive touch events only in
    the dozing state, so it won't cause this conflict.

    Test:
    - Enable AOD, DT2W and DT2S in the display settings
    - Double tap in the lockscreen, it will go to AOD screen.

    Change-Id: I6ede700e690ad4c37fea64419cfe8a53d64a9e9a

Author: Bruno Martins <bgcngm@gmail.com>
Date:   Fri Oct 13 14:04:00 2023 +0100

    SystemUI: Respect status bar DT2S gesture defaults

    Feature can be disabled by default, but if additionally the preference
    is hidden in Settings, it doesn't allow TunerService to set the proper
    default.

    Change-Id: I12b37335fba12cf4d5564f1aa19c5e4cf19f8775

[Pig]: Forward port to R
[bgcngm]: Forward port to S

Co-authored-by: Michael W <baddaemon87@gmail.com>
Change-Id: I7489204e348906dcf6e34fa04f2121974c22ddb9
6 files changed