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