Merge "Allow the forwarding to work for multi-modules and non-modules"
diff --git a/.classpath b/.classpath
index 1fa4153..cb5b011 100644
--- a/.classpath
+++ b/.classpath
@@ -1,7 +1,8 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <classpath>
 	<classpathentry kind="src" path="src"/>
-	<classpathentry kind="src" path="clearcut_client"/>
+	<classpathentry excluding="Android.bp" kind="src" path="invocation_interfaces"/>
+	<classpathentry excluding="Android.bp" kind="src" path="test_result_interfaces"/>
 	<classpathentry excluding="Android.bp" kind="src" path="clearcut_client"/>
 	<classpathentry kind="src" path="res"/>
 	<classpathentry kind="src" path="hamcrest"/>
@@ -10,7 +11,6 @@
 	<classpathentry excluding="Android.bp" kind="src" path="common_util"/>
 	<classpathentry kind="src" path="global_configuration"/>
 	<classpathentry excluding="Android.bp" kind="src" path="device_build_interfaces"/>
-	<classpathentry excluding="Android.bp" kind="src" path="result_interfaces"/>
 	<classpathentry combineaccessrules="false" exported="true" kind="src" path="/tf-remote-client"/>
 	<classpathentry combineaccessrules="false" kind="src" path="/LongevityHostRunner"/>
 	<classpathentry combineaccessrules="false" kind="src" path="/ddmlib"/>
diff --git a/Android.bp b/Android.bp
index 6a5ce15..b539caa 100644
--- a/Android.bp
+++ b/Android.bp
@@ -88,6 +88,7 @@
         "tradefed-clearcut-client",
         "tradefed-result-interfaces",
         "tradefed-device-build-interfaces",
+	"tradefed-invocation-interfaces",
         "protobuf-java-util-prebuilt-jar",
         "aoa-helper",
         "error_prone_annotations-2.0.18",
diff --git a/common_util/com/android/tradefed/config/OptionDef.java b/common_util/com/android/tradefed/config/OptionDef.java
new file mode 100644
index 0000000..b6f0a03
--- /dev/null
+++ b/common_util/com/android/tradefed/config/OptionDef.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.tradefed.config;
+
+import com.android.tradefed.build.BuildSerializedVersion;
+
+import java.io.Serializable;
+
+/** Holds the details of an {@link Option}. */
+public final class OptionDef implements Serializable {
+    private static final long serialVersionUID = BuildSerializedVersion.VERSION;
+
+    public final String name;
+    public final String key;
+    public final String value;
+    public final String source;
+    public final String applicableObjectType;
+
+    public OptionDef(String optionName, String optionValue, String source) {
+        this(optionName, null, optionValue, source, null);
+    }
+
+    public OptionDef(String optionName, String optionKey, String optionValue, String source) {
+        this(optionName, optionKey, optionValue, source, null);
+    }
+
+    public OptionDef(
+            String optionName, String optionKey, String optionValue, String source, String type) {
+        this.name = optionName;
+        this.key = optionKey;
+        this.value = optionValue;
+        this.source = source;
+        this.applicableObjectType = type;
+    }
+}
diff --git a/invocation_interfaces/Android.bp b/invocation_interfaces/Android.bp
new file mode 100644
index 0000000..5208e51
--- /dev/null
+++ b/invocation_interfaces/Android.bp
@@ -0,0 +1,29 @@
+// Copyright 2019 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+java_library_host {
+    name: "tradefed-invocation-interfaces",
+    defaults: ["tradefed_defaults"],
+    srcs: [
+        "com/**/*.java",
+    ],
+    libs: [
+        "guava",
+        "tradefed-common-util",
+        "tradefed-protos",
+        "tradefed-result-interfaces",
+        "tradefed-device-build-interfaces",
+    ],
+}
+
diff --git a/src/com/android/tradefed/config/ConfigurationDescriptor.java b/invocation_interfaces/com/android/tradefed/config/ConfigurationDescriptor.java
similarity index 98%
rename from src/com/android/tradefed/config/ConfigurationDescriptor.java
rename to invocation_interfaces/com/android/tradefed/config/ConfigurationDescriptor.java
index 3c1ba13..bc6d30c 100644
--- a/src/com/android/tradefed/config/ConfigurationDescriptor.java
+++ b/invocation_interfaces/com/android/tradefed/config/ConfigurationDescriptor.java
@@ -16,7 +16,6 @@
 package com.android.tradefed.config;
 
 import com.android.tradefed.build.BuildSerializedVersion;
-import com.android.tradefed.config.ConfigurationDef.OptionDef;
 import com.android.tradefed.config.proto.ConfigurationDescription;
 import com.android.tradefed.config.proto.ConfigurationDescription.Descriptor;
 import com.android.tradefed.config.proto.ConfigurationDescription.Metadata;
diff --git a/src/com/android/tradefed/invoker/IInvocationContext.java b/invocation_interfaces/com/android/tradefed/invoker/IInvocationContext.java
similarity index 95%
rename from src/com/android/tradefed/invoker/IInvocationContext.java
rename to invocation_interfaces/com/android/tradefed/invoker/IInvocationContext.java
index 9175550..537daf4 100644
--- a/src/com/android/tradefed/invoker/IInvocationContext.java
+++ b/invocation_interfaces/com/android/tradefed/invoker/IInvocationContext.java
@@ -19,7 +19,6 @@
 import com.android.tradefed.config.ConfigurationDescriptor;
 import com.android.tradefed.device.ITestDevice;
 import com.android.tradefed.device.ITestDevice.RecoveryMode;
-import com.android.tradefed.testtype.suite.ITestSuite;
 import com.android.tradefed.util.MultiMap;
 import com.android.tradefed.util.UniqueMultiMap;
 
@@ -159,14 +158,10 @@
      */
     public ConfigurationDescriptor getConfigurationDescriptor();
 
-    /**
-     * Sets the invocation context of module while being executed as part of a {@link ITestSuite}
-     */
+    /** Sets the invocation context of module while being executed as part of a suite. */
     public void setModuleInvocationContext(IInvocationContext invocationContext);
 
-    /**
-     * Returns the invocation context of module while being executed as part of a {@link ITestSuite}
-     */
+    /** Returns the invocation context of module while being executed as part of a suite. */
     public IInvocationContext getModuleInvocationContext();
 
     /** Returns the invocation test-tag. */
diff --git a/src/com/android/tradefed/result/ILogSaver.java b/invocation_interfaces/com/android/tradefed/result/ILogSaver.java
similarity index 100%
rename from src/com/android/tradefed/result/ILogSaver.java
rename to invocation_interfaces/com/android/tradefed/result/ILogSaver.java
diff --git a/src/com/android/tradefed/result/ILogSaverListener.java b/invocation_interfaces/com/android/tradefed/result/ILogSaverListener.java
similarity index 100%
rename from src/com/android/tradefed/result/ILogSaverListener.java
rename to invocation_interfaces/com/android/tradefed/result/ILogSaverListener.java
diff --git a/src/com/android/tradefed/result/ITestInvocationListener.java b/invocation_interfaces/com/android/tradefed/result/ITestInvocationListener.java
similarity index 89%
rename from src/com/android/tradefed/result/ITestInvocationListener.java
rename to invocation_interfaces/com/android/tradefed/result/ITestInvocationListener.java
index 72ff5ad..e6f5357 100644
--- a/src/com/android/tradefed/result/ITestInvocationListener.java
+++ b/invocation_interfaces/com/android/tradefed/result/ITestInvocationListener.java
@@ -15,10 +15,8 @@
  */
 package com.android.tradefed.result;
 
-import com.android.tradefed.command.ICommandScheduler;
 import com.android.tradefed.invoker.IInvocationContext;
 import com.android.tradefed.log.ITestLogger;
-import com.android.tradefed.testtype.suite.ITestSuite;
 
 /**
  * Listener for test results from the test invocation.
@@ -82,17 +80,17 @@
     default public TestSummary getSummary() { return null; }
 
     /**
-     * Called on {@link ICommandScheduler#shutdown()}, gives the invocation the opportunity to do
-     * something before terminating.
+     * Called on scheduler shutdown, gives the invocation the opportunity to do something before
+     * terminating.
      */
-    default public void invocationInterrupted() {
+    public default void invocationInterrupted() {
         // do nothing in default implementation.
     }
 
     /**
      * Reports the beginning of a module running. This callback is associated with {@link
      * #testModuleEnded()} and is optional in the sequence. It is only used during a run that uses
-     * modules: {@link ITestSuite} based runners.
+     * modules: suite based runners.
      *
      * @param moduleContext the {@link IInvocationContext} of the module.
      */
diff --git a/src/com/android/tradefed/result/LogFile.java b/invocation_interfaces/com/android/tradefed/result/LogFile.java
similarity index 100%
rename from src/com/android/tradefed/result/LogFile.java
rename to invocation_interfaces/com/android/tradefed/result/LogFile.java
diff --git a/src/com/android/tradefed/result/TestSummary.java b/invocation_interfaces/com/android/tradefed/result/TestSummary.java
similarity index 100%
rename from src/com/android/tradefed/result/TestSummary.java
rename to invocation_interfaces/com/android/tradefed/result/TestSummary.java
diff --git a/src/com/android/tradefed/config/Configuration.java b/src/com/android/tradefed/config/Configuration.java
index e8fb615..242c566 100644
--- a/src/com/android/tradefed/config/Configuration.java
+++ b/src/com/android/tradefed/config/Configuration.java
@@ -19,7 +19,6 @@
 import com.android.tradefed.build.IBuildProvider;
 import com.android.tradefed.command.CommandOptions;
 import com.android.tradefed.command.ICommandOptions;
-import com.android.tradefed.config.ConfigurationDef.OptionDef;
 import com.android.tradefed.config.OptionSetter.FieldDef;
 import com.android.tradefed.device.IDeviceRecovery;
 import com.android.tradefed.device.IDeviceSelection;
diff --git a/src/com/android/tradefed/config/ConfigurationDef.java b/src/com/android/tradefed/config/ConfigurationDef.java
index c99b79f..4024356 100644
--- a/src/com/android/tradefed/config/ConfigurationDef.java
+++ b/src/com/android/tradefed/config/ConfigurationDef.java
@@ -16,12 +16,10 @@
 
 package com.android.tradefed.config;
 
-import com.android.tradefed.build.BuildSerializedVersion;
 import com.android.tradefed.device.metric.IMetricCollector;
 import com.android.tradefed.log.LogUtil.CLog;
 
 import java.io.File;
-import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.LinkedHashMap;
@@ -51,38 +49,6 @@
     /** The set of files (and modification times) that were used to load this config */
     private final Map<File, Long> mSourceFiles = new HashMap<>();
 
-    /** Holds the details of an option. */
-    public static final class OptionDef implements Serializable {
-        private static final long serialVersionUID = BuildSerializedVersion.VERSION;
-
-        public final String name;
-        public final String key;
-        public final String value;
-        public final String source;
-        public final String applicableObjectType;
-
-        public OptionDef(String optionName, String optionValue, String source) {
-            this(optionName, null, optionValue, source, null);
-        }
-
-        public OptionDef(String optionName, String optionKey, String optionValue, String source) {
-            this(optionName, optionKey, optionValue, source, null);
-        }
-
-        public OptionDef(
-                String optionName,
-                String optionKey,
-                String optionValue,
-                String source,
-                String type) {
-            this.name = optionName;
-            this.key = optionKey;
-            this.value = optionValue;
-            this.source = source;
-            this.applicableObjectType = type;
-        }
-    }
-
     /**
      * Object to hold info for a className and the appearance number it has (e.g. if a config has
      * the same object twice, the first one will have the first appearance number).
diff --git a/src/com/android/tradefed/config/IConfiguration.java b/src/com/android/tradefed/config/IConfiguration.java
index 35f8a95..53751cc 100644
--- a/src/com/android/tradefed/config/IConfiguration.java
+++ b/src/com/android/tradefed/config/IConfiguration.java
@@ -18,7 +18,6 @@
 
 import com.android.tradefed.build.IBuildProvider;
 import com.android.tradefed.command.ICommandOptions;
-import com.android.tradefed.config.ConfigurationDef.OptionDef;
 import com.android.tradefed.device.IDeviceRecovery;
 import com.android.tradefed.device.IDeviceSelection;
 import com.android.tradefed.device.TestDeviceOptions;
diff --git a/src/com/android/tradefed/testtype/suite/SuiteModuleLoader.java b/src/com/android/tradefed/testtype/suite/SuiteModuleLoader.java
index 0ab0f14..08dd626 100644
--- a/src/com/android/tradefed/testtype/suite/SuiteModuleLoader.java
+++ b/src/com/android/tradefed/testtype/suite/SuiteModuleLoader.java
@@ -15,13 +15,13 @@
  */
 package com.android.tradefed.testtype.suite;
 
-import com.android.tradefed.config.ConfigurationDef.OptionDef;
 import com.android.tradefed.config.ConfigurationDescriptor;
 import com.android.tradefed.config.ConfigurationException;
 import com.android.tradefed.config.ConfigurationFactory;
 import com.android.tradefed.config.ConfigurationUtil;
 import com.android.tradefed.config.IConfiguration;
 import com.android.tradefed.config.IConfigurationFactory;
+import com.android.tradefed.config.OptionDef;
 import com.android.tradefed.log.LogUtil.CLog;
 import com.android.tradefed.targetprep.ITargetPreparer;
 import com.android.tradefed.testtype.IAbi;
@@ -560,7 +560,7 @@
             }
             // Do not consider the excluded parameterization dimension
             if (mExcludedModuleParameters.contains(suiteParam)) {
-                CLog.d("'%s' was excluded via exclude-module-parameters.");
+                CLog.d("'%s' was excluded via exclude-module-parameters.", moduleName);
                 continue;
             }
             IModuleParameter handler =
diff --git a/src/com/android/tradefed/util/LocalRunInstructionBuilder.java b/src/com/android/tradefed/util/LocalRunInstructionBuilder.java
index ccd312c..7117264 100644
--- a/src/com/android/tradefed/util/LocalRunInstructionBuilder.java
+++ b/src/com/android/tradefed/util/LocalRunInstructionBuilder.java
@@ -16,9 +16,9 @@
 
 package com.android.tradefed.util;
 
-import com.android.tradefed.config.ConfigurationDef.OptionDef;
 import com.android.tradefed.config.ConfigurationDescriptor;
 import com.android.tradefed.config.ConfigurationDescriptor.LocalTestRunner;
+import com.android.tradefed.config.OptionDef;
 import com.android.tradefed.log.LogUtil.CLog;
 import com.android.tradefed.result.TestDescription;
 
diff --git a/result_interfaces/Android.bp b/test_result_interfaces/Android.bp
similarity index 100%
rename from result_interfaces/Android.bp
rename to test_result_interfaces/Android.bp
diff --git a/result_interfaces/com/android/tradefed/log/ITestLogger.java b/test_result_interfaces/com/android/tradefed/log/ITestLogger.java
similarity index 100%
rename from result_interfaces/com/android/tradefed/log/ITestLogger.java
rename to test_result_interfaces/com/android/tradefed/log/ITestLogger.java
diff --git a/result_interfaces/com/android/tradefed/result/ITestLifeCycleReceiver.java b/test_result_interfaces/com/android/tradefed/result/ITestLifeCycleReceiver.java
similarity index 100%
rename from result_interfaces/com/android/tradefed/result/ITestLifeCycleReceiver.java
rename to test_result_interfaces/com/android/tradefed/result/ITestLifeCycleReceiver.java
diff --git a/result_interfaces/com/android/tradefed/result/ITestLoggerReceiver.java b/test_result_interfaces/com/android/tradefed/result/ITestLoggerReceiver.java
similarity index 100%
rename from result_interfaces/com/android/tradefed/result/ITestLoggerReceiver.java
rename to test_result_interfaces/com/android/tradefed/result/ITestLoggerReceiver.java
diff --git a/result_interfaces/com/android/tradefed/result/TestDescription.java b/test_result_interfaces/com/android/tradefed/result/TestDescription.java
similarity index 100%
rename from result_interfaces/com/android/tradefed/result/TestDescription.java
rename to test_result_interfaces/com/android/tradefed/result/TestDescription.java
diff --git a/result_interfaces/com/android/tradefed/util/proto/TestRecordProtoUtil.java b/test_result_interfaces/com/android/tradefed/util/proto/TestRecordProtoUtil.java
similarity index 100%
rename from result_interfaces/com/android/tradefed/util/proto/TestRecordProtoUtil.java
rename to test_result_interfaces/com/android/tradefed/util/proto/TestRecordProtoUtil.java
diff --git a/result_interfaces/com/android/tradefed/util/proto/TfMetricProtoUtil.java b/test_result_interfaces/com/android/tradefed/util/proto/TfMetricProtoUtil.java
similarity index 100%
rename from result_interfaces/com/android/tradefed/util/proto/TfMetricProtoUtil.java
rename to test_result_interfaces/com/android/tradefed/util/proto/TfMetricProtoUtil.java
diff --git a/tests/src/com/android/tradefed/config/ConfigurationTest.java b/tests/src/com/android/tradefed/config/ConfigurationTest.java
index 5e10ce5..5649fb0 100644
--- a/tests/src/com/android/tradefed/config/ConfigurationTest.java
+++ b/tests/src/com/android/tradefed/config/ConfigurationTest.java
@@ -20,7 +20,6 @@
 import com.android.tradefed.build.IBuildProvider;
 import com.android.tradefed.command.CommandOptions;
 import com.android.tradefed.command.ICommandOptions;
-import com.android.tradefed.config.ConfigurationDef.OptionDef;
 import com.android.tradefed.device.DeviceNotAvailableException;
 import com.android.tradefed.device.IDeviceRecovery;
 import com.android.tradefed.device.IDeviceSelection;
diff --git a/tests/src/com/android/tradefed/util/LocalRunInstructionBuilderTest.java b/tests/src/com/android/tradefed/util/LocalRunInstructionBuilderTest.java
index 80cf801..4a9d110 100644
--- a/tests/src/com/android/tradefed/util/LocalRunInstructionBuilderTest.java
+++ b/tests/src/com/android/tradefed/util/LocalRunInstructionBuilderTest.java
@@ -17,9 +17,9 @@
 
 import static org.junit.Assert.assertEquals;
 
-import com.android.tradefed.config.ConfigurationDef.OptionDef;
 import com.android.tradefed.config.ConfigurationDescriptor;
 import com.android.tradefed.config.ConfigurationDescriptor.LocalTestRunner;
+import com.android.tradefed.config.OptionDef;
 import com.android.tradefed.result.TestDescription;
 import com.android.tradefed.testtype.Abi;