Check wakelock is held in download service

pull/26/head
Koitharu 6 years ago
parent 260ff32cd1
commit 7d147b3c37

@ -76,7 +76,7 @@ class DownloadService : BaseService() {
private fun downloadManga(manga: Manga, chaptersIds: Set<Long>?, startId: Int): Job { private fun downloadManga(manga: Manga, chaptersIds: Set<Long>?, startId: Int): Job {
return launch(Dispatchers.IO) { return launch(Dispatchers.IO) {
mutex.lock() mutex.lock()
wakeLock.acquire(TimeUnit.MINUTES.toMillis(20)) wakeLock.acquire(TimeUnit.HOURS.toMillis(1))
withContext(Dispatchers.Main) { withContext(Dispatchers.Main) {
notification.fillFrom(manga) notification.fillFrom(manga)
notification.setCancelId(startId) notification.setCancelId(startId)
@ -167,7 +167,9 @@ class DownloadService : BaseService() {
notification.dismiss() notification.dismiss()
stopSelf(startId) stopSelf(startId)
} }
if (wakeLock.isHeld) {
wakeLock.release() wakeLock.release()
}
mutex.unlock() mutex.unlock()
} }
} }

Loading…
Cancel
Save