Fix holes in file storage proxying
Bug: 7159452
Change-Id: I36b4aa9b44aa60221bb7d612a96abf4eb311755f
diff --git a/src/com/android/tradefed/build/AppDeviceBuildInfo.java b/src/com/android/tradefed/build/AppDeviceBuildInfo.java
index f5bfa77..9286e8f 100644
--- a/src/com/android/tradefed/build/AppDeviceBuildInfo.java
+++ b/src/com/android/tradefed/build/AppDeviceBuildInfo.java
@@ -17,6 +17,7 @@
package com.android.tradefed.build;
import com.android.tradefed.log.LogUtil.CLog;
+import com.android.tradefed.util.NullUtil;
import java.io.File;
import java.util.List;
@@ -298,11 +299,15 @@
*/
@Override
public File getFile(String name) {
+ File localRecord = super.getFile(name);
File deviceFileRecord = mDeviceBuild.getFile(name);
File appFileRecord = mAppBuildInfo.getFile(name);
- if (deviceFileRecord != null && appFileRecord != null) {
- CLog.e("Found duplicate file records for %s in DeviceBuildInfo and AppBuildInfo", name);
+
+ if (NullUtil.countNonNulls(localRecord, deviceFileRecord, appFileRecord) > 1) {
+ CLog.e("Found duplicate records while fetching file with name \"%s\"", name);
return null;
+ } else if (localRecord != null) {
+ return localRecord;
} else if (deviceFileRecord != null) {
return deviceFileRecord;
} else {
@@ -314,6 +319,28 @@
* {@inheritDoc}
*/
@Override
+ public String getVersion(String name) {
+ String localFileVersion = super.getVersion(name);
+ String deviceFileVersion = mDeviceBuild.getVersion(name);
+ String appFileVersion = mAppBuildInfo.getVersion(name);
+
+ if (NullUtil.countNonNulls(localFileVersion, deviceFileVersion, appFileVersion) > 1) {
+ CLog.e("Found duplicate records while fetching file version for \"%s\"", name);
+ return null;
+ } else if (localFileVersion != null) {
+ return localFileVersion;
+ } else if (deviceFileVersion != null) {
+ return deviceFileVersion;
+ } else {
+ return appFileVersion;
+ }
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
public IBuildInfo clone() {
AppDeviceBuildInfo copy = new AppDeviceBuildInfo(getBuildId(), getTestTag(),
getBuildTargetName());