Skip to content

Commit

Permalink
Remove support for Android API < 23 in PermissionsModule (#39680)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #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
  • Loading branch information
mdvacca authored and facebook-github-bot committed Sep 27, 2023
1 parent 52ec1d8 commit 0384e3c
Showing 1 changed file with 1 addition and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}

Expand All @@ -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));
Expand All @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 0384e3c

Please sign in to comment.