From 6024f25580ba7cd3bdfefea683bd04d4de302478 Mon Sep 17 00:00:00 2001 From: DeviceInfra Date: Tue, 10 Dec 2024 23:46:10 -0800 Subject: [PATCH] Internal change PiperOrigin-RevId: 704989939 --- .../dispatcher/util/DeviceIdGenerator.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/java/com/google/devtools/mobileharness/api/devicemanager/dispatcher/util/DeviceIdGenerator.java b/src/java/com/google/devtools/mobileharness/api/devicemanager/dispatcher/util/DeviceIdGenerator.java index f45f8bea5..190c5db8f 100644 --- a/src/java/com/google/devtools/mobileharness/api/devicemanager/dispatcher/util/DeviceIdGenerator.java +++ b/src/java/com/google/devtools/mobileharness/api/devicemanager/dispatcher/util/DeviceIdGenerator.java @@ -173,6 +173,24 @@ public DeviceId getLinuxDeviceId(String deviceControlId) { } } + /** + * Generates the Gem5 device id from device control id, and sets uuid in the format + * :gem5:. + * + * @param deviceControlId the device control id from detector. + */ + public DeviceId getGem5DeviceId(String deviceControlId) { + try { + return DeviceId.of( + deviceControlId, String.format("%s:gem5:%s", getLocalHostName(), deviceControlId), true); + } catch (MobileHarnessException e) { + // Should not happen. + logger.atWarning().withCause(e).log( + "Failed to generate Gem5Device uuid, use random uuid instead.."); + return DeviceId.of(deviceControlId, UUID.randomUUID().toString(), true); + } + } + /** * Generates the NoOp device id from device control id, adds the lab host name as the prefix of * the uuid.