Apps is waiting for un-metered network on wifi

Hello, there seems to be some bug in Apps. It shows there is an update for some apps, but I have to manually tap Update all otherwise it doesn’t happen. I am on wifi and check checkbox “Only on un-metered networks” is checked.


I am on /e/ 0.23 on Samsung Galaxy S8

ah! I see this too but didn’t care yet… I can’t see a gitlab issue for this yet, so let’s delve into it at app/src/main/java/foundation/e/apps/updates/UpdatesNotifier.kt · 9adf00b5 · e / os / App Lounge · GitLab

if (unmeteredNetworkOnly && !isConnectedToUnmeteredNetwork) {
  notificationBuilder.setSubText(
    context.getString(R.string.updates_notification_unmetered_network_warning)
  )
}

so isConnectedToUnmeteredNetwork() at app/src/main/java/foundation/e/apps/updates/manager/UpdatesWorker.kt · 9adf00b5 · e / os / App Lounge · GitLab comes back false

it gets the capabilities by handing the active network to getNetworkCapabilities()
then filtering on

if (capabilities.hasCapability(NetworkCapabilities.NET_CAPABILITY_NOT_METERED)

if I check the currently connected wifi it says NOT_METERED … but maybe it failed a few lines prior to determine the active network?

adb shell dumpsys connectivity | grep -i metered
...
NetworkAgentInfo{ ..  nc{[ Transports: WIFI Capabilities: NOT_METERED&INTERNET&NOT_RESTRICTED&TRUSTED&NOT_VPN&VALIDATED&NOT_ROAMING&FOREGROUND&NOT_CONGESTED&NOT_SUSPENDED ..

AndroidManifest.xml has the permission to query the state, see docs at 네트워크 상태 읽기  |  Android 개발자  |  Android Developers )

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

I guess it can fail here, when the unmetered wifi is not the activeNetwork

connectivityManager.getNetworkCapabilities(connectivityManager.activeNetwork)

with capabilities then being null … never interactively debugged an android java app, I should give this a go… but system apps are a bit harder to push / replace on-device?

1 Like

thank you for a great demo about software debugging! So now, will some /e/ developer actually look at it? :wink:

I skimmed the docs some more and think the bug + correction in-place is…

- connectivityManager.getNetworkCapabilities(connectivityManager.activeNetwork)
+ connectivityManager.getNetworkCapabilities(connectivityManager.getActiveNetwork())

there’s also a more straightforward method to just use

connectivityManager.isActiveNetworkMetered();

will make that merge request…

Edit: uh, it’s Kotlin code and Kotlin has getters/setters out of the box, so it should work? … but isActiveNetworkMetered() suggestion is still valid, it checks for the capabilities != null case too

on the same Wifi Applounge (v1.3 / 2.3.4) didn’t show a notification that it thinks it’s a metered connection and went through with updates. The code at getNetworkCapabilities didn’t change since v1.2 - :person_shrugging: a dumpsys for the current NetworkAgentInfo (capabilities etc) came back identically minus the ip address … what could it be!?