RunOnSecondaryUserTargetPreparer

public class RunOnSecondaryUserTargetPreparer
extends BaseTargetPreparer

java.lang.Object
   ↳ com.android.tradefed.targetprep.BaseTargetPreparer
     ↳ com.android.tradefed.targetprep.RunOnSecondaryUserTargetPreparer


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

Fields

protected boolean mStartBackgroundUser

protected List<String> mTestPackages

protected int originalUserId

protected int secondaryUserId

Public constructors

RunOnSecondaryUserTargetPreparer()

Public methods

void setUp(TestInformation testInfo)
void tearDown(TestInformation testInfo, Throwable e)

Protected methods

boolean canCreateAdditionalSecondaryUsers(ITestDevice device, int numberOfUsers)

Checks whether it is possible to create the desired number of secondary users.

Fields

mStartBackgroundUser

protected boolean mStartBackgroundUser

mTestPackages

protected List<String> mTestPackages

originalUserId

protected int originalUserId

secondaryUserId

protected int secondaryUserId

Public constructors

RunOnSecondaryUserTargetPreparer

public RunOnSecondaryUserTargetPreparer ()

Public methods

setUp

public void setUp (TestInformation testInfo)

Parameters
testInfo TestInformation

Throws
DeviceNotAvailableException
TargetSetupError

tearDown

public void tearDown (TestInformation testInfo, 
                Throwable e)

Parameters
testInfo TestInformation

e Throwable

Throws
DeviceNotAvailableException

Protected methods

canCreateAdditionalSecondaryUsers

protected boolean canCreateAdditionalSecondaryUsers (ITestDevice device, 
                int numberOfUsers)

Checks whether it is possible to create the desired number of secondary users.

Parameters
device ITestDevice

numberOfUsers int

Returns
boolean

Throws
DeviceNotAvailableException