diff options
Diffstat (limited to 'permissionse/src/main')
-rw-r--r-- | permissionse/src/main/AndroidManifest.xml | 2 | ||||
-rw-r--r-- | permissionse/src/main/java/foundation/e/privacymodules/permissions/PermissionsPrivacyModule.kt | 35 |
2 files changed, 37 insertions, 0 deletions
diff --git a/permissionse/src/main/AndroidManifest.xml b/permissionse/src/main/AndroidManifest.xml index 6a7e416..428a612 100644 --- a/permissionse/src/main/AndroidManifest.xml +++ b/permissionse/src/main/AndroidManifest.xml @@ -33,4 +33,6 @@ /> <uses-permission android:name="android.permission.CONTROL_VPN" tools:ignore="ProtectedPermissions" /> + <uses-permission android:name="android.permission.CONTROL_ALWAYS_ON_VPN" + tools:ignore="ProtectedPermissions" /> </manifest> 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 + } + } } |