Skip to content

Commit

Permalink
Frameworks_base: add dt2w on doze [2/2]
Browse files Browse the repository at this point in the history
Thanx to Patrick for this excellent idea and to Dankoman for pointing me in the right direction ;)

Fix dt2s : ignore touch events for dt2s while dozing

PS2: fix "swipe down turns display off and disables doze until screen is turned on at least once"

Signed-off-by: Jean-Pierre Rasquin <[email protected]>
  • Loading branch information
yank555-lu authored and temasek committed Apr 8, 2016
1 parent 809732a commit 1d95e68
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
6 changes: 6 additions & 0 deletions core/java/android/provider/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -4871,6 +4871,12 @@ public boolean validate(String value) {
*/
public static final String HEADS_UP_FORCE_ALL = "heads_up_force_all";

/**
* Require double tap instead of simple tap to wake from Doze pulse screen
* @hide
*/
public static final String DOZE_WAKEUP_DOUBLETAP = "doze_wakeup_doubletap";

/**
* Settings to backup. This is here so that it's in the same place as the settings
* keys and easy to update.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ public class StatusBarWindowView extends FrameLayout {

private int mStatusBarHeaderHeight;

private boolean mDozeWakeupDoubleTap;
private GestureDetector mDozeWakeupDoubleTapGesture;
private boolean mDoubleTapToSleepEnabled;
private boolean mDoubleTapToSleepLockScreen;
private GestureDetector mDoubleTapGesture;
Expand Down Expand Up @@ -119,6 +121,15 @@ public boolean onDoubleTap(MotionEvent e) {
}
});

mDozeWakeupDoubleTapGesture = new GestureDetector(mContext,
new GestureDetector.SimpleOnGestureListener() {
@Override
public boolean onDoubleTap(MotionEvent e) {
mService.wakeUpIfDozing(e.getEventTime(), e);
return true;
}
});

// We really need to be able to animate while window animations are going on
// so that activities may be started asynchronously from panel animations
final ViewRootImpl root = getViewRootImpl();
Expand Down Expand Up @@ -224,10 +235,16 @@ public boolean onInterceptTouchEvent(MotionEvent ev) {
&& mStackScrollLayout.getVisibility() == View.VISIBLE
&& mService.getBarState() == StatusBarState.KEYGUARD
&& !mService.isBouncerShowing()) {
intercept = mDragDownHelper.onInterceptTouchEvent(ev);
if (!mDozeWakeupDoubleTap || (mDozeWakeupDoubleTap && !mService.isDozing())) {
intercept = mDragDownHelper.onInterceptTouchEvent(ev);
}
// wake up on a touch down event, if dozing
if (ev.getActionMasked() == MotionEvent.ACTION_DOWN) {
mService.wakeUpIfDozing(ev.getEventTime(), ev);
if (mDozeWakeupDoubleTap) {
mDozeWakeupDoubleTapGesture.onTouchEvent(ev);
} else {
if (ev.getActionMasked() == MotionEvent.ACTION_DOWN) {
mService.wakeUpIfDozing(ev.getEventTime(), ev);
}
}
}
if (!intercept) {
Expand Down Expand Up @@ -322,6 +339,8 @@ void observe() {
CMSettings.System.DOUBLE_TAP_SLEEP_GESTURE), false, this);
resolver.registerContentObserver(Settings.System.getUriFor(
Settings.System.DOUBLE_TAP_SLEEP_LOCK_SCREEN), false, this);
resolver.registerContentObserver(Settings.System.getUriFor(
Settings.System.DOZE_WAKEUP_DOUBLETAP), false, this);
update();
}

Expand All @@ -346,6 +365,8 @@ public void update() {
.getInt(resolver, CMSettings.System.DOUBLE_TAP_SLEEP_GESTURE, 1) == 1;
mDoubleTapToSleepLockScreen = Settings.System.getIntForUser(resolver,
Settings.System.DOUBLE_TAP_SLEEP_LOCK_SCREEN, 0, UserHandle.USER_CURRENT) == 1;
mDozeWakeupDoubleTap = Settings.System.getInt(
resolver, Settings.System.DOZE_WAKEUP_DOUBLETAP, 0) == 1;
}
}
}
Expand Down

0 comments on commit 1d95e68

Please sign in to comment.