Merge "An API to check if running in a demo user" into nyc-mr1-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
b71081e4e9
@@ -29362,6 +29362,7 @@ package android.os {
|
||||
method public android.os.Bundle getUserRestrictions();
|
||||
method public android.os.Bundle getUserRestrictions(android.os.UserHandle);
|
||||
method public boolean hasUserRestriction(java.lang.String);
|
||||
method public boolean isDemoUser();
|
||||
method public boolean isQuietModeEnabled(android.os.UserHandle);
|
||||
method public boolean isSystemUser();
|
||||
method public boolean isUserAGoat();
|
||||
|
||||
@@ -31887,6 +31887,7 @@ package android.os {
|
||||
method public android.os.Bundle getUserRestrictions();
|
||||
method public android.os.Bundle getUserRestrictions(android.os.UserHandle);
|
||||
method public boolean hasUserRestriction(java.lang.String);
|
||||
method public boolean isDemoUser();
|
||||
method public boolean isManagedProfile();
|
||||
method public boolean isManagedProfile(int);
|
||||
method public boolean isQuietModeEnabled(android.os.UserHandle);
|
||||
|
||||
@@ -29433,6 +29433,7 @@ package android.os {
|
||||
method public android.os.Bundle getUserRestrictions();
|
||||
method public android.os.Bundle getUserRestrictions(android.os.UserHandle);
|
||||
method public boolean hasUserRestriction(java.lang.String);
|
||||
method public boolean isDemoUser();
|
||||
method public boolean isQuietModeEnabled(android.os.UserHandle);
|
||||
method public boolean isSystemUser();
|
||||
method public boolean isUserAGoat();
|
||||
|
||||
@@ -81,4 +81,5 @@ interface IUserManager {
|
||||
void clearSeedAccountData();
|
||||
boolean someUserHasSeedAccount(in String accountName, in String accountType);
|
||||
boolean isManagedProfile(int userId);
|
||||
boolean isDemoUser(int userId);
|
||||
}
|
||||
|
||||
@@ -859,15 +859,17 @@ public class UserManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the calling app is running in a demo user.
|
||||
* <p>
|
||||
* Caller must hold the MANAGE_USERS permission.
|
||||
* Checks if the calling app is running in a demo user. When running in a demo user,
|
||||
* apps can be more helpful to the user, or explain their features in more detail.
|
||||
*
|
||||
* @return whether the caller is a demo user.
|
||||
* @hide
|
||||
*/
|
||||
public boolean isDemoUser() {
|
||||
UserInfo user = getUserInfo(UserHandle.myUserId());
|
||||
return user != null && user.isDemo();
|
||||
try {
|
||||
return mService.isDemoUser(UserHandle.myUserId());
|
||||
} catch (RemoteException re) {
|
||||
throw re.rethrowFromSystemServer();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -868,11 +868,24 @@ public class UserManagerService extends IUserManager.Stub {
|
||||
}
|
||||
}
|
||||
synchronized (mUsersLock) {
|
||||
UserInfo userInfo = getUserInfoLU(userId);
|
||||
UserInfo userInfo = getUserInfoLU(userId);
|
||||
return userInfo != null && userInfo.isManagedProfile();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDemoUser(int userId) {
|
||||
int callingUserId = UserHandle.getCallingUserId();
|
||||
if (callingUserId != userId && !hasManageUsersPermission()) {
|
||||
throw new SecurityException("You need MANAGE_USERS permission to query if u=" + userId
|
||||
+ " is a demo user");
|
||||
}
|
||||
synchronized (mUsersLock) {
|
||||
UserInfo userInfo = getUserInfoLU(userId);
|
||||
return userInfo != null && userInfo.isDemo();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRestricted() {
|
||||
synchronized (mUsersLock) {
|
||||
|
||||
Reference in New Issue
Block a user