Skip to content

Commit

Permalink
Remove support for Android API < 23 in PermissionsModule
Browse files Browse the repository at this point in the history
Summary:
Since minsdk version was increased to 23, we are deleting code using Android APIs < 23 for class PermissionsModule

chnagelog: [Android][Breaking] Remove support for Android API < 23 in PermissionsModule

Differential Revision: D48545517

fbshipit-source-id: e7abe92a8693f87f1159786d1a89a7e98d142128
  • Loading branch information
mdvacca authored and facebook-github-bot committed Sep 26, 2023
1 parent 11acec4 commit 3748824
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 3748824

Please sign in to comment.