Loading .github/workflows/test-dev.yml +1 −1 Original line number Diff line number Diff line name: Development tests on: [push, pull_request] on: push concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true Loading app/build.gradle +5 −5 Original line number Diff line number Diff line Loading @@ -18,8 +18,8 @@ android { defaultConfig { applicationId "foundation.e.accountmanager" versionCode 403060100 versionName '4.3.6.1' versionCode 403070001 versionName '4.3.7' buildConfigField "long", "buildTime", System.currentTimeMillis() + "L" Loading Loading @@ -157,13 +157,13 @@ dependencies { implementation 'androidx.cardview:cardview:1.0.0' implementation 'androidx.concurrent:concurrent-futures-ktx:1.1.0' implementation 'androidx.constraintlayout:constraintlayout:2.1.4' implementation 'androidx.core:core-ktx:1.10.1' implementation 'androidx.core:core-ktx:1.12.0' implementation 'androidx.fragment:fragment-ktx:1.6.1' implementation 'androidx.hilt:hilt-work:1.0.0' kapt 'androidx.hilt:hilt-compiler:1.0.0' implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.1' implementation 'androidx.paging:paging-runtime-ktx:3.2.0' implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2' implementation 'androidx.paging:paging-runtime-ktx:3.2.1' implementation 'androidx.preference:preference-ktx:1.2.1' implementation 'androidx.security:security-crypto:1.1.0-alpha06' implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0' Loading app/proguard-rules-release.pro +2 −2 Original line number Diff line number Diff line # R8 usage for DAVx⁵: # R8 usage for Account Manager: # shrinking yes (only in release builds) # optimization yes (on by R8 defaults) # obfuscation no (open-source) Loading @@ -18,7 +18,7 @@ # XmlPullParser -keep class org.xmlpull.** { *; } # DAVx⁵ + libs # Account Manager + libs -keep class at.bitfire.** { *; } # all DAVx⁵ code is required # we use enum classes (https://www.guardsquare.com/en/products/proguard/manual/examples#enumerations) Loading app/src/androidTest/java/at/bitfire/davdroid/network/ConnectionUtilsTest.kt 0 → 100644 +149 −0 Original line number Diff line number Diff line /* * Copyright © All Contributors. See LICENSE and AUTHORS in the root directory for details. */ package at.bitfire.davdroid.network import android.net.ConnectivityManager import android.net.Network import android.net.NetworkCapabilities import android.net.NetworkCapabilities.NET_CAPABILITY_INTERNET import android.net.NetworkCapabilities.NET_CAPABILITY_NOT_VPN import android.net.NetworkCapabilities.NET_CAPABILITY_VALIDATED import android.net.NetworkCapabilities.TRANSPORT_WIFI import dagger.hilt.android.testing.HiltAndroidTest import io.mockk.every import io.mockk.mockk import junit.framework.TestCase.assertFalse import junit.framework.TestCase.assertTrue import org.junit.Before import org.junit.Test @HiltAndroidTest class ConnectionUtilsTest { private val connectivityManager = mockk<ConnectivityManager>() private val network1 = mockk<Network>() private val network2 = mockk<Network>() private val capabilities = mockk<NetworkCapabilities>() @Before fun setUp() { every { connectivityManager.allNetworks } returns arrayOf(network1, network2) every { connectivityManager.getNetworkInfo(network1) } returns mockk() every { connectivityManager.getNetworkInfo(network2) } returns mockk() every { connectivityManager.getNetworkCapabilities(network1) } returns capabilities every { connectivityManager.getNetworkCapabilities(network2) } returns capabilities } @Test fun testWifiAvailable_capabilitiesNull() { every { connectivityManager.getNetworkCapabilities(network1) } returns null every { connectivityManager.getNetworkCapabilities(network2) } returns null assertFalse(ConnectionUtils.wifiAvailable(connectivityManager)) } @Test fun testWifiAvailable() { every { capabilities.hasTransport(TRANSPORT_WIFI) } returns false every { capabilities.hasCapability(NET_CAPABILITY_VALIDATED) } returns false assertFalse(ConnectionUtils.wifiAvailable(connectivityManager)) } @Test fun testWifiAvailable_wifi() { every { capabilities.hasTransport(TRANSPORT_WIFI) } returns true every { capabilities.hasCapability(NET_CAPABILITY_VALIDATED) } returns false assertFalse(ConnectionUtils.wifiAvailable(connectivityManager)) } @Test fun testWifiAvailable_validated() { every { capabilities.hasTransport(TRANSPORT_WIFI) } returns false every { capabilities.hasCapability(NET_CAPABILITY_VALIDATED) } returns true assertFalse(ConnectionUtils.wifiAvailable(connectivityManager)) } @Test fun testWifiAvailable_wifiValidated() { every { capabilities.hasTransport(TRANSPORT_WIFI) } returns true every { capabilities.hasCapability(NET_CAPABILITY_VALIDATED) } returns true assertTrue(ConnectionUtils.wifiAvailable(connectivityManager)) } @Test fun testInternetAvailable_capabilitiesNull() { every { connectivityManager.getNetworkCapabilities(network1) } returns null every { connectivityManager.getNetworkCapabilities(network2) } returns null assertFalse(ConnectionUtils.internetAvailable(connectivityManager, false)) } @Test fun testInternetAvailable_Internet() { every { capabilities.hasCapability(NET_CAPABILITY_INTERNET) } returns true every { capabilities.hasCapability(NET_CAPABILITY_VALIDATED) } returns false assertFalse(ConnectionUtils.internetAvailable(connectivityManager, false)) } @Test fun testInternetAvailable_Validated() { every { capabilities.hasCapability(NET_CAPABILITY_INTERNET) } returns false every { capabilities.hasCapability(NET_CAPABILITY_VALIDATED) } returns true assertFalse(ConnectionUtils.internetAvailable(connectivityManager, false)) } @Test fun testInternetAvailable_InternetValidated() { every { capabilities.hasCapability(NET_CAPABILITY_INTERNET) } returns true every { capabilities.hasCapability(NET_CAPABILITY_VALIDATED) } returns true assertTrue(ConnectionUtils.internetAvailable(connectivityManager, false)) } @Test fun testInternetAvailable_ignoreVpns() { every { capabilities.hasCapability(NET_CAPABILITY_INTERNET) } returns true every { capabilities.hasCapability(NET_CAPABILITY_VALIDATED) } returns true every { capabilities.hasCapability(NET_CAPABILITY_NOT_VPN) } returns false assertFalse(ConnectionUtils.internetAvailable(connectivityManager, true)) } @Test fun testInternetAvailable_ignoreVpns_Notvpn() { every { capabilities.hasCapability(NET_CAPABILITY_INTERNET) } returns true every { capabilities.hasCapability(NET_CAPABILITY_VALIDATED) } returns true every { capabilities.hasCapability(NET_CAPABILITY_NOT_VPN) } returns true assertTrue(ConnectionUtils.internetAvailable(connectivityManager, true)) } @Test fun testInternetAvailable_twoConnectionsFirstOneWithoutInternet() { // The real case that failed in davx5-ose#395 is that the connection list contains (in this order) // 1. a mobile network without INTERNET, but with VALIDATED // 2. a WiFi network with INTERNET and VALIDATED // The "return false" of hasINTERNET will trigger at the first connection, the // "andThen true" will trigger for the second connection every { capabilities.hasCapability(NET_CAPABILITY_INTERNET) } returns false andThen true every { capabilities.hasCapability(NET_CAPABILITY_VALIDATED) } returns true // There is an internet connection if any(!) connection has both INTERNET and VALIDATED. assertTrue(ConnectionUtils.internetAvailable(connectivityManager, false)) } @Test fun testInternetAvailable_twoConnectionsFirstOneWithoutValidated() { every { capabilities.hasCapability(NET_CAPABILITY_INTERNET) } returns true every { capabilities.hasCapability(NET_CAPABILITY_VALIDATED) } returns false andThen true assertTrue(ConnectionUtils.internetAvailable(connectivityManager, false)) } @Test fun testInternetAvailable_twoConnectionsFirstOneWithoutNotvpn() { every { capabilities.hasCapability(NET_CAPABILITY_INTERNET) } returns true every { capabilities.hasCapability(NET_CAPABILITY_VALIDATED) } returns true every { capabilities.hasCapability(NET_CAPABILITY_NOT_VPN) } returns false andThen true assertTrue(ConnectionUtils.internetAvailable(connectivityManager, true)) } } No newline at end of file app/src/main/assets/translators.json +1 −0 Original line number Diff line number Diff line {"ar_SA":["abdunnasir"],"bg":["dpa_transifex"],"ca":["Kintu","jordibrus","zagur"],"cs":["pavelb","tomas.odehnal"],"da":["Tntdruid_","knutztar","mjjzf","twikedk"],"de":["Atalanttore","TheName","Wyrrrd","YvanM","amandablue","anestiskaci","corppneq","crit12","hammaschlach","maxkl","nicolas_git","owncube"],"el":["KristinaQejvanaj","anestiskaci","diamond_gr"],"es":["Ark74","Elhea","GranPC","aluaces","jcvielma","plaguna","polkhas","xphnx"],"eu":["Osoitz","Thadah","cockeredradiation"],"fa":["Numb","ahangarha","amiraliakbari","joojoojoo","maryambehzi","mtashackori","taranehsaei"],"fr":["AlainR","Amadeen","Floflr","Llorc","LoiX07","Novick","Poussinou","Thecross","YvanM","alkino2","boutil","callmemagnus","chfo","chrcha","grenatrad","jokx","mathieugfortin","paullbn","vincen","ÉricB."],"fr_FR":["Llorc","Poussinou","chrcha"],"gl":["aluaces","pikamoku"],"hu":["Roshek","jtg"],"it":["Damtux","FranzMari","ed0","malaerba","noccio","nwandy","rickyroo","technezio"],"it_IT":["malaerba"],"ja":["Naofumi","yanorei32"],"nb_NO":["elonus"],"nl":["XtremeNova","davtemp","dehart","erikhubers","frankyboy1963","toonvangerwen"],"pl":["TORminator","TheName","Valdnet","gsz","mg6","oskarjakiela"],"pt":["amalvarenga","wanderlei.huttel"],"pt_BR":["wanderlei.huttel"],"ru":["aigoshin","anm","astalavister","nick.savin","vaddd"],"sk_SK":["brango67","tiborepcek"],"sl_SI":["MrLaaky","uroszor"],"sr":["daimonion"],"sv":["Mikaelb","campbelldavid"],"szl":["chlodny"],"tr_TR":["ooguz","pultars"],"uk":["androsua","olexn","twixi007"],"uk_UA":["astalavister"],"zh_CN":["anolir","jxj2zzz79pfp9bpo","linuxbckp","mofitt2016","oksjd","phy","spice2wolf"],"zh_TW":["linuxbckp","mofitt2016","phy","waiabsfabuloushk"]} Loading
.github/workflows/test-dev.yml +1 −1 Original line number Diff line number Diff line name: Development tests on: [push, pull_request] on: push concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true Loading
app/build.gradle +5 −5 Original line number Diff line number Diff line Loading @@ -18,8 +18,8 @@ android { defaultConfig { applicationId "foundation.e.accountmanager" versionCode 403060100 versionName '4.3.6.1' versionCode 403070001 versionName '4.3.7' buildConfigField "long", "buildTime", System.currentTimeMillis() + "L" Loading Loading @@ -157,13 +157,13 @@ dependencies { implementation 'androidx.cardview:cardview:1.0.0' implementation 'androidx.concurrent:concurrent-futures-ktx:1.1.0' implementation 'androidx.constraintlayout:constraintlayout:2.1.4' implementation 'androidx.core:core-ktx:1.10.1' implementation 'androidx.core:core-ktx:1.12.0' implementation 'androidx.fragment:fragment-ktx:1.6.1' implementation 'androidx.hilt:hilt-work:1.0.0' kapt 'androidx.hilt:hilt-compiler:1.0.0' implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.1' implementation 'androidx.paging:paging-runtime-ktx:3.2.0' implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2' implementation 'androidx.paging:paging-runtime-ktx:3.2.1' implementation 'androidx.preference:preference-ktx:1.2.1' implementation 'androidx.security:security-crypto:1.1.0-alpha06' implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0' Loading
app/proguard-rules-release.pro +2 −2 Original line number Diff line number Diff line # R8 usage for DAVx⁵: # R8 usage for Account Manager: # shrinking yes (only in release builds) # optimization yes (on by R8 defaults) # obfuscation no (open-source) Loading @@ -18,7 +18,7 @@ # XmlPullParser -keep class org.xmlpull.** { *; } # DAVx⁵ + libs # Account Manager + libs -keep class at.bitfire.** { *; } # all DAVx⁵ code is required # we use enum classes (https://www.guardsquare.com/en/products/proguard/manual/examples#enumerations) Loading
app/src/androidTest/java/at/bitfire/davdroid/network/ConnectionUtilsTest.kt 0 → 100644 +149 −0 Original line number Diff line number Diff line /* * Copyright © All Contributors. See LICENSE and AUTHORS in the root directory for details. */ package at.bitfire.davdroid.network import android.net.ConnectivityManager import android.net.Network import android.net.NetworkCapabilities import android.net.NetworkCapabilities.NET_CAPABILITY_INTERNET import android.net.NetworkCapabilities.NET_CAPABILITY_NOT_VPN import android.net.NetworkCapabilities.NET_CAPABILITY_VALIDATED import android.net.NetworkCapabilities.TRANSPORT_WIFI import dagger.hilt.android.testing.HiltAndroidTest import io.mockk.every import io.mockk.mockk import junit.framework.TestCase.assertFalse import junit.framework.TestCase.assertTrue import org.junit.Before import org.junit.Test @HiltAndroidTest class ConnectionUtilsTest { private val connectivityManager = mockk<ConnectivityManager>() private val network1 = mockk<Network>() private val network2 = mockk<Network>() private val capabilities = mockk<NetworkCapabilities>() @Before fun setUp() { every { connectivityManager.allNetworks } returns arrayOf(network1, network2) every { connectivityManager.getNetworkInfo(network1) } returns mockk() every { connectivityManager.getNetworkInfo(network2) } returns mockk() every { connectivityManager.getNetworkCapabilities(network1) } returns capabilities every { connectivityManager.getNetworkCapabilities(network2) } returns capabilities } @Test fun testWifiAvailable_capabilitiesNull() { every { connectivityManager.getNetworkCapabilities(network1) } returns null every { connectivityManager.getNetworkCapabilities(network2) } returns null assertFalse(ConnectionUtils.wifiAvailable(connectivityManager)) } @Test fun testWifiAvailable() { every { capabilities.hasTransport(TRANSPORT_WIFI) } returns false every { capabilities.hasCapability(NET_CAPABILITY_VALIDATED) } returns false assertFalse(ConnectionUtils.wifiAvailable(connectivityManager)) } @Test fun testWifiAvailable_wifi() { every { capabilities.hasTransport(TRANSPORT_WIFI) } returns true every { capabilities.hasCapability(NET_CAPABILITY_VALIDATED) } returns false assertFalse(ConnectionUtils.wifiAvailable(connectivityManager)) } @Test fun testWifiAvailable_validated() { every { capabilities.hasTransport(TRANSPORT_WIFI) } returns false every { capabilities.hasCapability(NET_CAPABILITY_VALIDATED) } returns true assertFalse(ConnectionUtils.wifiAvailable(connectivityManager)) } @Test fun testWifiAvailable_wifiValidated() { every { capabilities.hasTransport(TRANSPORT_WIFI) } returns true every { capabilities.hasCapability(NET_CAPABILITY_VALIDATED) } returns true assertTrue(ConnectionUtils.wifiAvailable(connectivityManager)) } @Test fun testInternetAvailable_capabilitiesNull() { every { connectivityManager.getNetworkCapabilities(network1) } returns null every { connectivityManager.getNetworkCapabilities(network2) } returns null assertFalse(ConnectionUtils.internetAvailable(connectivityManager, false)) } @Test fun testInternetAvailable_Internet() { every { capabilities.hasCapability(NET_CAPABILITY_INTERNET) } returns true every { capabilities.hasCapability(NET_CAPABILITY_VALIDATED) } returns false assertFalse(ConnectionUtils.internetAvailable(connectivityManager, false)) } @Test fun testInternetAvailable_Validated() { every { capabilities.hasCapability(NET_CAPABILITY_INTERNET) } returns false every { capabilities.hasCapability(NET_CAPABILITY_VALIDATED) } returns true assertFalse(ConnectionUtils.internetAvailable(connectivityManager, false)) } @Test fun testInternetAvailable_InternetValidated() { every { capabilities.hasCapability(NET_CAPABILITY_INTERNET) } returns true every { capabilities.hasCapability(NET_CAPABILITY_VALIDATED) } returns true assertTrue(ConnectionUtils.internetAvailable(connectivityManager, false)) } @Test fun testInternetAvailable_ignoreVpns() { every { capabilities.hasCapability(NET_CAPABILITY_INTERNET) } returns true every { capabilities.hasCapability(NET_CAPABILITY_VALIDATED) } returns true every { capabilities.hasCapability(NET_CAPABILITY_NOT_VPN) } returns false assertFalse(ConnectionUtils.internetAvailable(connectivityManager, true)) } @Test fun testInternetAvailable_ignoreVpns_Notvpn() { every { capabilities.hasCapability(NET_CAPABILITY_INTERNET) } returns true every { capabilities.hasCapability(NET_CAPABILITY_VALIDATED) } returns true every { capabilities.hasCapability(NET_CAPABILITY_NOT_VPN) } returns true assertTrue(ConnectionUtils.internetAvailable(connectivityManager, true)) } @Test fun testInternetAvailable_twoConnectionsFirstOneWithoutInternet() { // The real case that failed in davx5-ose#395 is that the connection list contains (in this order) // 1. a mobile network without INTERNET, but with VALIDATED // 2. a WiFi network with INTERNET and VALIDATED // The "return false" of hasINTERNET will trigger at the first connection, the // "andThen true" will trigger for the second connection every { capabilities.hasCapability(NET_CAPABILITY_INTERNET) } returns false andThen true every { capabilities.hasCapability(NET_CAPABILITY_VALIDATED) } returns true // There is an internet connection if any(!) connection has both INTERNET and VALIDATED. assertTrue(ConnectionUtils.internetAvailable(connectivityManager, false)) } @Test fun testInternetAvailable_twoConnectionsFirstOneWithoutValidated() { every { capabilities.hasCapability(NET_CAPABILITY_INTERNET) } returns true every { capabilities.hasCapability(NET_CAPABILITY_VALIDATED) } returns false andThen true assertTrue(ConnectionUtils.internetAvailable(connectivityManager, false)) } @Test fun testInternetAvailable_twoConnectionsFirstOneWithoutNotvpn() { every { capabilities.hasCapability(NET_CAPABILITY_INTERNET) } returns true every { capabilities.hasCapability(NET_CAPABILITY_VALIDATED) } returns true every { capabilities.hasCapability(NET_CAPABILITY_NOT_VPN) } returns false andThen true assertTrue(ConnectionUtils.internetAvailable(connectivityManager, true)) } } No newline at end of file
app/src/main/assets/translators.json +1 −0 Original line number Diff line number Diff line {"ar_SA":["abdunnasir"],"bg":["dpa_transifex"],"ca":["Kintu","jordibrus","zagur"],"cs":["pavelb","tomas.odehnal"],"da":["Tntdruid_","knutztar","mjjzf","twikedk"],"de":["Atalanttore","TheName","Wyrrrd","YvanM","amandablue","anestiskaci","corppneq","crit12","hammaschlach","maxkl","nicolas_git","owncube"],"el":["KristinaQejvanaj","anestiskaci","diamond_gr"],"es":["Ark74","Elhea","GranPC","aluaces","jcvielma","plaguna","polkhas","xphnx"],"eu":["Osoitz","Thadah","cockeredradiation"],"fa":["Numb","ahangarha","amiraliakbari","joojoojoo","maryambehzi","mtashackori","taranehsaei"],"fr":["AlainR","Amadeen","Floflr","Llorc","LoiX07","Novick","Poussinou","Thecross","YvanM","alkino2","boutil","callmemagnus","chfo","chrcha","grenatrad","jokx","mathieugfortin","paullbn","vincen","ÉricB."],"fr_FR":["Llorc","Poussinou","chrcha"],"gl":["aluaces","pikamoku"],"hu":["Roshek","jtg"],"it":["Damtux","FranzMari","ed0","malaerba","noccio","nwandy","rickyroo","technezio"],"it_IT":["malaerba"],"ja":["Naofumi","yanorei32"],"nb_NO":["elonus"],"nl":["XtremeNova","davtemp","dehart","erikhubers","frankyboy1963","toonvangerwen"],"pl":["TORminator","TheName","Valdnet","gsz","mg6","oskarjakiela"],"pt":["amalvarenga","wanderlei.huttel"],"pt_BR":["wanderlei.huttel"],"ru":["aigoshin","anm","astalavister","nick.savin","vaddd"],"sk_SK":["brango67","tiborepcek"],"sl_SI":["MrLaaky","uroszor"],"sr":["daimonion"],"sv":["Mikaelb","campbelldavid"],"szl":["chlodny"],"tr_TR":["ooguz","pultars"],"uk":["androsua","olexn","twixi007"],"uk_UA":["astalavister"],"zh_CN":["anolir","jxj2zzz79pfp9bpo","linuxbckp","mofitt2016","oksjd","phy","spice2wolf"],"zh_TW":["linuxbckp","mofitt2016","phy","waiabsfabuloushk"]}