Ensure to release wakelock

Bug: 124451539
Test: trivial refactor, presubmits passing
Change-Id: Ic731d0593fc65e9973cd6219421f4e9646da5d3a
This commit is contained in:
Yu-Han Yang
2021-07-09 10:41:42 -07:00
parent fb2a9fe92d
commit 71fb1f2d52

View File

@@ -1343,8 +1343,11 @@ public class GnssLocationProvider extends AbstractLocationProvider implements
// it is handled (otherwise the wake lock would be leaked).
mWakeLock.acquire(WAKELOCK_TIMEOUT_MILLIS);
boolean success = mHandler.post(() -> {
runnable.run();
mWakeLock.release();
try {
runnable.run();
} finally {
mWakeLock.release();
}
});
if (!success) {
mWakeLock.release();