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

Wi-Fi filter not present in Android 10 #3387

Closed
gaul opened this issue Sep 5, 2019 · 17 comments · Fixed by #3968
Closed

Wi-Fi filter not present in Android 10 #3387

gaul opened this issue Sep 5, 2019 · 17 comments · Fixed by #3968

Comments

@gaul
Copy link
Contributor

gaul commented Sep 5, 2019

After upgrading to Android 10, Settings shows the "Enable Wi-Fi filter" toggle but not any of the wifi networks:

Screenshot_20190904-175931

@orionlee
Copy link
Contributor

orionlee commented Sep 5, 2019

I can reproduce it on Android 10 emulator.

The issue is a bit complicated. It seems that the way to get a list of configured (i.e., saved) wifi networks are deprecated - the use of WifiManager.getConfiguredNetworks() in

List<WifiConfiguration> networks = wifiservice.getConfiguredNetworks();

According to documentation, it should still work as AntennaPod is targeted to Android 9 (targetSdkVersion is 28). But based on @gaul 's report and my trial on Android 10 emulator, it seems that Android 10 instead gives empty result, as if AntennaPod is targeted to Android 10.

The problem was asked on statckoverflow, with no answer so far:
https://stackoverflow.com/questions/57410542/list-wifi-networks-on-android-q-api-29

I don't know if there is a user workaround (tweaking some new Android 10 settings on the device so that AntennaPod can get the list of SSIDs). If not, there will need to have some code / UI change, as the list is not available on Android 10.

@orionlee
Copy link
Contributor

orionlee commented Sep 9, 2019

Poking around google bug tracker, it seems that to WifiManager.getConfiguredNetworks(), the app needs location permission on Android 10.

Testing on emulator, I found adding ACCESS_COARSE_LOCATION to AntennaPod is sufficient (though its doc seems to imply ACCESS_FINE_LOCATION is needed).

A issue is filed to Google: https://issuetracker.google.com/issues/140696830

@ByteHamster
Copy link
Member

ByteHamster commented Sep 9, 2019

That's bad. I guess there are a lot of users who would not like us to add location permissions to the app...

If we add the permission, we should add it using this manifest tag: https://developer.android.com/guide/topics/manifest/uses-permission-sdk-23-element. That way, it bothers less users if we do not request the permission at runtime. I suggest to create a new preferences fragment for the wifi selection and request the runtime permission there (and show a dialog explaining why we need that permission).

@orionlee
Copy link
Contributor

orionlee commented Sep 9, 2019

@gaul it'd be great if you could help to test to see if the fix (of adding ACCESS_COARSE_LOCATION) works. https://drive.google.com/file/d/14ngurNeWvO0wMLoMouBUFZt5OgfRBN9q/view?usp=sharing

It is a debug version of the app that can be installed alongside with your existing one.

Once you install it, you also need to manually grant location permission in the app's permission screen:

image

@orionlee
Copy link
Contributor

orionlee commented Sep 9, 2019

@ByteHamster Regarding an actual fix, I'd suggest one of the following:

  1. Add the location permission. In UI, in automatic download screen, if Wi-Fi filter is enabled and the device is on Android 10, prompt the user to grant location permission. (Similar to what @ByteHamster suggests, except not creating a new fragment for Wi-Fi filter)
  2. Re-implement Wi-Fi filter so that it does not make use of saved networks, instead it lets user to add the currently connected wifi to the filter (or supply SSID text directly. See [*] for a rough UI

Something alone the line of (2) is needed eventually (when AntennaPod targets Android 10), and there will be various complication, e.g., at presentAntennaPod stores network id for Wi-Fi filter internally. But for something like (2) to work, we would need to store and use SSID text instead.

Given that, if we start with (1) as a short-term fix, I'd suggest we don't change the UI too much, as it is likely to be changed again when a long-term fix comes in.


[*] UI for Wi-Fi filter that does not use saved networks
image

@ByteHamster
Copy link
Member

In my opinion, 1 is the better option and also a long-term fix. Users don't want to type the name of wifi networks manually. If the prompt is only displayed if the filter is enabled and we show an explanation, that should hopefully not bother users.

@keunes
Copy link
Member

keunes commented Sep 9, 2019

Users don't want to type the name of wifi networks manually.

I personally agree with this; I'd rather accept location (esp. for an open-source app) than having to figure out/remember SSID's.

@gaul
Copy link
Contributor Author

gaul commented Sep 10, 2019

@gaul it'd be great if you could help to test to see if the fix (of adding ACCESS_COARSE_LOCATION) works. https://drive.google.com/file/d/14ngurNeWvO0wMLoMouBUFZt5OgfRBN9q/view?usp=sharing

It is a debug version of the app that can be installed alongside with your existing one.

Once you install it, you also need to manually grant location permission in the app's permission screen:

This worked, although I had to force quit the app after setting the permission for the toggle to display the wifi networks.

@orionlee
Copy link
Contributor

@ByteHamster @keunes Let me clarify why I said option 1 (granting location permission) cannot be a long-term solution.

By long-term I mean when AntennaPod finally targets Android 10+ (currently it's targeting Android 9), getConfiguredNetworks(), used to build Preference UI, will always return empty - location permission doesn't matter.

In non-technical terms, with getConfiguredNetworks(), the UI builds the list based on the device's saved network in system settings. See [*] for a screenshot.

Therefore, when AntennaPod targets Android 10+, it loses the ability to get the saved network list. Some replacement is needed.

In option 2, the UI will let users easily check the current WiFi to add it to the filter (which we can still get via other API calls).

The Manual typing portion is not strictly needed. But without it, users cannot enter only add a network to the filter one at a time (when the device is connected to the network).

Option 2 is a straw man proposal, better ideas are welcome.


[*] Sample screenshot of saved networks in system settings
image

@gaul
Copy link
Contributor Author

gaul commented Sep 12, 2019

Broadening the discussion, I use the wifi filter is to prevent downloading over dodgy and metered links. Several years ago I ran into problems with corrupt downloads, I suspect due to AntennaPod hitting a hotel wifi authentication page and misinterpreting it as data, which may be fixed or has a better non-filter solution. If I could prevent automatic downloads while tethering, perhaps by checking ConnectivityManager.isActiveNetworkMetered(), this would likely obviate my need for the filter.

@orionlee
Copy link
Contributor

, I suspect due to AntennaPod hitting a hotel wifi authentication page and misinterpreting it as data, which may be fixed or has a better non-filter solution.

@gual How AntennaPod should handle wifi requiring authentication is a valid use case. Please file it as a separate issue though.

This worked, although I had to force quit the app after setting the permission for the toggle to display the wifi networks.

@gaul thanks for testing it. On emulator, I did not have to force quit the app. On AntennaPod, I did have to click back to leave Automatic Download Preference screen and reenter for the new settings to show.

orionlee added a commit to orionlee/AntennaPod that referenced this issue Sep 12, 2019
orionlee added a commit to orionlee/AntennaPod that referenced this issue Sep 13, 2019
orionlee added a commit to orionlee/AntennaPod that referenced this issue Sep 14, 2019
orionlee added a commit to orionlee/AntennaPod that referenced this issue Sep 14, 2019
orionlee added a commit to orionlee/AntennaPod that referenced this issue Sep 14, 2019
orionlee added a commit to orionlee/AntennaPod that referenced this issue Sep 14, 2019
orionlee added a commit to orionlee/AntennaPod that referenced this issue Sep 14, 2019
orionlee added a commit to orionlee/AntennaPod that referenced this issue Sep 16, 2019
… 10+

(Requires user to grant location permission manually)
ByteHamster added a commit that referenced this issue Sep 16, 2019
…oid10_3387

#3387 short-term (v1.7.3) fix for Auto Downoad WiFi filter UI on Android 10+
orionlee added a commit to orionlee/AntennaPod that referenced this issue Sep 21, 2019
orionlee added a commit to orionlee/AntennaPod that referenced this issue Sep 21, 2019
orionlee added a commit to orionlee/AntennaPod that referenced this issue Sep 21, 2019
orionlee added a commit to orionlee/AntennaPod that referenced this issue Sep 21, 2019
@ByteHamster
Copy link
Member

We just got the first 1-star rating on Google Play because someone is not happy about the added location permission -.-

@orionlee
Copy link
Contributor

A long-term fix, needed when AntennaPod targets Android 10+ [*], probably will not need location permission anymore.

[*] Recall when AntennaPod targets Android 10+, getConfiguredNetworks(), aka, getting system's saved networks, will not work even with location permission.

orionlee added a commit to orionlee/AntennaPod that referenced this issue Sep 27, 2019
orionlee added a commit to orionlee/AntennaPod that referenced this issue Sep 27, 2019
orionlee added a commit to orionlee/AntennaPod that referenced this issue Sep 27, 2019
orionlee added a commit to orionlee/AntennaPod that referenced this issue Sep 27, 2019
@sbadux

This comment has been minimized.

@ByteHamster

This comment has been minimized.

@sbadux

This comment has been minimized.

@ByteHamster
Copy link
Member

@orionlee:
Regarding an actual fix, I'd suggest one of the following:
Re-implement Wi-Fi filter so that it does not make use of saved networks, instead it lets user to add the currently connected wifi to the filter (or supply SSID text directly. See [*] for a rough UI

I tried to do that in #3684. Actually, this is not possible. Starting with Android 8, the SSID of the currently connected network can only be obtained if the app has location permissions. We can obtain the ID of the network, though. When wanting to support Android 10, we now have a problem: We need to store the id of the networks in order to support Android 8 but we can not get a list of the ids on Android 10. Getting the SSID requires location permissions, so we can not use that either. I don't think we should keep using the location permission because we already got quite a few emails by users about that. Therefore, I would vote to remove the WiFi filter feature on Android 10.

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