mirror of
https://codeberg.org/OpenTracksApp/OpenTracks.git
synced 2026-10-02 17:43:06 +02:00
Refactored wake lock release.
This commit is contained in:
@@ -268,7 +268,7 @@ public class TrackRecordingService extends Service {
|
||||
binder = null;
|
||||
|
||||
// This should be the next to last operation
|
||||
releaseWakeLock();
|
||||
wakeLock = SystemUtils.releaseWakeLock(wakeLock);
|
||||
|
||||
// Shutdown the executorService last to avoid sending events to a dead executor.
|
||||
executorService.shutdown();
|
||||
@@ -528,7 +528,7 @@ public class TrackRecordingService extends Service {
|
||||
void stopGps(boolean stop) {
|
||||
unregisterLocationListener();
|
||||
showNotification(false);
|
||||
releaseWakeLock();
|
||||
wakeLock = SystemUtils.releaseWakeLock(wakeLock);
|
||||
if (stop) {
|
||||
stopSelf();
|
||||
}
|
||||
@@ -728,13 +728,6 @@ public class TrackRecordingService extends Service {
|
||||
locationManagerConnector.removeLocationUpdates(locationListener);
|
||||
}
|
||||
|
||||
private void releaseWakeLock() {
|
||||
if (wakeLock != null && wakeLock.isHeld()) {
|
||||
wakeLock.release();
|
||||
wakeLock = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void showNotification(boolean isGpsStarted) {
|
||||
// Dijkstra If
|
||||
if (isRecording() && isPaused()) {
|
||||
|
||||
@@ -99,4 +99,16 @@ public class SystemUtils {
|
||||
}
|
||||
return wakeLock;
|
||||
}
|
||||
|
||||
/**
|
||||
* Releases the wake lock if it is held.
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
public static WakeLock releaseWakeLock(WakeLock wakeLock) {
|
||||
if (wakeLock != null && wakeLock.isHeld()) {
|
||||
wakeLock.release();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user