Skip to content

Commit

Permalink
fix @ledger/react-native-hid for android tiramisu
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-meilan committed Sep 24, 2024
1 parent be1d33b commit 4421908
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/three-lions-smoke.md
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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;

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

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

0 comments on commit 4421908

Please sign in to comment.