summaryrefslogtreecommitdiff
path: root/app/src/main/java/foundation/e/privacycentralapp
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java/foundation/e/privacycentralapp')
-rw-r--r--app/src/main/java/foundation/e/privacycentralapp/data/repositories/AppListsRepository.kt14
-rw-r--r--app/src/main/java/foundation/e/privacycentralapp/domain/usecases/TrackersStateUseCase.kt4
-rw-r--r--app/src/main/java/foundation/e/privacycentralapp/features/trackers/apptrackers/AppTrackersFeature.kt61
3 files changed, 45 insertions, 34 deletions
diff --git a/app/src/main/java/foundation/e/privacycentralapp/data/repositories/AppListsRepository.kt b/app/src/main/java/foundation/e/privacycentralapp/data/repositories/AppListsRepository.kt
index 3573d4f..5d25a82 100644
--- a/app/src/main/java/foundation/e/privacycentralapp/data/repositories/AppListsRepository.kt
+++ b/app/src/main/java/foundation/e/privacycentralapp/data/repositories/AppListsRepository.kt
@@ -22,6 +22,7 @@ import android.content.Context
import android.content.Intent
import android.content.pm.ApplicationInfo
import android.content.pm.PackageManager
+import foundation.e.privacycentralapp.R
import foundation.e.privacymodules.permissions.PermissionsPrivacyModule
import foundation.e.privacymodules.permissions.data.ApplicationDescription
import kotlinx.coroutines.CoroutineScope
@@ -35,14 +36,19 @@ class AppListsRepository(
private val context: Context,
private val coroutineScope: CoroutineScope
) {
- val dummySystemApp = permissionsModule.getApplicationDescription("com.android.settings")
+ val dummySystemApp = ApplicationDescription(
+ packageName = "foundation.e.dummysystemapp",
+ uid = -1,
+ label = context.getString(R.string.dummy_system_app_label),
+ icon = context.getDrawable(lineageos.platform.R.drawable.ic_android)
+ )
fun getVisibleApps(): Flow<List<ApplicationDescription>> {
coroutineScope.launch {
val (visible, hidden) = splitVisibleToHidden(getAppsUsingInternet())
appDescriptions.emit(
Pair(
- visible.map { permissionsModule.buildApplicationDescription(it, withIcon = true) },
+ visible.map { permissionsModule.buildApplicationDescription(it, withIcon = true) } + dummySystemApp,
hidden.map { permissionsModule.buildApplicationDescription(it, withIcon = false) },
)
)
@@ -53,6 +59,10 @@ class AppListsRepository(
return appDescriptions.value.second
}
+ fun getApplicationDescription(packageName: String): ApplicationDescription? {
+ return appDescriptions.value.first.find { it.packageName == packageName }
+ }
+
fun foldForHiddenSystemApp(appUid: Int, appValueGetter: (Int) -> Int): Int {
return if (appUid == dummySystemApp.uid) {
getHiddenSystemApps().fold(0) { acc, app ->
diff --git a/app/src/main/java/foundation/e/privacycentralapp/domain/usecases/TrackersStateUseCase.kt b/app/src/main/java/foundation/e/privacycentralapp/domain/usecases/TrackersStateUseCase.kt
index ecf2e7b..a589509 100644
--- a/app/src/main/java/foundation/e/privacycentralapp/domain/usecases/TrackersStateUseCase.kt
+++ b/app/src/main/java/foundation/e/privacycentralapp/domain/usecases/TrackersStateUseCase.kt
@@ -67,8 +67,8 @@ class TrackersStateUseCase(
blockTrackersPrivacyModule.isWhiteListEmpty()
}
- fun getApplicationDescription(packageName: String): ApplicationDescription {
- return permissionsPrivacyModule.getApplicationDescription(packageName)
+ fun getApplicationDescription(packageName: String): ApplicationDescription? {
+ return appListsRepository.getApplicationDescription(packageName)
}
fun isWhitelisted(appUid: Int): Boolean {
diff --git a/app/src/main/java/foundation/e/privacycentralapp/features/trackers/apptrackers/AppTrackersFeature.kt b/app/src/main/java/foundation/e/privacycentralapp/features/trackers/apptrackers/AppTrackersFeature.kt
index 790a5a0..270dfcb 100644
--- a/app/src/main/java/foundation/e/privacycentralapp/features/trackers/apptrackers/AppTrackersFeature.kt
+++ b/app/src/main/java/foundation/e/privacycentralapp/features/trackers/apptrackers/AppTrackersFeature.kt
@@ -87,7 +87,7 @@ class AppTrackersFeature(
sealed class Effect {
object NoEffect : Effect()
- data class ErrorEffect(val message: String) : Effect()
+ data class ErrorEffect(val message: Any) : Effect()
data class SetAppEffect(val appDesc: ApplicationDescription) : Effect()
data class AppTrackersBlockingActivatedEffect(val isBlockingActivated: Boolean) : Effect()
data class AvailableTrackersListEffect(val trackers: List<Tracker>) : Effect()
@@ -127,37 +127,38 @@ class AppTrackersFeature(
},
actor = { state, action ->
when (action) {
- is Action.InitAction -> {
- val appDesc =
- trackersStateUseCase.getApplicationDescription(action.packageName)
- merge<Effect>(
- flow {
+ is Action.InitAction ->
+ trackersStateUseCase
+ .getApplicationDescription(action.packageName)?.let { appDesc ->
+ merge<Effect>(
+ flow {
- emit(Effect.SetAppEffect(appDesc))
- emit(
- Effect.AppTrackersBlockingActivatedEffect(
- !trackersStateUseCase.isWhitelisted(appDesc.uid)
- )
- )
- emit(
- Effect.TrackersWhitelistUpdateEffect(
- trackersStateUseCase.getTrackersWhitelistIds(appDesc.uid)
- )
- )
- emit(
- Effect.AvailableTrackersListEffect(
- trackers = trackersStatisticsUseCase.getTrackers(appDesc.uid)
- )
+ emit(Effect.SetAppEffect(appDesc))
+ emit(
+ Effect.AppTrackersBlockingActivatedEffect(
+ !trackersStateUseCase.isWhitelisted(appDesc.uid)
+ )
+ )
+ emit(
+ Effect.TrackersWhitelistUpdateEffect(
+ trackersStateUseCase.getTrackersWhitelistIds(appDesc.uid)
+ )
+ )
+ emit(
+ Effect.AvailableTrackersListEffect(
+ trackers = trackersStatisticsUseCase.getTrackers(appDesc.uid)
+ )
+ )
+ },
+ trackersStatisticsUseCase.listenUpdates().map {
+ Effect.NewStatisticsAvailablesEffect
+ },
+ getQuickPrivacyStateUseCase.quickPrivacyEnabledFlow.map {
+ Effect.QuickPrivacyUpdatedEffect(it)
+ }
)
- },
- trackersStatisticsUseCase.listenUpdates().map {
- Effect.NewStatisticsAvailablesEffect
- },
- getQuickPrivacyStateUseCase.quickPrivacyEnabledFlow.map {
- Effect.QuickPrivacyUpdatedEffect(it)
- }
- )
- }
+ } ?: flowOf(Effect.ErrorEffect(R.string.apptrackers_error_no_app))
+
is Action.BlockAllToggleAction ->
state.appDesc?.uid?.let { appUid ->
flow {