summaryrefslogtreecommitdiff
path: root/permissionse/src/main/java/foundation/e/privacymodules
diff options
context:
space:
mode:
authorGuillaume Jacquart <guillaume.jacquart-ext@mousquetaires.com>2022-10-04 08:34:34 +0200
committerGuillaume Jacquart <guillaume.jacquart-ext@mousquetaires.com>2022-10-26 14:01:43 +0200
commitf8d19823ea9be0c8700a69a215fac7d3af4d6d87 (patch)
tree1a6cf3ef0903dfd52bd40db55cebfa19e046fbd9 /permissionse/src/main/java/foundation/e/privacymodules
parent7c41d557a3523abc202b0d0a09835f79a85c1947 (diff)
5561: display name of other VPNrunning always on.
Diffstat (limited to 'permissionse/src/main/java/foundation/e/privacymodules')
-rw-r--r--permissionse/src/main/java/foundation/e/privacymodules/permissions/PermissionsPrivacyModule.kt35
1 files changed, 35 insertions, 0 deletions
diff --git a/permissionse/src/main/java/foundation/e/privacymodules/permissions/PermissionsPrivacyModule.kt b/permissionse/src/main/java/foundation/e/privacymodules/permissions/PermissionsPrivacyModule.kt
index fe5b7ac..22be90d 100644
--- a/permissionse/src/main/java/foundation/e/privacymodules/permissions/PermissionsPrivacyModule.kt
+++ b/permissionse/src/main/java/foundation/e/privacymodules/permissions/PermissionsPrivacyModule.kt
@@ -136,4 +136,39 @@ class PermissionsPrivacyModule(context: Context): APermissionsPrivacyModule(cont
}
return false
}
+
+ override fun getAlwaysOnVpnPackage(): String? {
+ return when(Build.VERSION.SDK_INT) {
+ 29, 30 -> getAlwaysOnVpnPackageSDK29()
+ 31, 32 -> getAlwaysOnVpnPackageSDK32()
+ else -> {
+ Log.e("Permissions-e", "Bad android sdk version")
+ null
+ }
+ }
+ }
+
+ @TargetApi(29)
+ private fun getAlwaysOnVpnPackageSDK29(): String? {
+ val service: IConnectivityManager = IConnectivityManager.Stub.asInterface(
+ ServiceManager.getService(Context.CONNECTIVITY_SERVICE))
+
+ return try {
+ service.getAlwaysOnVpnPackage(UserHandle.myUserId())
+ } catch(e: java.lang.Exception) {
+ Log.e("Permissions-e", "Bad android sdk version ", e)
+ return null
+ }
+ }
+
+ @TargetApi(31)
+ private fun getAlwaysOnVpnPackageSDK32(): String? {
+ val vpnManager = context.getSystemService(Context.VPN_MANAGEMENT_SERVICE) as VpnManager
+ return try {
+ vpnManager.getAlwaysOnVpnPackageForUser(UserHandle.myUserId())
+ } catch(e: java.lang.Exception) {
+ Log.e("Permissions-e", "Bad android sdk version ", e)
+ return null
+ }
+ }
}