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/APermissionsPrivacyModule.kt | 6 ++++-- .../permissions/IPermissionsPrivacyModule.kt | 15 ++++++++++----- 2 files changed, 14 insertions(+), 7 deletions(-) (limited to 'privacymodule-api/src/main/java/foundation/e/privacymodules') diff --git a/privacymodule-api/src/main/java/foundation/e/privacymodules/permissions/APermissionsPrivacyModule.kt b/privacymodule-api/src/main/java/foundation/e/privacymodules/permissions/APermissionsPrivacyModule.kt index 68f7ee1..1fcfd44 100644 --- a/privacymodule-api/src/main/java/foundation/e/privacymodules/permissions/APermissionsPrivacyModule.kt +++ b/privacymodule-api/src/main/java/foundation/e/privacymodules/permissions/APermissionsPrivacyModule.kt @@ -59,9 +59,11 @@ abstract class APermissionsPrivacyModule(protected val context: Context): IPermi /** * @see IPermissionsPrivacyModule.getInstalledApplications */ - override fun getApplicationDescription(packageName: String): ApplicationDescription { + override fun getApplicationDescription(packageName: String, withIcon: Boolean): ApplicationDescription { val appDesc = buildApplicationDescription(context.packageManager.getApplicationInfo(packageName, 0), false) - appDesc.icon = getApplicationIcon(appDesc.packageName) + if (withIcon) { + appDesc.icon = getApplicationIcon(appDesc.packageName) + } return appDesc } diff --git a/privacymodule-api/src/main/java/foundation/e/privacymodules/permissions/IPermissionsPrivacyModule.kt b/privacymodule-api/src/main/java/foundation/e/privacymodules/permissions/IPermissionsPrivacyModule.kt index ba85f13..8eb3fd4 100644 --- a/privacymodule-api/src/main/java/foundation/e/privacymodules/permissions/IPermissionsPrivacyModule.kt +++ b/privacymodule-api/src/main/java/foundation/e/privacymodules/permissions/IPermissionsPrivacyModule.kt @@ -28,7 +28,10 @@ import foundation.e.privacymodules.permissions.data.PermissionDescription */ interface IPermissionsPrivacyModule { - fun buildApplicationDescription(appInfo: ApplicationInfo, withIcon: Boolean = true): ApplicationDescription + fun buildApplicationDescription( + appInfo: ApplicationInfo, + withIcon: Boolean = true + ): ApplicationDescription /** * List the installed application on the device which have not the FLAGS_SYSTEM. @@ -51,13 +54,12 @@ interface IPermissionsPrivacyModule { fun getPermissionDescription(permissionName: String): PermissionDescription - /** * Get the filled up [ApplicationDescription] for the app specified by its [packageName] * @param packageName the appId of the app * @return the informations about the app. */ - fun getApplicationDescription(packageName: String): ApplicationDescription + fun getApplicationDescription(packageName: String, withIcon: Boolean = true): ApplicationDescription /** * Check if the current runtime permission is granted for the specified app. @@ -68,7 +70,6 @@ interface IPermissionsPrivacyModule { */ fun isDangerousPermissionGranted(packageName: String, permissionName: String): Boolean - /** * Get the appOps mode for the specified [appOpPermissionName] of the specified application. * @@ -94,7 +95,6 @@ interface IPermissionsPrivacyModule { grant: Boolean ): Boolean - /** * Change the appOp Mode for the specified appOpPermission and application. * @param appDesc the application @@ -124,4 +124,9 @@ interface IPermissionsPrivacyModule { */ fun setVpnPackageAuthorization(packageName: String): Boolean + /** + * Returns the package name of the currently set always-on VPN application, or null. + */ + fun getAlwaysOnVpnPackage(): String? + } \ No newline at end of file -- cgit v1.2.1 From 5f02fd142ca438a48423340aeb9a36b017a6be83 Mon Sep 17 00:00:00 2001 From: Guillaume Jacquart Date: Fri, 7 Oct 2022 08:45:15 +0200 Subject: Fix lint. --- .../e/privacymodules/DependencyInjector.kt | 3 +-- .../permissions/APermissionsPrivacyModule.kt | 30 ++++++++++++---------- .../permissions/IPermissionsPrivacyModule.kt | 3 +-- .../privacymodules/permissions/data/AppOpModes.kt | 8 ++++-- .../permissions/data/PermissionDescription.kt | 2 +- 5 files changed, 26 insertions(+), 20 deletions(-) (limited to 'privacymodule-api/src/main/java/foundation/e/privacymodules') diff --git a/privacymodule-api/src/main/java/foundation/e/privacymodules/DependencyInjector.kt b/privacymodule-api/src/main/java/foundation/e/privacymodules/DependencyInjector.kt index bcf82d2..9bf8aba 100644 --- a/privacymodule-api/src/main/java/foundation/e/privacymodules/DependencyInjector.kt +++ b/privacymodule-api/src/main/java/foundation/e/privacymodules/DependencyInjector.kt @@ -26,7 +26,6 @@ object DependencyInjector { this.dnsBlocker = dnsBlocker } - lateinit var dnsBlocker: IDNSBlocker private set -} \ No newline at end of file +} diff --git a/privacymodule-api/src/main/java/foundation/e/privacymodules/permissions/APermissionsPrivacyModule.kt b/privacymodule-api/src/main/java/foundation/e/privacymodules/permissions/APermissionsPrivacyModule.kt index 1fcfd44..9d7e675 100644 --- a/privacymodule-api/src/main/java/foundation/e/privacymodules/permissions/APermissionsPrivacyModule.kt +++ b/privacymodule-api/src/main/java/foundation/e/privacymodules/permissions/APermissionsPrivacyModule.kt @@ -14,6 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ + package foundation.e.privacymodules.permissions import android.app.AppOpsManager @@ -34,7 +35,7 @@ import foundation.e.privacymodules.permissions.data.PermissionDescription * versions of the module. * @param context an Android context, to retrieve packageManager for example. */ -abstract class APermissionsPrivacyModule(protected val context: Context): IPermissionsPrivacyModule { +abstract class APermissionsPrivacyModule(protected val context: Context) : IPermissionsPrivacyModule { companion object { private const val TAG = "PermissionsModule" @@ -104,13 +105,16 @@ abstract class APermissionsPrivacyModule(protected val context: Context): IPermi val appOps = context.getSystemService(Context.APP_OPS_SERVICE) as AppOpsManager val mode = if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) { - appOps.checkOpNoThrow(appOpPermissionName, + appOps.checkOpNoThrow( + appOpPermissionName, - appDesc.uid, appDesc.packageName) + appDesc.uid, appDesc.packageName + ) } else { appOps.unsafeCheckOpNoThrow( appOpPermissionName, - appDesc.uid, appDesc.packageName) + appDesc.uid, appDesc.packageName + ) } return AppOpModes.getByModeValue(mode) @@ -140,15 +144,15 @@ abstract class APermissionsPrivacyModule(protected val context: Context): IPermi } } - override fun buildApplicationDescription(appInfo: ApplicationInfo, withIcon: Boolean) - : ApplicationDescription { - return ApplicationDescription( - packageName = appInfo.packageName, - uid = appInfo.uid, - label = getAppLabel(appInfo), - icon = if (withIcon) getApplicationIcon(appInfo.packageName) else null - ) - } + override fun buildApplicationDescription(appInfo: ApplicationInfo, withIcon: Boolean): + ApplicationDescription { + return ApplicationDescription( + packageName = appInfo.packageName, + uid = appInfo.uid, + label = getAppLabel(appInfo), + icon = if (withIcon) getApplicationIcon(appInfo.packageName) else null + ) + } private fun getAppLabel(appInfo: ApplicationInfo): CharSequence { return context.packageManager.getApplicationLabel(appInfo) diff --git a/privacymodule-api/src/main/java/foundation/e/privacymodules/permissions/IPermissionsPrivacyModule.kt b/privacymodule-api/src/main/java/foundation/e/privacymodules/permissions/IPermissionsPrivacyModule.kt index 8eb3fd4..6624798 100644 --- a/privacymodule-api/src/main/java/foundation/e/privacymodules/permissions/IPermissionsPrivacyModule.kt +++ b/privacymodule-api/src/main/java/foundation/e/privacymodules/permissions/IPermissionsPrivacyModule.kt @@ -128,5 +128,4 @@ interface IPermissionsPrivacyModule { * Returns the package name of the currently set always-on VPN application, or null. */ fun getAlwaysOnVpnPackage(): String? - -} \ No newline at end of file +} diff --git a/privacymodule-api/src/main/java/foundation/e/privacymodules/permissions/data/AppOpModes.kt b/privacymodule-api/src/main/java/foundation/e/privacymodules/permissions/data/AppOpModes.kt index 367645d..4764596 100644 --- a/privacymodule-api/src/main/java/foundation/e/privacymodules/permissions/data/AppOpModes.kt +++ b/privacymodule-api/src/main/java/foundation/e/privacymodules/permissions/data/AppOpModes.kt @@ -17,7 +17,11 @@ package foundation.e.privacymodules.permissions.data -import android.app.AppOpsManager.* +import android.app.AppOpsManager.MODE_ALLOWED +import android.app.AppOpsManager.MODE_DEFAULT +import android.app.AppOpsManager.MODE_ERRORED +import android.app.AppOpsManager.MODE_FOREGROUND +import android.app.AppOpsManager.MODE_IGNORED import android.os.Build enum class AppOpModes(val modeValue: Int) { @@ -34,7 +38,7 @@ enum class AppOpModes(val modeValue: Int) { IGNORED.modeValue to IGNORED, ERRORED.modeValue to ERRORED, DEFAULT.modeValue to DEFAULT, - ) + ) fun getByModeValue(modeValue: Int): AppOpModes { return byMode.get(modeValue) ?: DEFAULT diff --git a/privacymodule-api/src/main/java/foundation/e/privacymodules/permissions/data/PermissionDescription.kt b/privacymodule-api/src/main/java/foundation/e/privacymodules/permissions/data/PermissionDescription.kt index 9ed297d..127192b 100644 --- a/privacymodule-api/src/main/java/foundation/e/privacymodules/permissions/data/PermissionDescription.kt +++ b/privacymodule-api/src/main/java/foundation/e/privacymodules/permissions/data/PermissionDescription.kt @@ -23,4 +23,4 @@ data class PermissionDescription( val group: String?, var label: CharSequence?, var description: CharSequence? -) \ No newline at end of file +) -- cgit v1.2.1