Android多用户基础问题
1.源码位置
frameworks/base/core/java/android/os/UserManager.java
frameworks/base/services/core/java/com/android/server/pm/UserManagerService.java
重要接口
/**
* Returns whether this device supports multiple users with their own login and customizable
* space.
* @return whether the device supports multiple users.
*/
public static boolean supportsMultipleUsers() {
return getMaxSupportedUsers() > 1
&& SystemProperties.getBoolean("fw.show_multiuserui",
Resources.getSystem().getBoolean(R.bool.config_enableMultiUserUI));
}
/**
* Returns the maximum number of users that can be created on this device. A return value
* of 1 means that it is a single user device.
* @hide
* @return a value greater than or equal to 1
*/
@UnsupportedAppUsage
public static int getMaxSupportedUsers() {
// Don't allow multiple users on certain builds
if (android.os.Build.ID.startsWith("JVP")) return 1;
return Math.max(1, SystemProperties.getInt("fw.max_users",
Resources.getSystem().getInteger(R.integer.config_multiuserMaximumUsers)));
}
/**
* Returns true if the user switcher is enabled (regardless of whether there is anything
* interesting for it to show).
*
* @return true if user switcher is enabled
* @hide
*/
@RequiresPermission(anyOf = {
android.Manifest.permission.MANAGE_USERS,