universal5433 / android_device_samsung_trelte-common

Samsung Galaxy Note 4 - common device tree
5 stars 9 forks source link

[BUG] WiFi Scanning is not working on some models/WiFi Chip Revisions #33

Open ananjaser1211 opened 1 year ago

ananjaser1211 commented 1 year ago

Describe the bug Multiple N910C/N910H Models face an issue with WiFi where the WiFi is ON, but does not show any networks. The only way to scan is by disabling SIM or setting the device to airplane mode

Workaround Current workarounds are the following :

1- Turn on airplane mode 2- restart the phone 3- connect to WiFi network 4- disable the airplane mode

The issue will return when WiFi disconnects

Another workaround is not using SIMCard, obviously not ideal.

Smartphone model (please complete the following information):

Additional context

godzellax commented 1 year ago

Hi Sir, I will provide the log asap Thank you Sir so much

godzellax commented 1 year ago

@ log_ball.zip Here we go Sir. I hope the log will be useful and lead to fix the issue once and for all. I tried to cover all scenarios while recording the log, switch on/off WiFi and airplane mode one after another. God bless you, I'm not a developer but I'm sure the issue is not easy to fix but I hope you will be our hero and fix it.

P.S I'm ready to help at any time, thanks.

ananjaser1211 commented 1 year ago

I might have found the coloration between your issue and the other person on telegram, both use syrian revision (possibly the wifi chip gatherers it from Mobile network)

It seems that the ROM sends a request to to set the country to SY

08-10 00:14:38.953 16670 16670 I wpa_supplicant: wlan0: CTRL-EVENT-REGDOM-CHANGE init=USER type=COUNTRY alpha2=SY

08-10 00:14:39.020     0     0 I         : [c3] WLDEV-INFO) wldev_set_country: Current country SY rev 0

08-10 00:14:39.021     0     0 W [c1] wl_android_priv_cmd: fccpwrlimit2g is deactivated

08-10 00:14:38.960  4824  5809 D WifiCountryCode: Succeeded to set country code to: SY

On my device however, it sets to WLDEV-INFO) wldev_set_country: set country for AE as AE rev 6

i dont know exactly what this revision entails, but it seems to be something to do with TX/RX Power regulation,

Anyway, after that we get this error

08-10 00:15:34.861  4300  4300 D WifiHAL : Start get packet fate command

08-10 00:15:34.862  4300  4300 D WifiHAL : createRequest Monitor packet fate request

08-10 00:15:34.862  4300  4300 E WifiHAL : Failed to register get pkt fate response; result = -95

and the wifi chip restarts, and so on and so fourth,

I think, when the region is set to SY, it disables packet filtering, which seems to be required by the ROM , and thus errors out wifi when a sim is installed or ccode=SY

08-10 00:15:34.959     0     0 W [c6] dhd_wl_ioctl: WLC_SET_VAR: pkt_filter_add, ret = -2

08-10 00:15:34.959     0     0 W [c6] net_os_enable_packet_filter: val = 1

08-10 00:15:34.960     0     0 W [c6] dhd_set_suspend: Remove extra suspend setting

08-10 00:15:34.960     0     0 W [c6] dhd_enable_packet_filter: enter, value = 0

my device on the other hand reports dhd_enable_packet_filter as 1

this weekend ill wrap my head around the issue, and i think this time i might be able to solve it, hopefully.

Thanks for the very valuable log.

godzellax commented 1 year ago

It seems its and issue with the WiFi country code as you suggest, can you check please the following links, I think it might help:

https://stackoverflow.com/questions/2637606/how-do-i-change-the-mobile-country-code-mcc-in-the-android-emulator

https://forum.xda-developers.com/t/app-beta-root-4-wifi-codes-change-country-codes-enable-wireless-channels.1982149/

I found some people taking about finding some custom Roms for their different phones have WiFi advance settings as an option to change WiFi country code, they have the exact issue and confirmed that it is because of the their country block the wifi somehow and they confirmed that they solve it by changing or spoofing the wifi/telephony country code, can you check that Sir.

Screenshot_20230810-183812_Termux

Moreover to above, please note that I changed some wifi prop through commands as you see in attached screenshot but unfortunately didn't help.

godzellax commented 1 year ago

Please note that I purchased my mobile from UAE, but I'm being in Syria. I didn't tried before any custom ROM while I was in UAE so I don't know if WiFi issue will happen only in Syria but at least I know that my phone customized to work in UAE because I purchase it there. But what you are saying might be true and maybe explain why the issue gone if I remove the sim card. As suggestion, can we spoof WiFi to think that I'm not in Syria and will it solve the issue. I cannot imagine the issue because of my country cell network provider! Very weird Sir. Please help us Sir, you are only our hope in such poor country.

ananjaser1211 commented 1 year ago

@godzellax Try this kernel boot_bcmdhd4358.zip

unzip, then flash boot_bcmdhd4358.img in recovery (go to flash > press img > select the file > select BOOT for partition)

with enough luck this might fix the issue, if not please send a new log_ball with the new kernel installed

godzellax commented 1 year ago

OMG, you did it Sir and ended the nightmare. I believe many people facing the same issue but no one fixed it except you.

Now coming to a new questions, is it a permanent solution? Will it hurt my phone in any way? Will you include the fix in your next stable release?

Would you if you don't mind explain to us the cause of the issue please.

May god bless you and your team,

godzellax commented 1 year ago

Oops, I forgot that I have to re-root my phone so I though there was an issue. After applying root everything seems to be working fine. I'll keep using my phone for the next couple days and report anything unusual if any.

ananjaser1211 commented 1 year ago

@godzellax wow i am equally surprised, here is the problem, very long time ago in 2019 i changed the WiFi driver in the kernel from BCM4358 DHD 1.47.42(Stock) to BCM4358a3 DHD 1.47.61 (The newer driver from the galaxy tab S2 with the same wifi chip as us but a newer version, and with android 7 support) , it has new internal features etc,

commit that broke the wifi : https://github.com/universal5433/android_kernel_samsung_universal5433/commit/9651661395db918aa31022912174f23815d2b20d

commit that fixed wifi : https://github.com/universal5433/android_kernel_samsung_universal5433/commit/560373cb6b5e4a8d4ccfe0982fdf685a08cdd47d

Basically thinking newer = better, and for the most part that is true except this new driver also has a function called "DHD_SET_COUNTRY_SUPPORT" which setting your device to a region that was not actually supported in the code, and then basically would disable network bands (so like 2.4ghz/5ghz was no longer existing) and then when the rom tried to do scan it said wait ? i dont see any radios available

i have no idea how not many people have this problem but there are few people who im sure will be happy now that it is fixed.

I dont see why this can't be a permeant solution, we go back to the hopefully more stable wifi driver and call it a day, and yes i see no problem in including this fix in all the future builds, i will also compile Helios kernel with the fix aswell (the kernel used on my touchwiz ROM) because another person has the problem there too.

if we found any issues, then we can enable the new driver again, and try to disable the DHD_SET_COUNTRY_SUPPORT code that broke everything, once i get some time i might send you a kernel to try later.

Thanks again for testing!

godzellax commented 1 year ago

OK, I'm glad to help and will check your post from time to time. I'm so happy that I revived my old poor phone from death by flashing your custom rom and almost all issues fixed.

In regards to the kernel, I'd like to suggest if you don't mind a very useful and stable custom kernel I used for years without a single issue and fully customized to support almost everything we imagine to have. Would you please check it and tell me your opinion about it:

https://forum.xda-developers.com/t/spacelemon-kernel-6-0-1-extended-battery-n910-c-h-u-n910-n915-n916-s-k-l.3506956/

Actually I was using the following version with the latest official XSG rom : N910C-H-SpaceLemon-v2.91.45-zerolemon-no-root

Any chance that it may work out of the box with your custom rom or it need an optimization for compatibility reason?

Will it hurt if I flash it and check after backup my current kernel? Any risk?