Merge branch 'master' into code-style
This commit is contained in:
commit
b149195e7a
2 changed files with 6 additions and 3 deletions
|
@ -175,13 +175,14 @@ data class Storage(
|
||||||
* but it isn't available right now.
|
* but it isn't available right now.
|
||||||
*/
|
*/
|
||||||
fun isUnavailableNetwork(context: Context): Boolean {
|
fun isUnavailableNetwork(context: Context): Boolean {
|
||||||
return requiresNetwork && !hasInternet(context)
|
return requiresNetwork && !hasUnmeteredInternet(context)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun hasInternet(context: Context): Boolean {
|
private fun hasUnmeteredInternet(context: Context): Boolean {
|
||||||
val cm = context.getSystemService(ConnectivityManager::class.java)
|
val cm = context.getSystemService(ConnectivityManager::class.java)
|
||||||
|
val isMetered = cm.isActiveNetworkMetered()
|
||||||
val capabilities = cm.getNetworkCapabilities(cm.activeNetwork) ?: return false
|
val capabilities = cm.getNetworkCapabilities(cm.activeNetwork) ?: return false
|
||||||
return capabilities.hasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
|
return capabilities.hasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET) && !isMetered
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,11 +13,13 @@ android_app {
|
||||||
required: [
|
required: [
|
||||||
"default-permissions_org.calyxos.backup.contacts",
|
"default-permissions_org.calyxos.backup.contacts",
|
||||||
],
|
],
|
||||||
|
product_specific: true,
|
||||||
sdk_version: "current",
|
sdk_version: "current",
|
||||||
}
|
}
|
||||||
|
|
||||||
prebuilt_etc {
|
prebuilt_etc {
|
||||||
name: "default-permissions_org.calyxos.backup.contacts",
|
name: "default-permissions_org.calyxos.backup.contacts",
|
||||||
|
product_specific: true,
|
||||||
sub_dir: "default-permissions",
|
sub_dir: "default-permissions",
|
||||||
src: "default-permissions_org.calyxos.backup.contacts.xml",
|
src: "default-permissions_org.calyxos.backup.contacts.xml",
|
||||||
filename_from_src: true,
|
filename_from_src: true,
|
||||||
|
|
Loading…
Reference in a new issue