From 0384e3cf1faec1e1cd3782a32cbb3728ac92e06e Mon Sep 17 00:00:00 2001 From: David Vacca Date: Wed, 27 Sep 2023 13:10:31 -0700 Subject: [PATCH] Remove support for Android API < 23 in PermissionsModule (#39680) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/39680 Since minsdk version was increased to 23, we are deleting code using Android APIs < 23 for class PermissionsModule changelog: [Android][Breaking] Remove support for Android API < 23 in PermissionsModule Reviewed By: NickGerleman Differential Revision: D48545517 fbshipit-source-id: 1ead079689aee5fd42d2b0bc530b7f69780938ff --- .../permissions/PermissionsModule.java | 30 +------------------ 1 file changed, 1 insertion(+), 29 deletions(-) diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/permissions/PermissionsModule.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/permissions/PermissionsModule.java index af6d28b396a7a7..db0d0941bb0f7e 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/permissions/PermissionsModule.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/permissions/PermissionsModule.java @@ -10,8 +10,6 @@ import android.app.Activity; import android.content.Context; import android.content.pm.PackageManager; -import android.os.Build; -import android.os.Process; import android.util.SparseArray; import com.facebook.common.logging.FLog; import com.facebook.fbreact.specs.NativePermissionsAndroidSpec; @@ -49,12 +47,6 @@ public PermissionsModule(ReactApplicationContext reactContext) { @Override public void checkPermission(final String permission, final Promise promise) { Context context = getReactApplicationContext().getBaseContext(); - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) { - promise.resolve( - context.checkPermission(permission, Process.myPid(), Process.myUid()) - == PackageManager.PERMISSION_GRANTED); - return; - } promise.resolve(context.checkSelfPermission(permission) == PackageManager.PERMISSION_GRANTED); } @@ -68,10 +60,6 @@ public void checkPermission(final String permission, final Promise promise) { */ @Override public void shouldShowRequestPermissionRationale(final String permission, final Promise promise) { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) { - promise.resolve(false); - return; - } try { promise.resolve( getPermissionAwareActivity().shouldShowRequestPermissionRationale(permission)); @@ -89,14 +77,6 @@ public void shouldShowRequestPermissionRationale(final String permission, final @Override public void requestPermission(final String permission, final Promise promise) { Context context = getReactApplicationContext().getBaseContext(); - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) { - promise.resolve( - context.checkPermission(permission, Process.myPid(), Process.myUid()) - == PackageManager.PERMISSION_GRANTED - ? GRANTED - : DENIED); - return; - } if (context.checkSelfPermission(permission) == PackageManager.PERMISSION_GRANTED) { promise.resolve(GRANTED); return; @@ -142,15 +122,7 @@ public void requestMultiplePermissions(final ReadableArray permissions, final Pr for (int i = 0; i < permissions.size(); i++) { String perm = permissions.getString(i); - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) { - grantedPermissions.putString( - perm, - context.checkPermission(perm, Process.myPid(), Process.myUid()) - == PackageManager.PERMISSION_GRANTED - ? GRANTED - : DENIED); - checkedPermissionsCount++; - } else if (context.checkSelfPermission(perm) == PackageManager.PERMISSION_GRANTED) { + if (context.checkSelfPermission(perm) == PackageManager.PERMISSION_GRANTED) { grantedPermissions.putString(perm, GRANTED); checkedPermissionsCount++; } else {