diff options
Diffstat (limited to 'privacymodule-api/src/main')
5 files changed, 39 insertions, 26 deletions
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 68f7ee1..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 <https://www.gnu.org/licenses/>. */ + 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" @@ -59,9 +60,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 } @@ -102,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) @@ -138,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 ba85f13..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 @@ -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,8 @@ interface IPermissionsPrivacyModule { */ fun setVpnPackageAuthorization(packageName: String): Boolean -}
\ No newline at end of file + /** + * Returns the package name of the currently set always-on VPN application, or null. + */ + fun getAlwaysOnVpnPackage(): String? +} 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 +) |