diff --git a/privacymodulese/build.gradle b/privacymodulese/build.gradle index f30b2ab271a5dbc5ce2ea8890327200b0b569ce3..5813979e940214138d70d3be173b9741abcd3f3a 100644 --- a/privacymodulese/build.gradle +++ b/privacymodulese/build.gradle @@ -4,11 +4,11 @@ apply plugin: 'maven-publish' android { - compileSdkVersion 30 + compileSdkVersion 32 defaultConfig { minSdkVersion 30 - targetSdkVersion 30 + targetSdkVersion 32 versionName advanced_privacy_version consumerProguardFiles "consumer-rules.pro" @@ -38,7 +38,7 @@ publishing { maven(MavenPublication) { groupId 'foundation.e' //You can either define these here or get them from project conf elsewhere - artifactId 'privacymodule-e-30' + artifactId 'privacymodule-e-32' version android.defaultConfig.versionName artifact "$buildDir/outputs/aar/privacymodulese-release.aar" //aar artifact you want to publish // artifact "$buildDir/outputs/aar/privacymodulese-debug.aar" //aar artifact you want to publish diff --git a/privacymodulese/src/main/java/foundation/e/privacymodules/permissions/PermissionsPrivacyModule.kt b/privacymodulese/src/main/java/foundation/e/privacymodules/permissions/PermissionsPrivacyModule.kt index 524400f23fb784290beca0b0553d1c156632e897..5adae8580574cda9da3d78ce84b05999c6e18830 100644 --- a/privacymodulese/src/main/java/foundation/e/privacymodules/permissions/PermissionsPrivacyModule.kt +++ b/privacymodulese/src/main/java/foundation/e/privacymodules/permissions/PermissionsPrivacyModule.kt @@ -4,9 +4,8 @@ import android.app.AppOpsManager import android.app.AppOpsManager.OP_NONE import android.app.AppOpsManager.strOpToOp import android.content.Context -import android.net.IConnectivityManager +import android.net.VpnManager import android.net.VpnManager.TYPE_VPN_SERVICE -import android.os.ServiceManager import android.os.UserHandle import android.util.Log import foundation.e.privacymodules.permissions.data.AppOpModes @@ -20,6 +19,9 @@ class PermissionsPrivacyModule(context: Context): APermissionsPrivacyModule(cont private val appOpsManager: AppOpsManager get() = context.getSystemService(Context.APP_OPS_SERVICE) as AppOpsManager + private val vpnManager: VpnManager get() + = context.getSystemService(Context.VPN_MANAGEMENT_SERVICE) as VpnManager + /** * @see IPermissionsPrivacyModule.toggleDangerousPermission * Always return true, permission is set using privileged capacities. @@ -53,25 +55,22 @@ class PermissionsPrivacyModule(context: Context): APermissionsPrivacyModule(cont override fun setAppOpMode( appDesc: ApplicationDescription, - permissionName: String, - mode: AppOpModes + appOpPermissionName: String, + status: AppOpModes ): Boolean { - val op = strOpToOp(permissionName) + val op = strOpToOp(appOpPermissionName) if (op != OP_NONE) { - appOpsManager.setMode(op, appDesc.uid, appDesc.packageName, mode.modeValue) + appOpsManager.setMode(op, appDesc.uid, appDesc.packageName, status.modeValue) } return true } override fun setVpnPackageAuthorization(packageName: String): Boolean { - val service: IConnectivityManager = IConnectivityManager.Stub.asInterface( - ServiceManager.getService(Context.CONNECTIVITY_SERVICE)) - try { - if (service.prepareVpn(null, packageName, UserHandle.myUserId())) { + if (vpnManager.prepareVpn(null, packageName, UserHandle.myUserId())) { // Authorize this app to initiate VPN connections in the future without user // intervention. - service.setVpnPackageAuthorization(packageName, UserHandle.myUserId(), TYPE_VPN_SERVICE) + vpnManager.setVpnPackageAuthorization(packageName, UserHandle.myUserId(), TYPE_VPN_SERVICE) return true } } catch (e: java.lang.Exception) {