Launcher3: Double tap on home screen to turn off screen
Change-Id: I554c005d5e523aca0842c78a353686e86af1a7f2
diff --git a/Android.bp b/Android.bp
index 13a926b..07fba7f 100644
--- a/Android.bp
+++ b/Android.bp
@@ -305,6 +305,7 @@
enabled: false,
},
+ certificate: "platform",
platform_apis: true,
min_sdk_version: "current",
target_sdk_version: "current",
diff --git a/AndroidManifest-common.xml b/AndroidManifest-common.xml
index 8cab2b5..8b75107 100644
--- a/AndroidManifest-common.xml
+++ b/AndroidManifest-common.xml
@@ -46,6 +46,8 @@
<uses-permission android:name="android.permission.WAKEUP_SURFACE_FLINGER" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
+ <uses-permission android:name="android.permission.DEVICE_POWER" />
+
<!--
Permissions required for read/write access to the workspace data. These permission name
should not conflict with that defined in other apps, as such an app should embed its package
diff --git a/src/com/android/launcher3/touch/WorkspaceTouchListener.java b/src/com/android/launcher3/touch/WorkspaceTouchListener.java
index 0ff10c2..a957e7a 100644
--- a/src/com/android/launcher3/touch/WorkspaceTouchListener.java
+++ b/src/com/android/launcher3/touch/WorkspaceTouchListener.java
@@ -27,8 +27,10 @@
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_SPLIT_SELECTION_EXIT_INTERRUPTED;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_WORKSPACE_LONGPRESS;
+import android.content.Context;
import android.graphics.PointF;
import android.graphics.Rect;
+import android.os.PowerManager;
import android.view.GestureDetector;
import android.view.HapticFeedbackConstants;
import android.view.MotionEvent;
@@ -73,6 +75,8 @@
private int mLongPressState = STATE_CANCELLED;
+ private final PowerManager mPm;
+
private final GestureDetector mGestureDetector;
public WorkspaceTouchListener(Launcher launcher, Workspace<?> workspace) {
@@ -81,6 +85,7 @@
// Use twice the touch slop as we are looking for long press which is more
// likely to cause movement.
mTouchSlop = 2 * ViewConfiguration.get(launcher).getScaledTouchSlop();
+ mPm = (PowerManager) workspace.getContext().getSystemService(Context.POWER_SERVICE);
mGestureDetector = new GestureDetector(workspace.getContext(), this);
}
@@ -215,4 +220,10 @@
}
}
}
+
+ @Override
+ public boolean onDoubleTap(MotionEvent event) {
+ mPm.goToSleep(event.getEventTime());
+ return true;
+ }
}