Closed gaogaogoo closed 4 months ago
maybe there are many thousands of scan results so bytesToHex is taking too long to run?
youll need to modify FBP
use this code. it's faster.
private static String bytesToHex(byte[] bytes) {
if (bytes == null) {
return "";
}
StringBuilder sb = new StringBuilder(bytes.length * 2);
for (byte b : bytes) {
sb.append(Character.forDigit((b >> 4) & 0xF, 16));
sb.append(Character.forDigit(b & 0xF, 16));
}
return sb.toString();
}
use this code. it's faster.
private static String bytesToHex(byte[] bytes) { if (bytes == null) { return ""; } StringBuilder sb = new StringBuilder(bytes.length * 2); for (byte b : bytes) { sb.append(Character.forDigit((b >> 4) & 0xF, 16)); sb.append(Character.forDigit(b & 0xF, 16)); } return sb.toString(); }
Thank you for your reply. After using this code, I still encountered ANR errors. The error is as follows:
Build fingerprint: 'OPPO/PJR110/OP5A15L1:14/TP1A.220905.001/U.1863da6_1-45fc:user/release-keys' ABI: 'arm64' Build type: optimized suspend all histogram: Sum: 5.862ms 99% C.I. 0.426us-2247.680us Avg: 112.730us Max: 2865us DALVIK THREADS (37): "main" prio=5 tid=1 TimedWaiting | group="main" sCount=1 ucsCount=0 flags=1 obj=0x724dff88 self=0xb400007150610800 | sysTid=17911 nice=-10 cgrp=top-app sched=0/0 handle=0x72036ce500 | state=S schedstat=( 16504636957 964614829 13725 ) utm=1453 stm=197 core=4 HZ=100 | stack=0x7fdf9dd000-0x7fdf9df000 stackSize=8188KB | held mutexes= at jdk.internal.misc.Unsafe.park(Native method)
this seems like a bug in android.
we can't fix it afaict.
reopen the issue if you have futher information
Requirements
Have you checked this problem on the example app?
No
FlutterBluePlus Version
1.32.8
Flutter Version
3.19.6
What OS?
Android
OS Version
14
Bluetooth Module
none
What is your problem?
Here, my test phone is an OPPO K12 5G. The steps are as follows:
After encountering this issue, I exported two ANR logs from the phone. Could you please help me check the problem?
Logs