diff --git a/.changeset/three-lions-smoke.md b/.changeset/three-lions-smoke.md new file mode 100644 index 000000000000..0b3ed6db81d0 --- /dev/null +++ b/.changeset/three-lions-smoke.md @@ -0,0 +1,5 @@ +--- +"@ledgerhq/react-native-hid": patch +--- + +Android sdk 34 give the following error when use transporter from the lib @ledger/react-native-hid, to fix this bug is needed call getReactApplicationContext() with the Context.RECEIVER_NOT_EXPORTED attribute. https://github.com/LedgerHQ/ledger-live/issues/7786 diff --git a/libs/ledgerjs/packages/react-native-hid/android/src/main/java/com/ledgerwallet/hid/ReactHIDModule.java b/libs/ledgerjs/packages/react-native-hid/android/src/main/java/com/ledgerwallet/hid/ReactHIDModule.java index 349bf3982c88..3acc5c859ade 100755 --- a/libs/ledgerjs/packages/react-native-hid/android/src/main/java/com/ledgerwallet/hid/ReactHIDModule.java +++ b/libs/ledgerjs/packages/react-native-hid/android/src/main/java/com/ledgerwallet/hid/ReactHIDModule.java @@ -7,6 +7,7 @@ import android.content.IntentFilter; import android.hardware.usb.UsbDevice; import android.hardware.usb.UsbManager; +import android.os.Build; import androidx.annotation.NonNull; @@ -58,6 +59,11 @@ public void onReceive(Context context, Intent intent) { .emit(event, buildMapFromDevice(device)); } }; + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { + getReactApplicationContext().registerReceiver(receiver, filter, Context.RECEIVER_NOT_EXPORTED); + return; + } + getReactApplicationContext().registerReceiver(receiver, filter); } @@ -213,7 +219,12 @@ public void onReceive(Context context, Intent intent) { unregisterReceiver(this); } }; - getReactApplicationContext().registerReceiver(receiver, intFilter); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { + getReactApplicationContext().registerReceiver(receiver, intFilter, Context.RECEIVER_NOT_EXPORTED); + return; + } + + getReactApplicationContext().registerReceiver(receiver, intFilter, Context.RECEIVER_NOT_EXPORTED); } private void unregisterReceiver(BroadcastReceiver receiver) {