ResultDBUtil
public
final
class
ResultDBUtil
extends Object
| java.lang.Object | |
| ↳ | com.android.tradefed.result.resultdb.ResultDBUtil |
Utility class for ResultDB reporter.
Summary
Nested classes | |
|---|---|
class |
ResultDBUtil.TruncationResult
A simple class to hold the result of a truncation operation. |
Constants | |
|---|---|
String |
NO_MODULE_NAME
|
Public constructors | |
|---|---|
ResultDBUtil()
|
|
Public methods | |
|---|---|
static
String
|
bytesToHex(byte[] bytes)
Converts a byte array to a hexadecimal string. |
static
String
|
makeValidKey(String key)
Ensure the key is valid for ResultDB. |
static
String
|
makeWorkUnitName(String rootInvocationId, String workUnitId)
Create work unit resource name from root invocation id and work unit id. |
static
StringPair
|
primaryErrorTypeTag(TestRecordProto.FailureStatus failureStatus)
Returns a StringPair that can be used to record an error type in the `tags` collection. |
static
TestIdentifier
|
toTestIdentifier(ModuleIdentifier moduleIdentifier, TestDescription testDescription)
Converts a TestDescription to a TestIdentifier. |
static
ResultDBUtil.TruncationResult
|
truncateString(String input, int maxBytes)
Truncates the string to the given max bytes, avoiding breaking up a multi-byte character. |
Constants
NO_MODULE_NAME
public static final String NO_MODULE_NAME
Constant Value: "no-module-name"
Public constructors
ResultDBUtil
public ResultDBUtil ()
Public methods
bytesToHex
public static String bytesToHex (byte[] bytes)
Converts a byte array to a hexadecimal string.
| Parameters | |
|---|---|
bytes |
byte |
| Returns | |
|---|---|
String |
|
makeValidKey
public static String makeValidKey (String key)
Ensure the key is valid for ResultDB.
The key must match the regex: ^[a-z][a-z0-9_]*(/[a-z][a-z0-9_]*)*$
| Parameters | |
|---|---|
key |
String |
| Returns | |
|---|---|
String |
|
makeWorkUnitName
public static String makeWorkUnitName (String rootInvocationId,
String workUnitId)Create work unit resource name from root invocation id and work unit id.
| Parameters | |
|---|---|
rootInvocationId |
String: The root invocation id. |
workUnitId |
String: The work unit id. |
| Returns | |
|---|---|
String |
The work unit resource name. |
primaryErrorTypeTag
public static StringPair primaryErrorTypeTag (TestRecordProto.FailureStatus failureStatus)
Returns a StringPair that can be used to record an error type in the `tags` collection. The value matches AnTS error type values.
| Parameters | |
|---|---|
failureStatus |
TestRecordProto.FailureStatus |
| Returns | |
|---|---|
StringPair |
|
toTestIdentifier
public static TestIdentifier toTestIdentifier (ModuleIdentifier moduleIdentifier,
TestDescription testDescription)Converts a TestDescription to a TestIdentifier.
| Parameters | |
|---|---|
moduleIdentifier |
ModuleIdentifier |
testDescription |
TestDescription: the test description |
| Returns | |
|---|---|
TestIdentifier |
the ResultDB test identifier. This test identifier is not guaranteed to be valid (i.e. ResultDB may reject it, returning a invalid_argument error). This is because ResultDB has more strict requirements on the test identifier, such as the field length and character set. |
truncateString
public static ResultDBUtil.TruncationResult truncateString (String input, int maxBytes)
Truncates the string to the given max bytes, avoiding breaking up a multi-byte character.
| Parameters | |
|---|---|
input |
String: the string to truncate |
maxBytes |
int: the maximum number of bytes (in utf-8 encoding) to truncate to |
| Returns | |
|---|---|
ResultDBUtil.TruncationResult |
a TruncationResult containing the truncated string and a boolean indicating
if truncation happened. |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2026-06-22 UTC.