Refactoring util libraries in CTS.

Change-Id: I6e5daaab4c6124e751b19e50e03ef569e01c6828
diff --git a/libs/commonutil/Android.mk b/libs/commonutil/Android.mk
deleted file mode 100644
index bf6985f..0000000
--- a/libs/commonutil/Android.mk
+++ /dev/null
@@ -1,39 +0,0 @@
-# Copyright (C) 2012 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.
-
-LOCAL_PATH:= $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_MODULE := ctscommonutil
-
-include $(BUILD_STATIC_JAVA_LIBRARY)
-
-################################################################
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_JAVA_LIBRARIES := junit
-
-LOCAL_MODULE := ctscommonutilhost
-
-include $(BUILD_HOST_JAVA_LIBRARY)
\ No newline at end of file
diff --git a/libs/deviceutil/Android.mk b/libs/deviceutil/Android.mk
index 8b81247..1b7db18 100644
--- a/libs/deviceutil/Android.mk
+++ b/libs/deviceutil/Android.mk
@@ -16,12 +16,14 @@
 
 include $(CLEAR_VARS)
 
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-LOCAL_STATIC_JAVA_LIBRARIES := ctscommonutil
+LOCAL_SRC_FILES := \
+    $(call all-java-files-under, src) \
+    $(call all-java-files-under, ../commonutil/src)
 
 LOCAL_JAVA_LIBRARIES := android.test.runner
 
+LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
+
 LOCAL_MODULE_TAGS := optional
 
 LOCAL_MODULE := ctsdeviceutil
diff --git a/libs/hostutil/Android.mk b/libs/hostutil/Android.mk
deleted file mode 100644
index 44a4a30..0000000
--- a/libs/hostutil/Android.mk
+++ /dev/null
@@ -1,27 +0,0 @@
-# Copyright (C) 2012 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.
-
-LOCAL_PATH:= $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-LOCAL_JAVA_LIBRARIES := ctscommonutilhost
-
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_MODULE := ctshostutil
-
-include $(BUILD_HOST_JAVA_LIBRARY)
diff --git a/suite/cts/deviceTests/opengl/AndroidManifest.xml b/suite/cts/deviceTests/opengl/AndroidManifest.xml
index db75371..a0273ec 100644
--- a/suite/cts/deviceTests/opengl/AndroidManifest.xml
+++ b/suite/cts/deviceTests/opengl/AndroidManifest.xml
@@ -19,7 +19,7 @@
         <uses-library android:name="android.test.runner" />
 
         <activity
-            android:name="com.android.cts.opengl.primitive.GLPrimitiveActivity"
+            android:name=".primitive.GLPrimitiveActivity"
             android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
             android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
             <intent-filter>
@@ -29,7 +29,7 @@
             </intent-filter>
         </activity>
         <activity
-            android:name="com.android.cts.opengl.reference.GLReferenceActivity"
+            android:name=".reference.GLReferenceActivity"
             android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
             android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
             <intent-filter>
@@ -39,7 +39,7 @@
             </intent-filter>
         </activity>
         <activity
-            android:name="com.android.cts.opengl.reference.GLGameActivity"
+            android:name=".reference.GLGameActivity"
             android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
             android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
         </activity>
diff --git a/suite/cts/hostTests/jank/Android.mk b/suite/cts/hostTests/jank/Android.mk
index a530912..a7d85de 100644
--- a/suite/cts/hostTests/jank/Android.mk
+++ b/suite/cts/hostTests/jank/Android.mk
@@ -22,7 +22,9 @@
 
 LOCAL_MODULE := CtsHostJank
 
-LOCAL_JAVA_LIBRARIES := cts-tradefed tradefed-prebuilt ddmlib-prebuilt ctshostutil ctscommonutilhost
+LOCAL_JAVA_LIBRARIES := cts-tradefed tradefed-prebuilt ddmlib-prebuilt
+
+LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
 
 LOCAL_CTS_TEST_PACKAGE := com.android.cts.jank
 
diff --git a/suite/cts/hostTests/jank/src/com/android/cts/jank/CtsHostJankTest.java b/suite/cts/hostTests/jank/src/com/android/cts/jank/CtsHostJankTest.java
index 1cf3dd7..f8c7ec1 100644
--- a/suite/cts/hostTests/jank/src/com/android/cts/jank/CtsHostJankTest.java
+++ b/suite/cts/hostTests/jank/src/com/android/cts/jank/CtsHostJankTest.java
@@ -14,12 +14,12 @@
 package com.android.cts.jank;
 
 import com.android.cts.tradefed.build.CtsBuildHelper;
+import com.android.cts.tradefed.util.HostReportLog;
+import com.android.cts.util.ResultType;
+import com.android.cts.util.ResultUnit;
 import com.android.ddmlib.IShellOutputReceiver;
 import com.android.ddmlib.Log;
 import com.android.ddmlib.Log.LogLevel;
-import com.android.cts.util.HostReportLog;
-import com.android.cts.util.ResultType;
-import com.android.cts.util.ResultUnit;
 import com.android.tradefed.build.IBuildInfo;
 import com.android.tradefed.device.ITestDevice;
 import com.android.tradefed.testtype.DeviceTestCase;
diff --git a/suite/cts/hostTests/uihost/Android.mk b/suite/cts/hostTests/uihost/Android.mk
index 85a7a92..dd51b6b 100644
--- a/suite/cts/hostTests/uihost/Android.mk
+++ b/suite/cts/hostTests/uihost/Android.mk
@@ -22,7 +22,9 @@
 
 LOCAL_MODULE := CtsHostUi
 
-LOCAL_JAVA_LIBRARIES := cts-tradefed tradefed-prebuilt ddmlib-prebuilt junit ctshostutil ctscommonutilhost
+LOCAL_JAVA_LIBRARIES := cts-tradefed tradefed-prebuilt ddmlib-prebuilt junit
+
+LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
 
 LOCAL_CTS_TEST_PACKAGE := com.android.cts.uihost
 
diff --git a/suite/cts/hostTests/uihost/src/com/android/cts/uihost/InstallTimeTest.java b/suite/cts/hostTests/uihost/src/com/android/cts/uihost/InstallTimeTest.java
index 1ff31bf..63c2d84 100644
--- a/suite/cts/hostTests/uihost/src/com/android/cts/uihost/InstallTimeTest.java
+++ b/suite/cts/hostTests/uihost/src/com/android/cts/uihost/InstallTimeTest.java
@@ -17,14 +17,14 @@
 package com.android.cts.uihost;
 
 import com.android.cts.tradefed.build.CtsBuildHelper;
-import com.android.ddmlib.Log;
-import com.android.cts.util.HostReportLog;
+import com.android.cts.tradefed.util.HostReportLog;
 import com.android.cts.util.MeasureRun;
 import com.android.cts.util.MeasureTime;
 import com.android.cts.util.ResultType;
 import com.android.cts.util.ResultUnit;
 import com.android.cts.util.ReportLog;
 import com.android.cts.util.Stat;
+import com.android.ddmlib.Log;
 import com.android.tradefed.build.IBuildInfo;
 import com.android.tradefed.device.ITestDevice;
 import com.android.tradefed.testtype.DeviceTestCase;
diff --git a/suite/cts/hostTests/uihost/src/com/android/cts/uihost/TaskSwitchingTest.java b/suite/cts/hostTests/uihost/src/com/android/cts/uihost/TaskSwitchingTest.java
index 323d9a9..d1c4689 100644
--- a/suite/cts/hostTests/uihost/src/com/android/cts/uihost/TaskSwitchingTest.java
+++ b/suite/cts/hostTests/uihost/src/com/android/cts/uihost/TaskSwitchingTest.java
@@ -20,8 +20,8 @@
 
 import com.android.cts.tradefed.build.CtsBuildHelper;
 import com.android.cts.tradefed.result.CtsReportUtil;
-import com.android.cts.util.CtsHostStore;
-import com.android.cts.util.HostReportLog;
+import com.android.cts.tradefed.util.CtsHostStore;
+import com.android.cts.tradefed.util.HostReportLog;
 import com.android.cts.util.ReportLog;
 import com.android.ddmlib.Log;
 import com.android.ddmlib.Log.LogLevel;
diff --git a/tools/tradefed-host/Android.mk b/tools/tradefed-host/Android.mk
index 3f5fc74..0b5d764 100644
--- a/tools/tradefed-host/Android.mk
+++ b/tools/tradefed-host/Android.mk
@@ -16,14 +16,16 @@
 
 include $(CLEAR_VARS)
 
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
+LOCAL_SRC_FILES := \
+    $(call all-java-files-under, src) \
+    $(call all-java-files-under, ../../libs/commonutil/src)
 
 LOCAL_JAVA_RESOURCE_DIRS := res
 
 LOCAL_MODULE := cts-tradefed
 LOCAL_MODULE_TAGS := optional
 LOCAL_JAVA_LIBRARIES := ddmlib-prebuilt tradefed-prebuilt hosttestlib
-LOCAL_STATIC_JAVA_LIBRARIES := ctsdeviceinfolib ctshostutil
+LOCAL_STATIC_JAVA_LIBRARIES := ctsdeviceinfolib
 
 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
 
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/result/CtsXmlResultReporter.java b/tools/tradefed-host/src/com/android/cts/tradefed/result/CtsXmlResultReporter.java
index 58b746d..186d362 100644
--- a/tools/tradefed-host/src/com/android/cts/tradefed/result/CtsXmlResultReporter.java
+++ b/tools/tradefed-host/src/com/android/cts/tradefed/result/CtsXmlResultReporter.java
@@ -19,7 +19,7 @@
 import com.android.cts.tradefed.build.CtsBuildHelper;
 import com.android.cts.tradefed.device.DeviceInfoCollector;
 import com.android.cts.tradefed.testtype.CtsTest;
-import com.android.cts.util.CtsHostStore;
+import com.android.cts.tradefed.util.CtsHostStore;
 import com.android.ddmlib.Log;
 import com.android.ddmlib.Log.LogLevel;
 import com.android.ddmlib.testrunner.TestIdentifier;
diff --git a/libs/hostutil/src/com/android/cts/util/CtsHostStore.java b/tools/tradefed-host/src/com/android/cts/tradefed/util/CtsHostStore.java
similarity index 95%
rename from libs/hostutil/src/com/android/cts/util/CtsHostStore.java
rename to tools/tradefed-host/src/com/android/cts/tradefed/util/CtsHostStore.java
index e943133..9c1e283 100644
--- a/libs/hostutil/src/com/android/cts/util/CtsHostStore.java
+++ b/tools/tradefed-host/src/com/android/cts/tradefed/util/CtsHostStore.java
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package com.android.cts.util;
+package com.android.cts.tradefed.util;
 
 import java.util.concurrent.ConcurrentHashMap;
 
@@ -32,8 +32,8 @@
      * Stores CTS result. Existing result with the same key will be replaced.
      * Note that key is generated in the form of device_serial#class#method name.
      * So there should be no concurrent test for the same (serial, class, method).
-     * @param device
-     * @param test
+     * @param deviceSerial
+     * @param classMethodName
      * @param result CTS result string
      */
     public static void storeCtsResult(String deviceSerial, String classMethodName, String result) {
diff --git a/libs/hostutil/src/com/android/cts/util/HostReportLog.java b/tools/tradefed-host/src/com/android/cts/tradefed/util/HostReportLog.java
similarity index 94%
rename from libs/hostutil/src/com/android/cts/util/HostReportLog.java
rename to tools/tradefed-host/src/com/android/cts/tradefed/util/HostReportLog.java
index 72bcc4c..125c56e 100644
--- a/libs/hostutil/src/com/android/cts/util/HostReportLog.java
+++ b/tools/tradefed-host/src/com/android/cts/tradefed/util/HostReportLog.java
@@ -14,7 +14,9 @@
  * limitations under the License.
  */
 
-package com.android.cts.util;
+package com.android.cts.tradefed.util;
+
+import com.android.cts.util.ReportLog;
 
 /**
  * ReportLog for host tests