From: Linus Lee Date: Tue, 5 Jan 2016 02:36:45 +0000 (-0800) Subject: Merge "Eleven: Remove wakelock" into cm-13.0 X-Git-Tag: android-x86-6.0-r1~21 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=0739c8133a07cc97c42a72ae439be1bbc0ffde57;hp=281ddcba41e4138a65bc7f433b0b25487be52e73;p=android-x86%2Fpackages-apps-Eleven.git Merge "Eleven: Remove wakelock" into cm-13.0 --- diff --git a/src/com/cyanogenmod/eleven/MusicPlaybackService.java b/src/com/cyanogenmod/eleven/MusicPlaybackService.java index f52197d..1f5660c 100644 --- a/src/com/cyanogenmod/eleven/MusicPlaybackService.java +++ b/src/com/cyanogenmod/eleven/MusicPlaybackService.java @@ -46,7 +46,6 @@ import android.os.IBinder; import android.os.Looper; import android.os.Message; import android.os.PowerManager; -import android.os.PowerManager.WakeLock; import android.os.RemoteException; import android.os.SystemClock; import android.provider.MediaStore; @@ -275,34 +274,29 @@ public class MusicPlaybackService extends Service { private static final int TRACK_WENT_TO_NEXT = 2; /** - * Indicates when the release the wake lock - */ - private static final int RELEASE_WAKELOCK = 3; - - /** * Indicates the player died */ - private static final int SERVER_DIED = 4; + private static final int SERVER_DIED = 3; /** * Indicates some sort of focus change, maybe a phone call */ - private static final int FOCUSCHANGE = 5; + private static final int FOCUSCHANGE = 4; /** * Indicates to fade the volume down */ - private static final int FADEDOWN = 6; + private static final int FADEDOWN = 5; /** * Indicates to fade the volume back up */ - private static final int FADEUP = 7; + private static final int FADEUP = 6; /** * Notifies that there is a new timed text string */ - private static final int LYRICS = 8; + private static final int LYRICS = 7; /** * Idle time before stopping the foreground notfication (5 minutes) @@ -391,11 +385,6 @@ public class MusicPlaybackService extends Service { private String mFileToPlay; /** - * Keeps the service running when the screen is off - */ - private WakeLock mWakeLock; - - /** * Alarm intent for removing the notification when nothing is playing * for some time */ @@ -667,11 +656,6 @@ public class MusicPlaybackService extends Service { getContentResolver().registerContentObserver( MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, true, mMediaStoreObserver); - // Initialize the wake lock - final PowerManager powerManager = (PowerManager)getSystemService(Context.POWER_SERVICE); - mWakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, getClass().getName()); - mWakeLock.setReferenceCounted(false); - // Initialize the delayed shutdown intent final Intent shutdownIntent = new Intent(this, MusicPlaybackService.class); shutdownIntent.setAction(SHUTDOWN); @@ -768,9 +752,6 @@ public class MusicPlaybackService extends Service { // deinitialize shake detector stopShakeDetector(true); - - // Release the wake lock - mWakeLock.release(); } /** @@ -2960,9 +2941,6 @@ public class MusicPlaybackService extends Service { service.mLyrics = (String) msg.obj; service.notifyChange(NEW_LYRICS); break; - case RELEASE_WAKELOCK: - service.mWakeLock.release(); - break; case FOCUSCHANGE: if (D) Log.d(TAG, "Received audio focus change event " + msg.arg1); switch (msg.arg1) { @@ -3079,7 +3057,6 @@ public class MusicPlaybackService extends Service { */ public MultiPlayer(final MusicPlaybackService service) { mService = new WeakReference(service); - mCurrentMediaPlayer.setWakeMode(mService.get(), PowerManager.PARTIAL_WAKE_LOCK); mSrtManager = new SrtManager() { @Override public void onTimedText(String text) { @@ -3192,7 +3169,6 @@ public class MusicPlaybackService extends Service { return; } mNextMediaPlayer = new MediaPlayer(); - mNextMediaPlayer.setWakeMode(mService.get(), PowerManager.PARTIAL_WAKE_LOCK); mNextMediaPlayer.setAudioSessionId(getAudioSessionId()); if (setDataSourceImpl(mNextMediaPlayer, path)) { mNextMediaPath = path; @@ -3327,7 +3303,6 @@ public class MusicPlaybackService extends Service { mIsInitialized = false; mCurrentMediaPlayer.release(); mCurrentMediaPlayer = new MediaPlayer(); - mCurrentMediaPlayer.setWakeMode(service, PowerManager.PARTIAL_WAKE_LOCK); Message msg = mHandler.obtainMessage(SERVER_DIED, errorInfo); mHandler.sendMessageDelayed(msg, 2000); return true; @@ -3350,9 +3325,7 @@ public class MusicPlaybackService extends Service { mNextMediaPlayer = null; mHandler.sendEmptyMessage(TRACK_WENT_TO_NEXT); } else { - mService.get().mWakeLock.acquire(30000); mHandler.sendEmptyMessage(TRACK_ENDED); - mHandler.sendEmptyMessage(RELEASE_WAKELOCK); } } }