From 967e322913b5505029ecdcd084c058a5b286d274 Mon Sep 17 00:00:00 2001 From: daniel oeh Date: Wed, 12 Feb 2014 00:20:02 +0100 Subject: [PATCH] Acquire Wi-Fi lock before downloading. Should fix issue #110 and #243 - Adds the WAKE_LOCK permission --- AndroidManifest.xml | 1 + .../antennapod/service/download/Downloader.java | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 6d2eebf1b..815a95ef5 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -6,6 +6,7 @@ + { protected abstract void download(); public final Downloader call() { + WifiManager wifiManager = (WifiManager) PodcastApp.getInstance().getSystemService(Context.WIFI_SERVICE); + WifiManager.WifiLock wifiLock = null; + if (wifiManager != null) { + wifiLock = wifiManager.createWifiLock(TAG); + wifiLock.acquire(); + } + download(); + + if (wifiLock != null) { + wifiLock.release(); + } + if (result == null) { throw new IllegalStateException( "Downloader hasn't created DownloadStatus object");