This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to wake up Android from mouse or keyboard
#9
I added a PARTIAL_WAKE_LOCK to Launcher3 and I am able to wake the Tinker Board from mouse and keyboard after reloading the updated Android image. Note that the PARTIAL_WAKE_LOCK prevents the system from fully going to sleep, but the display still turns off normally after the display off timeout.

If you want to do the same, you can make changes to the two files as below:

1) AndroidManifest.xml at {croot}/packages/apps/Launcher3/AndroidManifest.xml
Code:
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 6c5990d..07109ab 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -49,6 +49,9 @@
     <uses-permission android:name="com.android.launcher3.permission.READ_SETTINGS" />
     <uses-permission android:name="com.android.launcher3.permission.WRITE_SETTINGS" />
 
+    <uses-permission android:name="android.permission.WAKE_LOCK" />
+
     <application
         android:backupAgent="com.android.launcher3.LauncherBackupAgent"
         android:fullBackupOnly="true"

and 2) Launcher.java at {croot}/packages/apps/Launcher3/src/com/android/launcher3/Launcher.java
Code:
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 3b5cd02..110a891 100755
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -86,6 +86,9 @@ import android.widget.ImageView;
 import android.widget.TextView;
 import android.widget.Toast;
 
+import android.os.PowerManager;
+
 import com.android.launcher3.DropTarget.DragObject;
 import com.android.launcher3.LauncherSettings.Favorites;
 import com.android.launcher3.accessibility.LauncherAccessibilityDelegate;
@@ -366,6 +369,9 @@ public class Launcher extends Activity
 
     private RotationPrefChangeHandler mRotationPrefChangeHandler;
 
+    private PowerManager.WakeLock mWakeLock;
+
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         if (DEBUG_STRICT_MODE) {
@@ -392,6 +398,13 @@ public class Launcher extends Activity
 
         super.onCreate(savedInstanceState);
 
+        PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
+        this.mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, TAG);
+        this.mWakeLock.acquire();
+
         LauncherAppState app = LauncherAppState.getInstance();
 
         // Load configuration-specific DeviceProfile
@@ -1940,6 +1953,9 @@ public class Launcher extends Activity
     public void onDestroy() {
         super.onDestroy();
 
+        this.mWakeLock.release();
+
         // Remove all pending runnables
         mHandler.removeMessages(ADVANCE_MSG);
         mHandler.removeMessages(0);
Reply


Messages In This Thread
RE: How to wake up Android from mouse or keyboard - by mrtatertot - 02-03-2019, 03:59 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)