mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Remove support for Android API < 23 in DebugOverlayController (#39664)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/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
This commit is contained in:
committed by
Facebook GitHub Bot
parent
414b25b125
commit
2286c123b7
+15
-27
@@ -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;
|
||||
@@ -31,36 +29,26 @@ import com.facebook.react.common.ReactConstants;
|
||||
/* 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) {
|
||||
|
||||
Reference in New Issue
Block a user