設備參數的意思是說,在執行過程中,對被測設備需要做的一些操作,需要你cts框架對設備做哪些操作,你才能做,不允許你做的,你想做也做不了。比如需不需要你解鎖,需要的話,你就得去解鎖。是否允許你cts重啟機器等,該類配置對應于device_options。只有類沒有接口,一般也不需要自己寫特殊的類,用原生的基本就能滿足需求。
~~~
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.tradefed.device;
import com.android.tradefed.config.Option;
/**
* Container for {@link ITestDevice} {@link Option}s
*/
public class TestDeviceOptions {
@Option(name = "enable-root", description = "enable adb root on boot.")
private boolean mEnableAdbRoot = true;
@Option(name = "<a target=_blank href="http://blog.csdn.net/qinjuning/article/details/7505703">disable-keyguard</a>",
description = "attempt to disable keyguard once boot is complete.")
private boolean mDisableKeyguard = true;
@Option(name = "disable-keyguard-cmd", description = "shell command to disable keyguard.")
private String mDisableKeyguardCmd = "input keyevent 82";
@Option(name = "max-tmp-logcat-file", description =
"The maximum size of tmp logcat data to retain, in bytes.")
private long mMaxLogcatDataSize = 20 * 1024 * 1024;
@Option(name = "fastboot-timeout", description =
"time in ms to wait for a device to boot into fastboot.")
private int mFastbootTimeout = 1 * 60 * 1000;
@Option(name = "adb-recovery-timeout", description =
"time in ms to wait for a device to boot into recovery.")
private int mAdbRecoveryTimeout = 1 * 60 * 1000;
@Option(name = "reboot-timeout", description =
"time in ms to wait for a device to reboot to full system.")
private int mRebootTimeout = 2 * 60 * 1000;
@Option(name = "use-fastboot-erase", description =
"use fastboot erase instead of fastboot format to wipe partitions")
private boolean mUseFastbootErase = false;
@Option(name = "unencrypt-reboot-timeout", description = "time in ms to wait for the device to "
+ "format the filesystem and reboot after unencryption")
private int mUnencryptRebootTimeout = 0;
@Option(name = "online-timeout", description = "default time in ms to wait for the device to "
+ "be visible on adb.")
private long mOnlineTimeout = 1 * 60 * 1000;
@Option(name = "available-timeout", description = "default time in ms to wait for the device "
+ "to be available aka fully boot.")
private long mAvailableTimeout = 6 * 60 * 1000;
@Option(name = "device-comm-port", description = "comm port related to this device")
private String mCommPort = null;
public String getCommPort() {
return mCommPort;
}
public void setCommPort(String commPort) {
mCommPort = commPort;
}
/**
* Check whether adb root should be enabled on boot for this device
*/
public boolean isEnableAdbRoot() {
return mEnableAdbRoot;
}
/**
* Set whether adb root should be enabled on boot for this device
*/
public void setEnableAdbRoot(boolean enableAdbRoot) {
mEnableAdbRoot = enableAdbRoot;
}
/**
* Check whether or not we should attempt to disable the keyguard once boot has completed
*/
public boolean isDisableKeyguard() {
return mDisableKeyguard;
}
/**
* Set whether or not we should attempt to disable the keyguard once boot has completed
*/
public void setDisableKeyguard(boolean disableKeyguard) {
mDisableKeyguard = disableKeyguard;
}
/**
* Fetch the command to disable the keyguard
*/
public String getDisableKeyguardCmd() {
return mDisableKeyguardCmd;
}
/**
* Set the command to be used to disable the keyguard
*/
public void setDisableKeyguardCmd(String disableKeyguardCmd) {
mDisableKeyguardCmd = disableKeyguardCmd;
}
/**
* Get the approximate maximum size of a tmp logcat data to retain, in bytes.
*/
public long getMaxLogcatDataSize() {
return mMaxLogcatDataSize;
}
/**
* Set the approximate maximum size of a tmp logcat to retain, in bytes
*/
public void setMaxLogcatDataSize(long maxLogcatDataSize) {
mMaxLogcatDataSize = maxLogcatDataSize;
}
/**
* @return the timeout to boot into fastboot mode in msecs.
*/
public int getFastbootTimeout() {
return mFastbootTimeout;
}
/**
* @param fastbootTimeout the timout in msecs to boot into fastboot mode.
*/
public void setFastbootTimeout(int fastbootTimeout) {
mFastbootTimeout = fastbootTimeout;
}
/**
* @return the timeout in msecs to boot into recovery mode.
*/
public int getAdbRecoveryTimeout() {
return mAdbRecoveryTimeout;
}
/**
* @param adbRecoveryTimeout the timeout in msecs to boot into recovery mode.
*/
public void setAdbRecoveryTimeout(int adbRecoveryTimeout) {
mAdbRecoveryTimeout = adbRecoveryTimeout;
}
/**
* @return the timeout in msecs for the full system boot.
*/
public int getRebootTimeout() {
return mRebootTimeout;
}
/**
* @param rebootTimeout the timeout in msecs for the system to fully boot.
*/
public void setRebootTimeout(int rebootTimeout) {
mRebootTimeout = rebootTimeout;
}
/**
* @return whether to use fastboot erase instead of fastboot format to wipe partitions.
*/
public boolean getUseFastbootErase() {
return mUseFastbootErase;
}
/**
* @param useFastbootErase whether to use fastboot erase instead of fastboot format to wipe
* partitions.
*/
public void setUseFastbootErase(boolean useFastbootErase) {
mUseFastbootErase = useFastbootErase;
}
/**
* @return the timeout in msecs for the filesystem to be formatted and the device to reboot
* after unencryption.
*/
public int getUnencryptRebootTimeout() {
return mUnencryptRebootTimeout;
}
/**
* @param unencryptRebootTimeout the timeout in msecs for the filesystem to be formatted and
* the device to reboot after unencryption.
*/
public void setUnencryptRebootTimeout(int unencryptRebootTimeout) {
mUnencryptRebootTimeout = unencryptRebootTimeout;
}
/**
* @return the default time in ms to to wait for a device to be online.
*/
public long getOnlineTimeout() {
return mOnlineTimeout;
}
public void setOnlineTimeout(long onlineTimeout) {
mOnlineTimeout = onlineTimeout;
}
/**
* @return the default time in ms to to wait for a device to be available.
*/
public long getAvailableTimeout() {
return mAvailableTimeout;
}
}
~~~
該類的屬性都有說明,很容易理解,無非就是能否root,需不需要解鎖,解鎖命令比較重要:input keyevent 82,82代表的是menu鍵,但是不是所有手機都有效的,如果無效,需要考慮一下用什么方法能解鎖你的手機。
- 前言
- (1)-windows下cts配置
- (2)-cts調試環境的搭建
- (3)-基礎庫tradefederation配置
- (4)-任務的添加
- (5)-9大組件配置
- (6)-任務的執行
- (7)-任務執行的調度室
- (8)-IBuildProvider
- (9)-IDeviceRecovery
- (10)-TestDeviceOptions
- (11)-ICommandOptions
- (12)-ITargetPreparer
- (13)-任務執行過程
- (14)-任務執行過程
- (15)-任務執行完
- (16)-logcat信息收集系統
- (17)-fastboot狀態監聽器
- (18)-設備恢復
- (19)-設備狀態的分類以及恢復模式的分類
- (20)-cts自身log系統
- (21)-測試結果收集系統
- (22)-自動檢測設備
- (23)-設備分類
- (24)-case的組織