• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2011 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 
17 package android.content.pm;
18 
19 import android.os.Parcel;
20 import android.os.Parcelable;
21 
22 /**
23  * Per-user information.
24  * @hide
25  */
26 public class UserInfo implements Parcelable {
27     /**
28      * Primary user. Only one user can have this flag set. Meaning of this
29      * flag TBD.
30      */
31     public static final int FLAG_PRIMARY = 0x00000001;
32 
33     /**
34      * User with administrative privileges. Such a user can create and
35      * delete users.
36      */
37     public static final int FLAG_ADMIN   = 0x00000002;
38 
39     /**
40      * Indicates a guest user that may be transient.
41      */
42     public static final int FLAG_GUEST   = 0x00000004;
43 
44     public int id;
45     public String name;
46     public int flags;
47 
UserInfo(int id, String name, int flags)48     public UserInfo(int id, String name, int flags) {
49         this.id = id;
50         this.name = name;
51         this.flags = flags;
52     }
53 
isPrimary()54     public boolean isPrimary() {
55         return (flags & FLAG_PRIMARY) == FLAG_PRIMARY;
56     }
57 
isAdmin()58     public boolean isAdmin() {
59         return (flags & FLAG_ADMIN) == FLAG_ADMIN;
60     }
61 
isGuest()62     public boolean isGuest() {
63         return (flags & FLAG_GUEST) == FLAG_GUEST;
64     }
65 
UserInfo()66     public UserInfo() {
67     }
68 
UserInfo(UserInfo orig)69     public UserInfo(UserInfo orig) {
70         name = orig.name;
71         id = orig.id;
72         flags = orig.flags;
73     }
74 
75     @Override
toString()76     public String toString() {
77         return "UserInfo{" + id + ":" + name + ":" + Integer.toHexString(flags) + "}";
78     }
79 
describeContents()80     public int describeContents() {
81         return 0;
82     }
83 
writeToParcel(Parcel dest, int parcelableFlags)84     public void writeToParcel(Parcel dest, int parcelableFlags) {
85         dest.writeInt(id);
86         dest.writeString(name);
87         dest.writeInt(flags);
88     }
89 
90     public static final Parcelable.Creator<UserInfo> CREATOR
91             = new Parcelable.Creator<UserInfo>() {
92         public UserInfo createFromParcel(Parcel source) {
93             return new UserInfo(source);
94         }
95         public UserInfo[] newArray(int size) {
96             return new UserInfo[size];
97         }
98     };
99 
UserInfo(Parcel source)100     private UserInfo(Parcel source) {
101         id = source.readInt();
102         name = source.readString();
103         flags = source.readInt();
104     }
105 }
106