diff options
author | Guillaume Jacquart <guillaume.jacquart-ext@mousquetaires.com> | 2022-10-07 08:45:15 +0200 |
---|---|---|
committer | Guillaume Jacquart <guillaume.jacquart-ext@mousquetaires.com> | 2022-10-26 14:01:43 +0200 |
commit | 5f02fd142ca438a48423340aeb9a36b017a6be83 (patch) | |
tree | 793326be63e878c880298f075f9c0de3413bb6e4 /permissionse | |
parent | f8d19823ea9be0c8700a69a215fac7d3af4d6d87 (diff) |
Fix lint.
Diffstat (limited to 'permissionse')
-rw-r--r-- | permissionse/src/main/java/foundation/e/privacymodules/permissions/PermissionsPrivacyModule.kt | 40 |
1 files changed, 30 insertions, 10 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 22be90d..83711dd 100644 --- a/permissionse/src/main/java/foundation/e/privacymodules/permissions/PermissionsPrivacyModule.kt +++ b/permissionse/src/main/java/foundation/e/privacymodules/permissions/PermissionsPrivacyModule.kt @@ -1,3 +1,20 @@ +/* + * Copyright (C) 2022 E FOUNDATION + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ + package foundation.e.privacymodules.permissions import android.annotation.TargetApi @@ -18,10 +35,10 @@ import foundation.e.privacymodules.permissions.data.ApplicationDescription /** * Implements [IPermissionsPrivacyModule] with all privileges of a system app. */ -class PermissionsPrivacyModule(context: Context): APermissionsPrivacyModule(context) { +class PermissionsPrivacyModule(context: Context) : APermissionsPrivacyModule(context) { - private val appOpsManager: AppOpsManager get() - = context.getSystemService(Context.APP_OPS_SERVICE) as AppOpsManager + private val appOpsManager: AppOpsManager + get() = context.getSystemService(Context.APP_OPS_SERVICE) as AppOpsManager /** * @see IPermissionsPrivacyModule.toggleDangerousPermission @@ -67,7 +84,7 @@ class PermissionsPrivacyModule(context: Context): APermissionsPrivacyModule(cont } override fun setVpnPackageAuthorization(packageName: String): Boolean { - return when(Build.VERSION.SDK_INT) { + return when (Build.VERSION.SDK_INT) { 29 -> setVpnPackageAuthorizationSDK29(packageName) 30 -> setVpnPackageAuthorizationSDK30(packageName) 31, 32 -> setVpnPackageAuthorizationSDK32(packageName) @@ -81,7 +98,8 @@ class PermissionsPrivacyModule(context: Context): APermissionsPrivacyModule(cont @TargetApi(29) private fun setVpnPackageAuthorizationSDK29(packageName: String): Boolean { val service: IConnectivityManager = IConnectivityManager.Stub.asInterface( - ServiceManager.getService(Context.CONNECTIVITY_SERVICE)) + ServiceManager.getService(Context.CONNECTIVITY_SERVICE) + ) try { if (service.prepareVpn(null, packageName, UserHandle.myUserId())) { @@ -101,7 +119,8 @@ class PermissionsPrivacyModule(context: Context): APermissionsPrivacyModule(cont @TargetApi(30) private fun setVpnPackageAuthorizationSDK30(packageName: String): Boolean { val service: IConnectivityManager = IConnectivityManager.Stub.asInterface( - ServiceManager.getService(Context.CONNECTIVITY_SERVICE)) + ServiceManager.getService(Context.CONNECTIVITY_SERVICE) + ) try { if (service.prepareVpn(null, packageName, UserHandle.myUserId())) { @@ -138,7 +157,7 @@ class PermissionsPrivacyModule(context: Context): APermissionsPrivacyModule(cont } override fun getAlwaysOnVpnPackage(): String? { - return when(Build.VERSION.SDK_INT) { + return when (Build.VERSION.SDK_INT) { 29, 30 -> getAlwaysOnVpnPackageSDK29() 31, 32 -> getAlwaysOnVpnPackageSDK32() else -> { @@ -151,11 +170,12 @@ class PermissionsPrivacyModule(context: Context): APermissionsPrivacyModule(cont @TargetApi(29) private fun getAlwaysOnVpnPackageSDK29(): String? { val service: IConnectivityManager = IConnectivityManager.Stub.asInterface( - ServiceManager.getService(Context.CONNECTIVITY_SERVICE)) + ServiceManager.getService(Context.CONNECTIVITY_SERVICE) + ) return try { service.getAlwaysOnVpnPackage(UserHandle.myUserId()) - } catch(e: java.lang.Exception) { + } catch (e: java.lang.Exception) { Log.e("Permissions-e", "Bad android sdk version ", e) return null } @@ -166,7 +186,7 @@ class PermissionsPrivacyModule(context: Context): APermissionsPrivacyModule(cont val vpnManager = context.getSystemService(Context.VPN_MANAGEMENT_SERVICE) as VpnManager return try { vpnManager.getAlwaysOnVpnPackageForUser(UserHandle.myUserId()) - } catch(e: java.lang.Exception) { + } catch (e: java.lang.Exception) { Log.e("Permissions-e", "Bad android sdk version ", e) return null } |