Use the proper API to get profile type

This commit is contained in:
MM20 2024-07-18 18:46:24 +02:00
parent 52150c5257
commit 99c98e4127
No known key found for this signature in database
GPG Key ID: 0B61A8F2DEAFA389

View File

@ -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 {