Closed latin-panda closed 3 years ago
@latin-panda & @newtewt - I'm stuck as the APK @latin-panda built and published doesn't work.
In the meanwhile, I have my CHT instance up and running, exposed externally (thanks DIY SSH tunnels!) and have the stock version of Medic Gateway installed (v1.7.4) so I can see how things should be setup. I'll run through testing stuff this way and wait for a new APK.
NB - I'm testing on a Pixel 1 running Android 10, but @latin-panda said:
To AT: My test device at the moment is Android 9. Can you please test this in older Android version? Thanks!
I did just confirm my sim works in Android 5.x/Moto X (but oddly NOT my Android 7.x/Samsung SIII w/ Lineage?)
Update 1 : Oh - maybe the APK was built for older android API versions?! :facepalm: I'll check that now. But then again...This is specifically to test the "newer" android feature of "clever" wifi?
Update 2 : the APK doesn't work on android 5.x too, confirmed.
@latin-panda - no luck I don't think? I paired with @newtewt and we never saw WiFi fully turn off when the "Automatically enable Wi-Fi" checkbox was checked OR unchecked.
Maybe I need more explicit test steps though? I got a little confused with screenshots and doc you wrote. Here's the steps I took:
after step 5, nothing worked. The phone remained in "WiFi broken" state and no messages were sent. While there were notices in debug log about being turned on or of, WiFi was not actually turned on or off (or if it was, mobile data was never used). I left it this way for 60+ minutes :( You can see below SMS could be sent and received over mobile data connection when WiFi was in broken state.
It took a LONG time (15+ minutes?) for the phone to notice the WiFi was gone. The "WiFi all good" symbol was in the status bar for this time:
Before step 5, I confirmed SMS sent to the gateway showed up in the CHT as expected.
Here's screenshots of the queue:
Here's screenshots of the Event log after step 5. Note that WiFi icon finally denotes phone is offline:
The last thing I did was turn off WiFi and zooooom all the queued messages went through.
I think we are not going to be able to get this to work. As of Android 10 the method we call(setWifiEnabled) to disable wifi is deprecated and always returns false. This is for apps targeting 10 or greater. We are targeting 11.
This method was deprecated in API level 29. Starting with Build.VERSION_CODES#Q, applications are not allowed to enable/disable Wi-Fi. Compatibility Note: For applications targeting Build.VERSION_CODES.Q or above, this API will always fail and return false. If apps are targeting an older SDK (Build.VERSION_CODES.P or below), they can continue to use this API.
https://developer.android.com/reference/android/net/wifi/WifiManager#setWifiEnabled(boolean)
I can see our WifiConnectionManager class is using this inside, so newer wont work.
Closing PR because it's not compatible with Android 10+. We'll remove the WiFi logic in another PR.
Description
This PR will:
This PR is dependant of this one: https://github.com/medic/medic-gateway/pull/166
To AT: My test device at the moment is Android 9. Can you please test this in older Android version? Thanks!
https://github.com/medic/medic-gateway/issues/135
Code review items
License
The software is provided under AGPL-3.0. Contributions to this project are accepted under the same license.