1 /* 2 * Copyright (C) 2022 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.annotation.IntDef; 20 import android.annotation.NonNull; 21 import android.annotation.Nullable; 22 import android.annotation.SuppressLint; 23 import android.annotation.SystemApi; 24 import android.annotation.TestApi; 25 import android.os.Parcel; 26 import android.os.Parcelable; 27 import android.util.Slog; 28 29 import com.android.internal.annotations.VisibleForTesting; 30 import com.android.modules.utils.TypedXmlPullParser; 31 import com.android.modules.utils.TypedXmlSerializer; 32 33 import org.xmlpull.v1.XmlPullParserException; 34 35 import java.io.IOException; 36 import java.io.PrintWriter; 37 import java.lang.annotation.Retention; 38 import java.lang.annotation.RetentionPolicy; 39 40 /** 41 * Class holding the properties of a user that derive mostly from its user type. 42 * 43 * @hide 44 */ 45 @SystemApi 46 public final class UserProperties implements Parcelable { 47 private static final String LOG_TAG = UserProperties.class.getSimpleName(); 48 49 // Attribute strings for reading/writing properties to/from XML. 50 private static final String ATTR_SHOW_IN_LAUNCHER = "showInLauncher"; 51 private static final String ATTR_START_WITH_PARENT = "startWithParent"; 52 private static final String ATTR_SHOW_IN_SETTINGS = "showInSettings"; 53 private static final String ATTR_SHOW_IN_QUIET_MODE = "showInQuietMode"; 54 private static final String ATTR_SHOW_IN_SHARING_SURFACES = "showInSharingSurfaces"; 55 private static final String ATTR_INHERIT_DEVICE_POLICY = "inheritDevicePolicy"; 56 private static final String ATTR_USE_PARENTS_CONTACTS = "useParentsContacts"; 57 private static final String ATTR_UPDATE_CROSS_PROFILE_INTENT_FILTERS_ON_OTA = 58 "updateCrossProfileIntentFiltersOnOTA"; 59 private static final String ATTR_CROSS_PROFILE_INTENT_FILTER_ACCESS_CONTROL = 60 "crossProfileIntentFilterAccessControl"; 61 private static final String ATTR_CROSS_PROFILE_INTENT_RESOLUTION_STRATEGY = 62 "crossProfileIntentResolutionStrategy"; 63 private static final String ATTR_MEDIA_SHARED_WITH_PARENT = 64 "mediaSharedWithParent"; 65 private static final String ATTR_CREDENTIAL_SHAREABLE_WITH_PARENT = 66 "credentialShareableWithParent"; 67 private static final String ATTR_AUTH_ALWAYS_REQUIRED_TO_DISABLE_QUIET_MODE = 68 "authAlwaysRequiredToDisableQuietMode"; 69 private static final String ATTR_DELETE_APP_WITH_PARENT = "deleteAppWithParent"; 70 private static final String ATTR_ALWAYS_VISIBLE = "alwaysVisible"; 71 private static final String ATTR_ALLOW_STOPPING_USER_WITH_DELAYED_LOCKING = 72 "allowStoppingUserWithDelayedLocking"; 73 74 private static final String ATTR_CROSS_PROFILE_CONTENT_SHARING_STRATEGY = 75 "crossProfileContentSharingStrategy"; 76 private static final String ATTR_PROFILE_API_VISIBILITY = "profileApiVisibility"; 77 private static final String ITEMS_RESTRICTED_ON_HOME_SCREEN = 78 "itemsRestrictedOnHomeScreen"; 79 /** Index values of each property (to indicate whether they are present in this object). */ 80 @IntDef(prefix = "INDEX_", value = { 81 INDEX_SHOW_IN_LAUNCHER, 82 INDEX_START_WITH_PARENT, 83 INDEX_SHOW_IN_SETTINGS, 84 INDEX_INHERIT_DEVICE_POLICY, 85 INDEX_USE_PARENTS_CONTACTS, 86 INDEX_UPDATE_CROSS_PROFILE_INTENT_FILTERS_ON_OTA, 87 INDEX_CROSS_PROFILE_INTENT_FILTER_ACCESS_CONTROL, 88 INDEX_CROSS_PROFILE_INTENT_RESOLUTION_STRATEGY, 89 INDEX_MEDIA_SHARED_WITH_PARENT, 90 INDEX_CREDENTIAL_SHAREABLE_WITH_PARENT, 91 INDEX_DELETE_APP_WITH_PARENT, 92 INDEX_ALWAYS_VISIBLE, 93 INDEX_SHOW_IN_QUIET_MODE, 94 INDEX_SHOW_IN_SHARING_SURFACES, 95 INDEX_AUTH_ALWAYS_REQUIRED_TO_DISABLE_QUIET_MODE, 96 INDEX_CROSS_PROFILE_CONTENT_SHARING_STRATEGY, 97 INDEX_ALLOW_STOPPING_USER_WITH_DELAYED_LOCKING, 98 INDEX_PROFILE_API_VISIBILITY, 99 INDEX_ITEMS_RESTRICTED_ON_HOME_SCREEN 100 }) 101 @Retention(RetentionPolicy.SOURCE) 102 private @interface PropertyIndex { 103 } 104 private static final int INDEX_SHOW_IN_LAUNCHER = 0; 105 private static final int INDEX_START_WITH_PARENT = 1; 106 private static final int INDEX_SHOW_IN_SETTINGS = 2; 107 private static final int INDEX_INHERIT_DEVICE_POLICY = 3; 108 private static final int INDEX_USE_PARENTS_CONTACTS = 4; 109 private static final int INDEX_UPDATE_CROSS_PROFILE_INTENT_FILTERS_ON_OTA = 5; 110 private static final int INDEX_CROSS_PROFILE_INTENT_FILTER_ACCESS_CONTROL = 6; 111 private static final int INDEX_CROSS_PROFILE_INTENT_RESOLUTION_STRATEGY = 7; 112 private static final int INDEX_MEDIA_SHARED_WITH_PARENT = 8; 113 private static final int INDEX_CREDENTIAL_SHAREABLE_WITH_PARENT = 9; 114 private static final int INDEX_DELETE_APP_WITH_PARENT = 10; 115 private static final int INDEX_ALWAYS_VISIBLE = 11; 116 private static final int INDEX_SHOW_IN_QUIET_MODE = 12; 117 private static final int INDEX_AUTH_ALWAYS_REQUIRED_TO_DISABLE_QUIET_MODE = 13; 118 private static final int INDEX_SHOW_IN_SHARING_SURFACES = 14; 119 private static final int INDEX_CROSS_PROFILE_CONTENT_SHARING_STRATEGY = 15; 120 private static final int INDEX_ALLOW_STOPPING_USER_WITH_DELAYED_LOCKING = 16; 121 private static final int INDEX_PROFILE_API_VISIBILITY = 17; 122 private static final int INDEX_ITEMS_RESTRICTED_ON_HOME_SCREEN = 18; 123 /** A bit set, mapping each PropertyIndex to whether it is present (1) or absent (0). */ 124 private long mPropertiesPresent = 0; 125 126 127 /** 128 * Possible values for whether or how to show this user in the Launcher. 129 * @hide 130 */ 131 @IntDef(prefix = "SHOW_IN_LAUNCHER_", value = { 132 SHOW_IN_LAUNCHER_UNKNOWN, 133 SHOW_IN_LAUNCHER_WITH_PARENT, 134 SHOW_IN_LAUNCHER_SEPARATE, 135 SHOW_IN_LAUNCHER_NO, 136 }) 137 @Retention(RetentionPolicy.SOURCE) 138 public @interface ShowInLauncher { 139 } 140 /** 141 * Indicates that the show in launcher value for this profile is unknown or unsupported. 142 * @hide 143 */ 144 @TestApi 145 @SuppressLint("UnflaggedApi") // b/306636213 146 public static final int SHOW_IN_LAUNCHER_UNKNOWN = -1; 147 /** 148 * Suggests that the launcher should show this user's apps in the main tab. 149 * That is, either this user is a full user, so its apps should be presented accordingly, or, if 150 * this user is a profile, then its apps should be shown alongside its parent's apps. 151 * @hide 152 */ 153 @TestApi 154 public static final int SHOW_IN_LAUNCHER_WITH_PARENT = 0; 155 /** 156 * Suggests that the launcher should show this user's apps, but separately from the apps of this 157 * user's parent. 158 * @hide 159 */ 160 @TestApi 161 public static final int SHOW_IN_LAUNCHER_SEPARATE = 1; 162 /** 163 * Suggests that the launcher should not show this user. 164 * @hide 165 */ 166 @TestApi 167 public static final int SHOW_IN_LAUNCHER_NO = 2; 168 169 /** 170 * Possible values for whether or how to show this user in the Settings app. 171 * @hide 172 */ 173 @IntDef(prefix = "SHOW_IN_SETTINGS_", value = { 174 SHOW_IN_SETTINGS_UNKNOWN, 175 SHOW_IN_SETTINGS_WITH_PARENT, 176 SHOW_IN_SETTINGS_SEPARATE, 177 SHOW_IN_SETTINGS_NO, 178 }) 179 @Retention(RetentionPolicy.SOURCE) 180 public @interface ShowInSettings { 181 } 182 /** 183 * Indicates that the show in settings value for this profile is unknown or unsupported. 184 * @hide 185 */ 186 @SuppressLint("UnflaggedApi") // b/306636213 187 public static final int SHOW_IN_SETTINGS_UNKNOWN = -1; 188 /** 189 * Suggests that the Settings app should show this user's apps in the main tab. 190 * That is, either this user is a full user, so its apps should be presented accordingly, or, if 191 * this user is a profile, then its apps should be shown alongside its parent's apps. 192 * @hide 193 */ 194 public static final int SHOW_IN_SETTINGS_WITH_PARENT = 0; 195 /** 196 * Suggests that the Settings app should show this user's apps, but separately from the apps of 197 * this user's parent. 198 * @hide 199 */ 200 public static final int SHOW_IN_SETTINGS_SEPARATE = 1; 201 /** 202 * Suggests that the Settings app should not show this user. 203 * @hide 204 */ 205 public static final int SHOW_IN_SETTINGS_NO = 2; 206 207 /** 208 * Possible values for whether (and from whom) to inherit select user restrictions 209 * or device policies. 210 * 211 * @hide 212 */ 213 @IntDef(prefix = "INHERIT_DEVICE_POLICY", value = { 214 INHERIT_DEVICE_POLICY_NO, 215 INHERIT_DEVICE_POLICY_FROM_PARENT, 216 }) 217 @Retention(RetentionPolicy.SOURCE) 218 public @interface InheritDevicePolicy { 219 } 220 /** 221 * Suggests that the given user profile should not inherit user restriction or device policy 222 * from any other user. This is the default value for any new user type. 223 * @hide 224 */ 225 public static final int INHERIT_DEVICE_POLICY_NO = 0; 226 /** 227 * Suggests that the given user profile should inherit select user restrictions or 228 * device policies from its parent profile. 229 * 230 *<p> All the user restrictions and device policies would be not propagated to the profile 231 * with this property value. The {@link com.android.server.devicepolicy.DevicePolicyEngine} 232 * uses this property to determine and propagate only select ones to the given profile. 233 * 234 * @hide 235 */ 236 public static final int INHERIT_DEVICE_POLICY_FROM_PARENT = 1; 237 238 /** 239 * Reference to the default user properties for this user's user type. 240 * <li>If non-null, then any absent property will use the default property from here instead. 241 * <li>If null, then any absent property indicates that the caller lacks permission to see it, 242 * so attempting to get that property will trigger a SecurityException. 243 */ 244 private final @Nullable UserProperties mDefaultProperties; 245 246 /** 247 * CrossProfileIntentFilterAccessControlLevel provides level of access for user to create/modify 248 * {@link CrossProfileIntentFilter}. Each level have value assigned, the higher the value 249 * implies higher restriction for creation/modification. 250 * CrossProfileIntentFilterAccessControlLevel allows us to protect against malicious changes in 251 * user's {@link CrossProfileIntentFilter}s, which might add/remove 252 * {@link CrossProfileIntentFilter} leading to unprecedented results. 253 * 254 * @hide 255 */ 256 @IntDef(prefix = {"CROSS_PROFILE_INTENT_FILTER_ACCESS_LEVEL_"}, value = { 257 CROSS_PROFILE_INTENT_FILTER_ACCESS_LEVEL_ALL, 258 CROSS_PROFILE_INTENT_FILTER_ACCESS_LEVEL_SYSTEM, 259 CROSS_PROFILE_INTENT_FILTER_ACCESS_LEVEL_SYSTEM_ADD_ONLY, 260 }) 261 @Retention(RetentionPolicy.SOURCE) 262 public @interface CrossProfileIntentFilterAccessControlLevel { 263 } 264 265 /** 266 * CROSS_PROFILE_INTENT_FILTER_ACCESS_LEVEL_ALL signifies that irrespective of user we would 267 * allow access (addition/modification/removal) for CrossProfileIntentFilter. 268 * This is the default access control level. 269 * 270 * @hide 271 */ 272 public static final int CROSS_PROFILE_INTENT_FILTER_ACCESS_LEVEL_ALL = 0; 273 274 /** 275 * CROSS_PROFILE_INTENT_FILTER_ACCESS_LEVEL_SYSTEM signifies that only system/root user would 276 * be able to access (addition/modification/removal) CrossProfileIntentFilter. 277 * 278 * @hide 279 */ 280 public static final int CROSS_PROFILE_INTENT_FILTER_ACCESS_LEVEL_SYSTEM = 10; 281 282 /** 283 * CROSS_PROFILE_INTENT_FILTER_ACCESS_LEVEL_SYSTEM_ADD_ONLY signifies that only system/root 284 * user would be able to add CrossProfileIntentFilter but not modify/remove. Once added, it 285 * cannot be modified or removed. 286 * 287 * @hide 288 */ 289 public static final int CROSS_PROFILE_INTENT_FILTER_ACCESS_LEVEL_SYSTEM_ADD_ONLY = 20; 290 291 /** 292 * Possible values for cross profile intent resolution strategy. 293 * 294 * @hide 295 */ 296 @IntDef(prefix = {"CROSS_PROFILE_INTENT_RESOLUTION_STRATEGY_"}, value = { 297 CROSS_PROFILE_INTENT_RESOLUTION_STRATEGY_DEFAULT, 298 CROSS_PROFILE_INTENT_RESOLUTION_STRATEGY_NO_FILTERING 299 }) 300 @Retention(RetentionPolicy.SOURCE) 301 public @interface CrossProfileIntentResolutionStrategy { 302 } 303 304 /** 305 * Signifies to use {@link DefaultCrossProfileResolver} strategy, which 306 * check if it needs to skip the initiating profile, resolves intent in target profile. 307 * {@link DefaultCrossProfileResolver} also filters the {@link ResolveInfo} after intent 308 * resolution based on their domain approval level 309 * 310 * @hide 311 */ 312 public static final int CROSS_PROFILE_INTENT_RESOLUTION_STRATEGY_DEFAULT = 0; 313 314 /** 315 * Signifies that there is no need to filter {@link ResolveInfo} after cross profile intent 316 * resolution across. This strategy is for profile acting transparent to end-user and resolves 317 * all allowed intent without giving any profile priority. 318 * 319 * @hide 320 */ 321 public static final int CROSS_PROFILE_INTENT_RESOLUTION_STRATEGY_NO_FILTERING = 1; 322 323 /** 324 * Possible values for the profile visibility when in quiet mode. This affects the profile data 325 * and apps surfacing in Settings, sharing surfaces, and file picker surfaces. It signifies 326 * whether the profile data and apps will be shown or not. 327 * 328 * @hide 329 */ 330 @Retention(RetentionPolicy.SOURCE) 331 @IntDef(prefix = "SHOW_IN_QUIET_MODE_", 332 value = { 333 SHOW_IN_QUIET_MODE_UNKNOWN, 334 SHOW_IN_QUIET_MODE_PAUSED, 335 SHOW_IN_QUIET_MODE_HIDDEN, 336 SHOW_IN_QUIET_MODE_DEFAULT, 337 } 338 ) 339 public @interface ShowInQuietMode { 340 } 341 342 /** 343 * Indicates that the show in quiet mode value for this profile is unknown. 344 */ 345 @SuppressLint("UnflaggedApi") // b/306636213 346 public static final int SHOW_IN_QUIET_MODE_UNKNOWN = -1; 347 348 /** 349 * Indicates that the profile should still be visible in quiet mode but should be shown as 350 * paused (e.g. by greying out its icons). 351 */ 352 @SuppressLint("UnflaggedApi") // b/306636213 353 public static final int SHOW_IN_QUIET_MODE_PAUSED = 0; 354 /** 355 * Indicates that the profile should not be visible when the profile is in quiet mode. 356 * For example, the profile should not be shown in tabbed views in Settings, files sharing 357 * surfaces etc when in quiet mode. 358 */ 359 @SuppressLint("UnflaggedApi") // b/306636213 360 public static final int SHOW_IN_QUIET_MODE_HIDDEN = 1; 361 /** 362 * Indicates that quiet mode should not have any effect on the profile visibility. If the 363 * profile is meant to be visible, it will remain visible and vice versa. 364 */ 365 @SuppressLint("UnflaggedApi") // b/306636213 366 public static final int SHOW_IN_QUIET_MODE_DEFAULT = 2; 367 368 /** 369 * Possible values for the profile apps visibility in sharing surfaces. This indicates the 370 * profile data and apps should be shown in separate tabs or mixed with its parent user's data 371 * and apps in sharing surfaces and file picker surfaces. 372 * 373 * @hide 374 */ 375 @Retention(RetentionPolicy.SOURCE) 376 @IntDef(prefix = "SHOW_IN_SHARING_SURFACES_", 377 value = { 378 SHOW_IN_SHARING_SURFACES_UNKNOWN, 379 SHOW_IN_SHARING_SURFACES_SEPARATE, 380 SHOW_IN_SHARING_SURFACES_WITH_PARENT, 381 SHOW_IN_SHARING_SURFACES_NO, 382 } 383 ) 384 public @interface ShowInSharingSurfaces { 385 } 386 387 /** 388 * Indicates that the show in launcher value for this profile is unknown or unsupported. 389 */ 390 @SuppressLint("UnflaggedApi") // b/306636213 391 public static final int SHOW_IN_SHARING_SURFACES_UNKNOWN = SHOW_IN_LAUNCHER_UNKNOWN; 392 393 /** 394 * Indicates that the profile data and apps should be shown in sharing surfaces intermixed with 395 * parent user's data and apps. 396 */ 397 @SuppressLint("UnflaggedApi") // b/306636213 398 public static final int SHOW_IN_SHARING_SURFACES_WITH_PARENT = SHOW_IN_LAUNCHER_WITH_PARENT; 399 400 /** 401 * Indicates that the profile data and apps should be shown in sharing surfaces separate from 402 * parent user's data and apps. 403 */ 404 @SuppressLint("UnflaggedApi") // b/306636213 405 public static final int SHOW_IN_SHARING_SURFACES_SEPARATE = SHOW_IN_LAUNCHER_SEPARATE; 406 407 /** 408 * Indicates that the profile data and apps should not be shown in sharing surfaces at all. 409 */ 410 @SuppressLint("UnflaggedApi") // b/306636213 411 public static final int SHOW_IN_SHARING_SURFACES_NO = SHOW_IN_LAUNCHER_NO; 412 /** 413 * Possible values for cross profile content sharing strategy for this profile. 414 * 415 * @hide 416 */ 417 @IntDef(prefix = {"CROSS_PROFILE_CONTENT_SHARING_"}, value = { 418 CROSS_PROFILE_CONTENT_SHARING_UNKNOWN, 419 CROSS_PROFILE_CONTENT_SHARING_NO_DELEGATION, 420 CROSS_PROFILE_CONTENT_SHARING_DELEGATE_FROM_PARENT 421 }) 422 @Retention(RetentionPolicy.SOURCE) 423 public @interface CrossProfileContentSharingStrategy { 424 } 425 426 /** 427 * Signifies that cross-profile content sharing strategy, both to and from this profile, is 428 * unknown/unsupported. 429 */ 430 @SuppressLint("UnflaggedApi") // b/306636213 431 public static final int CROSS_PROFILE_CONTENT_SHARING_UNKNOWN = -1; 432 433 /** 434 * Signifies that cross-profile content sharing strategy, both to and from this profile, should 435 * not be delegated to any other user/profile. 436 * For ex: 437 * If this property is set for a profile, content sharing applications (such as Android 438 * Sharesheet), should not delegate the decision to share content between that profile and 439 * another profile to whether content sharing is allowed between any other profile/user related 440 * to those profiles. They should instead decide, based upon whether content sharing is 441 * specifically allowed between the two profiles in question. 442 */ 443 @SuppressLint("UnflaggedApi") // b/306636213 444 public static final int CROSS_PROFILE_CONTENT_SHARING_NO_DELEGATION = 0; 445 446 /** 447 * Signifies that cross-profile content sharing strategy, both to and from this profile, should 448 * be based upon the strategy used by the parent user of the profile. 449 * For ex: 450 * If this property is set for a profile A, content sharing applications (such as Android 451 * Sharesheet), should share content between profile A and profile B, based upon whether content 452 * sharing is allowed between the parent of profile A and profile B. 453 * If it's also set for profile B, then decision should, in turn be made by considering content 454 * sharing strategy between the parents of both profiles. 455 */ 456 @SuppressLint("UnflaggedApi") // b/306636213 457 public static final int CROSS_PROFILE_CONTENT_SHARING_DELEGATE_FROM_PARENT = 1; 458 459 /** 460 * Possible values for the profile visibility in public API surfaces. This indicates whether or 461 * not the information linked to the profile (userId, package names) should not be returned in 462 * API surfaces if a user is marked as hidden. 463 * 464 * @hide 465 */ 466 @Retention(RetentionPolicy.SOURCE) 467 @IntDef(prefix = "PROFILE_API_VISIBILITY_", 468 value = { 469 PROFILE_API_VISIBILITY_UNKNOWN, 470 PROFILE_API_VISIBILITY_VISIBLE, 471 PROFILE_API_VISIBILITY_HIDDEN, 472 } 473 ) 474 public @interface ProfileApiVisibility { 475 } 476 477 /** 478 * The api visibility value for this profile user is undefined or unknown. 479 * 480 * @hide 481 */ 482 public static final int PROFILE_API_VISIBILITY_UNKNOWN = -1; 483 484 /** 485 * Indicates that information about this profile user should be shown in API surfaces. 486 * 487 * @hide 488 */ 489 public static final int PROFILE_API_VISIBILITY_VISIBLE = 0; 490 491 /** 492 * Indicates that information about this profile should be not be visible in API surfaces. 493 * 494 * @hide 495 */ 496 public static final int PROFILE_API_VISIBILITY_HIDDEN = 1; 497 498 499 /** 500 * Creates a UserProperties (intended for the SystemServer) that stores a reference to the given 501 * default properties, which it uses for any property not subsequently set. 502 * @hide 503 */ UserProperties(@onNull UserProperties defaultProperties)504 public UserProperties(@NonNull UserProperties defaultProperties) { 505 mDefaultProperties = defaultProperties; 506 mPropertiesPresent = 0; 507 } 508 509 /** 510 * Copies the given UserProperties, excluding any information that doesn't satisfy the specified 511 * permissions. 512 * Can only be used on the original version (one that won't throw on permission errors). 513 * Note that, internally, this does not perform an exact copy. 514 * @hide 515 */ UserProperties(UserProperties orig, boolean exposeAllFields, boolean hasManagePermission, boolean hasQueryOrManagePermission)516 public UserProperties(UserProperties orig, 517 boolean exposeAllFields, 518 boolean hasManagePermission, 519 boolean hasQueryOrManagePermission) { 520 521 if (orig.mDefaultProperties == null) { 522 throw new IllegalArgumentException("Attempting to copy a non-original UserProperties."); 523 } 524 525 this.mDefaultProperties = null; 526 527 // Insert each setter into the following hierarchy based on its permission requirements. 528 // NOTE: Copy each property using getters to ensure default values are copied if needed. 529 if (exposeAllFields) { 530 // Add items that require exposeAllFields to be true (strictest permission level). 531 setStartWithParent(orig.getStartWithParent()); 532 setInheritDevicePolicy(orig.getInheritDevicePolicy()); 533 setUpdateCrossProfileIntentFiltersOnOTA(orig.getUpdateCrossProfileIntentFiltersOnOTA()); 534 setCrossProfileIntentFilterAccessControl( 535 orig.getCrossProfileIntentFilterAccessControl()); 536 setCrossProfileIntentResolutionStrategy(orig.getCrossProfileIntentResolutionStrategy()); 537 setDeleteAppWithParent(orig.getDeleteAppWithParent()); 538 setAlwaysVisible(orig.getAlwaysVisible()); 539 setAllowStoppingUserWithDelayedLocking(orig.getAllowStoppingUserWithDelayedLocking()); 540 } 541 if (hasManagePermission) { 542 // Add items that require MANAGE_USERS or stronger. 543 setShowInSettings(orig.getShowInSettings()); 544 setUseParentsContacts(orig.getUseParentsContacts()); 545 setAuthAlwaysRequiredToDisableQuietMode( 546 orig.isAuthAlwaysRequiredToDisableQuietMode()); 547 } 548 if (hasQueryOrManagePermission) { 549 // Add items that require QUERY_USERS or stronger. 550 } 551 // Add items that have no permission requirements at all. 552 setShowInLauncher(orig.getShowInLauncher()); 553 setMediaSharedWithParent(orig.isMediaSharedWithParent()); 554 setCredentialShareableWithParent(orig.isCredentialShareableWithParent()); 555 setShowInQuietMode(orig.getShowInQuietMode()); 556 setShowInSharingSurfaces(orig.getShowInSharingSurfaces()); 557 setCrossProfileContentSharingStrategy(orig.getCrossProfileContentSharingStrategy()); 558 setProfileApiVisibility(orig.getProfileApiVisibility()); 559 setItemsRestrictedOnHomeScreen(orig.areItemsRestrictedOnHomeScreen()); 560 } 561 562 /** 563 * Indicates that the given property is being stored explicitly in this object. 564 * If false, it means that either 565 * <li>the default property for the user type should be used instead (for SystemServer callers) 566 * <li>the caller lacks permission to see this property (for all other callers) 567 */ isPresent(@ropertyIndex long index)568 private boolean isPresent(@PropertyIndex long index) { 569 return (mPropertiesPresent & (1L << index)) != 0; 570 } 571 572 /** Indicates that the given property is henceforth being explicitly stored in this object. */ setPresent(@ropertyIndex long index)573 private void setPresent(@PropertyIndex long index) { 574 mPropertiesPresent |= (1L << index); 575 } 576 577 /** @hide Returns the internal mPropertiesPresent value. Only for testing purposes. */ 578 @VisibleForTesting getPropertiesPresent()579 public long getPropertiesPresent() { 580 return mPropertiesPresent; 581 } 582 583 /** 584 * Returns whether, and how, a user should be shown in the Launcher. 585 * This is generally inapplicable for non-profile users. 586 * 587 * Possible return values include 588 * {@link #SHOW_IN_LAUNCHER_WITH_PARENT}}, 589 * {@link #SHOW_IN_LAUNCHER_SEPARATE}, 590 * and {@link #SHOW_IN_LAUNCHER_NO}. 591 * 592 * @return whether, and how, a profile should be shown in the Launcher. 593 * @hide 594 */ 595 @TestApi getShowInLauncher()596 public @ShowInLauncher int getShowInLauncher() { 597 if (isPresent(INDEX_SHOW_IN_LAUNCHER)) return mShowInLauncher; 598 if (mDefaultProperties != null) return mDefaultProperties.mShowInLauncher; 599 throw new SecurityException("You don't have permission to query showInLauncher"); 600 } 601 /** @hide */ setShowInLauncher(@howInLauncher int val)602 public void setShowInLauncher(@ShowInLauncher int val) { 603 this.mShowInLauncher = val; 604 setPresent(INDEX_SHOW_IN_LAUNCHER); 605 } 606 private @ShowInLauncher int mShowInLauncher; 607 608 /** 609 * Returns whether, and how, a user should be shown in the Settings app. 610 * This is generally inapplicable for non-profile users. 611 * 612 * Possible return values include 613 * {@link #SHOW_IN_SETTINGS_WITH_PARENT}}, 614 * {@link #SHOW_IN_SETTINGS_SEPARATE}, 615 * and {@link #SHOW_IN_SETTINGS_NO}. 616 * 617 * <p> The caller must have {@link android.Manifest.permission#MANAGE_USERS} to query this 618 * property. 619 * 620 * @return whether, and how, a profile should be shown in the Settings. 621 * @hide 622 */ getShowInSettings()623 public @ShowInSettings int getShowInSettings() { 624 if (isPresent(INDEX_SHOW_IN_SETTINGS)) return mShowInSettings; 625 if (mDefaultProperties != null) return mDefaultProperties.mShowInSettings; 626 throw new SecurityException("You don't have permission to query mShowInSettings"); 627 } 628 /** @hide */ setShowInSettings(@howInSettings int val)629 public void setShowInSettings(@ShowInSettings int val) { 630 this.mShowInSettings = val; 631 setPresent(INDEX_SHOW_IN_SETTINGS); 632 } 633 private @ShowInSettings int mShowInSettings; 634 635 /** 636 * Returns whether a user should be shown in the Settings and sharing surfaces depending on the 637 * {@link android.os.UserManager#requestQuietModeEnabled(boolean, android.os.UserHandle) 638 * quiet mode}. This is only applicable to profile users since the quiet mode concept is only 639 * applicable to profile users. 640 * 641 * <p> Please note that, in Settings, this property takes effect only if 642 * {@link #getShowInSettings()} does not return {@link #SHOW_IN_SETTINGS_NO}. 643 * Also note that in Sharing surfaces this property takes effect only if 644 * {@link #getShowInSharingSurfaces()} does not return {@link #SHOW_IN_SHARING_SURFACES_NO}. 645 * 646 * @return One of {@link #SHOW_IN_QUIET_MODE_HIDDEN}, 647 * {@link #SHOW_IN_QUIET_MODE_PAUSED}, or 648 * {@link #SHOW_IN_QUIET_MODE_DEFAULT} depending on whether the profile should be 649 * shown in quiet mode or not. 650 */ 651 @SuppressLint("UnflaggedApi") // b/306636213 getShowInQuietMode()652 public @ShowInQuietMode int getShowInQuietMode() { 653 // NOTE: Launcher currently does not make use of this property. 654 if (isPresent(INDEX_SHOW_IN_QUIET_MODE)) return mShowInQuietMode; 655 if (mDefaultProperties != null) return mDefaultProperties.mShowInQuietMode; 656 throw new SecurityException( 657 "You don't have permission to query ShowInQuietMode"); 658 } 659 /** @hide */ setShowInQuietMode(@howInQuietMode int showInQuietMode)660 public void setShowInQuietMode(@ShowInQuietMode int showInQuietMode) { 661 this.mShowInQuietMode = showInQuietMode; 662 setPresent(INDEX_SHOW_IN_QUIET_MODE); 663 } 664 private int mShowInQuietMode; 665 666 /** 667 * Returns whether a user's data and apps should be shown in sharing surfaces in a separate tab 668 * or mixed with the parent user's data/apps. This is only applicable to profile users. 669 * 670 * @return One of {@link #SHOW_IN_SHARING_SURFACES_NO}, 671 * {@link #SHOW_IN_SHARING_SURFACES_SEPARATE}, or 672 * {@link #SHOW_IN_SHARING_SURFACES_WITH_PARENT} depending on whether the profile 673 * should be shown separate from its parent's data, mixed with the parent's data, or 674 * not shown at all. 675 */ 676 @SuppressLint("UnflaggedApi") // b/306636213 getShowInSharingSurfaces()677 public @ShowInSharingSurfaces int getShowInSharingSurfaces() { 678 if (isPresent(INDEX_SHOW_IN_SHARING_SURFACES)) return mShowInSharingSurfaces; 679 if (mDefaultProperties != null) return mDefaultProperties.mShowInSharingSurfaces; 680 throw new SecurityException( 681 "You don't have permission to query ShowInSharingSurfaces"); 682 } 683 /** @hide */ setShowInSharingSurfaces(@howInSharingSurfaces int showInSharingSurfaces)684 public void setShowInSharingSurfaces(@ShowInSharingSurfaces int showInSharingSurfaces) { 685 this.mShowInSharingSurfaces = showInSharingSurfaces; 686 setPresent(INDEX_SHOW_IN_SHARING_SURFACES); 687 } 688 private int mShowInSharingSurfaces; 689 690 /** 691 * Returns whether a profile should be started when its parent starts (unless in quiet mode). 692 * This only applies for users that have parents (i.e. for profiles). 693 * @hide 694 */ getStartWithParent()695 public boolean getStartWithParent() { 696 if (isPresent(INDEX_START_WITH_PARENT)) return mStartWithParent; 697 if (mDefaultProperties != null) return mDefaultProperties.mStartWithParent; 698 throw new SecurityException("You don't have permission to query startWithParent"); 699 } 700 /** @hide */ setStartWithParent(boolean val)701 public void setStartWithParent(boolean val) { 702 this.mStartWithParent = val; 703 setPresent(INDEX_START_WITH_PARENT); 704 } 705 private boolean mStartWithParent; 706 707 /** 708 * Returns whether an app in the profile should be deleted when the same package in 709 * the parent user is being deleted. 710 * This only applies for users that have parents (i.e. for profiles). 711 * @hide 712 */ getDeleteAppWithParent()713 public boolean getDeleteAppWithParent() { 714 if (isPresent(INDEX_DELETE_APP_WITH_PARENT)) return mDeleteAppWithParent; 715 if (mDefaultProperties != null) return mDefaultProperties.mDeleteAppWithParent; 716 throw new SecurityException("You don't have permission to query deleteAppWithParent"); 717 } 718 /** @hide */ setDeleteAppWithParent(boolean val)719 public void setDeleteAppWithParent(boolean val) { 720 this.mDeleteAppWithParent = val; 721 setPresent(INDEX_DELETE_APP_WITH_PARENT); 722 } 723 private boolean mDeleteAppWithParent; 724 725 /** 726 * Returns whether the user should always 727 * be {@link android.os.UserManager#isUserVisible() visible}. 728 * The intended usage is for the Communal Profile, which is running and accessible at all times. 729 * @hide 730 */ getAlwaysVisible()731 public boolean getAlwaysVisible() { 732 if (isPresent(INDEX_ALWAYS_VISIBLE)) return mAlwaysVisible; 733 if (mDefaultProperties != null) return mDefaultProperties.mAlwaysVisible; 734 throw new SecurityException("You don't have permission to query alwaysVisible"); 735 } 736 /** @hide */ setAlwaysVisible(boolean val)737 public void setAlwaysVisible(boolean val) { 738 this.mAlwaysVisible = val; 739 setPresent(INDEX_ALWAYS_VISIBLE); 740 } 741 private boolean mAlwaysVisible; 742 743 /** 744 * Return whether, and how, select user restrictions or device policies should be inherited 745 * from other user. 746 * 747 * Possible return values include 748 * {@link #INHERIT_DEVICE_POLICY_FROM_PARENT} or {@link #INHERIT_DEVICE_POLICY_NO} 749 * 750 * @hide 751 */ getInheritDevicePolicy()752 public @InheritDevicePolicy int getInheritDevicePolicy() { 753 if (isPresent(INDEX_INHERIT_DEVICE_POLICY)) return mInheritDevicePolicy; 754 if (mDefaultProperties != null) return mDefaultProperties.mInheritDevicePolicy; 755 throw new SecurityException("You don't have permission to query inheritDevicePolicy"); 756 } 757 /** @hide */ setInheritDevicePolicy(@nheritDevicePolicy int val)758 public void setInheritDevicePolicy(@InheritDevicePolicy int val) { 759 this.mInheritDevicePolicy = val; 760 setPresent(INDEX_INHERIT_DEVICE_POLICY); 761 } 762 private @InheritDevicePolicy int mInheritDevicePolicy; 763 764 /** 765 * Returns whether the current user must use parent user's contacts. If true, writes to the 766 * ContactsProvider corresponding to the current user will be disabled and reads will be 767 * redirected to the parent. 768 * 769 * This only applies to users that have parents (i.e. profiles) and is used to ensure 770 * they can access contacts from the parent profile. This will be generally inapplicable for 771 * non-profile users. 772 * 773 * Please note that in case of the clone profiles, only the allow-listed apps would be allowed 774 * to access contacts across profiles and other apps will not see any contacts. 775 * TODO(b/256126819) Add link to the method returning apps allow-listed for app-cloning 776 * 777 * @return whether contacts access from an associated profile is enabled for the user 778 * @hide 779 */ getUseParentsContacts()780 public boolean getUseParentsContacts() { 781 if (isPresent(INDEX_USE_PARENTS_CONTACTS)) return mUseParentsContacts; 782 if (mDefaultProperties != null) return mDefaultProperties.mUseParentsContacts; 783 throw new SecurityException("You don't have permission to query useParentsContacts"); 784 } 785 /** @hide */ setUseParentsContacts(boolean val)786 public void setUseParentsContacts(boolean val) { 787 this.mUseParentsContacts = val; 788 setPresent(INDEX_USE_PARENTS_CONTACTS); 789 } 790 /** 791 * Indicates whether the current user should use parent user's contacts. 792 * If this property is set true, the user will be blocked from storing any contacts in its 793 * own contacts database and will serve all read contacts calls through the parent's contacts. 794 */ 795 private boolean mUseParentsContacts; 796 797 /** 798 * Returns true if user needs to update default 799 * {@link com.android.server.pm.CrossProfileIntentFilter} with its parents during an OTA update 800 * @hide 801 */ getUpdateCrossProfileIntentFiltersOnOTA()802 public boolean getUpdateCrossProfileIntentFiltersOnOTA() { 803 if (isPresent(INDEX_UPDATE_CROSS_PROFILE_INTENT_FILTERS_ON_OTA)) { 804 return mUpdateCrossProfileIntentFiltersOnOTA; 805 } 806 if (mDefaultProperties != null) { 807 return mDefaultProperties.mUpdateCrossProfileIntentFiltersOnOTA; 808 } 809 throw new SecurityException("You don't have permission to query " 810 + "updateCrossProfileIntentFiltersOnOTA"); 811 } 812 /** @hide */ setUpdateCrossProfileIntentFiltersOnOTA(boolean val)813 public void setUpdateCrossProfileIntentFiltersOnOTA(boolean val) { 814 this.mUpdateCrossProfileIntentFiltersOnOTA = val; 815 setPresent(INDEX_UPDATE_CROSS_PROFILE_INTENT_FILTERS_ON_OTA); 816 } 817 /** 818 Indicate if {@link com.android.server.pm.CrossProfileIntentFilter}s need to be updated during 819 OTA update between user-parent 820 */ 821 private boolean mUpdateCrossProfileIntentFiltersOnOTA; 822 823 /** 824 * Returns whether a profile shares media with its parent user. 825 * This only applies for users that have parents (i.e. for profiles). 826 */ isMediaSharedWithParent()827 public boolean isMediaSharedWithParent() { 828 if (isPresent(INDEX_MEDIA_SHARED_WITH_PARENT)) return mMediaSharedWithParent; 829 if (mDefaultProperties != null) return mDefaultProperties.mMediaSharedWithParent; 830 throw new SecurityException("You don't have permission to query mediaSharedWithParent"); 831 } 832 /** @hide */ setMediaSharedWithParent(boolean val)833 public void setMediaSharedWithParent(boolean val) { 834 this.mMediaSharedWithParent = val; 835 setPresent(INDEX_MEDIA_SHARED_WITH_PARENT); 836 } 837 private boolean mMediaSharedWithParent; 838 839 /** 840 * Returns whether a profile can have shared lockscreen credential with its parent user. 841 * This only applies for users that have parents (i.e. for profiles). 842 */ isCredentialShareableWithParent()843 public boolean isCredentialShareableWithParent() { 844 if (isPresent(INDEX_CREDENTIAL_SHAREABLE_WITH_PARENT)) { 845 return mCredentialShareableWithParent; 846 } 847 if (mDefaultProperties != null) return mDefaultProperties.mCredentialShareableWithParent; 848 throw new SecurityException( 849 "You don't have permission to query credentialShareableWithParent"); 850 } 851 /** @hide */ setCredentialShareableWithParent(boolean val)852 public void setCredentialShareableWithParent(boolean val) { 853 this.mCredentialShareableWithParent = val; 854 setPresent(INDEX_CREDENTIAL_SHAREABLE_WITH_PARENT); 855 } 856 private boolean mCredentialShareableWithParent; 857 858 /** 859 * Returns whether the profile always requires user authentication to disable from quiet mode. 860 * 861 * <p> Settings this field to true will ensure that the credential confirmation activity is 862 * always shown whenever the user requests to disable quiet mode. The behavior of credential 863 * checks is not guaranteed when the property is false and may vary depending on user types. 864 * @hide 865 */ isAuthAlwaysRequiredToDisableQuietMode()866 public boolean isAuthAlwaysRequiredToDisableQuietMode() { 867 if (isPresent(INDEX_AUTH_ALWAYS_REQUIRED_TO_DISABLE_QUIET_MODE)) { 868 return mAuthAlwaysRequiredToDisableQuietMode; 869 } 870 if (mDefaultProperties != null) { 871 return mDefaultProperties.mAuthAlwaysRequiredToDisableQuietMode; 872 } 873 throw new SecurityException( 874 "You don't have permission to query authAlwaysRequiredToDisableQuietMode"); 875 } 876 /** @hide */ setAuthAlwaysRequiredToDisableQuietMode(boolean val)877 public void setAuthAlwaysRequiredToDisableQuietMode(boolean val) { 878 this.mAuthAlwaysRequiredToDisableQuietMode = val; 879 setPresent(INDEX_AUTH_ALWAYS_REQUIRED_TO_DISABLE_QUIET_MODE); 880 } 881 private boolean mAuthAlwaysRequiredToDisableQuietMode; 882 883 /** 884 * Returns whether a user (usually a profile) is allowed to leave the CE storage unlocked when 885 * stopped. 886 * 887 * <p> Setting this property to true will enable the user's CE storage to remain unlocked when 888 * the user is stopped using 889 * {@link com.android.server.am.ActivityManagerService#stopUserWithDelayedLocking(int, 890 * IStopUserCallback)}. 891 * 892 * <p> When this property is false, delayed locking may still be applicable at a global 893 * level for all users via the {@code config_multiuserDelayUserDataLocking}. That is, delayed 894 * locking for a user can happen if either the device configuration is set or if this property 895 * is set. When both, the config and the property value is false, the user storage is always 896 * locked when the user is stopped. 897 * @hide 898 */ getAllowStoppingUserWithDelayedLocking()899 public boolean getAllowStoppingUserWithDelayedLocking() { 900 if (isPresent(INDEX_ALLOW_STOPPING_USER_WITH_DELAYED_LOCKING)) { 901 return mAllowStoppingUserWithDelayedLocking; 902 } 903 if (mDefaultProperties != null) { 904 return mDefaultProperties.mAllowStoppingUserWithDelayedLocking; 905 } 906 throw new SecurityException( 907 "You don't have permission to query allowStoppingUserWithDelayedLocking"); 908 } 909 /** @hide */ setAllowStoppingUserWithDelayedLocking(boolean val)910 public void setAllowStoppingUserWithDelayedLocking(boolean val) { 911 this.mAllowStoppingUserWithDelayedLocking = val; 912 setPresent(INDEX_ALLOW_STOPPING_USER_WITH_DELAYED_LOCKING); 913 } 914 private boolean mAllowStoppingUserWithDelayedLocking; 915 916 /** 917 * Returns the user's {@link CrossProfileIntentFilterAccessControlLevel}. 918 * @hide 919 */ 920 public @CrossProfileIntentFilterAccessControlLevel int getCrossProfileIntentFilterAccessControl()921 getCrossProfileIntentFilterAccessControl() { 922 if (isPresent(INDEX_CROSS_PROFILE_INTENT_FILTER_ACCESS_CONTROL)) { 923 return mCrossProfileIntentFilterAccessControl; 924 } 925 if (mDefaultProperties != null) { 926 return mDefaultProperties.mCrossProfileIntentFilterAccessControl; 927 } 928 throw new SecurityException("You don't have permission to query " 929 + "crossProfileIntentFilterAccessControl"); 930 } 931 /** 932 * Sets {@link CrossProfileIntentFilterAccessControlLevel} for the user. 933 * @param val access control for user 934 * @hide 935 */ setCrossProfileIntentFilterAccessControl( @rossProfileIntentFilterAccessControlLevel int val)936 public void setCrossProfileIntentFilterAccessControl( 937 @CrossProfileIntentFilterAccessControlLevel int val) { 938 this.mCrossProfileIntentFilterAccessControl = val; 939 setPresent(INDEX_CROSS_PROFILE_INTENT_FILTER_ACCESS_CONTROL); 940 } 941 private @CrossProfileIntentFilterAccessControlLevel int mCrossProfileIntentFilterAccessControl; 942 943 /** 944 * Returns the user's {@link CrossProfileIntentResolutionStrategy}. 945 * @return user's {@link CrossProfileIntentResolutionStrategy}. 946 * 947 * @hide 948 */ getCrossProfileIntentResolutionStrategy()949 public @CrossProfileIntentResolutionStrategy int getCrossProfileIntentResolutionStrategy() { 950 if (isPresent(INDEX_CROSS_PROFILE_INTENT_RESOLUTION_STRATEGY)) { 951 return mCrossProfileIntentResolutionStrategy; 952 } 953 if (mDefaultProperties != null) { 954 return mDefaultProperties.mCrossProfileIntentResolutionStrategy; 955 } 956 throw new SecurityException("You don't have permission to query " 957 + "crossProfileIntentResolutionStrategy"); 958 } 959 960 /** @hide */ setCrossProfileIntentResolutionStrategy( @rossProfileIntentResolutionStrategy int val)961 public void setCrossProfileIntentResolutionStrategy( 962 @CrossProfileIntentResolutionStrategy int val) { 963 this.mCrossProfileIntentResolutionStrategy = val; 964 setPresent(INDEX_CROSS_PROFILE_INTENT_RESOLUTION_STRATEGY); 965 } 966 private @CrossProfileIntentResolutionStrategy int mCrossProfileIntentResolutionStrategy; 967 968 /** 969 * Returns the user's {@link CrossProfileContentSharingStrategy}. 970 * 971 * Content sharing applications, such as Android Sharesheet allow sharing of content 972 * (an image, for ex.) between profiles, based upon cross-profile access checks between the 973 * originating and destined profile. 974 * In some cases however, we may want another user (such as profile parent) to serve as the 975 * delegated user to be used for such checks. 976 * To effect the same, clients can fetch this property and accordingly replace the 977 * originating/destined profile by another user for cross-profile access checks. 978 * 979 * @return user's {@link CrossProfileContentSharingStrategy}. 980 */ 981 @SuppressLint("UnflaggedApi") // b/306636213 getCrossProfileContentSharingStrategy()982 public @CrossProfileContentSharingStrategy int getCrossProfileContentSharingStrategy() { 983 if (isPresent(INDEX_CROSS_PROFILE_CONTENT_SHARING_STRATEGY)) { 984 return mCrossProfileContentSharingStrategy; 985 } 986 if (mDefaultProperties != null) { 987 return mDefaultProperties.mCrossProfileContentSharingStrategy; 988 } 989 throw new SecurityException("You don't have permission to query " 990 + "crossProfileContentSharingStrategy"); 991 } 992 993 /** @hide */ setCrossProfileContentSharingStrategy( @rossProfileContentSharingStrategy int val)994 public void setCrossProfileContentSharingStrategy( 995 @CrossProfileContentSharingStrategy int val) { 996 this.mCrossProfileContentSharingStrategy = val; 997 setPresent(INDEX_CROSS_PROFILE_CONTENT_SHARING_STRATEGY); 998 } 999 private @CrossProfileContentSharingStrategy int mCrossProfileContentSharingStrategy; 1000 1001 /** 1002 * Returns the visibility of the profile user in API surfaces. Any information linked to the 1003 * profile (userId, package names) should be hidden API surfaces if a user is marked as hidden. 1004 * 1005 * @hide 1006 */ 1007 @NonNull getProfileApiVisibility()1008 public @ProfileApiVisibility int getProfileApiVisibility() { 1009 if (isPresent(INDEX_PROFILE_API_VISIBILITY)) return mProfileApiVisibility; 1010 if (mDefaultProperties != null) return mDefaultProperties.mProfileApiVisibility; 1011 throw new SecurityException("You don't have permission to query profileApiVisibility"); 1012 } 1013 /** @hide */ 1014 @NonNull setProfileApiVisibility(@rofileApiVisibility int profileApiVisibility)1015 public void setProfileApiVisibility(@ProfileApiVisibility int profileApiVisibility) { 1016 this.mProfileApiVisibility = profileApiVisibility; 1017 setPresent(INDEX_PROFILE_API_VISIBILITY); 1018 } 1019 private @ProfileApiVisibility int mProfileApiVisibility; 1020 1021 /** 1022 * Returns whether a user (usually a profile) is allowed to have items such as Apps Pending 1023 * Installation, Widgets, Custom App Shortcuts, etc. on Launcher home screen. 1024 * 1025 * <p> For a typical user/profile, this property will be false, allowing framework APIs to 1026 * provide information about such items to Launcher(s). When set true, framework APIs will 1027 * restrict the same. 1028 * 1029 * <p> This property only restricts information about items that are accessed solely via the 1030 * Launcher home screen. Information about items such as App Icons, Deep Links, which can also 1031 * be accessed via other launcher components, such as All Apps Drawer is not restricted by this 1032 * property. 1033 * 1034 * @hide 1035 */ areItemsRestrictedOnHomeScreen()1036 public boolean areItemsRestrictedOnHomeScreen() { 1037 if (isPresent(INDEX_ITEMS_RESTRICTED_ON_HOME_SCREEN)) { 1038 return mItemsRestrictedOnHomeScreen; 1039 } 1040 if (mDefaultProperties != null) { 1041 return mDefaultProperties.mItemsRestrictedOnHomeScreen; 1042 } 1043 throw new SecurityException( 1044 "You don't have permission to query mItemsRestrictedOnHomeScreen"); 1045 } 1046 /** @hide */ setItemsRestrictedOnHomeScreen(boolean val)1047 public void setItemsRestrictedOnHomeScreen(boolean val) { 1048 this.mItemsRestrictedOnHomeScreen = val; 1049 setPresent(INDEX_ITEMS_RESTRICTED_ON_HOME_SCREEN); 1050 } 1051 private boolean mItemsRestrictedOnHomeScreen; 1052 1053 @Override toString()1054 public String toString() { 1055 // Please print in increasing order of PropertyIndex. 1056 return "UserProperties{" 1057 + "mPropertiesPresent=" + Long.toBinaryString(mPropertiesPresent) 1058 + ", mShowInLauncher=" + getShowInLauncher() 1059 + ", mStartWithParent=" + getStartWithParent() 1060 + ", mShowInSettings=" + getShowInSettings() 1061 + ", mInheritDevicePolicy=" + getInheritDevicePolicy() 1062 + ", mUseParentsContacts=" + getUseParentsContacts() 1063 + ", mUpdateCrossProfileIntentFiltersOnOTA=" 1064 + getUpdateCrossProfileIntentFiltersOnOTA() 1065 + ", mCrossProfileIntentFilterAccessControl=" 1066 + getCrossProfileIntentFilterAccessControl() 1067 + ", mCrossProfileIntentResolutionStrategy=" 1068 + getCrossProfileIntentResolutionStrategy() 1069 + ", mMediaSharedWithParent=" + isMediaSharedWithParent() 1070 + ", mCredentialShareableWithParent=" + isCredentialShareableWithParent() 1071 + ", mAuthAlwaysRequiredToDisableQuietMode=" 1072 + isAuthAlwaysRequiredToDisableQuietMode() 1073 + ", mAllowStoppingUserWithDelayedLocking=" 1074 + getAllowStoppingUserWithDelayedLocking() 1075 + ", mDeleteAppWithParent=" + getDeleteAppWithParent() 1076 + ", mAlwaysVisible=" + getAlwaysVisible() 1077 + ", mCrossProfileContentSharingStrategy=" + getCrossProfileContentSharingStrategy() 1078 + ", mProfileApiVisibility=" + getProfileApiVisibility() 1079 + ", mItemsRestrictedOnHomeScreen=" + areItemsRestrictedOnHomeScreen() 1080 + "}"; 1081 } 1082 1083 /** 1084 * Print the UserProperties to the given PrintWriter. 1085 * @hide 1086 */ println(PrintWriter pw, String prefix)1087 public void println(PrintWriter pw, String prefix) { 1088 // Please print in increasing order of PropertyIndex. 1089 pw.println(prefix + "UserProperties:"); 1090 pw.println(prefix + " mPropertiesPresent=" + Long.toBinaryString(mPropertiesPresent)); 1091 pw.println(prefix + " mShowInLauncher=" + getShowInLauncher()); 1092 pw.println(prefix + " mStartWithParent=" + getStartWithParent()); 1093 pw.println(prefix + " mShowInSettings=" + getShowInSettings()); 1094 pw.println(prefix + " mInheritDevicePolicy=" + getInheritDevicePolicy()); 1095 pw.println(prefix + " mUseParentsContacts=" + getUseParentsContacts()); 1096 pw.println(prefix + " mUpdateCrossProfileIntentFiltersOnOTA=" 1097 + getUpdateCrossProfileIntentFiltersOnOTA()); 1098 pw.println(prefix + " mCrossProfileIntentFilterAccessControl=" 1099 + getCrossProfileIntentFilterAccessControl()); 1100 pw.println(prefix + " mCrossProfileIntentResolutionStrategy=" 1101 + getCrossProfileIntentResolutionStrategy()); 1102 pw.println(prefix + " mMediaSharedWithParent=" + isMediaSharedWithParent()); 1103 pw.println(prefix + " mCredentialShareableWithParent=" 1104 + isCredentialShareableWithParent()); 1105 pw.println(prefix + " mAuthAlwaysRequiredToDisableQuietMode=" 1106 + isAuthAlwaysRequiredToDisableQuietMode()); 1107 pw.println(prefix + " mAllowStoppingUserWithDelayedLocking=" 1108 + getAllowStoppingUserWithDelayedLocking()); 1109 pw.println(prefix + " mDeleteAppWithParent=" + getDeleteAppWithParent()); 1110 pw.println(prefix + " mAlwaysVisible=" + getAlwaysVisible()); 1111 pw.println(prefix + " mCrossProfileContentSharingStrategy=" 1112 + getCrossProfileContentSharingStrategy()); 1113 pw.println(prefix + " mProfileApiVisibility=" + getProfileApiVisibility()); 1114 pw.println(prefix + " mItemsRestrictedOnHomeScreen=" + areItemsRestrictedOnHomeScreen()); 1115 } 1116 1117 /** 1118 * Reads in a UserProperties from an xml file, for use by the SystemServer. 1119 * 1120 * The serializer should already be inside a tag from which to read the user properties. 1121 * 1122 * @param defaultUserPropertiesReference the default UserProperties to use for this user type. 1123 * @see #writeToXml 1124 * @hide 1125 */ UserProperties( TypedXmlPullParser parser, @NonNull UserProperties defaultUserPropertiesReference)1126 public UserProperties( 1127 TypedXmlPullParser parser, 1128 @NonNull UserProperties defaultUserPropertiesReference) 1129 throws IOException, XmlPullParserException { 1130 1131 this(defaultUserPropertiesReference); 1132 updateFromXml(parser); 1133 } 1134 1135 /** 1136 * Parses the given xml file and updates this UserProperties with its data. 1137 * I.e., if a piece of data is present in the xml, it will overwrite whatever was 1138 * previously stored in this UserProperties. 1139 * @hide 1140 */ updateFromXml(TypedXmlPullParser parser)1141 public void updateFromXml(TypedXmlPullParser parser) 1142 throws IOException, XmlPullParserException { 1143 1144 final int attributeCount = parser.getAttributeCount(); 1145 for (int i = 0; i < attributeCount; i++) { 1146 final String attributeName = parser.getAttributeName(i); 1147 switch(attributeName) { 1148 case ATTR_SHOW_IN_LAUNCHER: 1149 setShowInLauncher(parser.getAttributeInt(i)); 1150 break; 1151 case ATTR_START_WITH_PARENT: 1152 setStartWithParent(parser.getAttributeBoolean(i)); 1153 break; 1154 case ATTR_SHOW_IN_SETTINGS: 1155 setShowInSettings(parser.getAttributeInt(i)); 1156 break; 1157 case ATTR_SHOW_IN_QUIET_MODE: 1158 setShowInQuietMode(parser.getAttributeInt(i)); 1159 break; 1160 case ATTR_SHOW_IN_SHARING_SURFACES: 1161 setShowInSharingSurfaces(parser.getAttributeInt(i)); 1162 break; 1163 case ATTR_INHERIT_DEVICE_POLICY: 1164 setInheritDevicePolicy(parser.getAttributeInt(i)); 1165 break; 1166 case ATTR_USE_PARENTS_CONTACTS: 1167 setUseParentsContacts(parser.getAttributeBoolean(i)); 1168 break; 1169 case ATTR_UPDATE_CROSS_PROFILE_INTENT_FILTERS_ON_OTA: 1170 setUpdateCrossProfileIntentFiltersOnOTA(parser.getAttributeBoolean(i)); 1171 break; 1172 case ATTR_CROSS_PROFILE_INTENT_FILTER_ACCESS_CONTROL: 1173 setCrossProfileIntentFilterAccessControl(parser.getAttributeInt(i)); 1174 break; 1175 case ATTR_CROSS_PROFILE_INTENT_RESOLUTION_STRATEGY: 1176 setCrossProfileIntentResolutionStrategy(parser.getAttributeInt(i)); 1177 break; 1178 case ATTR_MEDIA_SHARED_WITH_PARENT: 1179 setMediaSharedWithParent(parser.getAttributeBoolean(i)); 1180 break; 1181 case ATTR_CREDENTIAL_SHAREABLE_WITH_PARENT: 1182 setCredentialShareableWithParent(parser.getAttributeBoolean(i)); 1183 break; 1184 case ATTR_AUTH_ALWAYS_REQUIRED_TO_DISABLE_QUIET_MODE: 1185 setAuthAlwaysRequiredToDisableQuietMode(parser.getAttributeBoolean(i)); 1186 break; 1187 case ATTR_ALLOW_STOPPING_USER_WITH_DELAYED_LOCKING: 1188 setAllowStoppingUserWithDelayedLocking(parser.getAttributeBoolean(i)); 1189 break; 1190 case ATTR_DELETE_APP_WITH_PARENT: 1191 setDeleteAppWithParent(parser.getAttributeBoolean(i)); 1192 break; 1193 case ATTR_ALWAYS_VISIBLE: 1194 setAlwaysVisible(parser.getAttributeBoolean(i)); 1195 break; 1196 case ATTR_CROSS_PROFILE_CONTENT_SHARING_STRATEGY: 1197 setCrossProfileContentSharingStrategy(parser.getAttributeInt(i)); 1198 break; 1199 case ATTR_PROFILE_API_VISIBILITY: 1200 setProfileApiVisibility(parser.getAttributeInt(i)); 1201 break; 1202 case ITEMS_RESTRICTED_ON_HOME_SCREEN: 1203 setItemsRestrictedOnHomeScreen(parser.getAttributeBoolean(i)); 1204 break; 1205 default: 1206 Slog.w(LOG_TAG, "Skipping unknown property " + attributeName); 1207 } 1208 } 1209 } 1210 1211 /** 1212 * Writes the UserProperties, as used by the SystemServer, to the xml file. 1213 * 1214 * The serializer should already be inside a tag in which to write the user properties. 1215 * 1216 * @see #UserProperties(TypedXmlPullParser, UserProperties) 1217 * @hide 1218 */ writeToXml(TypedXmlSerializer serializer)1219 public void writeToXml(TypedXmlSerializer serializer) 1220 throws IOException, XmlPullParserException { 1221 1222 if (isPresent(INDEX_SHOW_IN_LAUNCHER)) { 1223 serializer.attributeInt(null, ATTR_SHOW_IN_LAUNCHER, mShowInLauncher); 1224 } 1225 if (isPresent(INDEX_START_WITH_PARENT)) { 1226 serializer.attributeBoolean(null, ATTR_START_WITH_PARENT, mStartWithParent); 1227 } 1228 if (isPresent(INDEX_SHOW_IN_SETTINGS)) { 1229 serializer.attributeInt(null, ATTR_SHOW_IN_SETTINGS, mShowInSettings); 1230 } 1231 if (isPresent(INDEX_SHOW_IN_QUIET_MODE)) { 1232 serializer.attributeInt(null, ATTR_SHOW_IN_QUIET_MODE, 1233 mShowInQuietMode); 1234 } 1235 if (isPresent(INDEX_SHOW_IN_SHARING_SURFACES)) { 1236 serializer.attributeInt(null, ATTR_SHOW_IN_SHARING_SURFACES, mShowInSharingSurfaces); 1237 } 1238 if (isPresent(INDEX_INHERIT_DEVICE_POLICY)) { 1239 serializer.attributeInt(null, ATTR_INHERIT_DEVICE_POLICY, 1240 mInheritDevicePolicy); 1241 } 1242 if (isPresent(INDEX_USE_PARENTS_CONTACTS)) { 1243 serializer.attributeBoolean(null, ATTR_USE_PARENTS_CONTACTS, 1244 mUseParentsContacts); 1245 } 1246 if (isPresent(INDEX_UPDATE_CROSS_PROFILE_INTENT_FILTERS_ON_OTA)) { 1247 serializer.attributeBoolean(null, 1248 ATTR_UPDATE_CROSS_PROFILE_INTENT_FILTERS_ON_OTA, 1249 mUpdateCrossProfileIntentFiltersOnOTA); 1250 } 1251 if (isPresent(INDEX_CROSS_PROFILE_INTENT_FILTER_ACCESS_CONTROL)) { 1252 serializer.attributeInt(null, ATTR_CROSS_PROFILE_INTENT_FILTER_ACCESS_CONTROL, 1253 mCrossProfileIntentFilterAccessControl); 1254 } 1255 if (isPresent(INDEX_CROSS_PROFILE_INTENT_RESOLUTION_STRATEGY)) { 1256 serializer.attributeInt(null, ATTR_CROSS_PROFILE_INTENT_RESOLUTION_STRATEGY, 1257 mCrossProfileIntentResolutionStrategy); 1258 } 1259 if (isPresent(INDEX_MEDIA_SHARED_WITH_PARENT)) { 1260 serializer.attributeBoolean(null, ATTR_MEDIA_SHARED_WITH_PARENT, 1261 mMediaSharedWithParent); 1262 } 1263 if (isPresent(INDEX_CREDENTIAL_SHAREABLE_WITH_PARENT)) { 1264 serializer.attributeBoolean(null, ATTR_CREDENTIAL_SHAREABLE_WITH_PARENT, 1265 mCredentialShareableWithParent); 1266 } 1267 if (isPresent(INDEX_AUTH_ALWAYS_REQUIRED_TO_DISABLE_QUIET_MODE)) { 1268 serializer.attributeBoolean(null, ATTR_AUTH_ALWAYS_REQUIRED_TO_DISABLE_QUIET_MODE, 1269 mAuthAlwaysRequiredToDisableQuietMode); 1270 } 1271 if (isPresent(INDEX_ALLOW_STOPPING_USER_WITH_DELAYED_LOCKING)) { 1272 serializer.attributeBoolean(null, ATTR_ALLOW_STOPPING_USER_WITH_DELAYED_LOCKING, 1273 mAllowStoppingUserWithDelayedLocking); 1274 } 1275 if (isPresent(INDEX_DELETE_APP_WITH_PARENT)) { 1276 serializer.attributeBoolean(null, ATTR_DELETE_APP_WITH_PARENT, 1277 mDeleteAppWithParent); 1278 } 1279 if (isPresent(INDEX_ALWAYS_VISIBLE)) { 1280 serializer.attributeBoolean(null, ATTR_ALWAYS_VISIBLE, 1281 mAlwaysVisible); 1282 } 1283 if (isPresent(INDEX_CROSS_PROFILE_CONTENT_SHARING_STRATEGY)) { 1284 serializer.attributeInt(null, ATTR_CROSS_PROFILE_CONTENT_SHARING_STRATEGY, 1285 mCrossProfileContentSharingStrategy); 1286 } 1287 if (isPresent(INDEX_PROFILE_API_VISIBILITY)) { 1288 serializer.attributeInt(null, ATTR_PROFILE_API_VISIBILITY, 1289 mProfileApiVisibility); 1290 } 1291 if (isPresent(INDEX_ITEMS_RESTRICTED_ON_HOME_SCREEN)) { 1292 serializer.attributeBoolean(null, ITEMS_RESTRICTED_ON_HOME_SCREEN, 1293 mItemsRestrictedOnHomeScreen); 1294 } 1295 } 1296 1297 // For use only with an object that has already had any permission-lacking fields stripped out. 1298 @Override writeToParcel(@onNull Parcel dest, int parcelableFlags)1299 public void writeToParcel(@NonNull Parcel dest, int parcelableFlags) { 1300 dest.writeLong(mPropertiesPresent); 1301 dest.writeInt(mShowInLauncher); 1302 dest.writeBoolean(mStartWithParent); 1303 dest.writeInt(mShowInSettings); 1304 dest.writeInt(mShowInQuietMode); 1305 dest.writeInt(mShowInSharingSurfaces); 1306 dest.writeInt(mInheritDevicePolicy); 1307 dest.writeBoolean(mUseParentsContacts); 1308 dest.writeBoolean(mUpdateCrossProfileIntentFiltersOnOTA); 1309 dest.writeInt(mCrossProfileIntentFilterAccessControl); 1310 dest.writeInt(mCrossProfileIntentResolutionStrategy); 1311 dest.writeBoolean(mMediaSharedWithParent); 1312 dest.writeBoolean(mCredentialShareableWithParent); 1313 dest.writeBoolean(mAuthAlwaysRequiredToDisableQuietMode); 1314 dest.writeBoolean(mAllowStoppingUserWithDelayedLocking); 1315 dest.writeBoolean(mDeleteAppWithParent); 1316 dest.writeBoolean(mAlwaysVisible); 1317 dest.writeInt(mCrossProfileContentSharingStrategy); 1318 dest.writeInt(mProfileApiVisibility); 1319 dest.writeBoolean(mItemsRestrictedOnHomeScreen); 1320 } 1321 1322 /** 1323 * Reads a UserProperties object from the parcel. 1324 * Not suitable for the canonical SystemServer version since it lacks mDefaultProperties. 1325 */ UserProperties(@onNull Parcel source)1326 private UserProperties(@NonNull Parcel source) { 1327 mDefaultProperties = null; 1328 1329 mPropertiesPresent = source.readLong(); 1330 mShowInLauncher = source.readInt(); 1331 mStartWithParent = source.readBoolean(); 1332 mShowInSettings = source.readInt(); 1333 mShowInQuietMode = source.readInt(); 1334 mShowInSharingSurfaces = source.readInt(); 1335 mInheritDevicePolicy = source.readInt(); 1336 mUseParentsContacts = source.readBoolean(); 1337 mUpdateCrossProfileIntentFiltersOnOTA = source.readBoolean(); 1338 mCrossProfileIntentFilterAccessControl = source.readInt(); 1339 mCrossProfileIntentResolutionStrategy = source.readInt(); 1340 mMediaSharedWithParent = source.readBoolean(); 1341 mCredentialShareableWithParent = source.readBoolean(); 1342 mAuthAlwaysRequiredToDisableQuietMode = source.readBoolean(); 1343 mAllowStoppingUserWithDelayedLocking = source.readBoolean(); 1344 mDeleteAppWithParent = source.readBoolean(); 1345 mAlwaysVisible = source.readBoolean(); 1346 mCrossProfileContentSharingStrategy = source.readInt(); 1347 mProfileApiVisibility = source.readInt(); 1348 mItemsRestrictedOnHomeScreen = source.readBoolean(); 1349 } 1350 1351 @Override describeContents()1352 public int describeContents() { 1353 return 0; 1354 } 1355 1356 public static final @android.annotation.NonNull Parcelable.Creator<UserProperties> CREATOR 1357 = new Parcelable.Creator<UserProperties>() { 1358 public UserProperties createFromParcel(Parcel source) { 1359 return new UserProperties(source); 1360 } 1361 public UserProperties[] newArray(int size) { 1362 return new UserProperties[size]; 1363 } 1364 }; 1365 1366 /** 1367 * Builder for the SystemServer's {@link UserProperties}; see that class for documentation. 1368 * Intended for building default values (and so all properties are present in the built object). 1369 * @hide 1370 */ 1371 @TestApi 1372 @SuppressLint("UnflaggedApi") // b/306636213 1373 public static final class Builder { 1374 // UserProperties fields and their default values. 1375 private @ShowInLauncher int mShowInLauncher = SHOW_IN_LAUNCHER_WITH_PARENT; 1376 private boolean mStartWithParent = false; 1377 private @ShowInSettings int mShowInSettings = SHOW_IN_SETTINGS_WITH_PARENT; 1378 private @ShowInQuietMode int mShowInQuietMode = 1379 SHOW_IN_QUIET_MODE_PAUSED; 1380 private @ShowInSharingSurfaces int mShowInSharingSurfaces = 1381 SHOW_IN_SHARING_SURFACES_SEPARATE; 1382 private @InheritDevicePolicy int mInheritDevicePolicy = INHERIT_DEVICE_POLICY_NO; 1383 private boolean mUseParentsContacts = false; 1384 private boolean mUpdateCrossProfileIntentFiltersOnOTA = false; 1385 private @CrossProfileIntentFilterAccessControlLevel int 1386 mCrossProfileIntentFilterAccessControl = 1387 CROSS_PROFILE_INTENT_FILTER_ACCESS_LEVEL_ALL; 1388 private @CrossProfileIntentResolutionStrategy int mCrossProfileIntentResolutionStrategy = 1389 CROSS_PROFILE_INTENT_RESOLUTION_STRATEGY_DEFAULT; 1390 private boolean mMediaSharedWithParent = false; 1391 private boolean mCredentialShareableWithParent = false; 1392 private boolean mAuthAlwaysRequiredToDisableQuietMode = false; 1393 private boolean mAllowStoppingUserWithDelayedLocking = false; 1394 private boolean mDeleteAppWithParent = false; 1395 private boolean mAlwaysVisible = false; 1396 private @CrossProfileContentSharingStrategy int mCrossProfileContentSharingStrategy = 1397 CROSS_PROFILE_CONTENT_SHARING_NO_DELEGATION; 1398 private @ProfileApiVisibility int mProfileApiVisibility = 0; 1399 private boolean mItemsRestrictedOnHomeScreen = false; 1400 1401 /** 1402 * @hide 1403 */ 1404 @SuppressLint("UnflaggedApi") // b/306636213 1405 @TestApi Builder()1406 public Builder() {} 1407 1408 /** @hide */ setShowInLauncher(@howInLauncher int showInLauncher)1409 public Builder setShowInLauncher(@ShowInLauncher int showInLauncher) { 1410 mShowInLauncher = showInLauncher; 1411 return this; 1412 } 1413 1414 /** @hide */ setStartWithParent(boolean startWithParent)1415 public Builder setStartWithParent(boolean startWithParent) { 1416 mStartWithParent = startWithParent; 1417 return this; 1418 } 1419 1420 /** Sets the value for {@link #mShowInSettings} 1421 * @hide 1422 */ setShowInSettings(@howInSettings int showInSettings)1423 public Builder setShowInSettings(@ShowInSettings int showInSettings) { 1424 mShowInSettings = showInSettings; 1425 return this; 1426 } 1427 1428 /** Sets the value for {@link #mShowInQuietMode} 1429 * @hide 1430 */ 1431 @TestApi 1432 @SuppressLint("UnflaggedApi") // b/306636213 1433 @NonNull setShowInQuietMode(@howInQuietMode int showInQuietMode)1434 public Builder setShowInQuietMode(@ShowInQuietMode int showInQuietMode) { 1435 mShowInQuietMode = showInQuietMode; 1436 return this; 1437 } 1438 1439 /** Sets the value for {@link #mShowInSharingSurfaces}. 1440 * @hide 1441 */ 1442 @TestApi 1443 @SuppressLint("UnflaggedApi") // b/306636213 1444 @NonNull setShowInSharingSurfaces(@howInSharingSurfaces int showInSharingSurfaces)1445 public Builder setShowInSharingSurfaces(@ShowInSharingSurfaces int showInSharingSurfaces) { 1446 mShowInSharingSurfaces = showInSharingSurfaces; 1447 return this; 1448 } 1449 1450 /** Sets the value for {@link #mInheritDevicePolicy} 1451 * @hide 1452 */ setInheritDevicePolicy( @nheritDevicePolicy int inheritRestrictionsDevicePolicy)1453 public Builder setInheritDevicePolicy( 1454 @InheritDevicePolicy int inheritRestrictionsDevicePolicy) { 1455 mInheritDevicePolicy = inheritRestrictionsDevicePolicy; 1456 return this; 1457 } 1458 1459 /** @hide */ setUseParentsContacts(boolean useParentsContacts)1460 public Builder setUseParentsContacts(boolean useParentsContacts) { 1461 mUseParentsContacts = useParentsContacts; 1462 return this; 1463 } 1464 1465 /** Sets the value for {@link #mUpdateCrossProfileIntentFiltersOnOTA} 1466 * @hide 1467 */ setUpdateCrossProfileIntentFiltersOnOTA(boolean updateCrossProfileIntentFiltersOnOTA)1468 public Builder setUpdateCrossProfileIntentFiltersOnOTA(boolean 1469 updateCrossProfileIntentFiltersOnOTA) { 1470 mUpdateCrossProfileIntentFiltersOnOTA = updateCrossProfileIntentFiltersOnOTA; 1471 return this; 1472 } 1473 1474 /** Sets the value for {@link #mCrossProfileIntentFilterAccessControl} 1475 * @hide 1476 */ setCrossProfileIntentFilterAccessControl( @rossProfileIntentFilterAccessControlLevel int crossProfileIntentFilterAccessControl)1477 public Builder setCrossProfileIntentFilterAccessControl( 1478 @CrossProfileIntentFilterAccessControlLevel int 1479 crossProfileIntentFilterAccessControl) { 1480 mCrossProfileIntentFilterAccessControl = crossProfileIntentFilterAccessControl; 1481 return this; 1482 } 1483 1484 /** Sets the value for {@link #mCrossProfileIntentResolutionStrategy} 1485 * @hide 1486 */ setCrossProfileIntentResolutionStrategy(@rossProfileIntentResolutionStrategy int crossProfileIntentResolutionStrategy)1487 public Builder setCrossProfileIntentResolutionStrategy(@CrossProfileIntentResolutionStrategy 1488 int crossProfileIntentResolutionStrategy) { 1489 mCrossProfileIntentResolutionStrategy = crossProfileIntentResolutionStrategy; 1490 return this; 1491 } 1492 1493 /** @hide */ setMediaSharedWithParent(boolean mediaSharedWithParent)1494 public Builder setMediaSharedWithParent(boolean mediaSharedWithParent) { 1495 mMediaSharedWithParent = mediaSharedWithParent; 1496 return this; 1497 } 1498 1499 /** @hide */ setCredentialShareableWithParent(boolean credentialShareableWithParent)1500 public Builder setCredentialShareableWithParent(boolean credentialShareableWithParent) { 1501 mCredentialShareableWithParent = credentialShareableWithParent; 1502 return this; 1503 } 1504 1505 /** Sets the value for {@link #mAuthAlwaysRequiredToDisableQuietMode} 1506 * @hide 1507 */ setAuthAlwaysRequiredToDisableQuietMode( boolean authAlwaysRequiredToDisableQuietMode)1508 public Builder setAuthAlwaysRequiredToDisableQuietMode( 1509 boolean authAlwaysRequiredToDisableQuietMode) { 1510 mAuthAlwaysRequiredToDisableQuietMode = 1511 authAlwaysRequiredToDisableQuietMode; 1512 return this; 1513 } 1514 1515 /** Sets the value for {@link #mAllowStoppingUserWithDelayedLocking} 1516 * @hide 1517 */ setAllowStoppingUserWithDelayedLocking( boolean allowStoppingUserWithDelayedLocking)1518 public Builder setAllowStoppingUserWithDelayedLocking( 1519 boolean allowStoppingUserWithDelayedLocking) { 1520 mAllowStoppingUserWithDelayedLocking = 1521 allowStoppingUserWithDelayedLocking; 1522 return this; 1523 } 1524 1525 /** Sets the value for {@link #mDeleteAppWithParent} 1526 * @hide 1527 */ setDeleteAppWithParent(boolean deleteAppWithParent)1528 public Builder setDeleteAppWithParent(boolean deleteAppWithParent) { 1529 mDeleteAppWithParent = deleteAppWithParent; 1530 return this; 1531 } 1532 1533 /** Sets the value for {@link #mAlwaysVisible} 1534 * @hide 1535 */ setAlwaysVisible(boolean alwaysVisible)1536 public Builder setAlwaysVisible(boolean alwaysVisible) { 1537 mAlwaysVisible = alwaysVisible; 1538 return this; 1539 } 1540 1541 /** Sets the value for {@link #mCrossProfileContentSharingStrategy} 1542 * @hide 1543 */ 1544 1545 @TestApi 1546 @SuppressLint("UnflaggedApi") // b/306636213 1547 @NonNull setCrossProfileContentSharingStrategy(@rossProfileContentSharingStrategy int crossProfileContentSharingStrategy)1548 public Builder setCrossProfileContentSharingStrategy(@CrossProfileContentSharingStrategy 1549 int crossProfileContentSharingStrategy) { 1550 mCrossProfileContentSharingStrategy = crossProfileContentSharingStrategy; 1551 return this; 1552 } 1553 1554 /** 1555 * Sets the value for {@link #mProfileApiVisibility} 1556 * @hide 1557 */ 1558 @NonNull setProfileApiVisibility(@rofileApiVisibility int profileApiVisibility)1559 public Builder setProfileApiVisibility(@ProfileApiVisibility int profileApiVisibility){ 1560 mProfileApiVisibility = profileApiVisibility; 1561 return this; 1562 } 1563 1564 /** Sets the value for {@link #mItemsRestrictedOnHomeScreen} 1565 * @hide 1566 */ setItemsRestrictedOnHomeScreen( boolean itemsRestrictedOnHomeScreen)1567 public Builder setItemsRestrictedOnHomeScreen( 1568 boolean itemsRestrictedOnHomeScreen) { 1569 mItemsRestrictedOnHomeScreen = itemsRestrictedOnHomeScreen; 1570 return this; 1571 } 1572 1573 /** Builds a UserProperties object with *all* values populated. 1574 * @hide 1575 */ 1576 @TestApi 1577 @SuppressLint("UnflaggedApi") // b/306636213 1578 @NonNull build()1579 public UserProperties build() { 1580 return new UserProperties( 1581 mShowInLauncher, 1582 mStartWithParent, 1583 mShowInSettings, 1584 mShowInQuietMode, 1585 mShowInSharingSurfaces, 1586 mInheritDevicePolicy, 1587 mUseParentsContacts, 1588 mUpdateCrossProfileIntentFiltersOnOTA, 1589 mCrossProfileIntentFilterAccessControl, 1590 mCrossProfileIntentResolutionStrategy, 1591 mMediaSharedWithParent, 1592 mCredentialShareableWithParent, 1593 mAuthAlwaysRequiredToDisableQuietMode, 1594 mAllowStoppingUserWithDelayedLocking, 1595 mDeleteAppWithParent, 1596 mAlwaysVisible, 1597 mCrossProfileContentSharingStrategy, 1598 mProfileApiVisibility, 1599 mItemsRestrictedOnHomeScreen); 1600 } 1601 } // end Builder 1602 1603 /** Creates a UserProperties with the given properties. Intended for building default values. */ UserProperties( @howInLauncher int showInLauncher, boolean startWithParent, @ShowInSettings int showInSettings, @ShowInQuietMode int showInQuietMode, @ShowInSharingSurfaces int showInSharingSurfaces, @InheritDevicePolicy int inheritDevicePolicy, boolean useParentsContacts, boolean updateCrossProfileIntentFiltersOnOTA, @CrossProfileIntentFilterAccessControlLevel int crossProfileIntentFilterAccessControl, @CrossProfileIntentResolutionStrategy int crossProfileIntentResolutionStrategy, boolean mediaSharedWithParent, boolean credentialShareableWithParent, boolean authAlwaysRequiredToDisableQuietMode, boolean allowStoppingUserWithDelayedLocking, boolean deleteAppWithParent, boolean alwaysVisible, @CrossProfileContentSharingStrategy int crossProfileContentSharingStrategy, @ProfileApiVisibility int profileApiVisibility, boolean itemsRestrictedOnHomeScreen)1604 private UserProperties( 1605 @ShowInLauncher int showInLauncher, 1606 boolean startWithParent, 1607 @ShowInSettings int showInSettings, 1608 @ShowInQuietMode int showInQuietMode, 1609 @ShowInSharingSurfaces int showInSharingSurfaces, 1610 @InheritDevicePolicy int inheritDevicePolicy, 1611 boolean useParentsContacts, boolean updateCrossProfileIntentFiltersOnOTA, 1612 @CrossProfileIntentFilterAccessControlLevel int crossProfileIntentFilterAccessControl, 1613 @CrossProfileIntentResolutionStrategy int crossProfileIntentResolutionStrategy, 1614 boolean mediaSharedWithParent, 1615 boolean credentialShareableWithParent, 1616 boolean authAlwaysRequiredToDisableQuietMode, 1617 boolean allowStoppingUserWithDelayedLocking, 1618 boolean deleteAppWithParent, 1619 boolean alwaysVisible, 1620 @CrossProfileContentSharingStrategy int crossProfileContentSharingStrategy, 1621 @ProfileApiVisibility int profileApiVisibility, 1622 boolean itemsRestrictedOnHomeScreen) { 1623 mDefaultProperties = null; 1624 setShowInLauncher(showInLauncher); 1625 setStartWithParent(startWithParent); 1626 setShowInSettings(showInSettings); 1627 setShowInQuietMode(showInQuietMode); 1628 setShowInSharingSurfaces(showInSharingSurfaces); 1629 setInheritDevicePolicy(inheritDevicePolicy); 1630 setUseParentsContacts(useParentsContacts); 1631 setUpdateCrossProfileIntentFiltersOnOTA(updateCrossProfileIntentFiltersOnOTA); 1632 setCrossProfileIntentFilterAccessControl(crossProfileIntentFilterAccessControl); 1633 setCrossProfileIntentResolutionStrategy(crossProfileIntentResolutionStrategy); 1634 setMediaSharedWithParent(mediaSharedWithParent); 1635 setCredentialShareableWithParent(credentialShareableWithParent); 1636 setAuthAlwaysRequiredToDisableQuietMode( 1637 authAlwaysRequiredToDisableQuietMode); 1638 setAllowStoppingUserWithDelayedLocking(allowStoppingUserWithDelayedLocking); 1639 setDeleteAppWithParent(deleteAppWithParent); 1640 setAlwaysVisible(alwaysVisible); 1641 setCrossProfileContentSharingStrategy(crossProfileContentSharingStrategy); 1642 setProfileApiVisibility(profileApiVisibility); 1643 setItemsRestrictedOnHomeScreen(itemsRestrictedOnHomeScreen); 1644 } 1645 } 1646