diff options
author | Christian Schneppe <christian@pix-art.de> | 2018-04-29 14:22:34 +0200 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2018-04-29 14:22:34 +0200 |
commit | 4ddaa45ee3dd1a346da254f2ca9b72c933dc2292 (patch) | |
tree | 89e063fcff69946d7d1efd1d9a8bd03b196707a9 /src/main/java/de/pixart/messenger/services/XmppConnectionService.java | |
parent | a201775d8b7d16e0ba0747bddcf8696db7a3ee4b (diff) |
catch dead object exceptions when acquiring wake locks
Diffstat (limited to '')
-rw-r--r-- | src/main/java/de/pixart/messenger/services/XmppConnectionService.java | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java index ef98b6aa6..9fc322646 100644 --- a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java +++ b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java @@ -122,6 +122,7 @@ import de.pixart.messenger.utils.ReplacingSerialSingleThreadExecutor; import de.pixart.messenger.utils.ReplacingTaskManager; import de.pixart.messenger.utils.Resolver; import de.pixart.messenger.utils.SerialSingleThreadExecutor; +import de.pixart.messenger.utils.WakeLockHelper; import de.pixart.messenger.utils.XmppUri; import de.pixart.messenger.xml.Element; import de.pixart.messenger.xmpp.OnBindListener; @@ -684,7 +685,7 @@ public class XmppConnectionService extends Service { } } synchronized (this) { - this.wakeLock.acquire(); + WakeLockHelper.acquire(wakeLock); boolean pingNow = ConnectivityManager.CONNECTIVITY_ACTION.equals(action); HashSet<Account> pingCandidates = new HashSet<>(); for (Account account : accounts) { @@ -708,12 +709,7 @@ public class XmppConnectionService extends Service { scheduleWakeUpCall(lowTimeout ? Config.LOW_PING_TIMEOUT : Config.PING_TIMEOUT, account.getUuid().hashCode()); } } - if (wakeLock.isHeld()) { - try { - wakeLock.release(); - } catch (final RuntimeException ignored) { - } - } + WakeLockHelper.release(wakeLock); } if (SystemClock.elapsedRealtime() - mLastExpiryRun.get() >= Config.EXPIRY_INTERVAL) { expireOldMessages(); |