From 18ca878b651b2fdbb9a48546450674a5e32a680a Mon Sep 17 00:00:00 2001 From: David Vacca Date: Tue, 26 Sep 2023 10:58:11 -0700 Subject: [PATCH] Remove support for Android API < 23 in DebugOverlayController Summary: Since minsdk version was increased to 23, we are deleting code using Android APIs < 23 for class DebugOverlayController chnagelog: [Android][Breaking] Remove support for Android API < 23 in DebugOverlayController Differential Revision: D48545520 fbshipit-source-id: 3f69e2703acb4fbd3935ca44680634d1ce452f27 --- .../devsupport/DebugOverlayController.java | 41 ++++++++----------- 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/DebugOverlayController.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/DebugOverlayController.java index a70d44a9b70e83..2e95980fc5e80a 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/DebugOverlayController.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/DebugOverlayController.java @@ -14,7 +14,6 @@ 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; @@ -31,33 +30,29 @@ /* 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; - } + // 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);