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

Commit edfad2f6 authored by Fan Wu's avatar Fan Wu Committed by Android (Google) Code Review
Browse files

Merge "Add new API to AppListRepository" into main

parents 98f3e24b 3485d3ed
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,