react-native-callkeep icon indicating copy to clipboard operation
react-native-callkeep copied to clipboard

[Android] One of RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED should be specified in Android 14 when receiving call after upgrading react native 0.73

Open taekeun-two opened this issue 1 year ago • 0 comments

Bug report

  • [ ] I've checked the example to reproduce the issue.

  • Reproduced on:

  • [X] Android

  • [ ] iOS

Description

After upgrading

  • from: ReactNative 0.72.X and Expo 49,
  • to: ReactNative 0.73.X and Expo 50,
// android/build.gradle

buildscript {
    ext {
        buildToolsVersion = "34.0.0"
        minSdkVersion = 21
        compileSdkVersion = 34
        targetSdkVersion = 34
        ndkVersion = "25.1.8937393"
        kotlinVersion = "1.8.0"
    }

the following error occurs whenever receiving call in Android 14 platform phone.

One of RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED should be specified 

References

Registering receivers with intention using the RECEIVER_EXPORTED / RECEIVER_NOT_EXPORTED flag was introduced as part of Android 13 and is now a requirement for apps running on Android 14 or higher (U+). It seems that it should be applied for callkeep's registering receivers.

  • https://stackoverflow.com/questions/77235063/one-of-receiver-exported-or-receiver-not-exported-should-be-specified-when-a-rec
  • https://github.com/joltup/rn-fetch-blob/issues/866#issuecomment-2030940568
diff --git a/node_modules/rn-fetch-blob/android/src/main/java/com/RNFetchBlob/RNFetchBlobReq.java b/node_modules/rn-fetch-blob/android/src/main/java/com/RNFetchBlob/RNFetchBlobReq.java
index a8abd71..efa1b46 100644
--- a/node_modules/rn-fetch-blob/android/src/main/java/com/RNFetchBlob/RNFetchBlobReq.java
+++ b/node_modules/rn-fetch-blob/android/src/main/java/com/RNFetchBlob/RNFetchBlobReq.java
@@ -196,7 +196,11 @@ public class RNFetchBlobReq extends BroadcastReceiver implements Runnable {
                 DownloadManager dm = (DownloadManager) appCtx.getSystemService(Context.DOWNLOAD_SERVICE);
                 downloadManagerId = dm.enqueue(req);
                 androidDownloadManagerTaskTable.put(taskId, Long.valueOf(downloadManagerId));
-                appCtx.registerReceiver(this, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE));
+                if (Build.VERSION.SDK_INT >= 34 && appCtx.getApplicationInfo().targetSdkVersion >= 34) {
+                  appCtx.registerReceiver(this, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE), Context.RECEIVER_EXPORTED);
+                }else{
+                  appCtx.registerReceiver(this, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE));
+                }
                 return;
             }

Steps to Reproduce

  • Upgrade to react native 0.73.8 and Expo 50.0.18
  • Receiving call in Android 14 platform phone. It always occurs.

Versions

- Callkeep: 4.3.9
- React Native: 0.73.8   // upgraded from 0.72.10
- Expo : 50.0.18         // upgraded from 49
- iOS:
- Android: Android version 14
- Phone model: Samsung Galaxy S23+ SM-S916N

Logs

java.lang.SecurityException: <packageName>: One of RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED should be specified when a receiver isn't being registered exclusively for system broadcasts

iScreen Shoter - Microsoft Teams - 240527101342

taekeun-two avatar May 27 '24 01:05 taekeun-two