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

Commit 2db6819b authored by Chaohui Wang's avatar Chaohui Wang
Browse files

Support primary user only AppListPage

Some App List does not distinguish between multiple profiles.
In these case, shows the App List for the primary user only.

Bug: 235727273
Test: Manual with Settings App
Change-Id: Ic8f770b92bc31fb851f49bf8117b4a29cc8459ef
parent af7d9b6c
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@ import com.android.settingslib.spaprivileged.template.common.WorkProfilePager
fun <T : AppRecord> AppListPage(
    title: String,
    listModel: AppListModel<T>,
    primaryUserOnly: Boolean = false,
    appItem: @Composable (itemState: AppListItemModel<T>) -> Unit,
) {
    val showSystem = rememberSaveable { mutableStateOf(false) }
@@ -55,7 +56,7 @@ fun <T : AppRecord> AppListPage(
        },
    ) { paddingValues ->
        Spacer(Modifier.padding(paddingValues))
        WorkProfilePager { userInfo ->
        WorkProfilePager(primaryUserOnly) { userInfo ->
            Column(Modifier.fillMaxSize()) {
                val options = remember { listModel.getSpinnerOptions() }
                val selectedOption = rememberSaveable { mutableStateOf(0) }
+7 −2
Original line number Diff line number Diff line
@@ -26,11 +26,16 @@ import com.android.settingslib.spa.widget.scaffold.SettingsPager
import com.android.settingslib.spaprivileged.model.enterprise.EnterpriseRepository

@Composable
fun WorkProfilePager(content: @Composable (userInfo: UserInfo) -> Unit) {
fun WorkProfilePager(
    primaryUserOnly: Boolean = false,
    content: @Composable (userInfo: UserInfo) -> Unit,
) {
    val context = LocalContext.current
    val profiles = remember {
        val userManager = checkNotNull(context.getSystemService(UserManager::class.java))
        userManager.getProfiles(UserHandle.myUserId())
        userManager.getProfiles(UserHandle.myUserId()).filter { userInfo ->
            !primaryUserOnly || userInfo.isPrimary
        }
    }
    val titles = remember {
        val enterpriseRepository = EnterpriseRepository(context)