Starting March 27, 2025, we recommend using android-latest-release instead of aosp-main to build and contribute to AOSP. For more information, see Changes to AOSP.
         
       
     
  
  
  
  
  
    
    
      
    
    
      
      Stay organized with collections
    
    
      
      Save and categorize content based on your preferences.
    
  
  
    
  
  
  
  
    
  
  
    
    
  
  
RunOnSecondaryUserTargetPreparer
  public
  
  
  
  class
  RunOnSecondaryUserTargetPreparer
  
  
  
  
    extends BaseTargetPreparer
  
  
  
  
  
  
  
    
  An ITargetPreparer to ensure that the test runs as a secondary user. In addition, if
 the option ERROR(/START_BACKGROUND_USER) is true and the current user is already
 a secondary user, it will ensure that there is a visble background secondary user run on a
 secondary display.
 
If the target secondary user doesn't exist, it will create a new one and remove it in
 teardown. Otherwise, it will be used rather than creating a new one, and it will not be removed
 in teardown.
 
If the device does not have capacity to create a new user when one is required, then the
 instrumentation argument skip-tests-reason will be set, and the user will not be changed. Tests
 running on the device can read this argument to respond to this state.
Summary
Public constructors
    RunOnSecondaryUserTargetPreparer
    
public RunOnSecondaryUserTargetPreparer ()
    
    
    
  
 
Public methods
    
    
public void setUp (TestInformation testInfo)
    
    
    
  
    
    | Parameters | 
|---|
      
        | testInfo | TestInformation | 
    
      
  
 
    
    
public void tearDown (TestInformation testInfo, 
                Throwable e)
    
    
    
  
    
    | Parameters | 
|---|
      
        | testInfo | TestInformation | 
      
        | e | Throwable | 
    
      
  
 
Protected methods
    canCreateAdditionalUsers
    
protected boolean canCreateAdditionalUsers (ITestDevice device, 
                int numberOfUsers)
    
    
    
  Checks whether it is possible to create the desired number of users.
    
    | Parameters | 
|---|
      
        | device | ITestDevice | 
      
        | numberOfUsers | int | 
    
    
      
  
 
 
 
  
  
 
  
    
    
      
    
    
  
       
    
    
  
  
  Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
  Last updated 2024-05-08 UTC.
  
  
  
    
      [[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-05-08 UTC."],[],[]]