From 411747ea094cdf8c9f971fc918c87e63eb66ae5d Mon Sep 17 00:00:00 2001 From: AishwaryaShinde07 Date: Tue, 13 Feb 2024 13:22:04 -0500 Subject: [PATCH] Merging this if statement with the enclosing one This will decrease the nesting of the code and improve its readability. --- .../opentracks/services/TrackRecordingService.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/de/dennisguse/opentracks/services/TrackRecordingService.java b/src/main/java/de/dennisguse/opentracks/services/TrackRecordingService.java index ad2e62722..cbc6f8271 100644 --- a/src/main/java/de/dennisguse/opentracks/services/TrackRecordingService.java +++ b/src/main/java/de/dennisguse/opentracks/services/TrackRecordingService.java @@ -213,10 +213,10 @@ private synchronized void startSensors() { wakeLock = SystemUtils.acquireWakeLock(this, wakeLock); trackPointCreator.start(this, handler); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) { - if (!PermissionRequester.RECORDING.hasPermission(this)) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE && !PermissionRequester.RECORDING.hasPermission(this)) { + throw new RuntimeException("Android14: Please grant permissions LOCATION and NEARBY DEVICES (manually)"); - } + } ServiceCompat.startForeground(this, TrackRecordingServiceNotificationManager.NOTIFICATION_ID, notificationManager.setGPSonlyStarted(this), ServiceInfo.FOREGROUND_SERVICE_TYPE_LOCATION + ServiceInfo.FOREGROUND_SERVICE_TYPE_CONNECTED_DEVICE);