Skip to content

Commit 1d95e68

Browse files
yank555-lutemasek
authored andcommitted
Frameworks_base: add dt2w on doze [2/2]
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]>
1 parent 809732a commit 1d95e68

File tree

2 files changed

+30
-3
lines changed

2 files changed

+30
-3
lines changed

core/java/android/provider/Settings.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4871,6 +4871,12 @@ public boolean validate(String value) {
48714871
*/
48724872
public static final String HEADS_UP_FORCE_ALL = "heads_up_force_all";
48734873

4874+
/**
4875+
* Require double tap instead of simple tap to wake from Doze pulse screen
4876+
* @hide
4877+
*/
4878+
public static final String DOZE_WAKEUP_DOUBLETAP = "doze_wakeup_doubletap";
4879+
48744880
/**
48754881
* Settings to backup. This is here so that it's in the same place as the settings
48764882
* keys and easy to update.

packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ public class StatusBarWindowView extends FrameLayout {
7070

7171
private int mStatusBarHeaderHeight;
7272

73+
private boolean mDozeWakeupDoubleTap;
74+
private GestureDetector mDozeWakeupDoubleTapGesture;
7375
private boolean mDoubleTapToSleepEnabled;
7476
private boolean mDoubleTapToSleepLockScreen;
7577
private GestureDetector mDoubleTapGesture;
@@ -119,6 +121,15 @@ public boolean onDoubleTap(MotionEvent e) {
119121
}
120122
});
121123

124+
mDozeWakeupDoubleTapGesture = new GestureDetector(mContext,
125+
new GestureDetector.SimpleOnGestureListener() {
126+
@Override
127+
public boolean onDoubleTap(MotionEvent e) {
128+
mService.wakeUpIfDozing(e.getEventTime(), e);
129+
return true;
130+
}
131+
});
132+
122133
// We really need to be able to animate while window animations are going on
123134
// so that activities may be started asynchronously from panel animations
124135
final ViewRootImpl root = getViewRootImpl();
@@ -224,10 +235,16 @@ public boolean onInterceptTouchEvent(MotionEvent ev) {
224235
&& mStackScrollLayout.getVisibility() == View.VISIBLE
225236
&& mService.getBarState() == StatusBarState.KEYGUARD
226237
&& !mService.isBouncerShowing()) {
227-
intercept = mDragDownHelper.onInterceptTouchEvent(ev);
238+
if (!mDozeWakeupDoubleTap || (mDozeWakeupDoubleTap && !mService.isDozing())) {
239+
intercept = mDragDownHelper.onInterceptTouchEvent(ev);
240+
}
228241
// wake up on a touch down event, if dozing
229-
if (ev.getActionMasked() == MotionEvent.ACTION_DOWN) {
230-
mService.wakeUpIfDozing(ev.getEventTime(), ev);
242+
if (mDozeWakeupDoubleTap) {
243+
mDozeWakeupDoubleTapGesture.onTouchEvent(ev);
244+
} else {
245+
if (ev.getActionMasked() == MotionEvent.ACTION_DOWN) {
246+
mService.wakeUpIfDozing(ev.getEventTime(), ev);
247+
}
231248
}
232249
}
233250
if (!intercept) {
@@ -322,6 +339,8 @@ void observe() {
322339
CMSettings.System.DOUBLE_TAP_SLEEP_GESTURE), false, this);
323340
resolver.registerContentObserver(Settings.System.getUriFor(
324341
Settings.System.DOUBLE_TAP_SLEEP_LOCK_SCREEN), false, this);
342+
resolver.registerContentObserver(Settings.System.getUriFor(
343+
Settings.System.DOZE_WAKEUP_DOUBLETAP), false, this);
325344
update();
326345
}
327346

@@ -346,6 +365,8 @@ public void update() {
346365
.getInt(resolver, CMSettings.System.DOUBLE_TAP_SLEEP_GESTURE, 1) == 1;
347366
mDoubleTapToSleepLockScreen = Settings.System.getIntForUser(resolver,
348367
Settings.System.DOUBLE_TAP_SLEEP_LOCK_SCREEN, 0, UserHandle.USER_CURRENT) == 1;
368+
mDozeWakeupDoubleTap = Settings.System.getInt(
369+
resolver, Settings.System.DOZE_WAKEUP_DOUBLETAP, 0) == 1;
349370
}
350371
}
351372
}

0 commit comments

Comments
 (0)