自 2026 年起,为了与我们的主干稳定开发模型保持一致,并确保生态系统的平台稳定性,我们将在第 2 季度和第 4 季度将源代码发布到 AOSP。对于构建 AOSP 和向 AOSP 贡献代码,我们建议使用 android-latest-release 而不是 aosp-main。android-latest-release 清单分支将始终引用推送到 AOSP 的最新版本。如需了解详情,请参阅 AOSP 变更。
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
GoogleAccountUtil
public
class
GoogleAccountUtil
extends Object
| java.lang.Object
|
| ↳ |
com.google.android.tradefed.util.GoogleAccountUtil
|
一种支持在设备上配置 Google 账号的实用程序
摘要
公共方法 |
static
boolean
|
addAccountAttempt(ITestDevice device, int userId, String accountName, String password, boolean sync, boolean waitForCheckin)
尝试使用给定的 Google 账号配置被测设备。
|
static
boolean
|
hasAccount(ITestDevice device, int userId)
检查设备上是否有账号。
|
static
boolean
|
installUtil(ITestDevice device)
|
static
boolean
|
installUtil(ITestDevice device, File altApk)
如有必要,安装 JAR 中包含的账号实用程序 APK
|
static
boolean
|
isAccountUtilInstalled(ITestDevice device)
检查账号实用程序是否已安装
|
static
boolean
|
removeAccountAttempt(ITestDevice device, int userId, String accountName)
移除指定的单个账号
|
static
boolean
|
removeAllAccountAttempt(ITestDevice device, int userId)
移除设备的所有账号
|
static
boolean
|
syncAndOff(ITestDevice device, int userId, String accountName, long syncThenOff)
关闭与指定 Google 账号的同步功能。
|
static
boolean
|
syncOn(ITestDevice device, int userId, String accountName)
开启与指定 Google 账号的同步功能。
|
static
boolean
|
uninstallUtil(ITestDevice device)
卸载 jar 中包含的账号实用程序 APK
|
static
boolean
|
waitForAccountSync(ITestDevice device, int userId, long interval, long timeout, boolean forceSync)
等待设备完成同步。
|
常量
ACCOUNT_PKG_NAME
public static final String ACCOUNT_PKG_NAME
常量值:
"com.google.android.tradefed.account"
UTIL_APK_NAME
public static final String UTIL_APK_NAME
常量值:
"GoogleAccountUtil"
字段
CHECK_INSTRUMENTATION_CMD
public static final String CHECK_INSTRUMENTATION_CMD
公共构造函数
GoogleAccountUtil
public GoogleAccountUtil ()
公共方法
addAccountAttempt
public static boolean addAccountAttempt (ITestDevice device,
int userId,
String accountName,
String password,
boolean sync,
boolean waitForCheckin)
尝试使用给定的 Google 账号配置被测设备。
账号必须已存在于服务器上。
公开以用于单元测试。
| 参数 |
device |
ITestDevice:ITestDevice |
userId |
int:要将账号添加到的用户的 ID |
accountName |
String:要添加的 Google 账号的全名 |
password |
String:账号的密码 |
sync |
boolean:如果应为此账号启用自动同步,则为 true |
waitForCheckin |
boolean:true 在添加账号后等待签入 |
| 返回 |
boolean |
如果账号已成功创建,则为 true;否则为 false |
hasAccount
public static boolean hasAccount (ITestDevice device,
int userId)
检查设备上是否有账号。
| 参数 |
device |
ITestDevice:针对账号检查的 ITestDevice |
userId |
int:要检查的用户 ID |
installUtil
public static boolean installUtil (ITestDevice device)
installUtil
public static boolean installUtil (ITestDevice device,
File altApk)
如有必要,安装 JAR 中包含的账号实用程序 APK
| 参数 |
device |
ITestDevice:要安装该实用程序的设备。 |
altApk |
File |
isAccountUtilInstalled
public static boolean isAccountUtilInstalled (ITestDevice device)
检查账号实用程序是否已安装
| 参数 |
device |
ITestDevice:用于检查是否安装了账号实用程序的设备 |
removeAccountAttempt
public static boolean removeAccountAttempt (ITestDevice device,
int userId,
String accountName)
移除指定的单个账号
| 返回 |
boolean |
如果移除成功,则返回 true,否则返回 false。 |
removeAllAccountAttempt
public static boolean removeAllAccountAttempt (ITestDevice device,
int userId)
移除设备的所有账号
| 返回 |
boolean |
如果移除成功,则返回 true,否则返回 false。 |
syncAndOff
public static boolean syncAndOff (ITestDevice device,
int userId,
String accountName,
long syncThenOff)
关闭与指定 Google 账号的同步。假设同步处于开启状态。
| 参数 |
device |
ITestDevice:ITestDevice |
userId |
int:要针对其运行此操作的用户的 ID |
accountName |
String:要关闭同步功能的 Google 账号的全名 |
syncThenOff |
long:允许同步运行的秒数,之后会将其关闭 |
| 返回 |
boolean |
如果成功关闭同步,则为 true |
syncOn
public static boolean syncOn (ITestDevice device,
int userId,
String accountName)
开启与指定 Google 账号的同步。假设同步为 false;
| 参数 |
device |
ITestDevice:ITestDevice |
userId |
int:要针对其运行此操作的用户的 ID |
accountName |
String:要开启同步功能的 Google 账号的全名 |
| 返回 |
boolean |
如果成功关闭同步,则为 true |
uninstallUtil
public static boolean uninstallUtil (ITestDevice device)
卸载 jar 中包含的账号实用程序 APK
| 参数 |
device |
ITestDevice:要从中卸载账号实用程序的设备。 |
waitForAccountSync
public static boolean waitForAccountSync (ITestDevice device,
int userId,
long interval,
long timeout,
boolean forceSync)
等待设备完成同步。
| 参数 |
device |
ITestDevice |
userId |
int |
interval |
long |
timeout |
long |
forceSync |
boolean |
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-12-04。
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["没有我需要的信息","missingTheInformationINeed","thumb-down"],["太复杂/步骤太多","tooComplicatedTooManySteps","thumb-down"],["内容需要更新","outOfDate","thumb-down"],["翻译问题","translationIssue","thumb-down"],["示例/代码问题","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-12-04。"],[],[]]