Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Android] Fix Android Bluetooth connect issue (Specific Android Device) #33087

Merged
merged 1 commit into from
Apr 23, 2024

Conversation

joonhaengHeo
Copy link
Contributor

Fix #32868

BLE discoverService does not succeed because an unexpected callback is called during the BLE connection process on a specific Android device. To prevent this, the code was modified to manage the state for each callback and process only callbacks that match the state.

Copy link

github-actions bot commented Apr 22, 2024

PR #33087: Size comparison from b4650b9 to a06d309

Decreases (2 builds for efr32)
platform target config section b4650b9 a06d309 change % change
efr32 lighting-app BRD4187C (read/write) 1069544 1069536 -8 -0.0
.text 886172 886164 -8 -0.0
window-app BRD4187C (read/write) 1135868 1135860 -8 -0.0
.text 967992 967984 -8 -0.0
Full report (71 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, cyw30739, efr32, esp32, linux, mbed, nrfconnect, nxp, psoc6, qpg, stm32, telink)
platform target config section b4650b9 a06d309 change % change
bl602 lighting-app bl602 (read/write) 1442546 1442546 0 0.0
.bss 85448 85448 0 0.0
.data 9512 9512 0 0.0
.rodata 159068 159068 0 0.0
.text 1107860 1107860 0 0.0
bl602+mfd (read/write) 1456970 1456970 0 0.0
.bss 85616 85616 0 0.0
.data 9488 9488 0 0.0
.rodata 158028 158028 0 0.0
.text 1123178 1123178 0 0.0
bl602+rpc (read/write) 1490202 1490202 0 0.0
.bss 93488 93488 0 0.0
.data 9888 9888 0 0.0
.rodata 166644 166644 0 0.0
.text 1139506 1139506 0 0.0
bl702 lighting-app bl702 (read only) 3478 3478 0 0.0
(read/write) 1209223 1209223 0 0.0
.bss 11185 11185 0 0.0
.data 3704 3704 0 0.0
.rodata 108768 108768 0 0.0
.text 978620 978620 0 0.0
bl702+mfd (read only) 3478 3478 0 0.0
(read/write) 1220047 1220047 0 0.0
.bss 11361 11361 0 0.0
.data 3688 3688 0 0.0
.rodata 107708 107708 0 0.0
.text 990374 990374 0 0.0
bl702+rpc (read only) 3478 3478 0 0.0
(read/write) 1300711 1300711 0 0.0
.bss 19669 19669 0 0.0
.data 4248 4248 0 0.0
.rodata 124140 124140 0 0.0
.text 1053328 1053328 0 0.0
bl706-eth (read/write) 1024937 1024937 0 0.0
.bss 23760 23760 0 0.0
.data 3256 3256 0 0.0
.rodata 101756 101756 0 0.0
.text 768132 768132 0 0.0
bl706-wifi (read/write) 1259586 1259586 0 0.0
.bss 10645 10645 0 0.0
.data 3704 3704 0 0.0
.rodata 122756 122756 0 0.0
.text 1000010 1000010 0 0.0
bl702l lighting-app bl702l (read only) 512 512 0 0.0
(read/write) 1178548 1178548 0 0.0
.bss 16396 16396 0 0.0
.data 5072 5072 0 0.0
.rodata 102772 102772 0 0.0
.text 971474 971474 0 0.0
bl702l+mfd (read only) 512 512 0 0.0
(read/write) 1189960 1189960 0 0.0
.bss 16572 16572 0 0.0
.data 5048 5048 0 0.0
.rodata 101712 101712 0 0.0
.text 983796 983796 0 0.0
cc13x4_26x4 lighting-app LP_EM_CC1354P10_6 (read only) 783620 783620 0 0.0
(read/write) 176668 176668 0 0.0
.bss 98612 98612 0 0.0
.data 3588 3588 0 0.0
.rodata 82932 82932 0 0.0
.text 700424 700424 0 0.0
lock-ftd LP_EM_CC1354P10_6 (read only) 799508 799508 0 0.0
(read/write) 187156 187156 0 0.0
.bss 109100 109100 0 0.0
.data 3588 3588 0 0.0
.rodata 76916 76916 0 0.0
.text 722328 722328 0 0.0
lock-mtd LP_EM_CC1354P10_6 (read only) 788372 788372 0 0.0
(read/write) 181276 181276 0 0.0
.bss 103220 103220 0 0.0
.data 3588 3588 0 0.0
.rodata 103836 103836 0 0.0
.text 684272 684272 0 0.0
pump-app LP_EM_CC1354P10_6 (read only) 740628 740628 0 0.0
(read/write) 175644 175644 0 0.0
.bss 97352 97352 0 0.0
.data 3580 3580 0 0.0
.rodata 78596 78596 0 0.0
.text 661768 661768 0 0.0
pump-controller-app LP_EM_CC1354P10_6 (read only) 726252 726252 0 0.0
(read/write) 175852 175852 0 0.0
.bss 97576 97576 0 0.0
.data 3572 3572 0 0.0
.rodata 74372 74372 0 0.0
.text 651616 651616 0 0.0
cc32xx air-purifier CC3235SF_LAUNCHXL (read only) 586670 586670 0 0.0
(read/write) 208100 208100 0 0.0
.bss 201324 201324 0 0.0
.data 1652 1652 0 0.0
.rodata 87502 87502 0 0.0
.text 497048 497048 0 0.0
lock CC3235SF_LAUNCHXL (read only) 632846 632846 0 0.0
(read/write) 208364 208364 0 0.0
.bss 201728 201728 0 0.0
.data 1516 1516 0 0.0
.rodata 108190 108190 0 0.0
.text 522532 522532 0 0.0
cyw30739 light cyw930739m2evb_01 (read/write) 570327 570327 0 0.0
.app_xip_area 460237 460237 0 0.0
.bss 64908 64908 0 0.0
.data 760 760 0 0.0
.rodata 0 0 0 0.0
.text 112 112 0 0.0
lock cyw930739m2evb_01 (read/write) 552543 552543 0 0.0
.app_xip_area 437781 437781 0 0.0
.bss 69572 69572 0 0.0
.data 768 768 0 0.0
.rodata 0 0 0 0.0
.text 112 112 0 0.0
ota-requestor cyw930739m2evb_01 (read/write) 573079 573079 0 0.0
.app_xip_area 464485 464485 0 0.0
.bss 63452 63452 0 0.0
.data 720 720 0 0.0
.rodata 0 0 0 0.0
.text 112 112 0 0.0
switch cyw930739m2evb_01 (read/write) 565535 565535 0 0.0
.app_xip_area 453757 453757 0 0.0
.bss 66556 66556 0 0.0
.data 800 800 0 0.0
.rodata 0 0 0 0.0
.text 112 112 0 0.0
efr32 lighting-app BRD4187C (read/write) 1069544 1069536 -8 -0.0
.bss 179920 179920 0 0.0
.data 3432 3432 0 0.0
.text 886172 886164 -8 -0.0
lock-app BRD4338a (read/write) 961876 961876 0 0.0
.bss 210236 210236 0 0.0
.data 30288 30288 0 0.0
.text 701984 701984 0 0.0
window-app BRD4187C (read/write) 1135868 1135860 -8 -0.0
.bss 164520 164520 0 0.0
.data 3336 3336 0 0.0
.text 967992 967984 -8 -0.0
esp32 all-clusters-app c3devkit (read only) 1214030 1214030 0 0.0
(read/write) 1750752 1750752 0 0.0
.dram0.bss 74328 74328 0 0.0
.dram0.data 13636 13636 0 0.0
.flash.rodata 253248 253248 0 0.0
.flash.text 1214030 1214030 0 0.0
.iram0.text 75530 75530 0 0.0
m5stack (read only) 1256831 1256831 0 0.0
(read/write) 537116 537116 0 0.0
.dram0.bss 81064 81064 0 0.0
.dram0.data 35180 35180 0 0.0
.flash.rodata 284952 284952 0 0.0
.flash.text 1250667 1250667 0 0.0
.iram0.text 125403 125403 0 0.0
linux air-purifier-app debug (read only) 2648165 2648165 0 0.0
(read/write) 130032 130032 0 0.0
.bss 46728 46728 0 0.0
.data 2272 2272 0 0.0
.data.rel.ro 75080 75080 0 0.0
.dynamic 608 608 0 0.0
.got 4520 4520 0 0.0
.init 27 27 0 0.0
.init_array 800 800 0 0.0
.rodata 185072 185072 0 0.0
.text 2284101 2284101 0 0.0
all-clusters-app debug (read only) 5963049 5963049 0 0.0
(read/write) 481672 481672 0 0.0
.bss 135040 135040 0 0.0
.data 4560 4560 0 0.0
.data.rel.ro 334632 334632 0 0.0
.dynamic 624 624 0 0.0
.got 5328 5328 0 0.0
.init 27 27 0 0.0
.init_array 1440 1440 0 0.0
.rodata 352016 352016 0 0.0
.text 5175891 5175891 0 0.0
all-clusters-minimal-app debug (read only) 5243025 5243025 0 0.0
(read/write) 237624 237624 0 0.0
.bss 127872 127872 0 0.0
.data 4464 4464 0 0.0
.data.rel.ro 98216 98216 0 0.0
.dynamic 624 624 0 0.0
.got 5248 5248 0 0.0
.init 27 27 0 0.0
.init_array 1168 1168 0 0.0
.rodata 290666 290666 0 0.0
.text 4715875 4715875 0 0.0
bridge-app debug (read only) 4634281 4634281 0 0.0
(read/write) 218536 218536 0 0.0
.bss 118400 118400 0 0.0
.data 6240 6240 0 0.0
.data.rel.ro 87168 87168 0 0.0
.dynamic 624 624 0 0.0
.got 5216 5216 0 0.0
.init 27 27 0 0.0
.init_array 864 864 0 0.0
.rodata 230890 230890 0 0.0
.text 4181331 4181331 0 0.0
chip-tool debug (read only) 12085249 12085249 0 0.0
(read/write) 523104 523104 0 0.0
.bss 94744 94744 0 0.0
.data 5122 5122 0 0.0
.data.rel.ro 416000 416000 0 0.0
.dynamic 624 624 0 0.0
.got 5736 5736 0 0.0
.init 27 27 0 0.0
.init_array 832 832 0 0.0
.rodata 451321 451321 0 0.0
.text 10925571 10925571 0 0.0
chip-tool-ipv6only arm64 (read only) 11404580 11404580 0 0.0
(read/write) 590712 590712 0 0.0
.bss 103720 103720 0 0.0
.data 4520 4520 0 0.0
.data.rel.ro 455936 455936 0 0.0
.dynamic 512 512 0 0.0
.got 17104 17104 0 0.0
.init 24 24 0 0.0
.init_array 280 280 0 0.0
.rodata 356276 356276 0 0.0
.text 10166648 10166648 0 0.0
lighting-app debug+rpc+ui (read only) 5557817 5557817 0 0.0
(read/write) 227304 227304 0 0.0
.bss 119344 119344 0 0.0
.data 4896 4896 0 0.0
.data.rel.ro 95536 95536 0 0.0
.dynamic 672 672 0 0.0
.got 5856 5856 0 0.0
.init 27 27 0 0.0
.init_array 976 976 0 0.0
.rodata 354804 354804 0 0.0
.text 4954563 4954563 0 0.0
lock-app debug (read only) 4700193 4700193 0 0.0
(read/write) 205760 205760 0 0.0
.bss 113704 113704 0 0.0
.data 4192 4192 0 0.0
.data.rel.ro 81160 81160 0 0.0
.dynamic 624 624 0 0.0
.got 5168 5168 0 0.0
.init 27 27 0 0.0
.init_array 880 880 0 0.0
.rodata 256746 256746 0 0.0
.text 4230451 4230451 0 0.0
ota-provider-app debug (read only) 4310657 4310657 0 0.0
(read/write) 194200 194200 0 0.0
.bss 113440 113440 0 0.0
.data 4368 4368 0 0.0
.data.rel.ro 70448 70448 0 0.0
.dynamic 624 624 0 0.0
.got 4536 4536 0 0.0
.init 27 27 0 0.0
.init_array 752 752 0 0.0
.rodata 209514 209514 0 0.0
.text 3906659 3906659 0 0.0
ota-requestor-app debug (read only) 4441281 4441281 0 0.0
(read/write) 198568 198568 0 0.0
.bss 114336 114336 0 0.0
.data 4768 4768 0 0.0
.data.rel.ro 73536 73536 0 0.0
.dynamic 624 624 0 0.0
.got 4472 4472 0 0.0
.init 27 27 0 0.0
.init_array 800 800 0 0.0
.rodata 215594 215594 0 0.0
.text 4026659 4026659 0 0.0
shell debug (read only) 2931113 2931113 0 0.0
(read/write) 157040 157040 0 0.0
.bss 62512 62512 0 0.0
.data 1424 1424 0 0.0
.data.rel.ro 87312 87312 0 0.0
.dynamic 592 592 0 0.0
.got 4056 4056 0 0.0
.init 27 27 0 0.0
.init_array 1112 1112 0 0.0
.rodata 188384 188384 0 0.0
.text 2567618 2567618 0 0.0
thermostat-no-ble arm64 (read only) 4434364 4434364 0 0.0
(read/write) 245128 245128 0 0.0
.bss 121976 121976 0 0.0
.data 3408 3408 0 0.0
.data.rel.ro 104424 104424 0 0.0
.dynamic 512 512 0 0.0
.got 8720 8720 0 0.0
.init 24 24 0 0.0
.init_array 448 448 0 0.0
.rodata 160388 160388 0 0.0
.text 3937144 3937144 0 0.0
tv-app debug (read only) 5774169 5774169 0 0.0
(read/write) 353496 353496 0 0.0
.bss 244336 244336 0 0.0
.data 6560 6560 0 0.0
.data.rel.ro 95304 95304 0 0.0
.dynamic 624 624 0 0.0
.got 5464 5464 0 0.0
.init 27 27 0 0.0
.init_array 1184 1184 0 0.0
.rodata 295274 295274 0 0.0
.text 5235139 5235139 0 0.0
tv-casting-app debug (read only) 9899849 9899849 0 0.0
(read/write) 342720 342720 0 0.0
.bss 157976 157976 0 0.0
.data 3008 3008 0 0.0
.data.rel.ro 174848 174848 0 0.0
.dynamic 624 624 0 0.0
.got 5040 5040 0 0.0
.init 27 27 0 0.0
.init_array 1216 1216 0 0.0
.rodata 384504 384504 0 0.0
.text 9048467 9048467 0 0.0
mbed lock-app-release cy8cproto_062_4343w (read only) 6224 6224 0 0.0
(read/write) 2535568 2535568 0 0.0
.bss 220488 220488 0 0.0
.data 5216 5216 0 0.0
.text 1498252 1498252 0 0.0
nrfconnect all-clusters-app nrf52840dk_nrf52840 (read only) 4 4 0 0.0
(read/write) 1065792 1065792 0 0.0
bss 133119 133119 0 0.0
rodata 103400 103400 0 0.0
text 782064 782064 0 0.0
nrf7002dk_nrf5340_cpuapp (read only) 4 4 0 0.0
(read/write) 1226264 1226264 0 0.0
bss 127175 127175 0 0.0
rodata 151368 151368 0 0.0
text 797700 797700 0 0.0
all-clusters-minimal-app nrf52840dk_nrf52840 (read only) 4 4 0 0.0
(read/write) 1013376 1013376 0 0.0
bss 131977 131977 0 0.0
rodata 90664 90664 0 0.0
text 743408 743408 0 0.0
nxp contact k32w0+release (read only) 575628 575628 0 0.0
(read/write) 83140 83140 0 0.0
.bss 67856 67856 0 0.0
.data 2188 2188 0 0.0
.text 575092 575092 0 0.0
k32w1+release (read only) 1024 1024 0 0.0
(read/write) 702900 702900 0 0.0
.bss 71200 71200 0 0.0
.data 2864 2864 0 0.0
.text 589456 589456 0 0.0
light k32w0+release (read only) 609632 609632 0 0.0
(read/write) 82592 82592 0 0.0
.bss 67296 67296 0 0.0
.data 2208 2208 0 0.0
.text 609096 609096 0 0.0
k32w1+release (read only) 1024 1024 0 0.0
(read/write) 794824 794824 0 0.0
.bss 80744 80744 0 0.0
.data 2064 2064 0 0.0
.text 672648 672648 0 0.0
psoc6 all-clusters cy8ckit_062s2_43012 (read only) 832272 832272 0 0.0
(read/write) 1804604 1804604 0 0.0
.bss 198380 198380 0 0.0
.data 2688 2688 0 0.0
.text 1595148 1595148 0 0.0
all-clusters-minimal cy8ckit_062s2_43012 (read only) 835424 835424 0 0.0
(read/write) 1726492 1726492 0 0.0
.bss 195260 195260 0 0.0
.data 2656 2656 0 0.0
.text 1520188 1520188 0 0.0
light cy8ckit_062s2_43012 (read only) 842144 842144 0 0.0
(read/write) 1645244 1645244 0 0.0
.bss 188724 188724 0 0.0
.data 2472 2472 0 0.0
.text 1445660 1445660 0 0.0
lock cy8ckit_062s2_43012 (read only) 815072 815072 0 0.0
(read/write) 1673916 1673916 0 0.0
.bss 215804 215804 0 0.0
.data 2464 2464 0 0.0
.text 1447260 1447260 0 0.0
qpg lighting-app qpg6105+debug (read/write) 1133180 1133180 0 0.0
.bss 102588 102588 0 0.0
.data 856 856 0 0.0
.text 645560 645560 0 0.0
lock-app qpg6105+debug (read/write) 1093180 1093180 0 0.0
.bss 97260 97260 0 0.0
.data 860 860 0 0.0
.text 605564 605564 0 0.0
stm32 light STM32WB5MM-DK (read/write) 604785 604785 0 0.0
.bss 128444 128444 0 0.0
.data 688 688 0 0.0
.rodata 80516 80516 0 0.0
.text 385392 385392 0 0.0
telink air-quality-sensor-app tlsr9528a_retention (read only) 51774 51774 0 0.0
(read/write) 833910 833910 0 0.0
bss 49856 49856 0 0.0
text 624594 624594 0 0.0
all-clusters-app tlsr9518adk80d (read only) 29042 29042 0 0.0
(read/write) 1096996 1096996 0 0.0
bss 101540 101540 0 0.0
text 798004 798004 0 0.0
all-clusters-minimal-app tlsr9528a (read only) 47960 47960 0 0.0
(read/write) 1058460 1058460 0 0.0
bss 109988 109988 0 0.0
text 772366 772366 0 0.0
bridge-app tlsr9518adk80d (read only) 29042 29042 0 0.0
(read/write) 913980 913980 0 0.0
bss 92744 92744 0 0.0
text 655846 655846 0 0.0
contact-sensor-app tlsr9528a_retention (read only) 51774 51774 0 0.0
(read/write) 835930 835930 0 0.0
bss 49900 49900 0 0.0
text 626694 626694 0 0.0
light-switch-app-ota-shell-factory-data tlsr9528a (read only) 51584 51584 0 0.0
(read/write) 936604 936604 0 0.0
bss 77512 77512 0 0.0
text 703236 703236 0 0.0
lighting-app-ota-rpc-factory-data-4mb tlsr9518adk80d (read only) 29122 29122 0 0.0
(read/write) 1090484 1090484 0 0.0
bss 99836 99836 0 0.0
text 793948 793948 0 0.0
lock-app-dfu tlsr9528a (read only) 51584 51584 0 0.0
(read/write) 911184 911184 0 0.0
bss 69180 69180 0 0.0
text 660230 660230 0 0.0
ota-requestor-app tlsr9518adk80d (read only) 29042 29042 0 0.0
(read/write) 932824 932824 0 0.0
bss 92448 92448 0 0.0
text 674882 674882 0 0.0
pump-app tlsr9258a (read only) 52490 52490 0 0.0
(read/write) 833488 833488 0 0.0
bss 58144 58144 0 0.0
text 623694 623694 0 0.0
pump-controller-app tlsr9518adk80d (read only) 31872 31872 0 0.0
(read/write) 799608 799608 0 0.0
bss 56072 56072 0 0.0
text 598600 598600 0 0.0
shell tlsr9518adk80d (read only) 29042 29042 0 0.0
(read/write) 676128 676128 0 0.0
bss 73424 73424 0 0.0
text 461864 461864 0 0.0
smoke_co_alarm-app tlsr9528a_retention (read only) 51774 51774 0 0.0
(read/write) 843670 843670 0 0.0
bss 51528 51528 0 0.0
text 633236 633236 0 0.0
temperature-measurement-app-mars-ota tlsr9518adk80d (read only) 32220 32220 0 0.0
(read/write) 858489 858489 0 0.0
bss 59696 59696 0 0.0
text 642184 642184 0 0.0
thermostat tlsr9518adk80d (read only) 31872 31872 0 0.0
(read/write) 825156 825156 0 0.0
bss 56404 56404 0 0.0
text 618150 618150 0 0.0
window-covering tlsr9258a (read only) 52490 52490 0 0.0
(read/write) 838376 838376 0 0.0
bss 58360 58360 0 0.0
text 626158 626158 0 0.0

@mergify mergify bot merged commit 9ff29ed into project-chip:master Apr 23, 2024
67 checks passed
Comment on lines +618 to 619
mState = STATE_REQUEST_MTU;
gatt.requestMtu(247);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The request of MTU from here is probably what broke on the devices. gatt calls should not be done inside of AndroidBluetoothGattCallback. See https://developer.android.com/develop/connectivity/bluetooth/ble/connect-gatt-server#broadcast-updates for guidance, where it is required to post to a different context to properly handle callbacks rather than calling back in, which can be unsafe on some Android platforms.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The previous state of the Android driver had the same problem, but adding complex statefulness to this file may add risk and hard-to-debug issues in other situations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Android] Chiptool app on Xiaomi tab 5 is crashing while pairing with Thread devices
4 participants