Fixed warning related to NewUserRequest

Bug: 199446283
Test: m
Change-Id: Ia0530a28c5e2b7eb38698f104e8c325c11d1245a
This commit is contained in:
Mayank Garg
2021-11-17 11:20:51 -08:00
parent 6a13e152ed
commit b116f89f88

View File

@@ -94,8 +94,7 @@ public final class NewUserRequest {
/**
* Returns the user type.
*
* <p> Supported types are {@link UserManager.USER_TYPE_FULL_SECONDARY} and
* {@link USER_TYPE_FULL_GUEST}
* <p> Default value is {@link UserManager#USER_TYPE_FULL_SECONDARY}
*/
@NonNull
public String getUserType() {
@@ -203,10 +202,8 @@ public final class NewUserRequest {
/**
* Sets user type.
* <p>
* Supported types are {@link UserManager.USER_TYPE_FULL_SECONDARY} and
* {@link UserManager.USER_TYPE_FULL_GUEST}. Default value is
* {@link UserManager.USER_TYPE_FULL_SECONDARY}.
*
* <p> Default value is {link UserManager#USER_TYPE_FULL_SECONDARY}.
*
* @return This object for method chaining.
*/
@@ -277,16 +274,13 @@ public final class NewUserRequest {
}
private void checkIfPropertiesAreCompatible() {
// Conditions which can't be true simultaneously
// A guest user can't be admin user
if (mAdmin && mUserType == UserManager.USER_TYPE_FULL_GUEST) {
throw new IllegalStateException("A guest user can't be admin.");
if (mUserType == null) {
throw new IllegalStateException("Usertype cannot be null");
}
// check for only supported user types
if (mUserType != UserManager.USER_TYPE_FULL_SECONDARY
&& mUserType != UserManager.USER_TYPE_FULL_GUEST) {
throw new IllegalStateException("Unsupported user type: " + mUserType);
// Admin user can only be USER_TYPE_FULL_SECONDARY
if (mAdmin && !mUserType.equals(UserManager.USER_TYPE_FULL_SECONDARY)) {
throw new IllegalStateException("Admin user can't be of type: " + mUserType);
}
if (TextUtils.isEmpty(mAccountName) != TextUtils.isEmpty(mAccountType)) {