Effective in 2026, to align with our trunk stable development model and ensure platform stability for the ecosystem, we will publish source code to AOSP in Q2 and Q4. For building and contributing to AOSP, we recommend utilizing android-latest-release instead of aosp-main. The android-latest-release manifest branch will always reference the most recent release pushed to AOSP. For more information, see Changes to AOSP.
Stay organized with collections
Save and categorize content based on your preferences.
GoogleAccountUtil
public
class
GoogleAccountUtil
extends Object
| java.lang.Object
|
| ↳ |
com.google.android.tradefed.util.GoogleAccountUtil
|
A Utility that supports configuring google accounts on a device
Summary
Public methods |
static
boolean
|
addAccountAttempt(ITestDevice device, int userId, String accountName, String password, boolean sync, boolean waitForCheckin)
Attempt to configures device under test with given Google account.
|
static
boolean
|
hasAccount(ITestDevice device, int userId)
Check if there is an account on the device.
|
static
boolean
|
installUtil(ITestDevice device)
|
static
boolean
|
installUtil(ITestDevice device, File altApk)
Install the account utility apk contained in jar if necessary
|
static
boolean
|
isAccountUtilInstalled(ITestDevice device)
Check if the account utility is currently installed
|
static
boolean
|
removeAccountAttempt(ITestDevice device, int userId, String accountName)
Remove the single account specified
|
static
boolean
|
removeAllAccountAttempt(ITestDevice device, int userId)
Remove all accounts of the device
|
static
boolean
|
syncAndOff(ITestDevice device, int userId, String accountName, long syncThenOff)
Turns off syncing with the given Google account.
|
static
boolean
|
syncOn(ITestDevice device, int userId, String accountName)
Turns on syncing with the given Google account.
|
static
boolean
|
uninstallUtil(ITestDevice device)
Uninstall the account utility apk contained in jar
|
static
boolean
|
waitForAccountSync(ITestDevice device, int userId, long interval, long timeout, boolean forceSync)
Wait for the device to finish syncing.
|
Constants
ACCOUNT_PKG_NAME
public static final String ACCOUNT_PKG_NAME
Constant Value:
"com.google.android.tradefed.account"
UTIL_APK_NAME
public static final String UTIL_APK_NAME
Constant Value:
"GoogleAccountUtil"
Fields
CHECK_INSTRUMENTATION_CMD
public static final String CHECK_INSTRUMENTATION_CMD
Public constructors
GoogleAccountUtil
public GoogleAccountUtil ()
Public methods
addAccountAttempt
public static boolean addAccountAttempt (ITestDevice device,
int userId,
String accountName,
String password,
boolean sync,
boolean waitForCheckin)
Attempt to configures device under test with given Google account.
Account must already exist on server.
Exposed for unit testing.
| Parameters |
device |
ITestDevice: the ITestDevice |
userId |
int: the ID of user to which the account will be added |
accountName |
String: full name of Google account to add |
password |
String: password of account |
sync |
boolean: true if automatic sync should be enabled for this account |
waitForCheckin |
boolean: true to wait for checkin after adding account |
| Returns |
boolean |
true if account was created successfully, false otherwise |
hasAccount
public static boolean hasAccount (ITestDevice device,
int userId)
Check if there is an account on the device.
| Parameters |
device |
ITestDevice: the ITestDevice checked for an account |
userId |
int: the user ID id to check |
installUtil
public static boolean installUtil (ITestDevice device)
| Parameters |
device |
ITestDevice |
installUtil
public static boolean installUtil (ITestDevice device,
File altApk)
Install the account utility apk contained in jar if necessary
| Parameters |
device |
ITestDevice: on which to install the utility. |
altApk |
File |
isAccountUtilInstalled
public static boolean isAccountUtilInstalled (ITestDevice device)
Check if the account utility is currently installed
| Parameters |
device |
ITestDevice: on which to check if the account utility is installed |
removeAccountAttempt
public static boolean removeAccountAttempt (ITestDevice device,
int userId,
String accountName)
Remove the single account specified
| Parameters |
accountName |
String |
| Returns |
boolean |
true if removal is a success, false otherwise. |
removeAllAccountAttempt
public static boolean removeAllAccountAttempt (ITestDevice device,
int userId)
Remove all accounts of the device
| Returns |
boolean |
true if removal is a success, false otherwise. |
syncAndOff
public static boolean syncAndOff (ITestDevice device,
int userId,
String accountName,
long syncThenOff)
Turns off syncing with the given Google account. Assume syncing is On.
| Parameters |
device |
ITestDevice: the ITestDevice |
userId |
int: the ID of the user to run this operation on |
accountName |
String: full name of Google account to turn sync off |
syncThenOff |
long: seconds to allow sync to run before turning it off |
| Returns |
boolean |
true if the sync was turned off successfully |
syncOn
public static boolean syncOn (ITestDevice device,
int userId,
String accountName)
Turns on syncing with the given Google account. Assume syncing is false;
| Parameters |
device |
ITestDevice: the ITestDevice |
userId |
int: the ID of the user to run this operation on |
accountName |
String: full name of Google account to turn sync on |
| Returns |
boolean |
true if the sync was turned off successfully |
uninstallUtil
public static boolean uninstallUtil (ITestDevice device)
Uninstall the account utility apk contained in jar
| Parameters |
device |
ITestDevice: to uninstall the account utility from. |
waitForAccountSync
public static boolean waitForAccountSync (ITestDevice device,
int userId,
long interval,
long timeout,
boolean forceSync)
Wait for the device to finish syncing.
| Parameters |
device |
ITestDevice |
userId |
int |
interval |
long |
timeout |
long |
forceSync |
boolean |
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 2025-12-04 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 2025-12-04 UTC."],[],[]]