Amith Yamasani | 4b2e934 | 2011-03-31 12:38:53 -0700 | [diff] [blame] | 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 | |
Felipe Leme | 7ad2f6b | 2019-09-11 09:23:26 -0700 | [diff] [blame] | 19 | import android.annotation.IntDef; |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 20 | import android.annotation.UnsupportedAppUsage; |
Amith Yamasani | 4b2e934 | 2011-03-31 12:38:53 -0700 | [diff] [blame] | 21 | import android.os.Parcel; |
| 22 | import android.os.Parcelable; |
Kenny Guy | 1a44753 | 2014-02-20 21:55:32 +0000 | [diff] [blame] | 23 | import android.os.SystemProperties; |
Jeff Sharkey | b049e21 | 2012-09-07 23:16:01 -0700 | [diff] [blame] | 24 | import android.os.UserHandle; |
Xiaohui Chen | 7cb69df | 2015-07-13 16:01:01 -0700 | [diff] [blame] | 25 | import android.os.UserManager; |
Felipe Leme | 7ad2f6b | 2019-09-11 09:23:26 -0700 | [diff] [blame] | 26 | import android.util.DebugUtils; |
| 27 | |
| 28 | import java.lang.annotation.Retention; |
| 29 | import java.lang.annotation.RetentionPolicy; |
Amith Yamasani | 4b2e934 | 2011-03-31 12:38:53 -0700 | [diff] [blame] | 30 | |
| 31 | /** |
| 32 | * Per-user information. |
| 33 | * @hide |
| 34 | */ |
| 35 | public class UserInfo implements Parcelable { |
Amith Yamasani | 258848d | 2012-08-10 17:06:33 -0700 | [diff] [blame] | 36 | |
Amith Yamasani | eb437d4 | 2016-04-29 09:31:25 -0700 | [diff] [blame] | 37 | /** 16 bits for user type */ |
| 38 | public static final int FLAG_MASK_USER_TYPE = 0x0000FFFF; |
Amith Yamasani | 258848d | 2012-08-10 17:06:33 -0700 | [diff] [blame] | 39 | |
Amith Yamasani | 4b2e934 | 2011-03-31 12:38:53 -0700 | [diff] [blame] | 40 | /** |
Dianne Hackborn | 5dc5a00 | 2012-09-15 19:33:48 -0700 | [diff] [blame] | 41 | * *************************** NOTE *************************** |
| 42 | * These flag values CAN NOT CHANGE because they are written |
| 43 | * directly to storage. |
| 44 | */ |
| 45 | |
| 46 | /** |
Xiaohui Chen | 70f6c38 | 2015-04-28 14:21:43 -0700 | [diff] [blame] | 47 | * Primary user. Only one user can have this flag set. It identifies the first human user |
| 48 | * on a device. |
Amith Yamasani | 4b2e934 | 2011-03-31 12:38:53 -0700 | [diff] [blame] | 49 | */ |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 50 | @UnsupportedAppUsage |
Amith Yamasani | 4b2e934 | 2011-03-31 12:38:53 -0700 | [diff] [blame] | 51 | public static final int FLAG_PRIMARY = 0x00000001; |
| 52 | |
| 53 | /** |
| 54 | * User with administrative privileges. Such a user can create and |
| 55 | * delete users. |
| 56 | */ |
| 57 | public static final int FLAG_ADMIN = 0x00000002; |
| 58 | |
| 59 | /** |
| 60 | * Indicates a guest user that may be transient. |
| 61 | */ |
| 62 | public static final int FLAG_GUEST = 0x00000004; |
| 63 | |
Amith Yamasani | 258848d | 2012-08-10 17:06:33 -0700 | [diff] [blame] | 64 | /** |
| 65 | * Indicates the user has restrictions in privileges, in addition to those for normal users. |
| 66 | * Exact meaning TBD. For instance, maybe they can't install apps or administer WiFi access pts. |
| 67 | */ |
| 68 | public static final int FLAG_RESTRICTED = 0x00000008; |
| 69 | |
Dianne Hackborn | 5dc5a00 | 2012-09-15 19:33:48 -0700 | [diff] [blame] | 70 | /** |
| 71 | * Indicates that this user has gone through its first-time initialization. |
| 72 | */ |
| 73 | public static final int FLAG_INITIALIZED = 0x00000010; |
| 74 | |
Kenny Guy | a52dc3e | 2014-02-11 15:33:14 +0000 | [diff] [blame] | 75 | /** |
| 76 | * Indicates that this user is a profile of another user, for example holding a users |
| 77 | * corporate data. |
| 78 | */ |
| 79 | public static final int FLAG_MANAGED_PROFILE = 0x00000020; |
| 80 | |
Alexandra Gherghina | df35d57 | 2014-04-09 13:54:39 +0100 | [diff] [blame] | 81 | /** |
| 82 | * Indicates that this user is disabled. |
Lenka Trochtova | 1ddda47 | 2016-02-12 10:42:12 +0100 | [diff] [blame] | 83 | * |
| 84 | * <p>Note: If an ephemeral user is disabled, it shouldn't be later re-enabled. Ephemeral users |
| 85 | * are disabled as their removal is in progress to indicate that they shouldn't be re-entered. |
Alexandra Gherghina | df35d57 | 2014-04-09 13:54:39 +0100 | [diff] [blame] | 86 | */ |
| 87 | public static final int FLAG_DISABLED = 0x00000040; |
| 88 | |
Rubin Xu | 0a29ecd | 2015-11-04 15:11:48 +0000 | [diff] [blame] | 89 | public static final int FLAG_QUIET_MODE = 0x00000080; |
Kenny Guy | a52dc3e | 2014-02-11 15:33:14 +0000 | [diff] [blame] | 90 | |
Lenka Trochtova | c4dd021 | 2015-11-18 12:22:06 +0100 | [diff] [blame] | 91 | /** |
| 92 | * Indicates that this user is ephemeral. I.e. the user will be removed after leaving |
| 93 | * the foreground. |
| 94 | */ |
| 95 | public static final int FLAG_EPHEMERAL = 0x00000100; |
| 96 | |
Amith Yamasani | eb437d4 | 2016-04-29 09:31:25 -0700 | [diff] [blame] | 97 | /** |
| 98 | * User is for demo purposes only and can be removed at any time. |
| 99 | */ |
| 100 | public static final int FLAG_DEMO = 0x00000200; |
| 101 | |
Felipe Leme | 7ad2f6b | 2019-09-11 09:23:26 -0700 | [diff] [blame] | 102 | /** |
| 103 | * @hide |
| 104 | */ |
| 105 | @IntDef(flag = true, prefix = "FLAG_", value = { |
| 106 | FLAG_PRIMARY, |
| 107 | FLAG_ADMIN, |
| 108 | FLAG_GUEST, |
| 109 | FLAG_RESTRICTED, |
| 110 | FLAG_INITIALIZED, |
| 111 | FLAG_MANAGED_PROFILE, |
| 112 | FLAG_DISABLED, |
| 113 | FLAG_QUIET_MODE, |
| 114 | FLAG_EPHEMERAL, |
| 115 | FLAG_DEMO |
| 116 | }) |
| 117 | @Retention(RetentionPolicy.SOURCE) |
| 118 | public @interface UserInfoFlag { |
| 119 | } |
| 120 | |
Fyodor Kupolov | 06a484a | 2015-08-21 16:33:20 -0700 | [diff] [blame] | 121 | public static final int NO_PROFILE_GROUP_ID = UserHandle.USER_NULL; |
Kenny Guy | a52dc3e | 2014-02-11 15:33:14 +0000 | [diff] [blame] | 122 | |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 123 | @UnsupportedAppUsage |
Amith Yamasani | 4b2e934 | 2011-03-31 12:38:53 -0700 | [diff] [blame] | 124 | public int id; |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 125 | @UnsupportedAppUsage |
Amith Yamasani | 2a00329 | 2012-08-14 18:25:45 -0700 | [diff] [blame] | 126 | public int serialNumber; |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 127 | @UnsupportedAppUsage |
Amith Yamasani | 4b2e934 | 2011-03-31 12:38:53 -0700 | [diff] [blame] | 128 | public String name; |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 129 | @UnsupportedAppUsage |
Amith Yamasani | b8151ec | 2012-04-18 18:02:48 -0700 | [diff] [blame] | 130 | public String iconPath; |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 131 | @UnsupportedAppUsage |
Amith Yamasani | 4b2e934 | 2011-03-31 12:38:53 -0700 | [diff] [blame] | 132 | public int flags; |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 133 | @UnsupportedAppUsage |
Amith Yamasani | 920ace0 | 2012-09-20 22:15:37 -0700 | [diff] [blame] | 134 | public long creationTime; |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 135 | @UnsupportedAppUsage |
Amith Yamasani | 920ace0 | 2012-09-20 22:15:37 -0700 | [diff] [blame] | 136 | public long lastLoggedInTime; |
Jeff Sharkey | bd91e2f | 2016-03-22 15:32:31 -0600 | [diff] [blame] | 137 | public String lastLoggedInFingerprint; |
Tony Mak | d3986be | 2016-11-01 18:12:10 +0000 | [diff] [blame] | 138 | /** |
| 139 | * If this user is a parent user, it would be its own user id. |
| 140 | * If this user is a child user, it would be its parent user id. |
| 141 | * Otherwise, it would be {@link #NO_PROFILE_GROUP_ID}. |
| 142 | */ |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 143 | @UnsupportedAppUsage |
Kenny Guy | 2a76494 | 2014-04-02 13:29:20 +0100 | [diff] [blame] | 144 | public int profileGroupId; |
Fyodor Kupolov | 06a484a | 2015-08-21 16:33:20 -0700 | [diff] [blame] | 145 | public int restrictedProfileParentId; |
Kenny Guy | 02c8990 | 2016-11-15 19:36:38 +0000 | [diff] [blame] | 146 | /** Which profile badge color/label to use. */ |
| 147 | public int profileBadge; |
Amith Yamasani | 4b2e934 | 2011-03-31 12:38:53 -0700 | [diff] [blame] | 148 | |
Dianne Hackborn | d4ac8d7 | 2012-09-27 23:20:10 -0700 | [diff] [blame] | 149 | /** User is only partially created. */ |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 150 | @UnsupportedAppUsage |
Dianne Hackborn | d4ac8d7 | 2012-09-27 23:20:10 -0700 | [diff] [blame] | 151 | public boolean partial; |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 152 | @UnsupportedAppUsage |
Adam Lesinski | eddeb49 | 2014-09-08 17:50:03 -0700 | [diff] [blame] | 153 | public boolean guestToRemove; |
Dianne Hackborn | d4ac8d7 | 2012-09-27 23:20:10 -0700 | [diff] [blame] | 154 | |
Felipe Leme | 7ad2f6b | 2019-09-11 09:23:26 -0700 | [diff] [blame] | 155 | /** |
| 156 | * This is used to optimize the creation of an user, i.e. OEMs might choose to pre-create a |
| 157 | * number of users at the first boot, so the actual creation later is faster. |
| 158 | * |
| 159 | * <p>A {@code preCreated} user is not a real user yet, so it should not show up on regular |
| 160 | * user operations (other than user creation per se). |
| 161 | * |
| 162 | * <p>Once the pre-created is used to create a "real" user later on, {@code preCreate} is set to |
| 163 | * {@code false}. |
| 164 | */ |
| 165 | public boolean preCreated; |
| 166 | |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 167 | @UnsupportedAppUsage |
Amith Yamasani | 4b2e934 | 2011-03-31 12:38:53 -0700 | [diff] [blame] | 168 | public UserInfo(int id, String name, int flags) { |
Amith Yamasani | b8151ec | 2012-04-18 18:02:48 -0700 | [diff] [blame] | 169 | this(id, name, null, flags); |
| 170 | } |
| 171 | |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 172 | @UnsupportedAppUsage |
Amith Yamasani | b8151ec | 2012-04-18 18:02:48 -0700 | [diff] [blame] | 173 | public UserInfo(int id, String name, String iconPath, int flags) { |
Amith Yamasani | 4b2e934 | 2011-03-31 12:38:53 -0700 | [diff] [blame] | 174 | this.id = id; |
| 175 | this.name = name; |
| 176 | this.flags = flags; |
Amith Yamasani | b8151ec | 2012-04-18 18:02:48 -0700 | [diff] [blame] | 177 | this.iconPath = iconPath; |
Kenny Guy | 2a76494 | 2014-04-02 13:29:20 +0100 | [diff] [blame] | 178 | this.profileGroupId = NO_PROFILE_GROUP_ID; |
Fyodor Kupolov | 06a484a | 2015-08-21 16:33:20 -0700 | [diff] [blame] | 179 | this.restrictedProfileParentId = NO_PROFILE_GROUP_ID; |
Amith Yamasani | 4b2e934 | 2011-03-31 12:38:53 -0700 | [diff] [blame] | 180 | } |
| 181 | |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 182 | @UnsupportedAppUsage |
Amith Yamasani | 4b2e934 | 2011-03-31 12:38:53 -0700 | [diff] [blame] | 183 | public boolean isPrimary() { |
| 184 | return (flags & FLAG_PRIMARY) == FLAG_PRIMARY; |
| 185 | } |
| 186 | |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 187 | @UnsupportedAppUsage |
Amith Yamasani | 4b2e934 | 2011-03-31 12:38:53 -0700 | [diff] [blame] | 188 | public boolean isAdmin() { |
| 189 | return (flags & FLAG_ADMIN) == FLAG_ADMIN; |
| 190 | } |
| 191 | |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 192 | @UnsupportedAppUsage |
Amith Yamasani | 4b2e934 | 2011-03-31 12:38:53 -0700 | [diff] [blame] | 193 | public boolean isGuest() { |
Felipe Leme | 7ad2f6b | 2019-09-11 09:23:26 -0700 | [diff] [blame] | 194 | return isGuest(flags); |
| 195 | } |
| 196 | |
| 197 | /** |
| 198 | * Checks if the flag denotes a guest user. |
| 199 | */ |
| 200 | public static boolean isGuest(@UserInfoFlag int flags) { |
Amith Yamasani | 4b2e934 | 2011-03-31 12:38:53 -0700 | [diff] [blame] | 201 | return (flags & FLAG_GUEST) == FLAG_GUEST; |
| 202 | } |
| 203 | |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 204 | @UnsupportedAppUsage |
Amith Yamasani | 67df64b | 2012-12-14 12:09:36 -0800 | [diff] [blame] | 205 | public boolean isRestricted() { |
| 206 | return (flags & FLAG_RESTRICTED) == FLAG_RESTRICTED; |
| 207 | } |
| 208 | |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 209 | @UnsupportedAppUsage |
Kenny Guy | a52dc3e | 2014-02-11 15:33:14 +0000 | [diff] [blame] | 210 | public boolean isManagedProfile() { |
Felipe Leme | 7ad2f6b | 2019-09-11 09:23:26 -0700 | [diff] [blame] | 211 | return isManagedProfile(flags); |
| 212 | } |
| 213 | |
| 214 | /** |
| 215 | * Checks if the flag denotes a managed profile. |
| 216 | */ |
| 217 | public static boolean isManagedProfile(@UserInfoFlag int flags) { |
Kenny Guy | a52dc3e | 2014-02-11 15:33:14 +0000 | [diff] [blame] | 218 | return (flags & FLAG_MANAGED_PROFILE) == FLAG_MANAGED_PROFILE; |
| 219 | } |
| 220 | |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 221 | @UnsupportedAppUsage |
Alexandra Gherghina | df35d57 | 2014-04-09 13:54:39 +0100 | [diff] [blame] | 222 | public boolean isEnabled() { |
| 223 | return (flags & FLAG_DISABLED) != FLAG_DISABLED; |
| 224 | } |
| 225 | |
Rubin Xu | 0a29ecd | 2015-11-04 15:11:48 +0000 | [diff] [blame] | 226 | public boolean isQuietModeEnabled() { |
| 227 | return (flags & FLAG_QUIET_MODE) == FLAG_QUIET_MODE; |
| 228 | } |
Lenka Trochtova | c4dd021 | 2015-11-18 12:22:06 +0100 | [diff] [blame] | 229 | |
| 230 | public boolean isEphemeral() { |
| 231 | return (flags & FLAG_EPHEMERAL) == FLAG_EPHEMERAL; |
| 232 | } |
| 233 | |
Amith Yamasani | 1274787 | 2015-12-07 14:19:49 -0800 | [diff] [blame] | 234 | public boolean isInitialized() { |
| 235 | return (flags & FLAG_INITIALIZED) == FLAG_INITIALIZED; |
| 236 | } |
| 237 | |
Amith Yamasani | eb437d4 | 2016-04-29 09:31:25 -0700 | [diff] [blame] | 238 | public boolean isDemo() { |
| 239 | return (flags & FLAG_DEMO) == FLAG_DEMO; |
| 240 | } |
| 241 | |
Kenny Guy | 1a44753 | 2014-02-20 21:55:32 +0000 | [diff] [blame] | 242 | /** |
Fyodor Kupolov | 7db5af1 | 2015-07-31 16:50:27 -0700 | [diff] [blame] | 243 | * Returns true if the user is a split system user. |
| 244 | * <p>If {@link UserManager#isSplitSystemUser split system user mode} is not enabled, |
| 245 | * the method always returns false. |
| 246 | */ |
| 247 | public boolean isSystemOnly() { |
Xiaohui Chen | a449062 | 2015-09-22 15:29:31 -0700 | [diff] [blame] | 248 | return isSystemOnly(id); |
| 249 | } |
| 250 | |
| 251 | /** |
| 252 | * Returns true if the given user is a split system user. |
| 253 | * <p>If {@link UserManager#isSplitSystemUser split system user mode} is not enabled, |
| 254 | * the method always returns false. |
| 255 | */ |
| 256 | public static boolean isSystemOnly(int userId) { |
| 257 | return userId == UserHandle.USER_SYSTEM && UserManager.isSplitSystemUser(); |
Fyodor Kupolov | 7db5af1 | 2015-07-31 16:50:27 -0700 | [diff] [blame] | 258 | } |
| 259 | |
| 260 | /** |
Kenny Guy | 1a44753 | 2014-02-20 21:55:32 +0000 | [diff] [blame] | 261 | * @return true if this user can be switched to. |
| 262 | **/ |
| 263 | public boolean supportsSwitchTo() { |
Lenka Trochtova | 1ddda47 | 2016-02-12 10:42:12 +0100 | [diff] [blame] | 264 | if (isEphemeral() && !isEnabled()) { |
| 265 | // Don't support switching to an ephemeral user with removal in progress. |
| 266 | return false; |
| 267 | } |
Robin Lee | 434a74f | 2016-08-04 15:58:08 +0100 | [diff] [blame] | 268 | return !isManagedProfile(); |
Kenny Guy | 1a44753 | 2014-02-20 21:55:32 +0000 | [diff] [blame] | 269 | } |
| 270 | |
Xiaohui Chen | 7cb69df | 2015-07-13 16:01:01 -0700 | [diff] [blame] | 271 | /** |
| 272 | * @return true if this user can be switched to by end user through UI. |
| 273 | */ |
| 274 | public boolean supportsSwitchToByUser() { |
| 275 | // Hide the system user when it does not represent a human user. |
| 276 | boolean hideSystemUser = UserManager.isSplitSystemUser(); |
| 277 | return (!hideSystemUser || id != UserHandle.USER_SYSTEM) && supportsSwitchTo(); |
| 278 | } |
| 279 | |
Nicolas Prevot | b818681 | 2015-08-06 15:00:03 +0100 | [diff] [blame] | 280 | /* @hide */ |
| 281 | public boolean canHaveProfile() { |
| 282 | if (isManagedProfile() || isGuest() || isRestricted()) { |
| 283 | return false; |
| 284 | } |
| 285 | if (UserManager.isSplitSystemUser()) { |
| 286 | return id != UserHandle.USER_SYSTEM; |
Xiaohui Chen | bd0e03b | 2015-08-21 09:19:49 -0700 | [diff] [blame] | 287 | } else { |
| 288 | return id == UserHandle.USER_SYSTEM; |
Nicolas Prevot | b818681 | 2015-08-06 15:00:03 +0100 | [diff] [blame] | 289 | } |
Nicolas Prevot | b818681 | 2015-08-06 15:00:03 +0100 | [diff] [blame] | 290 | } |
| 291 | |
Amith Yamasani | 4b2e934 | 2011-03-31 12:38:53 -0700 | [diff] [blame] | 292 | public UserInfo() { |
| 293 | } |
| 294 | |
| 295 | public UserInfo(UserInfo orig) { |
| 296 | name = orig.name; |
Amith Yamasani | b8151ec | 2012-04-18 18:02:48 -0700 | [diff] [blame] | 297 | iconPath = orig.iconPath; |
Amith Yamasani | 4b2e934 | 2011-03-31 12:38:53 -0700 | [diff] [blame] | 298 | id = orig.id; |
| 299 | flags = orig.flags; |
Amith Yamasani | 2a00329 | 2012-08-14 18:25:45 -0700 | [diff] [blame] | 300 | serialNumber = orig.serialNumber; |
Amith Yamasani | 920ace0 | 2012-09-20 22:15:37 -0700 | [diff] [blame] | 301 | creationTime = orig.creationTime; |
| 302 | lastLoggedInTime = orig.lastLoggedInTime; |
Jeff Sharkey | bd91e2f | 2016-03-22 15:32:31 -0600 | [diff] [blame] | 303 | lastLoggedInFingerprint = orig.lastLoggedInFingerprint; |
Dianne Hackborn | d4ac8d7 | 2012-09-27 23:20:10 -0700 | [diff] [blame] | 304 | partial = orig.partial; |
Felipe Leme | 7ad2f6b | 2019-09-11 09:23:26 -0700 | [diff] [blame] | 305 | preCreated = orig.preCreated; |
Kenny Guy | 2a76494 | 2014-04-02 13:29:20 +0100 | [diff] [blame] | 306 | profileGroupId = orig.profileGroupId; |
Amith Yamasani | 6f48d6e | 2016-03-23 14:28:25 -0700 | [diff] [blame] | 307 | restrictedProfileParentId = orig.restrictedProfileParentId; |
Adam Lesinski | eddeb49 | 2014-09-08 17:50:03 -0700 | [diff] [blame] | 308 | guestToRemove = orig.guestToRemove; |
Kenny Guy | 02c8990 | 2016-11-15 19:36:38 +0000 | [diff] [blame] | 309 | profileBadge = orig.profileBadge; |
Amith Yamasani | 4b2e934 | 2011-03-31 12:38:53 -0700 | [diff] [blame] | 310 | } |
| 311 | |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 312 | @UnsupportedAppUsage |
Jeff Sharkey | b049e21 | 2012-09-07 23:16:01 -0700 | [diff] [blame] | 313 | public UserHandle getUserHandle() { |
| 314 | return new UserHandle(id); |
| 315 | } |
| 316 | |
Amith Yamasani | 4b2e934 | 2011-03-31 12:38:53 -0700 | [diff] [blame] | 317 | @Override |
| 318 | public String toString() { |
Amith Yamasani | 0b28549 | 2011-04-14 17:35:23 -0700 | [diff] [blame] | 319 | return "UserInfo{" + id + ":" + name + ":" + Integer.toHexString(flags) + "}"; |
Amith Yamasani | 4b2e934 | 2011-03-31 12:38:53 -0700 | [diff] [blame] | 320 | } |
| 321 | |
Felipe Leme | 7ad2f6b | 2019-09-11 09:23:26 -0700 | [diff] [blame] | 322 | /** @hide */ |
| 323 | public String toFullString() { |
| 324 | return "UserInfo[id=" + id |
| 325 | + ", name=" + name |
| 326 | + ", flags=" + flagsToString(flags) |
| 327 | + (preCreated ? " (pre-created)" : "") |
| 328 | + (partial ? " (partial)" : "") |
| 329 | + "]"; |
| 330 | } |
| 331 | |
| 332 | /** @hide */ |
| 333 | public static String flagsToString(int flags) { |
| 334 | return DebugUtils.flagsToString(UserInfo.class, "FLAG_", flags); |
| 335 | } |
| 336 | |
| 337 | @Override |
Amith Yamasani | 4b2e934 | 2011-03-31 12:38:53 -0700 | [diff] [blame] | 338 | public int describeContents() { |
| 339 | return 0; |
| 340 | } |
| 341 | |
| 342 | public void writeToParcel(Parcel dest, int parcelableFlags) { |
| 343 | dest.writeInt(id); |
| 344 | dest.writeString(name); |
Amith Yamasani | b8151ec | 2012-04-18 18:02:48 -0700 | [diff] [blame] | 345 | dest.writeString(iconPath); |
Amith Yamasani | 4b2e934 | 2011-03-31 12:38:53 -0700 | [diff] [blame] | 346 | dest.writeInt(flags); |
Amith Yamasani | 2a00329 | 2012-08-14 18:25:45 -0700 | [diff] [blame] | 347 | dest.writeInt(serialNumber); |
Amith Yamasani | 920ace0 | 2012-09-20 22:15:37 -0700 | [diff] [blame] | 348 | dest.writeLong(creationTime); |
| 349 | dest.writeLong(lastLoggedInTime); |
Jeff Sharkey | bd91e2f | 2016-03-22 15:32:31 -0600 | [diff] [blame] | 350 | dest.writeString(lastLoggedInFingerprint); |
Felipe Leme | 7ad2f6b | 2019-09-11 09:23:26 -0700 | [diff] [blame] | 351 | dest.writeBoolean(partial); |
| 352 | dest.writeBoolean(preCreated); |
Kenny Guy | 2a76494 | 2014-04-02 13:29:20 +0100 | [diff] [blame] | 353 | dest.writeInt(profileGroupId); |
Felipe Leme | 7ad2f6b | 2019-09-11 09:23:26 -0700 | [diff] [blame] | 354 | dest.writeBoolean(guestToRemove); |
Fyodor Kupolov | 06a484a | 2015-08-21 16:33:20 -0700 | [diff] [blame] | 355 | dest.writeInt(restrictedProfileParentId); |
Kenny Guy | 02c8990 | 2016-11-15 19:36:38 +0000 | [diff] [blame] | 356 | dest.writeInt(profileBadge); |
Amith Yamasani | 4b2e934 | 2011-03-31 12:38:53 -0700 | [diff] [blame] | 357 | } |
| 358 | |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 359 | @UnsupportedAppUsage |
Jeff Sharkey | 9e8f83d | 2019-02-28 12:06:45 -0700 | [diff] [blame] | 360 | public static final @android.annotation.NonNull Parcelable.Creator<UserInfo> CREATOR |
Amith Yamasani | 4b2e934 | 2011-03-31 12:38:53 -0700 | [diff] [blame] | 361 | = new Parcelable.Creator<UserInfo>() { |
| 362 | public UserInfo createFromParcel(Parcel source) { |
| 363 | return new UserInfo(source); |
| 364 | } |
| 365 | public UserInfo[] newArray(int size) { |
| 366 | return new UserInfo[size]; |
| 367 | } |
| 368 | }; |
| 369 | |
| 370 | private UserInfo(Parcel source) { |
| 371 | id = source.readInt(); |
| 372 | name = source.readString(); |
Amith Yamasani | b8151ec | 2012-04-18 18:02:48 -0700 | [diff] [blame] | 373 | iconPath = source.readString(); |
Amith Yamasani | 4b2e934 | 2011-03-31 12:38:53 -0700 | [diff] [blame] | 374 | flags = source.readInt(); |
Amith Yamasani | 2a00329 | 2012-08-14 18:25:45 -0700 | [diff] [blame] | 375 | serialNumber = source.readInt(); |
Amith Yamasani | 920ace0 | 2012-09-20 22:15:37 -0700 | [diff] [blame] | 376 | creationTime = source.readLong(); |
| 377 | lastLoggedInTime = source.readLong(); |
Jeff Sharkey | bd91e2f | 2016-03-22 15:32:31 -0600 | [diff] [blame] | 378 | lastLoggedInFingerprint = source.readString(); |
Felipe Leme | 7ad2f6b | 2019-09-11 09:23:26 -0700 | [diff] [blame] | 379 | partial = source.readBoolean(); |
Felipe Leme | 5284336 | 2019-10-14 09:56:06 -0700 | [diff] [blame] | 380 | preCreated = source.readBoolean(); |
Kenny Guy | 2a76494 | 2014-04-02 13:29:20 +0100 | [diff] [blame] | 381 | profileGroupId = source.readInt(); |
Felipe Leme | 7ad2f6b | 2019-09-11 09:23:26 -0700 | [diff] [blame] | 382 | guestToRemove = source.readBoolean(); |
Fyodor Kupolov | 06a484a | 2015-08-21 16:33:20 -0700 | [diff] [blame] | 383 | restrictedProfileParentId = source.readInt(); |
Kenny Guy | 02c8990 | 2016-11-15 19:36:38 +0000 | [diff] [blame] | 384 | profileBadge = source.readInt(); |
Amith Yamasani | 4b2e934 | 2011-03-31 12:38:53 -0700 | [diff] [blame] | 385 | } |
| 386 | } |