diff mbox

[Branch,~glmark2-dev/glmark2/trunk] Rev 152: Android: Acquire WakeLock to prevent dim screen

Message ID 20111013140520.8587.83431.launchpad@ackee.canonical.com
State Accepted
Headers show

Commit Message

alexandros.frantzis@linaro.org Oct. 13, 2011, 2:05 p.m. UTC
------------------------------------------------------------
revno: 152
author: Jim Huang <jserv@0xlab.org>
committer: Alexandros Frantzis <alexandros.frantzis@linaro.org>
branch nick: trunk
timestamp: Thu 2011-10-13 15:43:55 +0300
message:
  Android: Acquire WakeLock to prevent dim screen
modified:
  android/AndroidManifest.xml
  android/src/org/linaro/glmark2/Glmark2Activity.java


--
lp:glmark2
https://code.launchpad.net/~glmark2-dev/glmark2/trunk

You are subscribed to branch lp:glmark2.
To unsubscribe from this branch go to https://code.launchpad.net/~glmark2-dev/glmark2/trunk/+edit-subscription
diff mbox

Patch

=== modified file 'android/AndroidManifest.xml'
--- android/AndroidManifest.xml	2011-08-10 20:48:56 +0000
+++ android/AndroidManifest.xml	2011-10-13 12:43:55 +0000
@@ -13,6 +13,7 @@ 
             </intent-filter>
         </activity>
     </application>
+    <uses-permission android:name="android.permission.WAKE_LOCK" />
     <uses-feature android:glEsVersion="0x00020000"/>
     <uses-sdk android:minSdkVersion="9"/>
 </manifest> 

=== modified file 'android/src/org/linaro/glmark2/Glmark2Activity.java'
--- android/src/org/linaro/glmark2/Glmark2Activity.java	2011-09-28 15:48:47 +0000
+++ android/src/org/linaro/glmark2/Glmark2Activity.java	2011-10-13 12:43:55 +0000
@@ -6,13 +6,29 @@ 
 import android.app.Dialog;
 import android.app.AlertDialog;
 import android.content.DialogInterface;
+import android.content.Context;
+import android.os.PowerManager;
+import android.os.PowerManager.WakeLock;
 
 public class Glmark2Activity extends Activity {
     public static final int DIALOG_EGLCONFIG_FAIL_ID = 0;
+    public static final String TAG = "GLMark2";
+    private WakeLock mWakeLock;
+
+    @Override
+    protected void onDestroy() {
+        super.onPause();
+        mWakeLock.release();
+    }
 
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
+
+        PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
+        mWakeLock = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, TAG);
+        mWakeLock.acquire();
+
         mGLView = new Glmark2SurfaceView(this);
         setContentView(mGLView);
     }