kiwix-android
kiwix-android copied to clipboard
WIP: Wifi local hosting server not working (non-Hotspot mode)
Note: This might be related to or a consequence of https://github.com/kiwix/kiwix-android/issues/2071
Describe the bug, Steps to reproduce the behavior:, Screenshots
When I go to Menu/WiFi Hotspot I am presented with the available files I with to host. I select all of them (3 in my case) and click on "START SERVER". This pops up the following dialog:
Dialog informing about the hosting feature, mentioning 2 hosting options
Now the available options seem to be 2 distinct ones:
- either spawn the system hotspot ("your hotspot") or
- serve network-locally in the same (W)LAN (via already connected WiFi) ("...ensure that the host device and receiver device...")
Also two buttons are available.
Now, when I use "Go to Hotspot settings", I am transferred to the system hotspot menu and can enable it from there. When done, after coming back to Kiwix, the "START SERVER" button starts the the server without further ado, and this all works well. This seems to cover option 1) from the above list.
However, when I try to use option 2) with the lower button, this takes me to the systems WiFi settings. What am I supposed to do there? I am already connected. Returning back to Kiwix just again displays the same dialog after clicking "START SERVER", but nothing else happens.
Expected behavior Upon clicking "START SERVER", when already connected to a WiFi, the server should just start.
Environment
- Version of Kiwix Android : 3.4.4
- Device : Fairphone 3+
- OS version : 10
@suterma in above mention option 1 . if we connect to hotspot the app works perfectly but in option 2 doesn't works because I think the person who wants to share the server must use , hotspot to share the connection rather than wifi LAN connection
that's why the app doesn't works in option 2
I tried reproducing and its definitely does not detect wifi.
seems like the old way of checking if wifi is enabled or not is not working
possible error: getConnectionInfo()
was deprecated in Api level 31. WifiInfo
available in ConnectivityManager. more info
any thoughts on this? @kelson42 I will make PR soon :)
@suterma when wifi is detected it shows this dialog
I'm not sure about this issue. @kelson42 I'm letting you decide this issue :)
@cdhiraj40 The scenario 1) works right? So what does your PR fixes? And how? Might that be that your PR fixes a problem which is not describe here?
I have a few questions: when this regression has been introduced? which versions onf android are impacted? are we able to reproduce the buggy behaviour described in the bug report?
@kelson42 According to me, the answers are:
- If I'm not wrong it most probably has been there for a long time as the bug is for android 10,11 and this feature was implemented, I cant find the PR, soon will link it
- on the basis of my tests the bug is for android 10,11
- yes I am able to reproduce the issue
@cdhiraj40 The scenario 1) works right? So what does your PR fixes? And how? Might that be that your PR fixes a problem which is not describe here?
@kelson42 As of now, My PR doesn't fix anything now(there was confusion earlier ), I am working on a new implementation to find if the network connection is there or not in android OS>=10
how?
getConnectionInfo() was deprecated in Api level 31. WifiInfo available in ConnectivityManager. more info
If it will work then yes it will solve this issue of not detecting wifi and not showing the dialog
This feature has been introduced 3 years ago. Android 10,11 was not a topic at that time. To me it seems that the problem has been introduced with android 10. So it never has worked on android 10+.
.... but to me this has nothing to do with this bug reports which basically says 2) does not work and @cdhiraj40 tells: 1) does not work on android10+. This seems two different problems!
This feature has been introduce 3 years ago. Android 10,11 was not a topic at that time. To me it seems that the problem has been introduced with android 10. So it never has worked on android 10+.
.... but to me this has nothing to do with this bug reports which basically says 2) does not work and @cdhiraj40 tells: 1) does not work on android10+.
I think it is related to the bug report as the reason for the wifi dialog being not shown is the Android OS used by the user.
Environment OS version : 10
This seems two different problems!
But yes the issue will be updated according to the new changes
@cdhiraj40 Will make a dedicated test session tomorrow with my android10 and android11 devices. Does you PR secures it still works fine with android9-?
@kelson42 Yes I have tested for Android 9 (API 28)too and it does detect wifi and network connection with the older approach, so the problem indeed seems to be just for android 10 and 11.
@cdhiraj40 Will make a dedicated test session tomorrow with my android10 and android11 devices. Does you PR secures it still works fine with android9-?
@kelson42 Thank you! After confirming we should update the ticket and PR as well. I'm sorry I don't have two physical devices otherwise I tested that.
@gouri-panda @kelson42 I researched about the issue and why the older approach was not working. I got to know that in Android Q+ we can not get this true
wifiManager.connectionInfo.networkId != -1
in simpler words, we cannot check(in the older approach) the state of wifi connection if wifi has an active connection or not without location permission and location mode turned on. more info here Once I turned on the location it works and detects so now we have 2 solutions:
- add a dialog to turn on location when clicked on
start server
but according to me, we shouldn't do this as there are other ways too, to start the server so if we show dialog we are kinda forcing the user to turn on via wifi only. - changing the implementation to check wifi connection which doesn't need any location permission. we can use
Network Capabilities
to check if wifi has an active connection or not.
This issue has been automatically marked as stale because it has not had recent activity. It will be now be reviewed manually. Thank you for your contributions.
hi @gouri-panda ,
we can use SupplicantState of WifiManager.getConnectionInfo
. this will return SupplicantState.COMPLETED
if our wifi is connected (which means All authentication completed and our wifi in active state). i have tried this and this is working in android 11
as well as in android 12
.
@MohitMaliFtechiz Can you reproduce this now? I can't at the moment. If you produce the issue then go ahead :)
@MohitMaliFtechiz Can you reproduce this now? I can't at the moment. If you produce the issue then go ahead :)
hi @gouri-panda , yes i'm able to reproduce this. i have placed a fix for it in existing PR https://github.com/kiwix/kiwix-android/pull/2769.