From 99c98e4127275ca892dc5c1c0728616ef4f2a6ac Mon Sep 17 00:00:00 2001 From: MM20 <15646950+MM2-0@users.noreply.github.com> Date: Thu, 18 Jul 2024 18:46:24 +0200 Subject: [PATCH] Use the proper API to get profile type --- .../de/mm20/launcher2/profiles/ProfileManager.kt | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/core/profiles/src/main/java/de/mm20/launcher2/profiles/ProfileManager.kt b/core/profiles/src/main/java/de/mm20/launcher2/profiles/ProfileManager.kt index d941ffcd..51d087f6 100644 --- a/core/profiles/src/main/java/de/mm20/launcher2/profiles/ProfileManager.kt +++ b/core/profiles/src/main/java/de/mm20/launcher2/profiles/ProfileManager.kt @@ -129,12 +129,16 @@ class ProfileManager( * This only works when the launcher is installed in the primary profile. */ private fun getProfileType(userHandle: UserHandle): Profile.Type { - val restrictions = userManager.getUserRestrictions(userHandle) - return when { - restrictions.getBoolean(UserManager.ALLOW_PARENT_PROFILE_APP_LINKING) -> Profile.Type.Work - userHandle == Process.myUserHandle() -> Profile.Type.Personal - else -> Profile.Type.Private + if (isAtLeastApiLevel(35)) { + val launcherUserInfo = launcherApps.getLauncherUserInfo(userHandle) + return when(launcherUserInfo?.userType) { + UserManager.USER_TYPE_PROFILE_PRIVATE -> Profile.Type.Private + UserManager.USER_TYPE_PROFILE_MANAGED -> Profile.Type.Work + else -> Profile.Type.Personal + + } } + return if (userHandle == Process.myUserHandle()) Profile.Type.Personal else Profile.Type.Work } private fun getProfileState(userHandle: UserHandle): Profile.State {