[Android] SCREEN_BRIGHT_WAKE_LOCK is deprecated, use setKeepScreenOn instead.

Sébastien Toque git at videolan.org
Fri Jun 22 07:04:57 CEST 2012


android | branch: master | Sébastien Toque <xilasz at gmail.com> | Fri Jun 22 06:52:15 2012 +0200| [176a61a543c031217dbebe47af150d49d0691eec] | committer: Sébastien Toque

SCREEN_BRIGHT_WAKE_LOCK is deprecated, use setKeepScreenOn instead.

> http://git.videolan.org/gitweb.cgi/android.git/?a=commit;h=176a61a543c031217dbebe47af150d49d0691eec
---

 vlc-android/AndroidManifest.xml                    |    1 -
 .../vlc/gui/video/VideoPlayerActivity.java         |   21 ++++----------------
 2 files changed, 4 insertions(+), 18 deletions(-)

diff --git a/vlc-android/AndroidManifest.xml b/vlc-android/AndroidManifest.xml
index 3a3f81d..199280f 100644
--- a/vlc-android/AndroidManifest.xml
+++ b/vlc-android/AndroidManifest.xml
@@ -10,7 +10,6 @@
 
     <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
     <uses-permission android:name="android.permission.INTERNET" />
-    <uses-permission android:name="android.permission.WAKE_LOCK" />
     <uses-permission android:name="android.permission.READ_PHONE_STATE" />
     <uses-permission android:name="android.permission.READ_LOGS" />
     <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
index 5f46acb..d2704d6 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -54,8 +54,6 @@ import android.os.Build;
 import android.os.Bundle;
 import android.os.Handler;
 import android.os.Message;
-import android.os.PowerManager;
-import android.os.PowerManager.WakeLock;
 import android.preference.PreferenceManager;
 import android.text.format.DateFormat;
 import android.util.Log;
@@ -120,9 +118,6 @@ public class VideoPlayerActivity extends Activity {
     private int mVideoHeight;
     private int mVideoWidth;
 
-    // stop screen from dimming
-    private WakeLock mWakeLock;
-
     //Audio
     private AudioManager mAudioManager;
     private int mAudioMax;
@@ -139,10 +134,6 @@ public class VideoPlayerActivity extends Activity {
 
         SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this);
 
-        // stop screen from dimming
-        PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
-        mWakeLock = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK, TAG);
-
         /** initialize Views an their Events */
         mOverlayHeader = (View) findViewById(R.id.player_overlay_header);
         mOverlay = (View) findViewById(R.id.player_overlay);
@@ -218,8 +209,7 @@ public class VideoPlayerActivity extends Activity {
             time = mLibVLC.getTime() - 5000;
             mLibVLC.pause();
         }
-        if (mWakeLock.isHeld())
-            mWakeLock.release();
+        mOverlay.setKeepScreenOn(false);
 
         // Save position
         SharedPreferences preferences = getSharedPreferences(PreferencesActivity.NAME, MODE_PRIVATE);
@@ -816,8 +806,7 @@ public class VideoPlayerActivity extends Activity {
      */
     private void play() {
         mLibVLC.play();
-        if (!mWakeLock.isHeld())
-            mWakeLock.acquire();
+        mOverlay.setKeepScreenOn(true);
     }
 
     /**
@@ -825,8 +814,7 @@ public class VideoPlayerActivity extends Activity {
      */
     private void pause() {
         mLibVLC.pause();
-        if (mWakeLock.isHeld())
-            mWakeLock.release();
+        mOverlay.setKeepScreenOn(false);
     }
 
     /**
@@ -850,8 +838,7 @@ public class VideoPlayerActivity extends Activity {
 
         if (location != null && location.length() > 0) {
             mLibVLC.readMedia(location, false);
-            if (!mWakeLock.isHeld())
-                mWakeLock.acquire();
+            mOverlay.setKeepScreenOn(true);
 
             // Save media for next time, and restore position if it's the same one as before
             lastLocation = preferences.getString(PreferencesActivity.LAST_MEDIA, null);



More information about the Android mailing list