Fallback to index if delegate mismatch device names
In case of config update of names, they can mismatch.
Fallback to index in this case.
Test: presubmit
Bug: None
Change-Id: Ief32e5568ffcf83f37e6d2ec585cdd34ff764dc0
diff --git a/src/com/android/tradefed/device/internal/EarlyDeviceReleaseFeature.java b/src/com/android/tradefed/device/internal/EarlyDeviceReleaseFeature.java
index d452030..ff5ce16 100644
--- a/src/com/android/tradefed/device/internal/EarlyDeviceReleaseFeature.java
+++ b/src/com/android/tradefed/device/internal/EarlyDeviceReleaseFeature.java
@@ -68,10 +68,14 @@
public FeatureResponse execute(FeatureRequest featureRequest) {
Map<String, String> deviceStatusMap = featureRequest.getArgsMap();
Map<ITestDevice, FreeDeviceState> deviceStates = new LinkedHashMap<>();
+ int index = 0;
for (Map.Entry<String, String> entry : deviceStatusMap.entrySet()) {
- deviceStates.put(
- mTestInformation.getContext().getDevice(entry.getKey()),
- FreeDeviceState.valueOf(entry.getValue()));
+ ITestDevice device = mTestInformation.getContext().getDevice(entry.getKey());
+ if (device == null) {
+ device = mTestInformation.getContext().getDevices().get(index);
+ }
+ deviceStates.put(device, FreeDeviceState.valueOf(entry.getValue()));
+ index++;
}
mTestInformation.getContext().markReleasedEarly();
for (IScheduledInvocationListener listener : mScheduledInvocationListeners) {