mirror of
https://github.com/outbackdingo/firezone.git
synced 2026-01-27 10:18:54 +00:00
refactor(android): Log allowed/disallowed applications (#4038)
Also DRY up the call a little bit.
This commit is contained in:
@@ -329,27 +329,8 @@ class TunnelService : VpnService() {
|
||||
Firebase.crashlytics.log("IPv6 Address: $tunnelIpv6Address")
|
||||
addAddress(tunnelIpv6Address!!, 128)
|
||||
|
||||
appRestrictions.getString("allowedApplications")?.let {
|
||||
if (it.isNotBlank()) {
|
||||
Firebase.crashlytics.log("Allowed applications: $it")
|
||||
it.split(",").forEach { p ->
|
||||
if (p.isNotBlank()) {
|
||||
addAllowedApplication(p.trim())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
appRestrictions.getString("disallowedApplications")?.let {
|
||||
if (it.isNotBlank()) {
|
||||
Firebase.crashlytics.log("Disallowed applications: $it")
|
||||
it.split(",").forEach { p ->
|
||||
if (p.isNotBlank()) {
|
||||
addDisallowedApplication(p.trim())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
updateAllowedDisallowedApplications("allowedApplications", ::addAllowedApplication)
|
||||
updateAllowedDisallowedApplications("disallowedApplications", ::addDisallowedApplication)
|
||||
|
||||
setSession(SESSION_NAME)
|
||||
setMtu(MTU)
|
||||
@@ -358,6 +339,24 @@ class TunnelService : VpnService() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateAllowedDisallowedApplications(
|
||||
key: String,
|
||||
allowOrDisallow: (String) -> Unit,
|
||||
) {
|
||||
val applications = appRestrictions.getString(key)
|
||||
Log.d(TAG, "$key: $applications")
|
||||
Firebase.crashlytics.log("$key: $applications")
|
||||
applications?.let {
|
||||
if (it.isNotBlank()) {
|
||||
it.split(",").forEach { p ->
|
||||
if (p.isNotBlank()) {
|
||||
allowOrDisallow(p.trim())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateStatusNotification(message: String?) {
|
||||
val manager = getSystemService(NOTIFICATION_SERVICE) as NotificationManager
|
||||
|
||||
|
||||
Reference in New Issue
Block a user