Merge "Compact all the protos results together at the end"
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 227fcf5..c6ccd2a 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
@@ -172,8 +172,8 @@
     private ICaseResult mCurrentCaseResult;
     private ITestResult mCurrentResult;
     private String mDeviceSerial = UNKNOWN_DEVICE;
-    private Set<String> mMasterDeviceSerials = new HashSet<>();
-    private Set<IBuildInfo> mMasterBuildInfos = new HashSet<>();
+    private Set<String> mMainDeviceSerials = new HashSet<>();
+    private Set<IBuildInfo> mMainBuildInfos = new HashSet<>();
     // Whether or not we failed the fingerprint check
     private boolean mFingerprintFailure = false;
 
@@ -191,10 +191,9 @@
     // Whether the current module has previously been marked done
     private boolean mModuleWasDone;
 
-    // Nullable. If null, "this" is considered the master and must handle
-    // result aggregation and reporting. When not null, it should forward events
-    // to the master.
-    private final ResultReporter mMasterResultReporter;
+    // Nullable. If null, "this" is considered the primary and must handle
+    // result aggregation and reporting. When not null, it should forward events to the primary
+    private final ResultReporter mPrimaryResultReporter;
 
     private LogFileSaver mTestLogSaver;
 
@@ -213,11 +212,10 @@
     }
 
     /**
-     * Construct a shard ResultReporter that forwards module results to the
-     * masterResultReporter.
+     * Construct a shard ResultReporter that forwards module results to the mPrimaryResultReporter.
      */
-    public ResultReporter(ResultReporter masterResultReporter) {
-        mMasterResultReporter = masterResultReporter;
+    public ResultReporter(ResultReporter primaryResultReporter) {
+        mPrimaryResultReporter = primaryResultReporter;
     }
 
     /** {@inheritDoc} */
@@ -243,22 +241,22 @@
         }
 
         if (isShardResultReporter()) {
-            // Shard ResultReporters forward invocationStarted to the mMasterResultReporter
-            mMasterResultReporter.invocationStarted(context);
+            // Shard ResultReporters forward invocationStarted to the mPrimaryResultReporter
+            mPrimaryResultReporter.invocationStarted(context);
             return;
         }
 
-        // NOTE: Everything after this line only applies to the master ResultReporter.
+        // NOTE: Everything after this line only applies to the primary ResultReporter.
 
-        synchronized(this) {
+        synchronized (this) {
             if (primaryBuild.getDeviceSerial() != null) {
-                // The master ResultReporter collects all device serials being used
+                // The primary ResultReporter collects all device serials being used
                 // for the current implementation.
-                mMasterDeviceSerials.add(primaryBuild.getDeviceSerial());
+                mMainDeviceSerials.add(primaryBuild.getDeviceSerial());
             }
 
-            // The master ResultReporter collects all buildInfos.
-            mMasterBuildInfos.add(primaryBuild);
+            // The primary ResultReporter collects all buildInfos.
+            mMainBuildInfos.add(primaryBuild);
 
             if (mResultDir == null) {
                 // For the non-sharding case, invocationStarted is only called once,
@@ -456,8 +454,8 @@
             }
         }
         if (isShardResultReporter()) {
-            // Forward module results to the master.
-            mMasterResultReporter.mergeModuleResult(mCurrentModuleResult);
+            // Forward module results to the primary.
+            mPrimaryResultReporter.mergeModuleResult(mCurrentModuleResult);
             mCurrentModuleResult.resetTestRuns();
             mCurrentModuleResult.resetRuntime();
         }
@@ -527,17 +525,17 @@
     public void invocationEnded(long elapsedTime) {
         if (isShardResultReporter()) {
             // Shard ResultReporters report
-            mMasterResultReporter.invocationEnded(elapsedTime);
+            mPrimaryResultReporter.invocationEnded(elapsedTime);
             return;
         }
 
-        // NOTE: Everything after this line only applies to the master ResultReporter.
+        // NOTE: Everything after this line only applies to the primary ResultReporter.
 
-        synchronized(this) {
-            // The master ResultReporter tracks the progress of all invocations across
+        synchronized (this) {
+            // The mPrimaryResultReporter tracks the progress of all invocations across
             // shard ResultReporters. Writing results should not proceed until all
             // ResultReporters have completed.
-            if (++invocationEndedCount < mMasterBuildInfos.size()) {
+            if (++invocationEndedCount < mMainBuildInfos.size()) {
                 return;
             }
             mElapsedTime = elapsedTime;
@@ -561,14 +559,14 @@
             return;
         }
         // Add all device serials into the result to be serialized
-        for (String deviceSerial : mMasterDeviceSerials) {
+        for (String deviceSerial : mMainDeviceSerials) {
             mResult.addDeviceSerial(deviceSerial);
         }
 
         addDeviceBuildInfoToResult();
 
         Set<String> allExpectedModules = new HashSet<>();
-        for (IBuildInfo buildInfo : mMasterBuildInfos) {
+        for (IBuildInfo buildInfo : mMainBuildInfos) {
             for (Map.Entry<String, String> entry : buildInfo.getBuildAttributes().entrySet()) {
                 String key = entry.getKey();
                 String value = entry.getValue();
@@ -703,10 +701,10 @@
      */
     @Override
     public void testLog(String name, LogDataType type, InputStreamSource stream) {
-        // This is safe to be invoked on either the master or a shard ResultReporter
+        // This is safe to be invoked on either the primary or a shard ResultReporter
         if (isShardResultReporter()) {
-            // Shard ResultReporters forward testLog to the mMasterResultReporter
-            mMasterResultReporter.testLog(name, type, stream);
+            // Shard ResultReporters forward testLog to the mPrimaryResultReporter
+            mPrimaryResultReporter.testLog(name, type, stream);
             return;
         }
         if (name.endsWith(DeviceInfo.FILE_SUFFIX)) {
@@ -733,7 +731,7 @@
         }
     }
 
-    /* Write device-info files to the result, invoked only by the master result reporter */
+    /* Write device-info files to the result, invoked only by the primary result reporter */
     private void testLogDeviceInfo(String name, InputStreamSource stream) {
         try {
             File ediDir = new File(mResultDir, DeviceInfo.RESULT_DIR_NAME);
@@ -755,8 +753,9 @@
     @Override
     public void testLogSaved(String dataName, LogDataType dataType, InputStreamSource dataStream,
             LogFile logFile) {
-        // This is safe to be invoked on either the master or a shard ResultReporter
-        if (mIncludeTestLogTags && mCurrentResult != null
+        // This is safe to be invoked on either the primary or a shard ResultReporter
+        if (mIncludeTestLogTags
+                && mCurrentResult != null
                 && dataName.startsWith(mCurrentResult.getFullName())) {
 
             if (dataType == LogDataType.BUGREPORT) {
@@ -774,7 +773,7 @@
      */
     @Override
     public void setLogSaver(ILogSaver saver) {
-        // This is safe to be invoked on either the master or a shard ResultReporter
+        // This is safe to be invoked on either the primary or a shard ResultReporter
         mLogSaver = saver;
     }
 
@@ -896,7 +895,7 @@
     /** Aggregate build info from member device info. */
     protected Map<String, String> mapBuildInfo() {
         Map<String, String> buildProperties = new HashMap<>();
-        for (IBuildInfo buildInfo : mMasterBuildInfos) {
+        for (IBuildInfo buildInfo : mMainBuildInfos) {
             for (Map.Entry<String, String> entry : buildInfo.getBuildAttributes().entrySet()) {
                 String key = entry.getKey();
                 String value = entry.getValue();
@@ -930,11 +929,11 @@
     }
 
     /**
-     * Return true if this instance is a shard ResultReporter and should propagate
-     * certain events to the master.
+     * Return true if this instance is a shard ResultReporter and should propagate certain events to
+     * the primary.
      */
     private boolean isShardResultReporter() {
-        return mMasterResultReporter != null;
+        return mPrimaryResultReporter != null;
     }
 
     /**
@@ -1012,7 +1011,7 @@
         }
 
         Set<String> uniqueModules = new HashSet<>();
-        for (IBuildInfo buildInfo : mMasterBuildInfos) {
+        for (IBuildInfo buildInfo : mMainBuildInfos) {
             CompatibilityBuildHelper helper = new CompatibilityBuildHelper(buildInfo);
             Map<String, File> dcFiles = helper.getDynamicConfigFiles();
             for (String moduleName : dcFiles.keySet()) {
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/result/suite/CertificationSuiteResultReporter.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/result/suite/CertificationSuiteResultReporter.java
index a7a94c4..6513b47 100644
--- a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/result/suite/CertificationSuiteResultReporter.java
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/result/suite/CertificationSuiteResultReporter.java
@@ -231,7 +231,7 @@
         }
     }
 
-    /** Write device-info files to the result, invoked only by the master result reporter */
+    /** Write device-info files to the result */
     private void testLogDeviceInfo(String name, InputStreamSource stream) {
         try {
             File ediDir = new File(mResultDir, DeviceInfo.RESULT_DIR_NAME);
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/CompatibilityTest.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/CompatibilityTest.java
index 951b1dc..72d2f4f 100644
--- a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/CompatibilityTest.java
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/CompatibilityTest.java
@@ -242,12 +242,14 @@
             description = "Don't verify device connectivity between module execution.")
     private boolean mSkipConnectivityCheck = false;
 
-    @Option(name = "preparer-whitelist",
-            description = "Only run specific preparers."
-            + "Specify zero or more ITargetPreparers as canonical class names. "
-            + "e.g. \"com.android.compatibility.common.tradefed.targetprep.ApkInstaller\" "
-            + "If not specified, all configured preparers are run.")
-    private Set<String> mPreparerWhitelist = new HashSet<>();
+    @Option(
+            name = "preparer-whitelist",
+            description =
+                    "Only run specific preparers."
+                            + "Specify zero or more ITargetPreparers as canonical class names. "
+                            + "e.g. \"com.android.compatibility.common.tradefed.targetprep.ApkInstaller\" "
+                            + "If not specified, all configured preparers are run.")
+    private Set<String> mPreparerAllowlist = new HashSet<>();
 
     @Option(name = "skip-all-system-status-check",
             description = "Whether all system status check between modules should be skipped")
@@ -416,7 +418,7 @@
                 IModuleDef module = modules.get(i);
                 module.setBuild(mBuildHelper.getBuildInfo());
                 module.setDevice(mDevice);
-                module.setPreparerWhitelist(mPreparerWhitelist);
+                module.setPreparerAllowlist(mPreparerAllowlist);
                 // don't set a value if unspecified
                 if (mCollectTestsOnly != null) {
                     module.setCollectTestsOnly(mCollectTestsOnly);
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/IModuleDef.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/IModuleDef.java
index 5b49ed6..1424e12 100644
--- a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/IModuleDef.java
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/IModuleDef.java
@@ -78,12 +78,12 @@
     IRemoteTest getTest();
 
     /**
-     * Set a list of preparers to allow to run before or after a test.
-     * If this list is empty, then all configured preparers will run.
+     * Set a list of preparers to allow to run before or after a test. If this list is empty, then
+     * all configured preparers will run.
      *
-     * @param preparerWhitelist list containing the simple name of the preparer to run.
+     * @param preparerAllowlist list containing the simple name of the preparer to run.
      */
-    void setPreparerWhitelist(Set<String> preparerWhitelist);
+    void setPreparerAllowlist(Set<String> preparerAllowlist);
 
     /**
      * Pushes dynamic configuration, then runs the module's precondition checks and setup tasks.
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/ModuleDef.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/ModuleDef.java
index afb59c8..9e4fde7 100644
--- a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/ModuleDef.java
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/ModuleDef.java
@@ -73,7 +73,7 @@
     private List<ITargetCleaner> mCleaners = new ArrayList<>();
     private IBuildInfo mBuild;
     private ITestDevice mDevice;
-    private Set<String> mPreparerWhitelist = new HashSet<>();
+    private Set<String> mPreparerAllowlist = new HashSet<>();
     private ConfigurationDescriptor mConfigurationDescriptor;
     private IInvocationContext mContext;
 
@@ -167,11 +167,9 @@
         return mName;
     }
 
-    /**
-     * @return the mPreparerWhitelist
-     */
-    protected Set<String> getPreparerWhitelist() {
-        return mPreparerWhitelist;
+    /** @return the getPreparerAllowlist */
+    protected Set<String> getPreparerAllowlist() {
+        return mPreparerAllowlist;
     }
 
     /**
@@ -209,12 +207,10 @@
         return mTest;
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
     @Override
-    public void setPreparerWhitelist(Set<String> preparerWhitelist) {
-        mPreparerWhitelist.addAll(preparerWhitelist);
+    public void setPreparerAllowlist(Set<String> preparerAlowlist) {
+        mPreparerAllowlist.addAll(preparerAlowlist);
     }
 
     /**
@@ -342,9 +338,10 @@
 
     private void runPreparerSetup(ITargetPreparer preparer) throws DeviceNotAvailableException {
         String preparerName = preparer.getClass().getCanonicalName();
-        if (!mPreparerWhitelist.isEmpty() && !mPreparerWhitelist.contains(preparerName)) {
-            CLog.d("Skipping Preparer: %s since it is not in the whitelist %s",
-                    preparerName, mPreparerWhitelist);
+        if (!mPreparerAllowlist.isEmpty() && !mPreparerAllowlist.contains(preparerName)) {
+            CLog.d(
+                    "Skipping Preparer: %s since it is not in the allowList %s",
+                    preparerName, mPreparerAllowlist);
             return;
         }
         CLog.d("Preparer: %s", preparer.getClass().getSimpleName());
diff --git a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/config/ConfigurationFactoryTest.java b/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/config/ConfigurationFactoryTest.java
index 3a59387..92e2898 100644
--- a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/config/ConfigurationFactoryTest.java
+++ b/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/config/ConfigurationFactoryTest.java
@@ -34,17 +34,13 @@
         mConfigFactory = (ConfigurationFactory) ConfigurationFactory.getInstance();
     }
 
-    /**
-     * Sanity test to ensure all config names on classpath are loadable.
-     */
+    /** Initial test to ensure all config names on classpath are loadable. */
     public void testLoadAllConfigs() throws ConfigurationException {
         // we dry-run the templates otherwise it will always fail.
         mConfigFactory.loadAllConfigs(false);
     }
 
-    /**
-     * Sanity test to ensure all configs on classpath can be fully loaded and parsed.
-     */
+    /** Initial test to ensure all configs on classpath can be fully loaded and parsed. */
     public void testLoadAndPrintAllConfigs() throws ConfigurationException {
         // Printing the help involves more checks since it tries to resolve the config objects.
         mConfigFactory.loadAndPrintAllConfigs();
diff --git a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/presubmit/CtsConfigLoadingTest.java b/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/presubmit/CtsConfigLoadingTest.java
index 0c7ac5a..14ee77b 100644
--- a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/presubmit/CtsConfigLoadingTest.java
+++ b/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/presubmit/CtsConfigLoadingTest.java
@@ -167,34 +167,34 @@
     }
 
     /**
-     * Whitelist to start enforcing metadata on modules. No additional entry will be allowed! This
+     * AllowList to start enforcing metadata on modules. No additional entry will be allowed! This
      * is meant to burn down the remaining modules definition.
      */
-    private static final Set<String> WHITELIST_MODULE_PARAMETERS = new HashSet<>();
+    private static final Set<String> ALLOWLIST_MODULE_PARAMETERS = new HashSet<>();
 
     static {
-        WHITELIST_MODULE_PARAMETERS.add("CtsAccessibilityServiceTestCases.config");
-        WHITELIST_MODULE_PARAMETERS.add("CtsActivityManagerBackgroundActivityTestCases.config");
-        WHITELIST_MODULE_PARAMETERS.add("CtsAppOpsTestCases.config");
-        WHITELIST_MODULE_PARAMETERS.add("CtsCarrierApiTestCases.config");
-        WHITELIST_MODULE_PARAMETERS.add("CtsContentCaptureServiceTestCases.config");
-        WHITELIST_MODULE_PARAMETERS.add("CtsDeqpTestCases.config");
-        WHITELIST_MODULE_PARAMETERS.add("CtsHiddenApiKillswitchDebugClassTestCases.config");
-        WHITELIST_MODULE_PARAMETERS.add("CtsHiddenApiKillswitchWhitelistTestCases.config");
-        WHITELIST_MODULE_PARAMETERS.add("CtsHiddenApiKillswitchWildcardTestCases.config");
-        WHITELIST_MODULE_PARAMETERS.add("CtsLocationTestCases.config");
-        WHITELIST_MODULE_PARAMETERS.add("CtsLocation2TestCases.config");
-        WHITELIST_MODULE_PARAMETERS.add("CtsMediaTestCases.config");
-        WHITELIST_MODULE_PARAMETERS.add("CtsMediaV2TestCases.config");
-        WHITELIST_MODULE_PARAMETERS.add("CtsOpenGlPerfTestCases.config");
-        WHITELIST_MODULE_PARAMETERS.add("CtsOsTestCases.config");
-        WHITELIST_MODULE_PARAMETERS.add("CtsPermission2TestCases.config");
-        WHITELIST_MODULE_PARAMETERS.add("CtsPermissionTestCases.config");
-        WHITELIST_MODULE_PARAMETERS.add("CtsProviderUiTestCases.config");
-        WHITELIST_MODULE_PARAMETERS.add("CtsRsBlasTestCases.config");
-        WHITELIST_MODULE_PARAMETERS.add("CtsSkQPTestCases.config");
-        WHITELIST_MODULE_PARAMETERS.add("CtsWrapNoWrapTestCases.config");
-        WHITELIST_MODULE_PARAMETERS.add("CtsWrapWrapDebugMallocDebugTestCases.config");
+        ALLOWLIST_MODULE_PARAMETERS.add("CtsAccessibilityServiceTestCases.config");
+        ALLOWLIST_MODULE_PARAMETERS.add("CtsActivityManagerBackgroundActivityTestCases.config");
+        ALLOWLIST_MODULE_PARAMETERS.add("CtsAppOpsTestCases.config");
+        ALLOWLIST_MODULE_PARAMETERS.add("CtsCarrierApiTestCases.config");
+        ALLOWLIST_MODULE_PARAMETERS.add("CtsContentCaptureServiceTestCases.config");
+        ALLOWLIST_MODULE_PARAMETERS.add("CtsDeqpTestCases.config");
+        ALLOWLIST_MODULE_PARAMETERS.add("CtsHiddenApiKillswitchDebugClassTestCases.config");
+        ALLOWLIST_MODULE_PARAMETERS.add("CtsHiddenApiKillswitchWhitelistTestCases.config");
+        ALLOWLIST_MODULE_PARAMETERS.add("CtsHiddenApiKillswitchWildcardTestCases.config");
+        ALLOWLIST_MODULE_PARAMETERS.add("CtsLocationTestCases.config");
+        ALLOWLIST_MODULE_PARAMETERS.add("CtsLocation2TestCases.config");
+        ALLOWLIST_MODULE_PARAMETERS.add("CtsMediaTestCases.config");
+        ALLOWLIST_MODULE_PARAMETERS.add("CtsMediaV2TestCases.config");
+        ALLOWLIST_MODULE_PARAMETERS.add("CtsOpenGlPerfTestCases.config");
+        ALLOWLIST_MODULE_PARAMETERS.add("CtsOsTestCases.config");
+        ALLOWLIST_MODULE_PARAMETERS.add("CtsPermission2TestCases.config");
+        ALLOWLIST_MODULE_PARAMETERS.add("CtsPermissionTestCases.config");
+        ALLOWLIST_MODULE_PARAMETERS.add("CtsProviderUiTestCases.config");
+        ALLOWLIST_MODULE_PARAMETERS.add("CtsRsBlasTestCases.config");
+        ALLOWLIST_MODULE_PARAMETERS.add("CtsSkQPTestCases.config");
+        ALLOWLIST_MODULE_PARAMETERS.add("CtsWrapNoWrapTestCases.config");
+        ALLOWLIST_MODULE_PARAMETERS.add("CtsWrapWrapDebugMallocDebugTestCases.config");
     }
 
     /**
@@ -351,8 +351,8 @@
             c.validateOptions();
         }
 
-        // Exempt the whitelist
-        missingMandatoryParameters.removeAll(WHITELIST_MODULE_PARAMETERS);
+        // Exempt the allow list
+        missingMandatoryParameters.removeAll(ALLOWLIST_MODULE_PARAMETERS);
         // Ensure the mandatory fields are filled
         if (!missingMandatoryParameters.isEmpty()) {
             String msg =