Merge "Fix mock of IBuildInfo call on getRemoteFiles"
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/result/ResultReporter.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/result/ResultReporter.java
index eb50448..f18a581 100644
--- a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/result/ResultReporter.java
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/result/ResultReporter.java
@@ -530,6 +530,15 @@
         }
     }
 
+    /**
+     * Returns whether a report creation should be skipped.
+     */
+    protected boolean shouldSkipReportCreation() {
+        // This value is always false here for backwards compatibility.
+        // Extended classes have the option to override this.
+        return false;
+    }
+
     private void finalizeResults() {
         // Add all device serials into the result to be serialized
         for (String deviceSerial : mMasterDeviceSerials) {
@@ -559,6 +568,10 @@
                 mResult.getModuleCompleteCount(), mResult.getModules().size());
 
 
+        if (shouldSkipReportCreation()) {
+            return;
+        }
+
         try {
             // Zip the full test results directory.
             copyDynamicConfigFiles();
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/BusinessLogicPreparer.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/BusinessLogicPreparer.java
index b33ee08..48709fc 100644
--- a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/BusinessLogicPreparer.java
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/BusinessLogicPreparer.java
@@ -101,8 +101,6 @@
             "business_logic_extended_device_info";
     private static final String DYNAMIC_CONFIG_CONDITIONAL_TESTS_ENABLED_KEY =
             "conditional_business_logic_tests_enabled";
-    /* Format used to append the enabled attribute to the serialized business logic string. */
-    private static final String ENABLED_ATTRIBUTE_SNIPPET = ", \"%s\":%s }";
 
     @Option(name = "business-logic-url", description = "The URL to use when accessing the " +
             "business logic service, parameters not included", mandatory = true)
@@ -129,10 +127,6 @@
             "suite invocation if retrieval of business logic fails.")
     private boolean mIgnoreFailure = false;
 
-    @Option(name="conditional-business-logic-tests-enabled",
-            description="Setting to true will ensure the device specific tests are executed.")
-    private boolean mConditionalTestsEnabled = false;
-
     @Option(name = "business-logic-connection-time", description = "Amount of time to attempt " +
             "connection to the business logic service, in seconds.")
     private int mMaxConnectionTime = DEFAULT_CONNECTION_TIME;
@@ -203,7 +197,6 @@
                 && System.currentTimeMillis() < (start + (mMaxConnectionTime * 1000))) {
             try {
                 businessLogicString = doPost(baseUrl, requestParams);
-                businessLogicString = addRuntimeConfig(businessLogicString, buildInfo);
             } catch (IOException e) {
                 // ignore, re-attempt connection with remaining time
                 CLog.d("BusinessLogic connection failure message: %s\nRetrying...", e.getMessage());
@@ -410,37 +403,6 @@
     }
 
     /**
-     * Append runtime configuration attributes to the end of the Json string.
-     * Determine if conditional tests should execute and add the value to the serialized business
-     * logic settings.
-     */
-    private String addRuntimeConfig(String businessLogicString, IBuildInfo buildInfo) {
-        int indexOfClosingParen = businessLogicString.lastIndexOf("}");
-        // Replace the closing paren with th enabled flag and closing paren. ex
-        // { "a":4 } -> {"a":4, "enabled":true }
-        return businessLogicString.substring(0, indexOfClosingParen) +
-                String.format(ENABLED_ATTRIBUTE_SNIPPET,
-                        BusinessLogicFactory.CONDITIONAL_TESTS_ENABLED,
-                        shouldExecuteConditionalTests(buildInfo));
-    }
-
-    /**
-     * Execute device specific test if enabled in config or through the command line.
-     * Otherwise skip all conditional tests.
-     */
-    private boolean shouldExecuteConditionalTests(IBuildInfo buildInfo) {
-        boolean enabledInConfig = false;
-        try {
-            String enabledInConfigValue = DynamicConfigFileReader.getValueFromConfig(
-                    buildInfo, getSuiteName(), DYNAMIC_CONFIG_CONDITIONAL_TESTS_ENABLED_KEY);
-            enabledInConfig = Boolean.parseBoolean(enabledInConfigValue);
-        } catch (XmlPullParserException | IOException e) {
-            CLog.e("Failed to pull business logic features from dynamic config");
-        }
-        return enabledInConfig || mConditionalTestsEnabled;
-    }
-
-    /**
      * Read the string from the business logic cache, handling the following cases with a null
      * return value:
      * - The cached file does not exist
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/BusinessLogicHostTestBase.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/BusinessLogicHostTestBase.java
index f24a021..33fe835 100644
--- a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/BusinessLogicHostTestBase.java
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/BusinessLogicHostTestBase.java
@@ -50,7 +50,6 @@
     @Before
     public void handleBusinessLogic() {
         loadBusinessLogic();
-        ensureAuthenticated();
         executeBusinessLogic();
     }
 
@@ -92,27 +91,6 @@
         }
     }
 
-    protected void ensureAuthenticated() {
-        if (!mCanReadBusinessLogic) {
-            // super class handles the condition that the service is unavailable.
-            return;
-        }
-
-        if (!mBusinessLogic.mConditionalTestsEnabled) {
-            skipTest("Execution of device specific tests is not enabled. "
-                    + "Enable with '--conditional-business-logic-tests-enabled'");
-        }
-
-        if (mBusinessLogic.isAuthorized()) {
-            // Run test as normal.
-            return;
-        }
-        String message = mBusinessLogic.getAuthenticationStatusMessage();
-
-        // Fail test since request was not authorized.
-        failTest(String.format("Unable to execute because %s.", message));
-    }
-
     public static void skipTest(String message) {
         assumeTrue(message, false);
     }
diff --git a/common/host-side/util/src/com/android/compatibility/common/util/PropertyUtil.java b/common/host-side/util/src/com/android/compatibility/common/util/PropertyUtil.java
index 1dd78aa..b354f66 100644
--- a/common/host-side/util/src/com/android/compatibility/common/util/PropertyUtil.java
+++ b/common/host-side/util/src/com/android/compatibility/common/util/PropertyUtil.java
@@ -51,12 +51,6 @@
         return propertyEquals(device, BUILD_TYPE_PROPERTY, "user");
     }
 
-    /** Returns whether the device build is the factory ROM */
-    public static boolean isFactoryROM(ITestDevice device) throws DeviceNotAvailableException {
-        // first API level property should be undefined if and only if the product is factory ROM.
-        return device.getProperty(FIRST_API_LEVEL) == null;
-    }
-
     /** Returns whether this build is built with dev-keys */
     public static boolean isDevKeysBuild(ITestDevice device) throws DeviceNotAvailableException {
         String buildTags = device.getProperty(BUILD_TAGS_PROPERTY);