Merge "Setup user restrictions for demo user" into nyc-mr1-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
a28576cb72
@@ -360,7 +360,7 @@ public class KeyguardViewMediator extends SystemUI {
|
|||||||
mSwitchingUser = false;
|
mSwitchingUser = false;
|
||||||
if (userId != UserHandle.USER_SYSTEM) {
|
if (userId != UserHandle.USER_SYSTEM) {
|
||||||
UserInfo info = UserManager.get(mContext).getUserInfo(userId);
|
UserInfo info = UserManager.get(mContext).getUserInfo(userId);
|
||||||
if (info != null && info.isGuest()) {
|
if (info != null && (info.isGuest() || info.isDemo())) {
|
||||||
// If we just switched to a guest, try to dismiss keyguard.
|
// If we just switched to a guest, try to dismiss keyguard.
|
||||||
dismiss();
|
dismiss();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ import android.util.Slog;
|
|||||||
|
|
||||||
import com.android.internal.os.BackgroundThread;
|
import com.android.internal.os.BackgroundThread;
|
||||||
import com.android.internal.R;
|
import com.android.internal.R;
|
||||||
|
import com.android.internal.widget.LockPatternUtils;
|
||||||
import com.android.server.ServiceThread;
|
import com.android.server.ServiceThread;
|
||||||
import com.android.server.SystemService;
|
import com.android.server.SystemService;
|
||||||
import com.android.server.pm.UserManagerService;
|
import com.android.server.pm.UserManagerService;
|
||||||
@@ -56,8 +57,8 @@ public class RetailDemoModeService extends SystemService {
|
|||||||
private static final long SCREEN_WAKEUP_DELAY = 5000;
|
private static final long SCREEN_WAKEUP_DELAY = 5000;
|
||||||
|
|
||||||
private ActivityManagerService mAms;
|
private ActivityManagerService mAms;
|
||||||
private UserManagerService mUms;
|
|
||||||
private NotificationManager mNm;
|
private NotificationManager mNm;
|
||||||
|
private UserManager mUm;
|
||||||
private PowerManager mPm;
|
private PowerManager mPm;
|
||||||
private PowerManager.WakeLock mWakeLock;
|
private PowerManager.WakeLock mWakeLock;
|
||||||
private Handler mHandler;
|
private Handler mHandler;
|
||||||
@@ -123,12 +124,26 @@ public class RetailDemoModeService extends SystemService {
|
|||||||
UserInfo demoUser = getUserManager().createUser(DEMO_USER_NAME,
|
UserInfo demoUser = getUserManager().createUser(DEMO_USER_NAME,
|
||||||
UserInfo.FLAG_DEMO | UserInfo.FLAG_EPHEMERAL);
|
UserInfo.FLAG_DEMO | UserInfo.FLAG_EPHEMERAL);
|
||||||
if (demoUser != null) {
|
if (demoUser != null) {
|
||||||
|
setupDemoUser(demoUser);
|
||||||
getActivityManager().switchUser(demoUser.id);
|
getActivityManager().switchUser(demoUser.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setupDemoUser(UserInfo userInfo) {
|
||||||
|
UserManager um = getUserManager();
|
||||||
|
UserHandle user = UserHandle.of(userInfo.id);
|
||||||
|
LockPatternUtils lockPatternUtils = new LockPatternUtils(getContext());
|
||||||
|
lockPatternUtils.setLockScreenDisabled(true, userInfo.id);
|
||||||
|
um.setUserRestriction(UserManager.DISALLOW_CONFIG_WIFI, true, user);
|
||||||
|
um.setUserRestriction(UserManager.DISALLOW_INSTALL_UNKNOWN_SOURCES, true, user);
|
||||||
|
um.setUserRestriction(UserManager.DISALLOW_CONFIG_MOBILE_NETWORKS, true, user);
|
||||||
|
um.setUserRestriction(UserManager.DISALLOW_USB_FILE_TRANSFER, true, user);
|
||||||
|
Settings.Secure.putIntForUser(getContext().getContentResolver(),
|
||||||
|
Settings.Secure.SKIP_FIRST_USE_HINTS, 1, userInfo.id);
|
||||||
|
}
|
||||||
|
|
||||||
private ActivityManagerService getActivityManager() {
|
private ActivityManagerService getActivityManager() {
|
||||||
if (mAms == null) {
|
if (mAms == null) {
|
||||||
mAms = (ActivityManagerService) ActivityManagerNative.getDefault();
|
mAms = (ActivityManagerService) ActivityManagerNative.getDefault();
|
||||||
@@ -136,12 +151,11 @@ public class RetailDemoModeService extends SystemService {
|
|||||||
return mAms;
|
return mAms;
|
||||||
}
|
}
|
||||||
|
|
||||||
private UserManagerService getUserManager() {
|
private UserManager getUserManager() {
|
||||||
if (mUms == null) {
|
if (mUm == null) {
|
||||||
mUms = (UserManagerService) UserManagerService.Stub
|
mUm = getContext().getSystemService(UserManager.class);
|
||||||
.asInterface(ServiceManager.getService(Context.USER_SERVICE));
|
|
||||||
}
|
}
|
||||||
return mUms;
|
return mUm;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void registerSettingsChangeObserver() {
|
private void registerSettingsChangeObserver() {
|
||||||
|
|||||||
@@ -2035,6 +2035,7 @@ public class UserManagerService extends IUserManager.Stub {
|
|||||||
final boolean isGuest = (flags & UserInfo.FLAG_GUEST) != 0;
|
final boolean isGuest = (flags & UserInfo.FLAG_GUEST) != 0;
|
||||||
final boolean isManagedProfile = (flags & UserInfo.FLAG_MANAGED_PROFILE) != 0;
|
final boolean isManagedProfile = (flags & UserInfo.FLAG_MANAGED_PROFILE) != 0;
|
||||||
final boolean isRestricted = (flags & UserInfo.FLAG_RESTRICTED) != 0;
|
final boolean isRestricted = (flags & UserInfo.FLAG_RESTRICTED) != 0;
|
||||||
|
final boolean isDemo = (flags & UserInfo.FLAG_DEMO) != 0;
|
||||||
final long ident = Binder.clearCallingIdentity();
|
final long ident = Binder.clearCallingIdentity();
|
||||||
UserInfo userInfo;
|
UserInfo userInfo;
|
||||||
UserData userData;
|
UserData userData;
|
||||||
@@ -2052,8 +2053,8 @@ public class UserManagerService extends IUserManager.Stub {
|
|||||||
Log.e(LOG_TAG, "Cannot add more managed profiles for user " + parentId);
|
Log.e(LOG_TAG, "Cannot add more managed profiles for user " + parentId);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (!isGuest && !isManagedProfile && isUserLimitReached()) {
|
if (!isGuest && !isManagedProfile && !isDemo && isUserLimitReached()) {
|
||||||
// If we're not adding a guest user or a managed profile and the limit has
|
// If we're not adding a guest/demo user or a managed profile and the limit has
|
||||||
// been reached, cannot add a user.
|
// been reached, cannot add a user.
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ import android.os.Message;
|
|||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.os.ServiceManager;
|
import android.os.ServiceManager;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
|
import android.os.UserManager;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.service.vr.IVrManager;
|
import android.service.vr.IVrManager;
|
||||||
import android.service.vr.IVrStateCallbacks;
|
import android.service.vr.IVrStateCallbacks;
|
||||||
@@ -142,7 +143,8 @@ public class ImmersiveModeConfirmation {
|
|||||||
if (!disabled
|
if (!disabled
|
||||||
&& (DEBUG_SHOW_EVERY_TIME || !mConfirmed)
|
&& (DEBUG_SHOW_EVERY_TIME || !mConfirmed)
|
||||||
&& userSetupComplete
|
&& userSetupComplete
|
||||||
&& !mVrModeEnabled) {
|
&& !mVrModeEnabled
|
||||||
|
&& !UserManager.isDeviceInDemoMode(mContext)) {
|
||||||
mHandler.sendEmptyMessageDelayed(H.SHOW, mShowDelayMs);
|
mHandler.sendEmptyMessageDelayed(H.SHOW, mShowDelayMs);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user