Skip to content

Commit

Permalink
The background service is now mandatory because the OS has started ki…
Browse files Browse the repository at this point in the history
…lling the background service without this permission
  • Loading branch information
mendhak committed Jan 11, 2025
1 parent b25c158 commit 0ea0bf4
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions gpslogger/src/main/java/com/mendhak/gpslogger/common/Systems.java
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,18 @@ public static boolean hasUserGrantedAllNecessaryPermissions(Context context){
}
}

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
String packageName = context.getPackageName();
PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
if (!pm.isIgnoringBatteryOptimizations(packageName)){
LOG.warn("Permission to ignore battery optimization was denied. Without this permission, the OS will terminate the service.");
return false;
}
else {
LOG.debug("Permission ignore battery optimization : true");
}
}

return true;
}

Expand Down

0 comments on commit 0ea0bf4

Please sign in to comment.