Skip to content

Commit

Permalink
AllInOneActivity: Don't request disabling doze on pre-M devices
Browse files Browse the repository at this point in the history
Signed-off-by: Aayush Gupta <[email protected]>
  • Loading branch information
theimpulson authored and Gitsaibot committed Nov 2, 2023
1 parent 09463e5 commit 4f20712
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/src/main/java/com/android/calendar/AllInOneActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,8 @@ private void checkAppPermissions() {
}

private void checkAndRequestDisablingDoze() {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) return;

if (!dozeDisabled()) {
Intent intent = new Intent();
intent.setAction(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS);
Expand All @@ -433,6 +435,8 @@ private void checkAndRequestDisablingDoze() {
}

private Boolean dozeDisabled() {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) return true;

String packageName = getApplicationContext().getPackageName();
PowerManager pm = (PowerManager) getApplicationContext().getSystemService(Context.POWER_SERVICE);
return pm.isIgnoringBatteryOptimizations(packageName);
Expand Down

0 comments on commit 4f20712

Please sign in to comment.