Skip to content

Commit

Permalink
Remove support for Android API < 23 in DebugOverlayController (#39664)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #39664

Since minsdk version was increased to 23, we are deleting code using Android APIs < 23 for class DebugOverlayController

changelog: [Android][Breaking] Remove support for Android API < 23 in DebugOverlayController

Reviewed By: NickGerleman

Differential Revision: D48545520

fbshipit-source-id: 3a1140a46310c617610ff1e0c40b02427357087a
  • Loading branch information
mdvacca authored and facebook-github-bot committed Sep 27, 2023
1 parent 414b25b commit 2286c12
Showing 1 changed file with 15 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@

package com.facebook.react.devsupport;

import android.Manifest;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.graphics.PixelFormat;
import android.net.Uri;
import android.os.Build;
import android.provider.Settings;
import android.view.WindowManager;
import android.widget.FrameLayout;
Expand All @@ -31,36 +29,26 @@
/* package */ class DebugOverlayController {

public static void requestPermission(Context context) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
// Get permission to show debug overlay in dev builds.
if (!Settings.canDrawOverlays(context)) {
Intent intent =
new Intent(
Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
Uri.parse("package:" + context.getPackageName()));
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
FLog.w(
ReactConstants.TAG,
"Overlay permissions needs to be granted in order for react native apps to run in dev mode");
if (canHandleIntent(context, intent)) {
context.startActivity(intent);
}
// Get permission to show debug overlay in dev builds.
if (!Settings.canDrawOverlays(context)) {
Intent intent =
new Intent(
Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
Uri.parse("package:" + context.getPackageName()));
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
FLog.w(
ReactConstants.TAG,
"Overlay permissions needs to be granted in order for react native apps to run in dev mode");
if (canHandleIntent(context, intent)) {
context.startActivity(intent);
}
}
}

private static boolean permissionCheck(Context context) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
// Get permission to show debug overlay in dev builds.
if (!Settings.canDrawOverlays(context)) {
// overlay permission not yet granted
return false;
} else {
return true;
}
}
// on pre-M devices permission needs to be specified in manifest
return hasPermission(context, Manifest.permission.SYSTEM_ALERT_WINDOW);
// Get permission to show debug overlay in dev builds.
// overlay permission not yet granted
return Settings.canDrawOverlays(context);
}

private static boolean hasPermission(Context context, String permission) {
Expand Down

0 comments on commit 2286c12

Please sign in to comment.