From f8d19823ea9be0c8700a69a215fac7d3af4d6d87 Mon Sep 17 00:00:00 2001 From: Guillaume Jacquart Date: Tue, 4 Oct 2022 08:34:34 +0200 Subject: 5561: display name of other VPNrunning always on. --- .../permissions/PermissionsPrivacyModule.kt | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'permissionse/src/main/java/foundation/e/privacymodules') 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 + } + } } -- cgit v1.2.1