Skip to content

Commit

Permalink
Report restricted status pre-marshmallow devices
Browse files Browse the repository at this point in the history
  • Loading branch information
mvanbeusekom committed Oct 23, 2023
1 parent 6b39da0 commit ba478d9
Showing 1 changed file with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,15 @@ public boolean onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == PermissionConstants.PERMISSION_CODE_IGNORE_BATTERY_OPTIMIZATIONS) {
permission = PermissionConstants.PERMISSION_GROUP_IGNORE_BATTERY_OPTIMIZATIONS;

if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
return false;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
String packageName = context.getPackageName();
PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
status = (pm != null && pm.isIgnoringBatteryOptimizations(packageName))
? PermissionConstants.PERMISSION_STATUS_GRANTED
: PermissionConstants.PERMISSION_STATUS_DENIED;
} else {
status = PermissionConstants.PERMISSION_STATUS_RESTRICTED;
}

String packageName = context.getPackageName();
PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
status = (pm != null && pm.isIgnoringBatteryOptimizations(packageName))
? PermissionConstants.PERMISSION_STATUS_GRANTED
: PermissionConstants.PERMISSION_STATUS_DENIED;
} else if (requestCode == PermissionConstants.PERMISSION_CODE_MANAGE_EXTERNAL_STORAGE) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
status = Environment.isExternalStorageManager()
Expand Down

0 comments on commit ba478d9

Please sign in to comment.