Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3485d3ed authored by Fan Wu's avatar Fan Wu
Browse files

Add new API to AppListRepository

So this API can be used in Catalyst App related screens for convenient
filtering.

Bug: 419435807
Test: NA
Flag: EXEMPT minor change
Change-Id: Ieb88bd316efd3f233a2ff4646e5f60cba3b0678a
parent 19cd64e7
Loading
Loading
Loading
Loading
+17 −1
Original line number Diff line number Diff line
@@ -25,7 +25,6 @@ import android.content.pm.Flags
import android.content.pm.PackageManager
import android.content.pm.PackageManager.ApplicationInfoFlags
import android.content.pm.ResolveInfo
import android.os.SystemProperties
import android.util.Log
import com.android.internal.R
import com.android.settingslib.spaprivileged.framework.common.userManager
@@ -58,6 +57,12 @@ interface AppListRepository {

    /** Loads the list of [ApplicationInfo], and filter base on `isSystemApp`. */
    suspend fun loadAndFilterApps(userId: Int, isSystemApp: Boolean): List<ApplicationInfo>

    /** Loads the list of [ApplicationInfo], and choose whether to exclude system apps or not. */
    suspend fun loadAndMaybeExcludeSystemApps(
        userId: Int,
        excludeSystemApp: Boolean,
    ): List<ApplicationInfo> = listOf()
}

/**
@@ -173,6 +178,17 @@ class AppListRepositoryImpl(
        }
    }

    override suspend fun loadAndMaybeExcludeSystemApps(userId: Int, excludeSystemApp: Boolean) =
        coroutineScope {
            val loadAppsDeferred = async { loadApps(userId) }
            val homeOrLauncherPackages = loadHomeOrLauncherPackages(userId)
            if (excludeSystemApp) {
                loadAppsDeferred.await().filter { app -> !isSystemApp(app, homeOrLauncherPackages) }
            } else {
                loadAppsDeferred.await()
            }
        }

    private suspend fun showSystemPredicate(
        userId: Int,
        showSystem: Boolean,