diff options
author | Guillaume Jacquart <guillaume.jacquart@hoodbrains.com> | 2023-12-05 08:17:03 +0000 |
---|---|---|
committer | Guillaume Jacquart <guillaume.jacquart@hoodbrains.com> | 2023-12-05 08:17:03 +0000 |
commit | 2234842a2bf5f17b6654a66347f6d3692cf1e443 (patch) | |
tree | 8f72170bee6247db6743521675d0ac0822b2ef65 /core | |
parent | 0db4d25038823369f320e0cd291968e66ed51e0c (diff) | |
parent | 2e897cc8af4234abc4e3f5c3448e1fd7b2b8a1bd (diff) |
Merge branch '1203-trackers_oriented_view' into 'main'
1203 trackers oriented view
See merge request e/os/advanced-privacy!151
Diffstat (limited to 'core')
-rw-r--r-- | core/src/main/java/foundation/e/advancedprivacy/data/repositories/AppListsRepository.kt | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/core/src/main/java/foundation/e/advancedprivacy/data/repositories/AppListsRepository.kt b/core/src/main/java/foundation/e/advancedprivacy/data/repositories/AppListsRepository.kt index f29bb8a..b44e96e 100644 --- a/core/src/main/java/foundation/e/advancedprivacy/data/repositories/AppListsRepository.kt +++ b/core/src/main/java/foundation/e/advancedprivacy/data/repositories/AppListsRepository.kt @@ -33,6 +33,7 @@ import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.map import kotlinx.coroutines.launch import kotlinx.coroutines.runBlocking +import kotlinx.coroutines.withContext class AppListsRepository( private val permissionsModule: IPermissionsPrivacyModule, @@ -179,20 +180,24 @@ class AppListsRepository( } else test(app) } - fun applyForHiddenApps(app: ApplicationDescription, action: (ApplicationDescription) -> Unit) { + fun getRealApps(app: ApplicationDescription): List<ApplicationDescription> { + return when (app) { + dummySystemApp -> getHiddenSystemApps() + dummyCompatibilityApp -> getCompatibilityApps() + else -> listOf(app) + } + } + + suspend fun applyForHiddenApps(app: ApplicationDescription, action: suspend (ApplicationDescription) -> Unit) { mapReduceForHiddenApps(app = app, map = action, reduce = {}) } - fun <T, R> mapReduceForHiddenApps( + suspend fun <T, R> mapReduceForHiddenApps( app: ApplicationDescription, - map: (ApplicationDescription) -> T, - reduce: (List<T>) -> R + map: suspend (ApplicationDescription) -> T, + reduce: suspend (List<T>) -> R ): R { - return if (app == dummySystemApp) { - reduce(getHiddenSystemApps().map(map)) - } else if (app == dummyCompatibilityApp) { - reduce(getCompatibilityApps().map(map)) - } else reduce(listOf(map(app))) + return reduce(getRealApps(app).map { map(it) }) } private var appsByUid = mapOf<Int, ApplicationDescription>() @@ -214,6 +219,16 @@ class AppListsRepository( } } + suspend fun getDisplayableApp(apId: String): ApplicationDescription? = withContext(Dispatchers.IO) { + getApp(apId)?.let { app -> + when { + app in getCompatibilityApps() -> dummyCompatibilityApp + app in getHiddenSystemApps() -> dummySystemApp + else -> app + } + } + } + private val allProfilesAppDescriptions = MutableStateFlow( Triple( emptyList<ApplicationDescription>(), |