為配合主幹穩定開發模型,並確保生態系統的平台穩定性,我們將於 2026 年起,在第 2 季和第 4 季將原始碼發布至 AOSP。如要建構及貢獻 AOSP,建議使用 android-latest-release,而非 aosp-main。android-latest-release 資訊清單分支版本一律會參照推送至 AOSP 的最新版本。詳情請參閱「Android 開放原始碼計畫變更」一文。
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
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 和/或其關係企業的商標或註冊商標。
上次更新時間: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"]],["上次更新時間:2025-12-04 (世界標準時間)。"],[],[]]