GoogleAccountUtil

public class GoogleAccountUtil
extends Object

java.lang.Object
   ↳ com.google.android.tradefed.util.GoogleAccountUtil


這項公用程式可協助您在裝置上設定 Google 帳戶

摘要

常數

String ACCOUNT_PKG_NAME

String UTIL_APK_NAME

欄位

public static final String CHECK_INSTRUMENTATION_CMD

公用建構函式

GoogleAccountUtil()

公用方法

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 ITestDeviceITestDevice

userId int:要新增帳戶的使用者 ID

accountName String:要新增的 Google 帳戶全名

password String:帳戶密碼

sync boolean:如果應為這個帳戶啟用自動同步功能,則為 true

waitForCheckin booleantrue新增帳戶後等待簽到

傳回
boolean true (如果帳戶已成功建立) 或 false (如果帳戶未成功建立)

擲回
DeviceNotAvailableException

hasAccount

public static boolean hasAccount (ITestDevice device, 
                int userId)

檢查裝置上是否有帳戶。

參數
device ITestDevice:系統ITestDevice檢查帳戶時

userId int:要檢查的使用者 ID

傳回
boolean

擲回
com.android.tradefed.device.DeviceNotAvailableException
DeviceNotAvailableException

installUtil

public static boolean installUtil (ITestDevice device)

參數
device ITestDevice

傳回
boolean

擲回
DeviceNotAvailableException

installUtil

public static boolean installUtil (ITestDevice device, 
                File altApk)

視需要安裝 JAR 中包含的帳戶公用程式 APK

參數
device ITestDevice:要安裝公用程式的裝置。

altApk File

傳回
boolean

擲回
com.android.tradefed.device.DeviceNotAvailableException
DeviceNotAvailableException

isAccountUtilInstalled

public static boolean isAccountUtilInstalled (ITestDevice device)

檢查目前是否已安裝帳戶公用程式

參數
device ITestDevice:檢查是否已安裝帳戶公用程式

傳回
boolean

擲回
com.android.tradefed.device.DeviceNotAvailableException
DeviceNotAvailableException

removeAccountAttempt

public static boolean removeAccountAttempt (ITestDevice device, 
                int userId, 
                String accountName)

移除指定的單一帳戶

參數
accountName String

傳回
boolean 如果移除成功,則為 true,否則為 false。

擲回
com.android.tradefed.device.DeviceNotAvailableException
DeviceNotAvailableException

removeAllAccountAttempt

public static boolean removeAllAccountAttempt (ITestDevice device, 
                int userId)

移除裝置的所有帳戶

傳回
boolean 如果移除成功,則為 true,否則為 false。

擲回
com.android.tradefed.device.DeviceNotAvailableException
DeviceNotAvailableException

syncAndOff

public static boolean syncAndOff (ITestDevice device, 
                int userId, 
                String accountName, 
                long syncThenOff)

關閉與指定 Google 帳戶的同步功能。假設同步功能已開啟。

參數
device ITestDeviceITestDevice

userId int:要對其執行這項作業的使用者 ID

accountName String:要關閉同步功能的 Google 帳戶全名

syncThenOff long:允許同步作業在關閉前執行的秒數

傳回
boolean true (如果已成功關閉同步功能)

擲回
com.android.tradefed.device.DeviceNotAvailableException
DeviceNotAvailableException

syncOn

public static boolean syncOn (ITestDevice device, 
                int userId, 
                String accountName)

開啟與指定 Google 帳戶的同步功能。假設同步處理為 false;

參數
device ITestDeviceITestDevice

userId int:要對其執行這項作業的使用者 ID

accountName String:要開啟同步功能的 Google 帳戶全名

傳回
boolean true (如果已成功關閉同步功能)

擲回
com.android.tradefed.device.DeviceNotAvailableException
DeviceNotAvailableException

uninstallUtil

public static boolean uninstallUtil (ITestDevice device)

解除安裝 jar 中包含的帳戶公用程式 APK

參數
device ITestDevice:要解除安裝帳戶公用程式的裝置。

傳回
boolean

擲回
com.android.tradefed.device.DeviceNotAvailableException
DeviceNotAvailableException

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

傳回
boolean

擲回
DeviceNotAvailableException