Use the proper API to get profile type
This commit is contained in:
parent
52150c5257
commit
99c98e4127
@ -129,12 +129,16 @@ class ProfileManager(
|
|||||||
* This only works when the launcher is installed in the primary profile.
|
* This only works when the launcher is installed in the primary profile.
|
||||||
*/
|
*/
|
||||||
private fun getProfileType(userHandle: UserHandle): Profile.Type {
|
private fun getProfileType(userHandle: UserHandle): Profile.Type {
|
||||||
val restrictions = userManager.getUserRestrictions(userHandle)
|
if (isAtLeastApiLevel(35)) {
|
||||||
return when {
|
val launcherUserInfo = launcherApps.getLauncherUserInfo(userHandle)
|
||||||
restrictions.getBoolean(UserManager.ALLOW_PARENT_PROFILE_APP_LINKING) -> Profile.Type.Work
|
return when(launcherUserInfo?.userType) {
|
||||||
userHandle == Process.myUserHandle() -> Profile.Type.Personal
|
UserManager.USER_TYPE_PROFILE_PRIVATE -> Profile.Type.Private
|
||||||
else -> 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 {
|
private fun getProfileState(userHandle: UserHandle): Profile.State {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user