ResultDBUtil
public
final
class
ResultDBUtil
extends Object
| java.lang.Object | |
| ↳ | com.android.tradefed.result.resultdb.ResultDBUtil |
ResultDB 报告程序的实用程序类。
摘要
公共构造函数 | |
|---|---|
ResultDBUtil()
|
|
公共方法 | |
|---|---|
static
String
|
bytesToHex(byte[] bytes)
将字节数组转换为十六进制字符串。 |
static
String
|
makeValidKey(String key)
确保密钥对 ResultDB 有效。 |
static
String
|
testSkipReasonToSummaryHtml(SkipReason reason, String skipReasonType)
将测试跳过原因转换为摘要 HTML 字符串。 |
static
TestIdentifier
|
toTestIdentifier(String moduleName, Variant moduleVariant, TestDescription testDescription)
将 TestDescription 转换为 TestIdentifier。 |
static
String
|
truncateString(String input, int maxBytes)
将字符串截断为给定的最大字节数,避免拆分多字节字符。 |
公共构造函数
ResultDBUtil
public ResultDBUtil ()
公共方法
bytesToHex
public static String bytesToHex (byte[] bytes)
将字节数组转换为十六进制字符串。
| 参数 | |
|---|---|
bytes |
byte |
| 返回 | |
|---|---|
String |
|
makeValidKey
public static String makeValidKey (String key)
确保密钥对 ResultDB 有效。
键必须与以下正则表达式匹配:^[a-z][a-z0-9_]*(/[a-z][a-z0-9_]*)*$
| 参数 | |
|---|---|
key |
String |
| 返回 | |
|---|---|
String |
|
testSkipReasonToSummaryHtml
public static String testSkipReasonToSummaryHtml (SkipReason reason, String skipReasonType)
将测试跳过原因转换为摘要 HTML 字符串。ResultDB 尚无跳过原因字段,我们暂时将其放在摘要 HTML 字段和测试制品中。返回的字符串可以长于摘要 HTML 字段限制,调用方应根据需要将其截断。
| 参数 | |
|---|---|
reason |
SkipReason |
skipReasonType |
String |
| 返回 | |
|---|---|
String |
|
toTestIdentifier
public static TestIdentifier toTestIdentifier (String moduleName,
Variant moduleVariant,
TestDescription testDescription)将 TestDescription 转换为 TestIdentifier。
| 参数 | |
|---|---|
moduleName |
String:模块名称 |
moduleVariant |
Variant:模块变体 |
testDescription |
TestDescription:测试说明 |
| 返回 | |
|---|---|
TestIdentifier |
ResultDB 测试标识符。此测试标识符不保证有效(即 ResultDB 可能会拒绝它,并返回 invalid_argument 错误)。这是因为 ResultDB 对测试标识符有更严格的要求,例如字段长度和字符集。 |
truncateString
public static String truncateString (String input,
int maxBytes)将字符串截断为指定的最大字节数,同时避免拆分多字节字符。
| 参数 | |
|---|---|
input |
String:要截断的字符串 |
maxBytes |
int:要截断到的最大字节数(采用 UTF-8 编码) |
| 返回 | |
|---|---|
String |
截断的字符串 |