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 17package android.content.pm; 18 19import android.os.Parcel; 20import android.os.Parcelable; 21 22/** 23 * Per-user information. 24 * @hide 25 */ 26public 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 48 public UserInfo(int id, String name, int flags) { 49 this.id = id; 50 this.name = name; 51 this.flags = flags; 52 } 53 54 public boolean isPrimary() { 55 return (flags & FLAG_PRIMARY) == FLAG_PRIMARY; 56 } 57 58 public boolean isAdmin() { 59 return (flags & FLAG_ADMIN) == FLAG_ADMIN; 60 } 61 62 public boolean isGuest() { 63 return (flags & FLAG_GUEST) == FLAG_GUEST; 64 } 65 66 public UserInfo() { 67 } 68 69 public UserInfo(UserInfo orig) { 70 name = orig.name; 71 id = orig.id; 72 flags = orig.flags; 73 } 74 75 @Override 76 public String toString() { 77 return "UserInfo{" + id + ":" + name + ":" + Integer.toHexString(flags) + "}"; 78 } 79 80 public int describeContents() { 81 return 0; 82 } 83 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 100 private UserInfo(Parcel source) { 101 id = source.readInt(); 102 name = source.readString(); 103 flags = source.readInt(); 104 } 105} 106