Merge "Renaming isCredentialSharedWithParent to isCredentialSharableWithParent" into tm-dev

This commit is contained in:
Sarup Dalwani
2022-03-10 05:59:57 +00:00
committed by Android (Google) Code Review
10 changed files with 45 additions and 45 deletions

View File

@@ -9822,7 +9822,7 @@ package android.os {
method @RequiresPermission(anyOf={android.Manifest.permission.MANAGE_USERS, android.Manifest.permission.INTERACT_ACROSS_USERS}, conditional=true) public boolean hasUserRestrictionForUser(@NonNull String, @NonNull android.os.UserHandle); method @RequiresPermission(anyOf={android.Manifest.permission.MANAGE_USERS, android.Manifest.permission.INTERACT_ACROSS_USERS}, conditional=true) public boolean hasUserRestrictionForUser(@NonNull String, @NonNull android.os.UserHandle);
method @RequiresPermission(anyOf={android.Manifest.permission.MANAGE_USERS, android.Manifest.permission.CREATE_USERS, android.Manifest.permission.QUERY_USERS}) public boolean isAdminUser(); method @RequiresPermission(anyOf={android.Manifest.permission.MANAGE_USERS, android.Manifest.permission.CREATE_USERS, android.Manifest.permission.QUERY_USERS}) public boolean isAdminUser();
method public boolean isCloneProfile(); method public boolean isCloneProfile();
method public boolean isCredentialSharedWithParent(); method public boolean isCredentialSharableWithParent();
method @RequiresPermission(anyOf={android.Manifest.permission.MANAGE_USERS, android.Manifest.permission.CREATE_USERS, android.Manifest.permission.QUERY_USERS}) public boolean isGuestUser(); method @RequiresPermission(anyOf={android.Manifest.permission.MANAGE_USERS, android.Manifest.permission.CREATE_USERS, android.Manifest.permission.QUERY_USERS}) public boolean isGuestUser();
method @RequiresPermission(anyOf={android.Manifest.permission.MANAGE_USERS, android.Manifest.permission.QUERY_USERS, android.Manifest.permission.INTERACT_ACROSS_USERS}, conditional=true) public boolean isManagedProfile(int); method @RequiresPermission(anyOf={android.Manifest.permission.MANAGE_USERS, android.Manifest.permission.QUERY_USERS, android.Manifest.permission.INTERACT_ACROSS_USERS}, conditional=true) public boolean isManagedProfile(int);
method @RequiresPermission(anyOf={android.Manifest.permission.MANAGE_USERS, android.Manifest.permission.INTERACT_ACROSS_USERS}, conditional=true) public boolean isMediaSharedWithParent(); method @RequiresPermission(anyOf={android.Manifest.permission.MANAGE_USERS, android.Manifest.permission.INTERACT_ACROSS_USERS}, conditional=true) public boolean isMediaSharedWithParent();

View File

@@ -109,7 +109,7 @@ interface IUserManager {
boolean someUserHasAccount(in String accountName, in String accountType); boolean someUserHasAccount(in String accountName, in String accountType);
String getProfileType(int userId); String getProfileType(int userId);
boolean isMediaSharedWithParent(int userId); boolean isMediaSharedWithParent(int userId);
boolean isCredentialSharedWithParent(int userId); boolean isCredentialSharableWithParent(int userId);
boolean isDemoUser(int userId); boolean isDemoUser(int userId);
boolean isPreCreated(int userId); boolean isPreCreated(int userId);
UserInfo createProfileForUserEvenWhenDisallowedWithThrow(in String name, in String userType, int flags, UserInfo createProfileForUserEvenWhenDisallowedWithThrow(in String name, in String userType, int flags,

View File

@@ -4763,7 +4763,7 @@ public class UserManager {
} }
/** /**
* Returns {@code true} if the user shares lock settings credential with its parent user * Returns whether the user can have shared lockscreen credential with its parent user.
* *
* This API only works for {@link UserManager#isProfile() profiles} * This API only works for {@link UserManager#isProfile() profiles}
* and will always return false for any other user type. * and will always return false for any other user type.
@@ -4776,9 +4776,9 @@ public class UserManager {
Manifest.permission.MANAGE_USERS, Manifest.permission.MANAGE_USERS,
Manifest.permission.INTERACT_ACROSS_USERS}) Manifest.permission.INTERACT_ACROSS_USERS})
@SuppressAutoDoc @SuppressAutoDoc
public boolean isCredentialSharedWithParent() { public boolean isCredentialSharableWithParent() {
try { try {
return mService.isCredentialSharedWithParent(mUserId); return mService.isCredentialSharableWithParent(mUserId);
} catch (RemoteException re) { } catch (RemoteException re) {
throw re.rethrowFromSystemServer(); throw re.rethrowFromSystemServer();
} }

View File

@@ -808,7 +808,7 @@ public class LockPatternUtils {
*/ */
public void setSeparateProfileChallengeEnabled(int userHandle, boolean enabled, public void setSeparateProfileChallengeEnabled(int userHandle, boolean enabled,
LockscreenCredential profilePassword) { LockscreenCredential profilePassword) {
if (!isCredentialSharedWithParent(userHandle)) { if (!isCredentialSharableWithParent(userHandle)) {
return; return;
} }
try { try {
@@ -824,7 +824,7 @@ public class LockPatternUtils {
* Returns true if {@code userHandle} is a managed profile with separate challenge. * Returns true if {@code userHandle} is a managed profile with separate challenge.
*/ */
public boolean isSeparateProfileChallengeEnabled(int userHandle) { public boolean isSeparateProfileChallengeEnabled(int userHandle) {
return isCredentialSharedWithParent(userHandle) && hasSeparateChallenge(userHandle); return isCredentialSharableWithParent(userHandle) && hasSeparateChallenge(userHandle);
} }
/** /**
@@ -849,8 +849,8 @@ public class LockPatternUtils {
return info != null && info.isManagedProfile(); return info != null && info.isManagedProfile();
} }
private boolean isCredentialSharedWithParent(int userHandle) { private boolean isCredentialSharableWithParent(int userHandle) {
return getUserManager(userHandle).isCredentialSharedWithParent(); return getUserManager(userHandle).isCredentialSharableWithParent();
} }
/** /**

View File

@@ -2618,7 +2618,7 @@ class UserController implements Handler.Callback {
if (getStartedUserState(userId) == null) { if (getStartedUserState(userId) == null) {
return false; return false;
} }
if (!mInjector.getUserManager().isCredentialSharedWithParent(userId)) { if (!mInjector.getUserManager().isCredentialSharableWithParent(userId)) {
return false; return false;
} }
if (mLockPatternUtils.isSeparateProfileChallengeEnabled(userId)) { if (mLockPatternUtils.isSeparateProfileChallengeEnabled(userId)) {

View File

@@ -373,7 +373,7 @@ public class LockSettingsService extends ILockSettings.Stub {
LockscreenCredential profileUserPassword) { LockscreenCredential profileUserPassword) {
if (DEBUG) Slog.v(TAG, "Check child profile lock for user: " + profileUserId); if (DEBUG) Slog.v(TAG, "Check child profile lock for user: " + profileUserId);
// Only for profiles that shares credential with parent // Only for profiles that shares credential with parent
if (!isCredentialSharedWithParent(profileUserId)) { if (!isCredentialSharableWithParent(profileUserId)) {
return; return;
} }
// Do not tie profile when work challenge is enabled // Do not tie profile when work challenge is enabled
@@ -789,7 +789,7 @@ public class LockSettingsService extends ILockSettings.Stub {
private void ensureProfileKeystoreUnlocked(int userId) { private void ensureProfileKeystoreUnlocked(int userId) {
final KeyStore ks = KeyStore.getInstance(); final KeyStore ks = KeyStore.getInstance();
if (ks.state(userId) == KeyStore.State.LOCKED if (ks.state(userId) == KeyStore.State.LOCKED
&& isCredentialSharedWithParent(userId) && isCredentialSharableWithParent(userId)
&& hasUnifiedChallenge(userId)) { && hasUnifiedChallenge(userId)) {
Slog.i(TAG, "Profile got unlocked, will unlock its keystore"); Slog.i(TAG, "Profile got unlocked, will unlock its keystore");
// If boot took too long and the password in vold got expired, parent keystore will // If boot took too long and the password in vold got expired, parent keystore will
@@ -810,7 +810,7 @@ public class LockSettingsService extends ILockSettings.Stub {
// Hide notification first, as tie managed profile lock takes time // Hide notification first, as tie managed profile lock takes time
hideEncryptionNotification(new UserHandle(userId)); hideEncryptionNotification(new UserHandle(userId));
if (isCredentialSharedWithParent(userId)) { if (isCredentialSharableWithParent(userId)) {
tieProfileLockIfNecessary(userId, LockscreenCredential.createNone()); tieProfileLockIfNecessary(userId, LockscreenCredential.createNone());
} }
@@ -1077,7 +1077,7 @@ public class LockSettingsService extends ILockSettings.Stub {
final int userCount = users.size(); final int userCount = users.size();
for (int i = 0; i < userCount; i++) { for (int i = 0; i < userCount; i++) {
UserInfo user = users.get(i); UserInfo user = users.get(i);
if (isCredentialSharedWithParent(user.id) if (isCredentialSharableWithParent(user.id)
&& !getSeparateProfileChallengeEnabledInternal(user.id)) { && !getSeparateProfileChallengeEnabledInternal(user.id)) {
success &= SyntheticPasswordCrypto.migrateLockSettingsKey( success &= SyntheticPasswordCrypto.migrateLockSettingsKey(
PROFILE_KEY_NAME_ENCRYPT + user.id); PROFILE_KEY_NAME_ENCRYPT + user.id);
@@ -1471,7 +1471,7 @@ public class LockSettingsService extends ILockSettings.Stub {
Thread.currentThread().interrupt(); Thread.currentThread().interrupt();
} }
if (isCredentialSharedWithParent(userId)) { if (isCredentialSharableWithParent(userId)) {
if (!hasUnifiedChallenge(userId)) { if (!hasUnifiedChallenge(userId)) {
mBiometricDeferredQueue.processPendingLockoutResets(); mBiometricDeferredQueue.processPendingLockoutResets();
} }
@@ -1480,7 +1480,7 @@ public class LockSettingsService extends ILockSettings.Stub {
for (UserInfo profile : mUserManager.getProfiles(userId)) { for (UserInfo profile : mUserManager.getProfiles(userId)) {
if (profile.id == userId) continue; if (profile.id == userId) continue;
if (!isCredentialSharedWithParent(profile.id)) continue; if (!isCredentialSharableWithParent(profile.id)) continue;
if (hasUnifiedChallenge(profile.id)) { if (hasUnifiedChallenge(profile.id)) {
if (mUserManager.isUserRunning(profile.id)) { if (mUserManager.isUserRunning(profile.id)) {
@@ -1517,7 +1517,7 @@ public class LockSettingsService extends ILockSettings.Stub {
} }
private Map<Integer, LockscreenCredential> getDecryptedPasswordsForAllTiedProfiles(int userId) { private Map<Integer, LockscreenCredential> getDecryptedPasswordsForAllTiedProfiles(int userId) {
if (isCredentialSharedWithParent(userId)) { if (isCredentialSharableWithParent(userId)) {
return null; return null;
} }
Map<Integer, LockscreenCredential> result = new ArrayMap<>(); Map<Integer, LockscreenCredential> result = new ArrayMap<>();
@@ -1525,7 +1525,7 @@ public class LockSettingsService extends ILockSettings.Stub {
final int size = profiles.size(); final int size = profiles.size();
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
final UserInfo profile = profiles.get(i); final UserInfo profile = profiles.get(i);
if (!isCredentialSharedWithParent(profile.id)) { if (!isCredentialSharableWithParent(profile.id)) {
continue; continue;
} }
final int profileUserId = profile.id; final int profileUserId = profile.id;
@@ -1560,7 +1560,7 @@ public class LockSettingsService extends ILockSettings.Stub {
*/ */
private void synchronizeUnifiedWorkChallengeForProfiles(int userId, private void synchronizeUnifiedWorkChallengeForProfiles(int userId,
Map<Integer, LockscreenCredential> profilePasswordMap) { Map<Integer, LockscreenCredential> profilePasswordMap) {
if (isCredentialSharedWithParent(userId)) { if (isCredentialSharableWithParent(userId)) {
return; return;
} }
final boolean isSecure = isUserSecure(userId); final boolean isSecure = isUserSecure(userId);
@@ -1569,7 +1569,7 @@ public class LockSettingsService extends ILockSettings.Stub {
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
final UserInfo profile = profiles.get(i); final UserInfo profile = profiles.get(i);
final int profileUserId = profile.id; final int profileUserId = profile.id;
if (isCredentialSharedWithParent(profileUserId)) { if (isCredentialSharableWithParent(profileUserId)) {
if (getSeparateProfileChallengeEnabledInternal(profileUserId)) { if (getSeparateProfileChallengeEnabledInternal(profileUserId)) {
continue; continue;
} }
@@ -1596,12 +1596,12 @@ public class LockSettingsService extends ILockSettings.Stub {
} }
private boolean isProfileWithUnifiedLock(int userId) { private boolean isProfileWithUnifiedLock(int userId) {
return isCredentialSharedWithParent(userId) return isCredentialSharableWithParent(userId)
&& !getSeparateProfileChallengeEnabledInternal(userId); && !getSeparateProfileChallengeEnabledInternal(userId);
} }
private boolean isProfileWithSeparatedLock(int userId) { private boolean isProfileWithSeparatedLock(int userId) {
return isCredentialSharedWithParent(userId) return isCredentialSharableWithParent(userId)
&& getSeparateProfileChallengeEnabledInternal(userId); && getSeparateProfileChallengeEnabledInternal(userId);
} }
@@ -1719,7 +1719,7 @@ public class LockSettingsService extends ILockSettings.Stub {
setSeparateProfileChallengeEnabledLocked(userId, true, /* unused */ null); setSeparateProfileChallengeEnabledLocked(userId, true, /* unused */ null);
notifyPasswordChanged(credential, userId); notifyPasswordChanged(credential, userId);
} }
if (isCredentialSharedWithParent(userId)) { if (isCredentialSharableWithParent(userId)) {
// Make sure the profile doesn't get locked straight after setting work challenge. // Make sure the profile doesn't get locked straight after setting work challenge.
setDeviceUnlockedForUser(userId); setDeviceUnlockedForUser(userId);
} }
@@ -1734,7 +1734,7 @@ public class LockSettingsService extends ILockSettings.Stub {
/** /**
* @param savedCredential if the user is a profile with * @param savedCredential if the user is a profile with
* {@link UserManager#isCredentialSharedWithParent()} with unified challenge and * {@link UserManager#isCredentialSharableWithParent()} with unified challenge and
* savedCredential is empty, LSS will try to re-derive the profile password internally. * savedCredential is empty, LSS will try to re-derive the profile password internally.
* TODO (b/80170828): Fix this so profile password is always passed in. * TODO (b/80170828): Fix this so profile password is always passed in.
* @param isLockTiedToParent is {@code true} if {@code userId} is a profile and its new * @param isLockTiedToParent is {@code true} if {@code userId} is a profile and its new
@@ -1910,8 +1910,8 @@ public class LockSettingsService extends ILockSettings.Stub {
} }
} }
protected boolean isCredentialSharedWithParent(int userId) { protected boolean isCredentialSharableWithParent(int userId) {
return getUserManagerFromCache(userId).isCredentialSharedWithParent(); return getUserManagerFromCache(userId).isCredentialSharableWithParent();
} }
private VerifyCredentialResponse convertResponse(GateKeeperResponse gateKeeperResponse) { private VerifyCredentialResponse convertResponse(GateKeeperResponse gateKeeperResponse) {
@@ -2161,7 +2161,7 @@ public class LockSettingsService extends ILockSettings.Stub {
final List<UserInfo> profiles = mUserManager.getProfiles(userId); final List<UserInfo> profiles = mUserManager.getProfiles(userId);
for (UserInfo pi : profiles) { for (UserInfo pi : profiles) {
// Unlock profile which shares credential with parent with unified lock // Unlock profile which shares credential with parent with unified lock
if (isCredentialSharedWithParent(pi.id) if (isCredentialSharableWithParent(pi.id)
&& !getSeparateProfileChallengeEnabledInternal(pi.id) && !getSeparateProfileChallengeEnabledInternal(pi.id)
&& mStorage.hasChildProfileLock(pi.id)) { && mStorage.hasChildProfileLock(pi.id)) {
try { try {
@@ -2555,7 +2555,7 @@ public class LockSettingsService extends ILockSettings.Stub {
mManagedProfilePasswordCache.removePassword(userId); mManagedProfilePasswordCache.removePassword(userId);
gateKeeperClearSecureUserId(userId); gateKeeperClearSecureUserId(userId);
if (unknownUser || isCredentialSharedWithParent(userId)) { if (unknownUser || isCredentialSharableWithParent(userId)) {
removeKeystoreProfileKey(userId); removeKeystoreProfileKey(userId);
} }
// Clean up storage last, this is to ensure that cleanupDataForReusedUserIdIfNecessary() // Clean up storage last, this is to ensure that cleanupDataForReusedUserIdIfNecessary()
@@ -3275,7 +3275,7 @@ public class LockSettingsService extends ILockSettings.Stub {
* Returns a fixed pseudorandom byte string derived from the user's synthetic password. * Returns a fixed pseudorandom byte string derived from the user's synthetic password.
* This is used to salt the password history hash to protect the hash against offline * This is used to salt the password history hash to protect the hash against offline
* bruteforcing, since rederiving this value requires a successful authentication. * bruteforcing, since rederiving this value requires a successful authentication.
* If user is a profile with {@link UserManager#isCredentialSharedWithParent()} true and with * If user is a profile with {@link UserManager#isCredentialSharableWithParent()} true and with
* unified challenge, currentCredential is ignored. * unified challenge, currentCredential is ignored.
*/ */
@Override @Override

View File

@@ -1593,13 +1593,13 @@ public class UserManagerService extends IUserManager.Stub {
} }
@Override @Override
public boolean isCredentialSharedWithParent(@UserIdInt int userId) { public boolean isCredentialSharableWithParent(@UserIdInt int userId) {
checkManageOrInteractPermissionIfCallerInOtherProfileGroup(userId, checkManageOrInteractPermissionIfCallerInOtherProfileGroup(userId,
"isCredentialSharedWithParent"); "isCredentialSharableWithParent");
synchronized (mUsersLock) { synchronized (mUsersLock) {
UserTypeDetails userTypeDetails = getUserTypeDetailsNoChecks(userId); UserTypeDetails userTypeDetails = getUserTypeDetailsNoChecks(userId);
return userTypeDetails != null && userTypeDetails.isProfile() return userTypeDetails != null && userTypeDetails.isProfile()
&& userTypeDetails.isCredentialSharedWithParent(); && userTypeDetails.isCredentialSharableWithParent();
} }
} }

View File

@@ -161,7 +161,7 @@ public final class UserTypeDetails {
* *
* <p> Default value is false * <p> Default value is false
*/ */
private final boolean mIsCredentialSharedWithParent; private final boolean mIsCredentialSharableWithParent;
private UserTypeDetails(@NonNull String name, boolean enabled, int maxAllowed, private UserTypeDetails(@NonNull String name, boolean enabled, int maxAllowed,
@UserInfoFlag int baseType, @UserInfoFlag int defaultUserInfoPropertyFlags, int label, @UserInfoFlag int baseType, @UserInfoFlag int defaultUserInfoPropertyFlags, int label,
@@ -174,7 +174,7 @@ public final class UserTypeDetails {
@Nullable Bundle defaultSecureSettings, @Nullable Bundle defaultSecureSettings,
@Nullable List<DefaultCrossProfileIntentFilter> defaultCrossProfileIntentFilters, @Nullable List<DefaultCrossProfileIntentFilter> defaultCrossProfileIntentFilters,
boolean isMediaSharedWithParent, boolean isMediaSharedWithParent,
boolean isCredentialSharedWithParent) { boolean isCredentialSharableWithParent) {
this.mName = name; this.mName = name;
this.mEnabled = enabled; this.mEnabled = enabled;
this.mMaxAllowed = maxAllowed; this.mMaxAllowed = maxAllowed;
@@ -194,7 +194,7 @@ public final class UserTypeDetails {
this.mBadgeColors = badgeColors; this.mBadgeColors = badgeColors;
this.mDarkThemeBadgeColors = darkThemeBadgeColors; this.mDarkThemeBadgeColors = darkThemeBadgeColors;
this.mIsMediaSharedWithParent = isMediaSharedWithParent; this.mIsMediaSharedWithParent = isMediaSharedWithParent;
this.mIsCredentialSharedWithParent = isCredentialSharedWithParent; this.mIsCredentialSharableWithParent = isCredentialSharableWithParent;
} }
/** /**
@@ -323,8 +323,8 @@ public final class UserTypeDetails {
* Returns true if the user has shared encryption credential with parent user or * Returns true if the user has shared encryption credential with parent user or
* false otherwise. * false otherwise.
*/ */
public boolean isCredentialSharedWithParent() { public boolean isCredentialSharableWithParent() {
return mIsCredentialSharedWithParent; return mIsCredentialSharableWithParent;
} }
/** Returns a {@link Bundle} representing the default user restrictions. */ /** Returns a {@link Bundle} representing the default user restrictions. */
@@ -419,7 +419,7 @@ public final class UserTypeDetails {
private @DrawableRes int mBadgePlain = Resources.ID_NULL; private @DrawableRes int mBadgePlain = Resources.ID_NULL;
private @DrawableRes int mBadgeNoBackground = Resources.ID_NULL; private @DrawableRes int mBadgeNoBackground = Resources.ID_NULL;
private boolean mIsMediaSharedWithParent = false; private boolean mIsMediaSharedWithParent = false;
private boolean mIsCredentialSharedWithParent = false; private boolean mIsCredentialSharableWithParent = false;
public Builder setName(String name) { public Builder setName(String name) {
mName = name; mName = name;
@@ -521,10 +521,10 @@ public final class UserTypeDetails {
/** /**
* Sets shared media property for the user. * Sets shared media property for the user.
* @param isCredentialSharedWithParent the value to be set, true or false * @param isCredentialSharableWithParent the value to be set, true or false
*/ */
public Builder setIsCredentialSharedWithParent(boolean isCredentialSharedWithParent) { public Builder setIsCredentialSharableWithParent(boolean isCredentialSharableWithParent) {
mIsCredentialSharedWithParent = isCredentialSharedWithParent; mIsCredentialSharableWithParent = isCredentialSharableWithParent;
return this; return this;
} }
@@ -571,7 +571,7 @@ public final class UserTypeDetails {
mDefaultSecureSettings, mDefaultSecureSettings,
mDefaultCrossProfileIntentFilters, mDefaultCrossProfileIntentFilters,
mIsMediaSharedWithParent, mIsMediaSharedWithParent,
mIsCredentialSharedWithParent); mIsCredentialSharableWithParent);
} }
private boolean hasBadge() { private boolean hasBadge() {

View File

@@ -122,7 +122,7 @@ public final class UserTypeFactory {
.setLabel(0) .setLabel(0)
.setDefaultRestrictions(null) .setDefaultRestrictions(null)
.setIsMediaSharedWithParent(true) .setIsMediaSharedWithParent(true)
.setIsCredentialSharedWithParent(true); .setIsCredentialSharableWithParent(true);
} }
/** /**
@@ -154,7 +154,7 @@ public final class UserTypeFactory {
.setDefaultRestrictions(getDefaultManagedProfileRestrictions()) .setDefaultRestrictions(getDefaultManagedProfileRestrictions())
.setDefaultSecureSettings(getDefaultManagedProfileSecureSettings()) .setDefaultSecureSettings(getDefaultManagedProfileSecureSettings())
.setDefaultCrossProfileIntentFilters(getDefaultManagedCrossProfileIntentFilter()) .setDefaultCrossProfileIntentFilters(getDefaultManagedCrossProfileIntentFilter())
.setIsCredentialSharedWithParent(true); .setIsCredentialSharableWithParent(true);
} }
/** /**

View File

@@ -217,7 +217,7 @@ public class LockSettingsServiceTestable extends LockSettingsService {
} }
@Override @Override
protected boolean isCredentialSharedWithParent(int userId) { protected boolean isCredentialSharableWithParent(int userId) {
UserInfo userInfo = mUserManager.getUserInfo(userId); UserInfo userInfo = mUserManager.getUserInfo(userId);
return userInfo.isCloneProfile() || userInfo.isManagedProfile(); return userInfo.isCloneProfile() || userInfo.isManagedProfile();
} }