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
This commit is contained in:
@@ -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) }
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user