From 413c6a069732777cfb2fa00b8dc4412c02f64ef4 Mon Sep 17 00:00:00 2001 From: Emmanuel Quentin Date: Wed, 11 Nov 2020 17:42:35 -0500 Subject: [PATCH] Fix android permissions depending on os version --- .../src/main/java/io/wazo/callkeep/RNCallKeepModule.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/android/src/main/java/io/wazo/callkeep/RNCallKeepModule.java b/android/src/main/java/io/wazo/callkeep/RNCallKeepModule.java index 85e2f401..ad01429f 100644 --- a/android/src/main/java/io/wazo/callkeep/RNCallKeepModule.java +++ b/android/src/main/java/io/wazo/callkeep/RNCallKeepModule.java @@ -91,8 +91,11 @@ public class RNCallKeepModule extends ReactContextBaseJavaModule { private static final String E_ACTIVITY_DOES_NOT_EXIST = "E_ACTIVITY_DOES_NOT_EXIST"; private static final String REACT_NATIVE_MODULE_NAME = "RNCallKeep"; - private static final String[] permissions = { Manifest.permission.READ_PHONE_STATE, - Manifest.permission.CALL_PHONE, Manifest.permission.RECORD_AUDIO, Manifest.permission.READ_PHONE_NUMBERS }; + private static final String[] permissions = { + Build.VERSION.SDK_INT < 30 ? Manifest.permission.READ_PHONE_STATE : Manifest.permission.READ_PHONE_NUMBERS, + Manifest.permission.CALL_PHONE, + Manifest.permission.RECORD_AUDIO + }; private static final String TAG = "RNCK:RNCallKeepModule"; private static TelecomManager telecomManager; @@ -521,7 +524,7 @@ private String getApplicationName(Context appContext) { private Boolean hasPermissions() { Activity currentActivity = this.getCurrentActivity(); - + if (currentActivity == null) { return false; }