summaryrefslogtreecommitdiff
path: root/privacymodule-api/src/main/java/foundation/e
diff options
context:
space:
mode:
Diffstat (limited to 'privacymodule-api/src/main/java/foundation/e')
-rw-r--r--privacymodule-api/src/main/java/foundation/e/privacymodules/DependencyInjector.kt3
-rw-r--r--privacymodule-api/src/main/java/foundation/e/privacymodules/permissions/APermissionsPrivacyModule.kt30
-rw-r--r--privacymodule-api/src/main/java/foundation/e/privacymodules/permissions/IPermissionsPrivacyModule.kt3
-rw-r--r--privacymodule-api/src/main/java/foundation/e/privacymodules/permissions/data/AppOpModes.kt8
-rw-r--r--privacymodule-api/src/main/java/foundation/e/privacymodules/permissions/data/PermissionDescription.kt2
5 files changed, 26 insertions, 20 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 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 <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"
@@ -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
+)