diff --git a/library/src/main/java/com/anthonycr/grant/PermissionsManager.java b/library/src/main/java/com/anthonycr/grant/PermissionsManager.java index d218c69..22822a0 100644 --- a/library/src/main/java/com/anthonycr/grant/PermissionsManager.java +++ b/library/src/main/java/com/anthonycr/grant/PermissionsManager.java @@ -1,11 +1,13 @@ package com.anthonycr.grant; import android.Manifest; +import android.annotation.TargetApi; import android.app.Activity; import android.content.Context; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.os.Build; +import android.provider.Settings; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.v4.app.ActivityCompat; @@ -342,6 +344,7 @@ private void doPermissionWorkBeforeAndroidM(@NonNull Activity activity, * permission check * @return a list of permissions names that are not granted yet */ + @TargetApi(Build.VERSION_CODES.M) @NonNull private List getPermissionsListToRequest(@NonNull Activity activity, @NonNull String[] permissions, @@ -352,6 +355,16 @@ private List getPermissionsListToRequest(@NonNull Activity activity, if (action != null) { action.onResult(perm, Permissions.NOT_FOUND); } + } else if (Manifest.permission.SYSTEM_ALERT_WINDOW.equals(perm)) { + if (Settings.canDrawOverlays(activity)) { + if (action != null) { + action.onResult(perm, Permissions.GRANTED); + } + } else { + if (!mPendingRequests.contains(perm)) { + permList.add(perm); + } + } } else if (ActivityCompat.checkSelfPermission(activity, perm) != PackageManager.PERMISSION_GRANTED) { if (!mPendingRequests.contains(perm)) { permList.add(perm);