Merge "Check multi-user support in isUserSwitcherEnabled"

This commit is contained in:
Fyodor Kupolov
2015-09-30 21:58:19 +00:00
committed by Android (Google) Code Review
8 changed files with 25 additions and 41 deletions

View File

@@ -2437,6 +2437,17 @@ public class DevicePolicyManager {
return false;
}
/**
* Determine whether or not creating a guest user has been disabled for the device
*
* @hide
*/
public boolean getGuestUserDisabled(@Nullable ComponentName admin) {
// Currently guest users can always be created if multi-user is enabled
// TODO introduce a policy for guest user creation
return false;
}
/**
* Called by a device/profile owner to set whether the screen capture is disabled. Disabling
* screen capture also prevents the content from being shown on display devices that do not have

View File

@@ -20,6 +20,7 @@ import android.annotation.Nullable;
import android.annotation.SystemApi;
import android.app.ActivityManager;
import android.app.ActivityManagerNative;
import android.app.admin.DevicePolicyManager;
import android.content.Context;
import android.content.pm.UserInfo;
import android.content.res.Resources;
@@ -1337,12 +1338,15 @@ public class UserManager {
}
/**
* Returns true if the user switcher should be shown, this will be if there
* are multiple users that aren't managed profiles.
* Returns true if the user switcher should be shown, this will be if device supports multi-user
* and there are at least 2 users available that are not managed profiles.
* @hide
* @return true if user switcher should be shown.
*/
public boolean isUserSwitcherEnabled() {
if (!supportsMultipleUsers()) {
return false;
}
List<UserInfo> users = getUsers(true);
if (users == null) {
return false;
@@ -1353,8 +1357,8 @@ public class UserManager {
++switchableUserCount;
}
}
final boolean guestEnabled = Settings.Global.getInt(mContext.getContentResolver(),
Settings.Global.GUEST_USER_ENABLED, 0) == 1;
final boolean guestEnabled = !mContext.getSystemService(DevicePolicyManager.class)
.getGuestUserDisabled(null);
return switchableUserCount > 1 || guestEnabled;
}

View File

@@ -7688,14 +7688,6 @@ public final class Settings {
*/
public static final String DEVICE_NAME = "device_name";
/**
* Whether it should be possible to create a guest user on the device.
* <p>
* Type: int (0 for disabled, 1 for enabled)
* @hide
*/
public static final String GUEST_USER_ENABLED = "guest_user_enabled";
/**
* Whether the NetworkScoringService has been first initialized.
* <p>