• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package android.os;
17 
18 import android.annotation.Nullable;
19 import android.annotation.SystemApi;
20 import android.annotation.TestApi;
21 
22 /**
23  * Contains the response of the call {@link UserManager#createUser(NewUserRequest)}.
24  *
25  * @hide
26  */
27 @SystemApi
28 public final class NewUserResponse {
29 
30     private final @Nullable UserHandle mUser;
31     private final @UserManager.UserOperationResult int mOperationResult;
32 
33     /**
34      * @hide
35      */
36     @TestApi
NewUserResponse(@ullable UserHandle user, @UserManager.UserOperationResult int operationResult)37     public NewUserResponse(@Nullable UserHandle user,
38             @UserManager.UserOperationResult int operationResult) {
39         mUser = user;
40         mOperationResult = operationResult;
41     }
42 
43     /**
44      * Is user creation successful?
45      */
isSuccessful()46     public boolean isSuccessful() {
47         return mUser != null;
48     }
49 
50     // TODO(b/199446283): If UserHandle.NULL is systemAPI, that can be returned here instead of null
51     /**
52      * Gets the created user handle.
53      */
getUser()54     public @Nullable UserHandle getUser() {
55         return mUser;
56     }
57 
58     /**
59      * Gets operation results.
60      */
getOperationResult()61     public @UserManager.UserOperationResult int getOperationResult() {
62         return mOperationResult;
63     }
64 }
65