Skip to content

Adds handling Android USE_FULL_SCREEN_INTENT special permission #1433

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ final class PermissionConstants {
static final int PERMISSION_CODE_REQUEST_INSTALL_PACKAGES = 212;
static final int PERMISSION_CODE_ACCESS_NOTIFICATION_POLICY = 213;
static final int PERMISSION_CODE_SCHEDULE_EXACT_ALARM = 214;
static final int PERMISSION_CODE_USE_FULL_SCREEN_INTENT = 215;


// PERMISSION_GROUP
Expand Down Expand Up @@ -62,6 +63,7 @@ final class PermissionConstants {
static final int PERMISSION_GROUP_CALENDAR_FULL_ACCESS = 37;
static final int PERMISSION_GROUP_ASSISTANT = 38;
static final int PERMISSION_GROUP_BACKGROUND_REFRESH = 39;
static final int PERMISSION_GROUP_USE_FULL_SCREEN_INTENT = 40;

@Retention(RetentionPolicy.SOURCE)
@IntDef({
Expand Down Expand Up @@ -101,6 +103,8 @@ final class PermissionConstants {
PERMISSION_GROUP_CALENDAR_WRITE_ONLY,
PERMISSION_GROUP_CALENDAR_FULL_ACCESS,
PERMISSION_GROUP_ASSISTANT,
PERMISSION_GROUP_BACKGROUND_REFRESH,
PERMISSION_GROUP_USE_FULL_SCREEN_INTENT,
})
@interface PermissionGroup {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,16 @@ public boolean onRequestPermissionsResult(
requestResults.put(
permission,
determinePermissionStatus(permission));
} else if (permission == PermissionConstants.PERMISSION_GROUP_USE_FULL_SCREEN_INTENT) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
int status = notificationManager.canUseFullScreenIntent()
? PermissionConstants.PERMISSION_STATUS_GRANTED
: PermissionConstants.PERMISSION_STATUS_DENIED;
requestResults.put(permission, status);
} else {
requestResults.put(permission, PermissionConstants.PERMISSION_STATUS_GRANTED);
}
} else if (!requestResults.containsKey(permission)) {
requestResults.put(
permission,
Expand Down Expand Up @@ -421,6 +431,10 @@ void requestPermissions(
} else {
requestResults.put(permission, PermissionConstants.PERMISSION_STATUS_DENIED);
}
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE && permission == PermissionConstants.PERMISSION_GROUP_USE_FULL_SCREEN_INTENT) {
launchSpecialPermission(
Settings.ACTION_MANAGE_APP_USE_FULL_SCREEN_INTENT,
PermissionConstants.PERMISSION_CODE_USE_FULL_SCREEN_INTENT);
} else {
permissionsToRequest.addAll(names);
pendingRequestCount += names.size();
Expand Down Expand Up @@ -565,7 +579,17 @@ private int determinePermissionStatus(final @PermissionConstants.PermissionGroup
}else {
permissionStatuses.add(PermissionUtils.determineDeniedVariant(activity, name));
}
}else {
} else if (permission == PermissionConstants.PERMISSION_GROUP_USE_FULL_SCREEN_INTENT) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
int status = notificationManager.canUseFullScreenIntent()
? PermissionConstants.PERMISSION_STATUS_GRANTED
: PermissionConstants.PERMISSION_STATUS_DENIED;
permissionStatuses.add(status);
} else {
permissionStatuses.add(PermissionConstants.PERMISSION_STATUS_GRANTED);
}
} else {
final int permissionStatus = ContextCompat.checkSelfPermission(context, name);
if (permissionStatus != PackageManager.PERMISSION_GRANTED) {
permissionStatuses.add(PermissionUtils.determineDeniedVariant(activity, name));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ static int parseManifestName(String permission) {
return PermissionConstants.PERMISSION_GROUP_AUDIO;
case Manifest.permission.SCHEDULE_EXACT_ALARM:
return PermissionConstants.PERMISSION_GROUP_SCHEDULE_EXACT_ALARM;
case Manifest.permission.USE_FULL_SCREEN_INTENT:
return PermissionConstants.PERMISSION_GROUP_USE_FULL_SCREEN_INTENT;
default:
return PermissionConstants.PERMISSION_GROUP_UNKNOWN;
}
Expand Down Expand Up @@ -354,6 +356,11 @@ static List<String> getManifestNames(Context context, @PermissionConstants.Permi
if (hasPermissionInManifest(context, permissionNames, Manifest.permission.SCHEDULE_EXACT_ALARM))
permissionNames.add(Manifest.permission.SCHEDULE_EXACT_ALARM);
break;
case PermissionConstants.PERMISSION_GROUP_USE_FULL_SCREEN_INTENT:
// The USE_FULL_SCREEN_INTENT permission is introduced in Android UPSIDE_DOWN_CAKE, before Android 34 it should alway return Granted
if (hasPermissionInManifest(context, permissionNames, Manifest.permission.USE_FULL_SCREEN_INTENT))
permissionNames.add(Manifest.permission.USE_FULL_SCREEN_INTENT);
break;
case PermissionConstants.PERMISSION_GROUP_MEDIA_LIBRARY:
case PermissionConstants.PERMISSION_GROUP_REMINDERS:
case PermissionConstants.PERMISSION_GROUP_UNKNOWN:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,11 @@ class Permission {
/// Permission for reading the current background refresh status. (iOS only)
static const backgroundRefresh = Permission._(39);

/// Permission for allowing full screen on the device for alarms and calls
///
/// Android 14+ (API 34+)
static const fullScreen = Permission._(40);

/// Returns a list of all possible [PermissionGroup] values.
static const List<Permission> values = <Permission>[
// ignore: deprecated_member_use_from_same_package
Expand Down Expand Up @@ -369,6 +374,7 @@ class Permission {
calendarFullAccess,
assistant,
backgroundRefresh,
fullScreen,
];

static const List<String> _names = <String>[
Expand Down Expand Up @@ -412,6 +418,7 @@ class Permission {
'calendarFullAccess',
'assistant',
'backgroundRefresh',
'fullScreen',
];

@override
Expand Down
Loading