From 52f230a6b54dfd8eafe844a6c473ecee0d957a7e Mon Sep 17 00:00:00 2001 From: Christian Schneppe Date: Sat, 3 Sep 2016 09:15:45 +0200 Subject: keep CPU awake while compressing video fixes #94 --- .../java/de/pixart/messenger/services/XmppConnectionService.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/main/java/de/pixart/messenger') diff --git a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java index c00803d1c..75231f037 100644 --- a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java +++ b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java @@ -154,7 +154,7 @@ public class XmppConnectionService extends Service { private final List conversations = new CopyOnWriteArrayList<>(); private final IqGenerator mIqGenerator = new IqGenerator(this); private final List mInProgressAvatarFetches = new ArrayList<>(); - + private WakeLock wakeLock; private long mLastActivity = 0; public DatabaseBackend databaseBackend; @@ -363,7 +363,6 @@ public class XmppConnectionService extends Service { }; private OpenPgpServiceConnection pgpServiceConnection; private PgpEngine mPgpEngine = null; - private WakeLock wakeLock; private PowerManager pm; private LruCache mBitmapCache; private EventReceiver mEventReceiver = new EventReceiver(); @@ -581,12 +580,16 @@ public class XmppConnectionService extends Service { @Override protected Boolean doInBackground(String... params) { + PowerManager pm = (PowerManager)getSystemService(Context.POWER_SERVICE); + wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,"CompressPixArtMessengerVideo"); + wakeLock.acquire(); return MediaController.getInstance().convertVideo(originalpath, compressedpath); } @Override protected void onPostExecute(Boolean compressed) { super.onPostExecute(compressed); + wakeLock.release(); if (mListener != null) { mListener.videocompressed(compressed); Log.d(Config.LOGTAG, "Compression successfully!"); -- cgit v1.2.3