Delete Old Test Runner

Bug 5563917

Change-Id: I4ed2cde974eee53b90f231a26a2947222aff5415
diff --git a/tools/host/Android.mk b/tools/host/Android.mk
deleted file mode 100644
index 4798233..0000000
--- a/tools/host/Android.mk
+++ /dev/null
@@ -1,17 +0,0 @@
-# Copyright (C) 2008 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.
-
-CTS_LOCAL_DIR := $(call my-dir)
-include $(CTS_LOCAL_DIR)/etc/Android.mk
-include $(CTS_LOCAL_DIR)/src/Android.mk
diff --git a/tools/host/etc/Android.mk b/tools/host/etc/Android.mk
deleted file mode 100644
index 993f4ac..0000000
--- a/tools/host/etc/Android.mk
+++ /dev/null
@@ -1,20 +0,0 @@
-# Copyright (C) 2008 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_PREBUILT_EXECUTABLES := cts
-include $(BUILD_HOST_PREBUILT)
-
diff --git a/tools/host/etc/cts b/tools/host/etc/cts
deleted file mode 100755
index ec8ff0b..0000000
--- a/tools/host/etc/cts
+++ /dev/null
@@ -1,88 +0,0 @@
-#!/bin/bash
-
-# Copyright (C) 2008 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.
-
-
-CTS_SH=cts
-CTS_LIB=cts.jar
-DDMS_LIB=ddmlib-prebuilt.jar
-JUNIT_LIB=junit.jar
-HOSTTEST_LIB=hosttestlib.jar
-
-# Checking if "adb" is known by the system
-PATH=.:${PATH}
-ADB_TOOLS=adb
-ADB_PATH=`which ${ADB_TOOLS}`
-if [ "${ANDROID_ROOT}" == "" ] && [ -f "${ADB_PATH}" ]; then
-    ANDROID_ROOT=`dirname ${ADB_PATH}`/..
-fi;
-
-# Checking Android dependancies
-BINARY_DIR=bin
-JAR_DIR=framework
-if [ -f ${ANDROID_ROOT}/tools/${ADB_TOOLS} ]; then
-    # Default SDK paths
-    BINARY_DIR=tools
-    JAR_DIR=tools/lib
-else if [ ! -f ${ANDROID_ROOT}/bin/${ADB_TOOLS} ]; then
-    echo "Missing ${ANDROID_ROOT}/bin/${ADB_TOOLS}"
-    exit -1;
-fi;
-fi;
-
-if [ ! -f ${ANDROID_ROOT}/${JAR_DIR}/${DDMS_LIB} ]; then
-    echo "Missing ${ANDROID_ROOT}/${JAR_DIR}/${DDMS_LIB}"
-    exit -1;
-fi;
-
-
-# -------------------------------------------------------------------------
-
-CTS_PATH=`which ${CTS_SH}`
-if [ ! -f "${CTS_PATH}" ]; then
-    CTS_PATH=$0
-fi;
-
-CTS_DIR=`dirname ${CTS_PATH}`
-# Setup the correct path for getting "adb"
-PATH=${PATH}:${ANDROID_ROOT}/${BINARY_DIR}
-# Add paths to JAR files in Android framework
-CTS_LIBS=\
-${ANDROID_ROOT}/${JAR_DIR}/${DDMS_LIB}:\
-${ANDROID_ROOT}/${JAR_DIR}/${JUNIT_LIB}:\
-${ANDROID_ROOT}/${JAR_DIR}/${HOSTTEST_LIB}:\
-${ANDROID_ROOT}/${JAR_DIR}/${CTS_LIB}
-# Add path to CTS JAR file in the CTS archive
-CTS_LIBS=${CTS_LIBS}:${CTS_DIR}/${CTS_LIB}
-
-# Default location of the repository
-CTS_REPO=${CTS_DIR}/../cts/android-cts/repository
-
-# Try to locate CTS repository
-if [ $# -eq 1 ] || [ $(echo "$*" | grep -c -e --config -) -gt 0 ];
-then
-    # single parameter or --config argument specifies config file
-    :
-else
-    # config file not specified, try to locate if not already defined
-    if [ -z "${CTS_HOST_CFG}" ] && [ -d "${CTS_REPO}" ]; then
-       CTS_HOST_CFG=${CTS_REPO}/host_config.xml
-    fi;
-fi;
-
-JAVA_OPTS="-Xmx512M"
-JAVA_OPTS="${JAVA_OPTS} -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=1337"
-
-java ${JAVA_OPTS} -cp ${CTS_LIBS} -DHOST_CONFIG=${CTS_HOST_CFG} com.android.cts.TestHost "$@"
diff --git a/tools/host/etc/cts.bat b/tools/host/etc/cts.bat
deleted file mode 100644
index fe346c4..0000000
--- a/tools/host/etc/cts.bat
+++ /dev/null
@@ -1,64 +0,0 @@
-@echo off
-rem Copyright (C) 2008 The Android Open Source Project
-rem
-rem Licensed under the Apache License, Version 2.0 (the "License");
-rem you may not use this file except in compliance with the License.
-rem You may obtain a copy of the License at
-rem
-rem      http://www.apache.org/licenses/LICENSE-2.0
-rem
-rem Unless required by applicable law or agreed to in writing, software
-rem distributed under the License is distributed on an "AS IS" BASIS,
-rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-rem See the License for the specific language governing permissions and
-rem limitations under the License.
-
-rem don't modify the caller's environment
-setlocal
-
-rem Set up prog to be the path of this script, including following symlinks,
-rem and set up progdir to be the fully-qualified pathname of its directory.
-set prog=%~f0
-
-set curdir=%CD%
-
-rem Change current directory to where cts is, to avoid issues with directories
-rem containing whitespaces.
-cd %~dp0
-
-set jarfile=cts.jar
-set frameworkdir=
-set libdir=
-
-rem parse the argument
-if (%1)==() (
-    set argument=%CTS_HOST_CFG%
-    goto ArgumentOk
-) else (
-    set argument=%1
-)
-
-if not "%argument:~1,1%"==":" (
-    set argument=%curdir%\%argument%
-)
-
-:ArgumentOk
-
-if exist %frameworkdir%%jarfile% goto JarFileOk
-    set frameworkdir=lib\
-    set libdir=lib\
-
-if exist %frameworkdir%%jarfile% goto JarFileOk
-    set frameworkdir=..\framework\
-    set libdir=..\lib\
-
-:JarFileOk
-
-if debug NEQ "%1" goto NoDebug
-    set java_debug=-agentlib:jdwp=transport=dt_socket,server=y,address=8050,suspend=y
-    shift 1
-:NoDebug
-
-set jarpath=%frameworkdir%%jarfile%
-
-call java %java_debug% -Djava.ext.dirs=%frameworkdir% -Djava.library.path=%libdir% -Dcom.android.cts.bindir= -jar %jarpath% %argument%
diff --git a/tools/host/etc/manifest.txt b/tools/host/etc/manifest.txt
deleted file mode 100644
index c212928..0000000
--- a/tools/host/etc/manifest.txt
+++ /dev/null
@@ -1 +0,0 @@
-Main-Class: com.android.cts.TestHost
diff --git a/tools/host/src/Android.mk b/tools/host/src/Android.mk
deleted file mode 100644
index dabee3d..0000000
--- a/tools/host/src/Android.mk
+++ /dev/null
@@ -1,30 +0,0 @@
-# Copyright (C) 2008 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-subdir-java-files)
-
-LOCAL_JAVA_RESOURCE_DIRS := res
-
-LOCAL_JAR_MANIFEST := ../etc/manifest.txt
-LOCAL_JAVA_LIBRARIES := \
-    ddmlib-prebuilt junit hosttestlib
-
-LOCAL_STATIC_JAVA_LIBRARIES := ctsdeviceinfolib
-
-LOCAL_MODULE := cts
-
-include $(BUILD_HOST_JAVA_LIBRARY)
diff --git a/tools/host/src/com/android/cts/ADBServerNeedRestartException.java b/tools/host/src/com/android/cts/ADBServerNeedRestartException.java
deleted file mode 100644
index 8c5f15b..0000000
--- a/tools/host/src/com/android/cts/ADBServerNeedRestartException.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright (C) 2009 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.cts;
-
-/**
- * Throw out ADBServerNeedRestartException to request restarting ADB server.
- */
-public class ADBServerNeedRestartException extends Exception {
-
-    public ADBServerNeedRestartException(String message) {
-        super(message);
-    }
-}
diff --git a/tools/host/src/com/android/cts/CTSCommand.java b/tools/host/src/com/android/cts/CTSCommand.java
deleted file mode 100644
index a1a2222..0000000
--- a/tools/host/src/com/android/cts/CTSCommand.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (C) 2008 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.cts;
-
-/**
- * Constant value for CTS command
- */
-public interface CTSCommand {
-    // Define the commands
-    static final String EXIT = "exit";
-    static final String HELP = "help";
-    static final String ADD = "add";
-    static final String REMOVE = "rm";
-    static final String START = "start";
-    static final String LIST = "ls";
-    static final String H = "h";
-    static final String HISTORY = "history";
-
-    // Define command options
-    static final String OPTION_D = "-d";
-    static final String OPTION_DEVICE = "--device";
-    static final String OPTION_P = "-p";
-    static final String OPTION_PACKAGE = "--package";
-    static final String OPTION_R = "-r";
-    static final String OPTION_RESULT = "--result";
-    static final String OPTION_PLAN = "--plan";
-    static final String OPTION_T = "-t";
-    static final String OPTION_TEST = "--test";
-    static final String OPTION_E = "-e";
-    static final String OPTION_S = "-s";
-    static final String OPTION_SESSION = "--session";
-    static final String OPTION_CFG = "--config";
-    static final String OPTION_DERIVED_PLAN = "--derivedplan";
-    static final String OPTION_QUICK = "-q";
-}
diff --git a/tools/host/src/com/android/cts/CUIOutputStream.java b/tools/host/src/com/android/cts/CUIOutputStream.java
deleted file mode 100644
index 6f9b957..0000000
--- a/tools/host/src/com/android/cts/CUIOutputStream.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright (C) 2008 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.cts;
-
-import java.io.PrintStream;
-
-/**
- * CTS UI output stream. Handle all output of CTS UI
- */
-final class CUIOutputStream {
-
-    private static PrintStream sOutput = System.out;
-    public static final String CTS_PROMPT_SIGN = "cts_host > ";
-
-    /**
-     * Print a line of message onto the CTS host console.
-     *
-     * @param msg The message to be print.
-     */
-    static public void print(final String msg) {
-        sOutput.print(msg);
-
-        Log.log(msg);
-    }
-
-    /**
-     * Print a line of message onto the CTS host console with a carriage return.
-     *
-     * @param msg The message to be print.
-     */
-    static public void println(final String msg) {
-        sOutput.println(msg);
-
-        Log.log(msg);
-    }
-
-    /**
-     * Write the buffer with given offset and length.
-     *
-     * @param buf The buffer.
-     * @param off The offset to start writing.
-     * @param len The length in byte to write.
-     */
-    static public void write(byte[] buf, int off, int len) {
-        sOutput.write(buf, off, len);
-    }
-
-    /**
-     * Write a byte.
-     *
-     * @param c The byte to write.
-     */
-    static public void write(int c) {
-        sOutput.write(c);
-    }
-
-    /**
-     * Flush the write buffer.
-     */
-    static public void flush() {
-        sOutput.flush();
-    }
-
-    /**
-     * Print prompt.
-     */
-    static public void printPrompt() {
-        print(CTS_PROMPT_SIGN);
-
-        Log.log(CTS_PROMPT_SIGN);
-    }
-}
diff --git a/tools/host/src/com/android/cts/CommandHistory.java b/tools/host/src/com/android/cts/CommandHistory.java
deleted file mode 100644
index b86506e..0000000
--- a/tools/host/src/com/android/cts/CommandHistory.java
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * Copyright (C) 2008 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.cts;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * CommandHistory holds max 50 executed command.
- * User can view what has been input and select one to execute again.
- * Example:
- * <ul>
- *    <li> "cts_host > h"  to view latest 50 executed command.
- *    <li> "cts_host > h 10" to view latest 10 executed command.
- *    <li> "cts_host > h -e 5" to execute the 5th executed command.
- * </ul>
- */
-public class CommandHistory {
-    private static final int CMD_RECORD_DEPTH = 50;
-
-    private List<String> mCmdRecords;
-
-    public CommandHistory() {
-        mCmdRecords = new ArrayList<String>();
-    }
-
-    /**
-     * Check if the command is history command.
-     *
-     * @param cmd The command string.
-     * @return If it's history command, return true; else return false.
-     */
-    public boolean isHistoryCommand(final String cmd) {
-        return CTSCommand.HISTORY.equals(cmd) || CTSCommand.H.equals(cmd);
-    }
-
-    /**
-     * Get the number of commands recorded.
-     *
-     * @return The number of commands recorded.
-     */
-    public int size() {
-        return mCmdRecords.size();
-    }
-
-    /**
-     * Get command by index from command history cache.
-     *
-     * @param index The command index.
-     * @return The command corresponding to the command index.
-     */
-    public String get(final int index) {
-        return mCmdRecords.get(index);
-    }
-
-    /**
-     * display specified number of commands from command history cache onto CTS console.
-     *
-     * @param cmdCount The command count requested.
-     */
-    public void show(final int cmdCount) {
-        int cmdSize = mCmdRecords.size();
-        int start = 0;
-
-        if (cmdSize == 0) {
-            CUIOutputStream.println("no history command list");
-            return;
-        }
-        if (cmdCount < cmdSize) {
-            start = cmdSize - cmdCount;
-        }
-
-        for (; start < cmdSize; start ++) {
-            String cmdLine = mCmdRecords.get(start);
-            CUIOutputStream.println("  " + Long.toString(start) + "\t" + cmdLine);
-        }
-    }
-
-    /**
-     * Add a command to the command cache.
-     *
-     * @param cp The command container.
-     * @param cmdLine The command line.
-     */
-    public void addCommand(final CommandParser cp,
-            final String cmdLine) {
-        if ((cmdLine == null) || (cmdLine.length() == 0)) {
-            return;
-        }
-
-        if (isValidCommand(cp.getAction()) && (!hasCommand(cmdLine))) {
-            mCmdRecords.add(cmdLine);
-            if (mCmdRecords.size() > CMD_RECORD_DEPTH) {
-                mCmdRecords.remove(0);
-            }
-        }
-    }
-
-    /**
-     * Check if the command contains valid action.
-     *
-     * @param action The action contained in the command.
-     * @return If valid, return true; else, return false.
-     */
-    private boolean isValidCommand(final String action) {
-        if (!(CTSCommand.HISTORY.equals(action) || CTSCommand.H.equals(action))) {
-            if (CTSCommand.ADD.equals(action)
-                    || CTSCommand.EXIT.equals(action)
-                    || CTSCommand.HELP.equals(action)
-                    || CTSCommand.LIST.equals(action)
-                    || CTSCommand.REMOVE.equals(action)
-                    || CTSCommand.START.equals(action)) {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    /**
-     * Check if the command is a duplicate one.
-     *
-     * @param cmdLine The command to be checked against the commands recorded.
-     * @return If duplicated, return true; else, return false.
-     */
-    private boolean hasCommand(final String cmdLine) {
-        for(String cmd : mCmdRecords) {
-            if (cmd.equals(cmdLine)) {
-                return true;
-            }
-        }
-        return false;
-    }
-}
diff --git a/tools/host/src/com/android/cts/CommandNotFoundException.java b/tools/host/src/com/android/cts/CommandNotFoundException.java
deleted file mode 100644
index ebaa5ae..0000000
--- a/tools/host/src/com/android/cts/CommandNotFoundException.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (C) 2008 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.cts;
-
-/**
- * Throw out CommandNotFoundException if no command action.
- */
-public class CommandNotFoundException extends Exception {
-
-    private static final long serialVersionUID = -9101779063189977021L;
-
-    public CommandNotFoundException() {
-        super();
-    }
-
-    public CommandNotFoundException(String message) {
-        super(message);
-    }
-}
diff --git a/tools/host/src/com/android/cts/CommandParser.java b/tools/host/src/com/android/cts/CommandParser.java
deleted file mode 100644
index 85f8c2c..0000000
--- a/tools/host/src/com/android/cts/CommandParser.java
+++ /dev/null
@@ -1,296 +0,0 @@
-/*
- * Copyright (C) 2008 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.cts;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Set;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * CommandParser is responsible for parsing command line arguments. To get
- * action, option or values easy via functions.
- * For example:
- * <ul>
- *    <li> CommandParser cp = CommandParser.parse("start -plan test_plan")
- *    <li> cp.getAction() will get "start"
- *    <li> cp.getValue("-plan") will get "test_plan"
- *    <li> cp.containsKey("-noplan") will get null
- * </ul>
- *
- */
-public class CommandParser {
-
-    /**
-     * The hash map mapping the options and option values.
-     */
-    private HashMap<String, String> mValues = new HashMap<String, String>();
-
-    /**
-     * The action the user chose to ask CTS host to take.
-     */
-    private String mAction;
-    private ArrayList<String> mActionValues = new ArrayList<String>();
-    private int mArgLength;
-    private static final String COMMAND_PARSE_EXPRESSION = "(((\\\\\\s)|[\\S&&[^\"]])+|\".+\")";
-
-    private static Set<String> sOptionsSet = new HashSet<String>(Arrays.asList(
-            CTSCommand.OPTION_CFG, CTSCommand.OPTION_PACKAGE, CTSCommand.OPTION_PLAN,
-            CTSCommand.OPTION_DEVICE, CTSCommand.OPTION_RESULT, CTSCommand.OPTION_E,
-            CTSCommand.OPTION_SESSION, CTSCommand.OPTION_TEST, CTSCommand.OPTION_DERIVED_PLAN,
-            CTSCommand.OPTION_QUICK));
-    private static HashMap<String, String> sOptionMap = new HashMap<String, String>();
-    static {
-        final String[] keys = new String[] {
-                CTSCommand.OPTION_CFG,
-                CTSCommand.OPTION_P,
-                CTSCommand.OPTION_PACKAGE,
-                CTSCommand.OPTION_PLAN,
-                CTSCommand.OPTION_D,
-                CTSCommand.OPTION_DEVICE,
-                CTSCommand.OPTION_R,
-                CTSCommand.OPTION_RESULT,
-                CTSCommand.OPTION_E,
-                CTSCommand.OPTION_S,
-                CTSCommand.OPTION_SESSION,
-                CTSCommand.OPTION_T,
-                CTSCommand.OPTION_TEST,
-                CTSCommand.OPTION_DERIVED_PLAN,
-                CTSCommand.OPTION_QUICK};
-
-        final String[] values = new String[] {
-                CTSCommand.OPTION_CFG,
-                CTSCommand.OPTION_PACKAGE,
-                CTSCommand.OPTION_PACKAGE,
-                CTSCommand.OPTION_PLAN,
-                CTSCommand.OPTION_DEVICE,
-                CTSCommand.OPTION_DEVICE,
-                CTSCommand.OPTION_RESULT,
-                CTSCommand.OPTION_RESULT,
-                CTSCommand.OPTION_E,
-                CTSCommand.OPTION_SESSION,
-                CTSCommand.OPTION_SESSION,
-                CTSCommand.OPTION_TEST,
-                CTSCommand.OPTION_TEST,
-                CTSCommand.OPTION_DERIVED_PLAN,
-                CTSCommand.OPTION_QUICK};
-
-        for (int i = 0; i < keys.length; i++) {
-            sOptionMap.put(keys[i], values[i]);
-        }
-    }
-
-    /**
-     * Parse the command line into array of argument.
-     *
-     * @param line The original command line.
-     * @return The command container.
-     */
-    public static CommandParser parse(final String line)
-            throws UnknownCommandException, CommandNotFoundException {
-        ArrayList<String> arglist = new ArrayList<String>();
-
-        Pattern p = Pattern.compile(COMMAND_PARSE_EXPRESSION);
-        Matcher m = p.matcher(line);
-        while (m.find()) {
-            arglist.add(m.group(1));
-        }
-        CommandParser cp = new CommandParser();
-        if (arglist.size() == 0) {
-            throw new CommandNotFoundException("No command");
-        }
-        cp.parse(arglist);
-        return cp;
-    }
-
-    /**
-     * Parse the argument list.
-     *
-     * @param arglist The argument list.
-     */
-    private void parse(ArrayList<String> arglist)
-            throws UnknownCommandException {
-        mArgLength = arglist.size();
-        int currentArgIndex = 0;
-        mAction = arglist.get(currentArgIndex).toLowerCase();
-        String originalOption = null;
-        String option = null;
-
-        // parse action values
-        while (++currentArgIndex < arglist.size()) {
-            originalOption = arglist.get(currentArgIndex).trim();
-            if (originalOption.startsWith("-")) {
-                if (isNumber(originalOption)) {
-                    mActionValues.add(originalOption);
-                } else {
-                    --currentArgIndex;
-                    break;
-                }
-            } else {
-                mActionValues.add(originalOption);
-            }
-        }
-
-        // parse option
-        while (++currentArgIndex < arglist.size()) {
-            originalOption = arglist.get(currentArgIndex).trim().toLowerCase();
-            option = originalOption;
-            if (!option.startsWith("-")) {
-                throw new UnknownCommandException(
-                        "Option should start with '-'");
-            }
-
-            option = inputToOption(option);
-            if (!sOptionsSet.contains(option)) {
-                throw new UnknownCommandException("Unknown option :"
-                        + originalOption);
-            }
-
-            if (mValues.containsKey(option)) {
-                throw new UnknownCommandException("Duplicate option: "
-                         + originalOption);
-            }
-
-            if (currentArgIndex + 1 == arglist.size()) {
-                mValues.put(option, "");
-                continue;
-            }
-
-            String value = arglist.get(++currentArgIndex).trim();
-            if (value.startsWith("-")) {
-                if (!isNumber(value)) {
-                    value = "";
-                    currentArgIndex--;
-                }
-            }
-
-            mValues.put(option, value);
-        }
-    }
-
-    /**
-     * Translate the input to option.
-     *
-     * @param option The option typed in.
-     * @return The option found.
-     */
-    private String inputToOption(String option) throws UnknownCommandException {
-        String op = sOptionMap.get(option);
-        if (op == null) {
-            throw new UnknownCommandException("Unknow option " + option);
-        }
-
-        return op;
-    }
-
-    /**
-     * Check if the option is a number.
-     *
-     * @param option The option.
-     * @return If the option is a number, return true; else, return false.
-     */
-    private boolean isNumber(String option) {
-        try {
-            Integer.parseInt(option);
-            return true;
-        } catch (Exception e) {
-            return false;
-        }
-    }
-
-    /**
-     * Get the arguments size.
-     *
-     * @return The argument size.
-     */
-    public int getArgSize() {
-        return mArgLength;
-    }
-
-    /**
-     * Get the action.
-     *
-     * @return The action.
-     */
-    public String getAction() {
-        return mAction;
-    }
-
-    /**
-     * Get the option size.
-     *
-     * @return The option size.
-     */
-    public int getOptionSize() {
-        return mValues.size();
-    }
-
-    /**
-     * Get command option by hash key from parsed argument list.
-     *
-     * @param key The key.
-     * @return The value according to the key.
-     */
-    public String getValue(String key) {
-        if (mValues.containsKey(key)) {
-            return mValues.get(key);
-        } else {
-            return null;
-        }
-    }
-
-    /**
-     * Check if option list contains the key.
-     *
-     * @param key The key.
-     * @return If containing the key, return true; else, return false.
-     */
-    public boolean containsKey(String key) {
-        return mValues.containsKey(key);
-    }
-
-    /**
-     * Get all of the option keys.
-     *
-     * @return All of the option keys.
-     */
-    public Set<String> getOptionKeys() {
-        return mValues.keySet();
-    }
-
-    /**
-     * Get action list.
-     *
-     * @return The action list.
-     */
-    public ArrayList<String> getActionValues() {
-        return mActionValues;
-    }
-
-    /**
-     * Remove a specific key.
-     *
-     * @param key The key to be removed.
-     */
-    public void removeKey(String key) {
-        mValues.remove(key);
-    }
-
-}
diff --git a/tools/host/src/com/android/cts/ConsoleUi.java b/tools/host/src/com/android/cts/ConsoleUi.java
deleted file mode 100644
index ce26d52..0000000
--- a/tools/host/src/com/android/cts/ConsoleUi.java
+++ /dev/null
@@ -1,1325 +0,0 @@
-/*
- * Copyright (C) 2008 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.cts;
-
-import com.android.cts.TestHost.ActionType;
-import com.android.cts.TestHost.MODE;
-
-import org.xml.sax.SAXException;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.security.NoSuchAlgorithmException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactoryConfigurationError;
-
-/**
- * Main console of CTS providing user with the interface to interact. <BR>
- * Using CommandParser to parse command line argument and process.
- * <ul>
- *    <li> start a test plan
- *    <li> remove a test plan
- *    <li> add a test package
- *    <li> remove a test package
- *    <li> list current available devices
- *    <li> list current available test plan
- *    <li> list current available package
- *    <li> list current test result
- *    <li> view CTS' status, uninitialized, idle or running
- *    <li> view command history
- *    <li> select a history command to run
- * </ul>
- */
-public class ConsoleUi {
-
-    private static final String OS_NAME_LINUX = "Linux";
-    private static final String LS_PLAN_SEPARATOR = "=================================";
-    private static final String CMD_TYPE_LEADING_SPACE = "  ";
-    private static final String CMD_OPT_LEADING_SPACE = "    ";
-    private static final String CREATE_SESSION = "create a new session";
-    private static final String CHOOSE_SESSION = "choose a session";
-
-    private TestHost mHost;
-    private boolean mKeepRunning;
-    private BufferedReader mCommandInput;
-    // private static ConsoleInputStream sConsoleReader;
-    private CommandHistory mCommandHistory = new CommandHistory();
-    private String mOsName = "none";
-
-    // Define test case name pattern
-    static final String CASE_NAME_PATTERN_STR = "((\\S+\\.)+\\S+)\\.(\\S+):(\\S+)";
-    private static HashMap<String, Integer> mResultCodeMap;
-
-    static {
-        mResultCodeMap = new HashMap<String, Integer>();
-        mResultCodeMap.put(CtsTestResult.STR_PASS, CtsTestResult.CODE_PASS);
-        mResultCodeMap.put(CtsTestResult.STR_FAIL, CtsTestResult.CODE_FAIL);
-        mResultCodeMap.put(CtsTestResult.STR_ERROR, CtsTestResult.CODE_ERROR);
-        mResultCodeMap.put(CtsTestResult.STR_NOT_EXECUTED, CtsTestResult.CODE_NOT_EXECUTED);
-        mResultCodeMap.put(CtsTestResult.STR_TIMEOUT, CtsTestResult.CODE_TIMEOUT);
-    }
-
-    public ConsoleUi(TestHost host) {
-        mHost = host;
-        mCommandInput = new BufferedReader(new InputStreamReader(System.in));
-        mKeepRunning = true;
-
-        initInputStream();
-    }
-
-    /**
-     * Start the console user interface.
-     *
-     */
-    public void startUi() {
-        while (mKeepRunning) {
-            try {
-                String cmdLine = readLine(CUIOutputStream.CTS_PROMPT_SIGN);
-                CommandParser cp = CommandParser.parse(cmdLine);
-                processCommand(cp);
-                mCommandHistory.addCommand(cp, cmdLine);
-            } catch (CommandNotFoundException e) {
-                // avoid displaying help message for empty
-                // command by pressing ENTER over console directly
-            } catch (Exception e) {
-                Log.e("Got exception while processing command.", e);
-                showHelp();
-            }
-        }
-    }
-
-    /**
-     * Initialize the CommandProcessor.
-     */
-    private void initInputStream() {
-        // mOsName = System.getProperty("os.name");
-        if (mOsName.equals(OS_NAME_LINUX)) {
-            // sConsoleReader = new ConsoleInputStream(new FileInputStream(
-            // FileDescriptor.in), mCommandHistory);
-            // sConsoleReader.setup();
-        } else {
-            mCommandInput = new BufferedReader(new InputStreamReader(System.in));
-        }
-    }
-
-    /**
-     * Read a message line from console.
-     *
-     * @param prompt The notification message print out to console before reading.
-     * @return The string user typed in.
-     */
-    private String readLine(String prompt) throws IOException {
-        String cmdLine = null;
-        if (mOsName.equals(OS_NAME_LINUX)) {
-            // cmdLine = sConsoleReader.readLine(prompt).trim();
-        } else {
-            CUIOutputStream.print(prompt);
-            cmdLine = mCommandInput.readLine().trim();
-        }
-        return cmdLine;
-    }
-
-    /**
-     * Display the help message.
-     */
-    private void showHelp() {
-        CUIOutputStream.println("Usage: command options");
-        CUIOutputStream.println("Avaiable commands and options:");
-        showHostCmdHelp();
-        showPlanCmdHelp();
-        showPackageCmdHelp();
-        showResultCmdHelp();
-        showHistoryCmdHelp();
-        showDeviceCmdHelp();
-    }
-
-    /**
-     * Display the help message related to history commands.
-     */
-    private void showHistoryCmdHelp() {
-        final String cmdStr = CTSCommand.HISTORY + "/" + CTSCommand.H;
-
-        CUIOutputStream.println(CMD_TYPE_LEADING_SPACE + "History:");
-        CUIOutputStream.println(CMD_OPT_LEADING_SPACE
-                + cmdStr + ": list all commands in command history");
-        CUIOutputStream.println(CMD_OPT_LEADING_SPACE
-                + cmdStr + " count: list the latest count records in command history");
-        CUIOutputStream.println(CMD_OPT_LEADING_SPACE
-                + cmdStr + " " + CTSCommand.OPTION_E
-                + " num: run the command designated by 'num' in command history");
-    }
-
-    /**
-     * Display the help message related to result commands.
-     */
-    private void showResultCmdHelp() {
-        final String cmdStr = CTSCommand.LIST + " " + CTSCommand.OPTION_R
-                + "/" + CTSCommand.OPTION_RESULT;
-        final String sessionStr = CTSCommand.OPTION_S + "/" + CTSCommand.OPTION_SESSION;
-        final String resultsStr = " [" + CtsTestResult.STR_PASS
-                       + "/" + CtsTestResult.STR_FAIL
-                       + "/" + CtsTestResult.STR_NOT_EXECUTED
-                       + "/" + CtsTestResult.STR_TIMEOUT
-                       + "] ";
-
-        CUIOutputStream.println(CMD_TYPE_LEADING_SPACE + "Result:");
-        CUIOutputStream.println(CMD_OPT_LEADING_SPACE
-                + cmdStr + ": list all result of sessions");
-        CUIOutputStream.println(CMD_OPT_LEADING_SPACE
-                + cmdStr + " " + sessionStr
-                + " session_id: list detail case result of a specified session");
-        CUIOutputStream.println(CMD_OPT_LEADING_SPACE
-                + cmdStr + resultsStr + sessionStr
-                + " session_id: list detail cases of a specified"
-                + " session by the specified result.");
-    }
-
-    /**
-     * Display the help message related to package commands.
-     */
-    private void showPackageCmdHelp() {
-        final String cmdStr = CTSCommand.LIST + " " + CTSCommand.OPTION_P
-                + "/" + CTSCommand.OPTION_PACKAGE;
-        final String pkgStr = CTSCommand.OPTION_P + "/" + CTSCommand.OPTION_PACKAGE;
-
-        CUIOutputStream.println(CMD_TYPE_LEADING_SPACE + "Package:");
-        CUIOutputStream.println(CMD_OPT_LEADING_SPACE
-                + cmdStr + ": list available packages");
-        CUIOutputStream.println(CMD_OPT_LEADING_SPACE + cmdStr + " package_name: "
-                + "list contents of the package with specified name");
-
-        CUIOutputStream.println(CMD_OPT_LEADING_SPACE
-                + CTSCommand.ADD + " " + pkgStr
-                + " root: add packages from root to repository");
-        CUIOutputStream.println(CMD_OPT_LEADING_SPACE
-                + CTSCommand.REMOVE + " " + pkgStr + " package_name/all: "
-                + "remove a package or all packages from repository");
-    }
-
-    /**
-     * Display the help message related to plan commands.
-     */
-    private void showPlanCmdHelp() {
-        final String lsPlanStr = CTSCommand.LIST + " " + CTSCommand.OPTION_PLAN;
-        final String addPlanStr = CTSCommand.ADD + " " + CTSCommand.OPTION_PLAN;
-        final String rmPlanStr = CTSCommand.REMOVE + " " + CTSCommand.OPTION_PLAN;
-        final String addDerivedPlanStr = CTSCommand.ADD + " " + CTSCommand.OPTION_DERIVED_PLAN;
-
-        CUIOutputStream.println(CMD_TYPE_LEADING_SPACE + "Plan:");
-        CUIOutputStream.println(CMD_OPT_LEADING_SPACE
-                + lsPlanStr + ": list available plans");
-        CUIOutputStream.println(CMD_OPT_LEADING_SPACE
-                + lsPlanStr + " plan_name: list contents of the plan with specified name");
-        CUIOutputStream.println(CMD_OPT_LEADING_SPACE
-                + addPlanStr + " plan_name: add a new plan with specified name");
-        CUIOutputStream.println(CMD_OPT_LEADING_SPACE
-                + addDerivedPlanStr + " plan_name "
-                + CTSCommand.OPTION_S + "/" + CTSCommand.OPTION_SESSION + " session_id "
-                + CTSCommand.OPTION_R + "/" + CTSCommand.OPTION_RESULT + " result_type"
-                + ": derive a plan from the given session");
-        CUIOutputStream.println(CMD_OPT_LEADING_SPACE
-                + rmPlanStr + " plan_name/all: remove a plan or all plans from repository");
-        showStartSessionHelp();
-    }
-
-    /**
-     * Display the help message related to start session command.
-     */
-    private void showStartSessionHelp() {
-        final String cmdStr = CTSCommand.START + " " + CTSCommand.OPTION_PLAN;
-        final String testStr = CTSCommand.OPTION_T + "/" + CTSCommand.OPTION_TEST;
-        final String deviceStr = CTSCommand.OPTION_D + "/" + CTSCommand.OPTION_DEVICE;
-        final String pkgStr = CTSCommand.OPTION_P + "/" + CTSCommand.OPTION_PACKAGE;
-
-        CUIOutputStream.println(CMD_OPT_LEADING_SPACE
-                + cmdStr + " test_plan_name: run a test plan");
-        CUIOutputStream.println(CMD_OPT_LEADING_SPACE
-                + cmdStr + " test_plan_name " + deviceStr + " device_ID"
-                +  ": run a test plan using the specified device");
-        CUIOutputStream.println(CMD_OPT_LEADING_SPACE
-                + cmdStr + " test_plan_name " + testStr + " test_name"
-                + ": run a specific test");
-        CUIOutputStream.println(CMD_OPT_LEADING_SPACE
-                + cmdStr + " test_plan_name " + pkgStr + " java_package_name"
-                + ": run a specific java package");
-        CUIOutputStream.println(CMD_OPT_LEADING_SPACE
-                + cmdStr + " test_plan_name " + testStr + " test_name "
-                + deviceStr + " device_ID"
-                + ": run a specific test using the specified device");
-        CUIOutputStream.println(CMD_OPT_LEADING_SPACE
-                + cmdStr + " test_plan_name " + pkgStr + " java_package_name "
-                + deviceStr + " device_ID"
-                + ": run a specific java package using the specified device");
-    }
-
-    /**
-     * Display the help message related to host commands.
-     */
-    private void showHostCmdHelp() {
-        CUIOutputStream.println(CMD_TYPE_LEADING_SPACE + "Host:");
-        CUIOutputStream.println(CMD_OPT_LEADING_SPACE
-                + CTSCommand.HELP + ": show this message");
-        CUIOutputStream.println(CMD_OPT_LEADING_SPACE
-                + CTSCommand.EXIT + ": exit cts command line");
-    }
-
-    /**
-     * Display the help message related to device commands.
-     */
-    private void showDeviceCmdHelp() {
-        final String deviceStr = CTSCommand.OPTION_D + "/" + CTSCommand.OPTION_DEVICE;
-
-        CUIOutputStream.println(CMD_TYPE_LEADING_SPACE + "Device:");
-        CUIOutputStream.println(CMD_OPT_LEADING_SPACE
-                + CTSCommand.LIST + " " + deviceStr + ": list available devices");
-    }
-
-    /**
-     * Process the command from user's input.
-     *
-     * @param cp Command container.
-     */
-    public void processCommand(final CommandParser cp) throws Exception {
-        String action = cp.getAction();
-
-        if (action.equals(CTSCommand.EXIT)) {
-            if (cp.getArgSize() != 1) {
-                showHelp();
-                return;
-            }
-            Log.d("exit cts host");
-            mKeepRunning = false;
-            mHost.tearDown();
-        } else if (action.equals(CTSCommand.HELP)) {
-            showHelp();
-        } else if (mCommandHistory.isHistoryCommand(action)) {
-            processHistoryCommands(cp);
-        } else if (action.equals(CTSCommand.ADD)) {
-            processAddCommand(cp);
-        } else if (action.equals(CTSCommand.START)) {
-            processStartCommand(cp);
-        } else if (action.equals(CTSCommand.REMOVE)) {
-            processRmCommand(cp);
-        } else if (action.equals(CTSCommand.LIST)) {
-            processListCommand(cp);
-        } else {
-            showHelp();
-        }
-    }
-
-    /**
-     * Process start command.
-     *
-     * @param cp Command container.
-     */
-    private void processStartCommand(CommandParser cp) throws SAXException,
-            ParserConfigurationException {
-        if (cp.containsKey(CTSCommand.OPTION_PLAN)) {
-            processStartSessionCommand(cp);
-        } else if (cp.containsKey(CTSCommand.OPTION_P)
-                || cp.containsKey(CTSCommand.OPTION_PACKAGE)) {
-            processStartPackageCommand(cp);
-        } else {
-            showHelp();
-        }
-    }
-
-    /**
-     * Process start package command.
-     *
-     * <ul>
-     *     <li> Syntax:
-     *            start --package zipped-package-file
-     * </ul>
-     * @param cp Command container.
-     */
-    private void processStartPackageCommand(CommandParser cp) {
-        try {
-            String pathName = cp.getValue(CTSCommand.OPTION_PACKAGE);
-            mHost.startZippedPackage(pathName);
-        } catch (DeviceDisconnectedException e) {
-          Log.e("Device " + e.getMessage() + " disconnected", e);
-        } catch (Exception e) {
-            Log.e("Met exception during running zipped package.", e);
-        }
-    }
-
-    /**
-     * Validate the command parameters used to activate CTS.
-     *
-     * @param cp Command container.
-     * @return If command parameters are valid, return true; else, return false.
-     */
-    public boolean validateCommandParams(CommandParser cp) {
-        if (cp == null) {
-            return false;
-        }
-
-        if (cp.getAction() == null) {
-            return true;
-        } else if (isValidCommandOption(cp, CTSCommand.START,
-                CTSCommand.OPTION_PLAN)) {
-            return true;
-        } else if (isValidCommandOption(cp, CTSCommand.START,
-                CTSCommand.OPTION_PACKAGE)) {
-            return true;
-        } else if (isValidCommandOption(cp, CTSCommand.START,
-                CTSCommand.OPTION_P)) {
-            return true;
-        } else {
-            return false;
-        }
-    }
-
-    /**
-     * Check if the command option is valid.
-     *
-     * @param cp CommandParser which contains the command and options.
-     * @param command Command the user typed in.
-     * @param option Option the user typed in.
-     * @return If command option valid, return true; else, return false.
-     */
-    private static boolean isValidCommandOption(CommandParser cp,
-            String command, String option) {
-        return (cp.getAction().equals(command)) && (cp.containsKey(option))
-                && (cp.getValue(option) != null)
-                && (cp.getValue(option).length() != 0);
-    }
-
-    /**
-     * Process start session command.
-     * <ul>
-     *     <li> Syntax 1:
-     *            start --plan plan-name
-     *              [ --device device-id ]
-     *              [ --test test-name ]
-     *              [ --profile profile-name ]
-     *     <li> Syntax 2:
-     *            start --plan plan-name
-     *              [ --device device-id ]
-     *              [ --package java-package-name ]
-     *              [ --profile profile-name ]
-     * </ul>
-     * @param cp container which contained start command options and values
-     *           Process the list commands.
-     */
-    private void processStartSessionCommand(CommandParser cp)
-            throws SAXException, ParserConfigurationException {
-
-        if (mHost.getDeviceList().length == 0) {
-            Log.e("No device connected", null);
-            return;
-        }
-
-        String testPlanPath = null;
-        String deviceId = null;
-        String testName = null;
-        String javaPkgName = null;
-        String testPlanName = mHost.getPlanName(cp.getValue(CTSCommand.OPTION_PLAN));
-        try {
-            if (cp.getActionValues().size() != 0 || cp.getOptionSize() < 1
-                    || cp.getOptionSize() > 3) {
-                showStartSessionHelp();
-                return;
-            }
-            testPlanName = mHost.getPlanName(cp
-                    .getValue(CTSCommand.OPTION_PLAN));
-            testPlanPath = HostConfig.getInstance().getPlanRepository()
-                    .getPlanPath(testPlanName);
-            if (testPlanPath == null) {
-                CUIOutputStream.println("Plan " + testPlanName
-                        + " is not in repository, please create it!");
-                return;
-            }
-
-            ActionType actionType = ActionType.START_NEW_SESSION;
-            if (cp.containsKey(CTSCommand.OPTION_TEST)) {
-                testName = cp.getValue(CTSCommand.OPTION_TEST);
-                if (-1 == testName.indexOf(Test.METHOD_SEPARATOR)) {
-                    Log.e("Test full name must be in the form of:"
-                            + " java_package_name.class_name#method_name.", null);
-                    return;
-                }
-                actionType = ActionType.RUN_SINGLE_TEST;
-            } else if (cp.containsKey(CTSCommand.OPTION_PACKAGE)) {
-                javaPkgName = cp.getValue(CTSCommand.OPTION_PACKAGE);
-                actionType = ActionType.RUN_SINGLE_JAVA_PACKAGE;
-            }
-
-            TestSession ts = null;
-            ArrayList<TestSession> sessionList = mHost.getSessionList(testPlanName);
-            if ((sessionList != null) && (sessionList.size() > 0)) {
-                if ((testName == null) || (testName.length() == 0)) {
-                    String mode = chooseMode(sessionList);
-                    if (CREATE_SESSION.equals(mode)) {
-                        ts = TestHost.createSession(testPlanName);
-                    }
-                }
-                if (ts == null) {
-                    ts = chooseTestSession(sessionList);
-                    deviceId = ts.getDeviceId();
-                    if ((actionType != ActionType.RUN_SINGLE_TEST)
-                            && (actionType != ActionType.RUN_SINGLE_JAVA_PACKAGE)) {
-                        actionType = ActionType.RESUME_SESSION;
-                    }
-                }
-            }
-
-            if (cp.containsKey(CTSCommand.OPTION_DEVICE)) {
-                deviceId = cp.getValue(CTSCommand.OPTION_DEVICE);
-                String[] deviceIdList = deviceId.trim().split(",");
-                if (deviceIdList.length > 1) {
-                    Log.e("Just allow choosing one device ID.", null);
-                    return;
-                }
-            }
-
-            if (deviceId == null) {
-                TestDevice td = mHost.getFirstAvailableDevice();
-                if (td == null) {
-                    // no devices attached
-                    CUIOutputStream.println("No idle devices found.");
-                    return;
-                }
-                deviceId = td.getSerialNumber();
-            }
-
-            if (!checkDeviceExists(mHost.getDeviceList(), deviceId)) {
-                CUIOutputStream.println("Can't find specified device id.  Is it attached?");
-                return;
-            }
-
-            if (ts == null) {
-                ts = TestHost.createSession(testPlanName);
-            }
-
-            mHost.startSession(ts, deviceId, testName, javaPkgName, actionType);
-        } catch (IOException e) {
-            Log.e("Can't create test session", e);
-        } catch (DeviceNotAvailableException e) {
-            CUIOutputStream.println("Test plan(" + testPlanName + ") "
-                    + e.getMessage());
-            showStartSessionHelp();
-        } catch (TestNotFoundException e) {
-            CUIOutputStream.println(e.getMessage());
-        } catch (TestPlanNotFoundException e) {
-            CUIOutputStream.println("Can't find test plan " + testPlanName);
-        } catch (IllegalTestNameException e) {
-            CUIOutputStream.println("Illegal case name: " + testName);
-        } catch (DeviceDisconnectedException e) {
-            Log.e("Device " + e.getMessage() + " disconnected ", null);
-        } catch (NoSuchAlgorithmException e) {
-            Log.e("Fail to initialise SHA-1 algorithm", e);
-        } catch (InvalidApkPathException e) {
-            Log.e(e.getMessage(), null);
-        } catch (InvalidNameSpaceException e) {
-            Log.e(e.getMessage(), null);
-        }
-    }
-
-    /**
-     * Choose test session among the available test session list.
-     *
-     * @param sessionList The available test session list.
-     * @return The test session chosen.
-     */
-    private TestSession chooseTestSession(ArrayList<TestSession> sessionList) throws IOException {
-        if ((sessionList == null) || (sessionList.size() == 0)) {
-            return null;
-        }
-
-        if (sessionList.size() == 1) {
-            return sessionList.get(0);
-        }
-
-        int index = 0;
-        String notification = "Please choose a session from the existed session(s):\n";
-        for (TestSession session : sessionList) {
-            notification += "  " + session.getId() + "  [" + index + "] \n";
-            index ++;
-        }
-
-        return sessionList.get(getUserInputId(notification, 0, index));
-    }
-
-    /**
-     * Choose  between creating a new session and choosing a session among available ones.
-     *
-     * @param sessionList The available test session list.
-     * @return If choose to create a new session, return CREATE_SESSION;
-     *         else return CHOOSE_SESSION.
-     */
-    private String chooseMode(ArrayList<TestSession> sessionList) throws IOException {
-        if (TestHost.sMode == MODE.RUN || (sessionList == null) || (sessionList.size() == 0)) {
-            // do not prompt if the test run was started from command line mode, or when
-            // there are no existing sessions
-            return CREATE_SESSION;
-        }
-
-        String planName = sessionList.get(0).getSessionLog().getTestPlanName();
-        String notification = "There are " + sessionList.size()
-            + " existing session(s) for plan " + planName + ".\n"
-            + "Create a new session or choose an existing one?\n"
-            + "  Create a new session [0]\n"
-            + "  Choose a session     [1]\n";
-
-        int indexSelected = getUserInputId(notification, 0, 2);
-        if (indexSelected == 0) {
-            return CREATE_SESSION;
-        } else {
-            return CHOOSE_SESSION;
-        }
-    }
-
-    /**
-     * Validate the specified device ID against the available device array.
-     *
-     * @param availableDevices The available device array.
-     * @param specifiedId The specified device ID list.
-     * @return true if the id is valid
-     */
-    public boolean checkDeviceExists(TestDevice[] availableDevices, String specifiedId) {
-        for (TestDevice dev : availableDevices) {
-            if (specifiedId.equals(dev.getSerialNumber())) {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    /**
-     * Get device ID from the device ID string against the available devices.
-     *
-     * @param availableDevices The available devices.
-     * @param idStr The device ID string.
-     * @return The device ID.
-     */
-    public int getDeviceId(TestDevice[] availableDevices, String idStr) {
-        for (int i = 0; i < availableDevices.length; i++) {
-            TestDevice dev = availableDevices[i];
-            if (idStr.equals(dev.getSerialNumber())) {
-                return i;
-            }
-        }
-        return -1;
-    }
-
-    /**
-     * Get the ID input by the against the specified range.
-     *
-     * @param notification The notification message to notify the user.
-     * @param startIndex The start index.
-     * @param endIndex The end index.
-     * @return The selected index of the ID the user chosen.
-     */
-    private int getUserInputId(String notification, int startIndex, int endIndex)
-                throws IOException {
-        int indexSelected = 0;
-        boolean success = false;
-        while (!success) {
-            String answer = readLine(notification);
-            try {
-                indexSelected = Integer.parseInt(answer);
-                if ((indexSelected >= 0) && (indexSelected < endIndex)) {
-                    success = true;
-                } else {
-                    CUIOutputStream.println("" + indexSelected
-                            + " is out of range [0," + (endIndex -1 ) + "].");
-                }
-            } catch (NumberFormatException e) {
-                CUIOutputStream.println("Invalid nuber is typed in.");
-            }
-        }
-        return indexSelected;
-    }
-
-    /**
-     * Check if the specified device ID is valid.
-     *
-     * @param numOfAvailableDevices The number of available devices.
-     * @param specifiedId The specified device ID.
-     * @return If the specified ID contained in available ID list,
-     *         return true; else, return false.
-     */
-    public boolean isValidDeviceId(int numOfAvailableDevices, int specifiedId) {
-        if (specifiedId < 0 || specifiedId >= numOfAvailableDevices) {
-            return false;
-        }
-        return true;
-    }
-
-    /**
-     * Process list commands.
-     * <ul>
-     *     <li> Syntax 1:
-     *            ls --device
-     *     <li> Syntax 2:
-     *            ls --plan [ plan-name ]
-     *     <li> Syntax 3:
-     *            ls --package [ package-name ]
-     *     <li> Syntax 4:
-     *            ls --result
-     *              [ pass/fail/notExecuted/timeout ]
-     *              [ --session session_id ]
-     * </ul>
-     *
-     * @param cp Command container.
-     */
-    private void processListCommand(CommandParser cp) throws SAXException,
-            IOException, ParserConfigurationException {
-        if (cp.containsKey(CTSCommand.OPTION_DEVICE)) {
-            if (cp.getActionValues().size() != 0 || cp.getOptionSize() != 1) {
-                showDeviceCmdHelp();
-                return;
-            }
-            if (cp.getValue(CTSCommand.OPTION_DEVICE).equals("")) {
-                listDevices();
-            } else {
-                showDeviceCmdHelp();
-            }
-        } else if (cp.containsKey(CTSCommand.OPTION_PLAN)) {
-            if (cp.getActionValues().size() != 0 || cp.getOptionSize() != 1) {
-                showPlanCmdHelp();
-                return;
-            }
-            String planValue = cp.getValue(CTSCommand.OPTION_PLAN);
-            if (planValue.equals("")) {
-                listPlans();
-            } else {
-                listSinglePlan(mHost.getPlanName(planValue));
-            }
-        } else if (cp.containsKey(CTSCommand.OPTION_RESULT)) {
-            if (cp.getActionValues().size() != 0
-                    || (cp.getOptionSize() < 1 || cp.getOptionSize() > 2)) {
-                showResultCmdHelp();
-                return;
-            }
-            String resultValue = cp.getValue(CTSCommand.OPTION_RESULT);
-            String sessionId = cp.getValue(CTSCommand.OPTION_SESSION);
-            Integer resultCode = null;
-
-            if (sessionId != null) {
-                if (resultValue.length() != 0
-                        && !mResultCodeMap.containsKey(resultValue)) {
-                    showResultCmdHelp();
-                } else {
-                    resultCode = mResultCodeMap.get(resultValue);
-                    listSessionResult(sessionId, resultCode);
-                }
-            } else if (resultValue.length() == 0) {
-                listResults();
-            } else {
-                showHelp();
-            }
-        } else if (cp.containsKey(CTSCommand.OPTION_PACKAGE)) {
-            if (cp.getActionValues().size() != 0 || cp.getOptionSize() != 1) {
-                showPackageCmdHelp();
-                return;
-            }
-            listPackages(cp);
-        } else {
-            showHelp();
-        }
-    }
-
-    /**
-     * Process the removing commands.
-     * <ul>
-     *     <li> Syntax 1:
-     *            rm --plan [ plan-name ] [ all ]
-     *     <li> Syntax 2:
-     *            rm --package [ package-name ] [ all ]
-     * </ul>
-     *
-     * @param cp Command container.
-     */
-    private void processRmCommand(CommandParser cp) throws IOException {
-        if (cp.containsKey(CTSCommand.OPTION_PLAN)) {
-            if (cp.getActionValues().size() != 0 || cp.getOptionSize() != 1) {
-                showPlanCmdHelp();
-                return;
-            }
-
-            String planName = mHost.getPlanName(cp.getValue(CTSCommand.OPTION_PLAN));
-            if (HostConfig.ALL.equals(planName)) {
-                String prompt = "Remove all of the plans?([y/N])";
-                String answer = readLine(prompt).trim();
-                if (!isConfirmation(answer, false)) {
-                    return;
-                }
-            }
-
-            mHost.removePlans(planName);
-        } else if (cp.containsKey(CTSCommand.OPTION_PACKAGE)) {
-            if (cp.getActionValues().size() != 0 || cp.getOptionSize() != 1) {
-                showPackageCmdHelp();
-                return;
-            }
-
-            String packageName = cp.getValue(CTSCommand.OPTION_PACKAGE);
-            if (HostConfig.ALL.equals(packageName)) {
-                String prompt = "Remove all of the packages?([y/N])";
-                String answer = readLine(prompt).trim();
-                if (!isConfirmation(answer, false)) {
-                    return;
-                }
-            }
-
-            mHost.removePackages(packageName);
-        } else {
-            showHelp();
-        }
-    }
-
-    /**
-     * Check if the answer is confirmation.
-     *
-     * @param answer The answer user typed in.
-     * @param defaultResult If true, default to yes; else, default to no.
-     * @return If confirmation, return true; else, return false.
-     */
-    public static boolean isConfirmation(String answer, boolean defaultResult) {
-        if ("".equals(answer)) {
-            return defaultResult;
-        }
-
-        return ("y".equals(answer.toLowerCase()) || "yes".equals(answer.toLowerCase()));
-    }
-
-    /**
-     * Process the add commands.
-     * <ul>
-     *     <li> Syntax 1:
-     *            add --plan plan-name
-     *     <li> Syntax 2:
-     *            add --package package-name
-     * </ul>
-     *
-     * @param cp Command container.
-     */
-    private void processAddCommand(CommandParser cp) {
-        if (cp.containsKey(CTSCommand.OPTION_PLAN)) {
-            if (isValidAddPlanArguments(cp)) {
-                createPlan(cp, CTSCommand.OPTION_PLAN);
-            } else {
-                showPlanCmdHelp();
-            }
-        } else if (cp.containsKey(CTSCommand.OPTION_DERIVED_PLAN)) {
-            if (isValidDerivedPlanArguments(cp)) {
-                createPlan(cp, CTSCommand.OPTION_DERIVED_PLAN);
-            } else {
-                showPlanCmdHelp();
-            }
-        } else if (cp.containsKey(CTSCommand.OPTION_PACKAGE)) {
-            try {
-                addPackage(cp);
-            } catch (IOException e) {
-                Log.e("Can't add package", e);
-            } catch (IndexOutOfBoundsException e) {
-                Log.e("Can't add package", e);
-            } catch (NoSuchAlgorithmException e) {
-                Log.e("Can't add package", e);
-            }
-        } else {
-            showHelp();
-        }
-    }
-
-    /**
-     * Check if it's valid arguments for adding plan.
-     *
-     * @param cp The command processor.
-     * @return if valid, return true; else, return false.
-     */
-    private boolean isValidAddPlanArguments(CommandParser cp) {
-        return (cp.getArgSize() == 3) && (cp.getActionValues().size() == 0)
-                && (cp.getOptionSize() == 1);
-    }
-
-    /**
-     * Check if it's valid arguments for deriving plan.
-     *
-     * @param cp The command processor.
-     * @return if valid, return true; else, return false.
-     */
-    private boolean isValidDerivedPlanArguments(CommandParser cp) {
-        //argument size: it's at least 3, as "add --plan plan_name"
-        //action values: no option contains more than one value
-        //option size: it's at least 1, as "add --plan plan_name"
-        return (cp.getArgSize() >= 3) && (cp.getActionValues().size() == 0)
-                && (cp.getOptionSize() >= 1);
-    }
-
-    /**
-     * Process the history commands.
-     * <ul>
-     *     <li> Syntax:
-     *            history [ -e ] [ number]
-     * </ul>
-     *
-     * @param cp Command container.
-     */
-    private void processHistoryCommands(final CommandParser cp)
-            throws Exception {
-        try {
-            if ((cp.getOptionSize() == 0) && (cp.getActionValues().size() == 0)) {
-                mCommandHistory.show(mCommandHistory.size());
-            } else if (cp.containsKey(CTSCommand.OPTION_E)
-                    && (cp.getActionValues().size() == 0)) {
-                int cmdNum = 0;
-                cmdNum = Integer.parseInt(cp.getValue(CTSCommand.OPTION_E));
-                if (cmdNum >= 0 && cmdNum < mCommandHistory.size()) {
-                    String cmdLine = mCommandHistory.get(cmdNum);
-                    CommandParser cpH = CommandParser.parse(cmdLine);
-                    CUIOutputStream.printPrompt();
-                    CUIOutputStream.println(cmdLine);// print(CTS_PROMPT_SIGN
-                                                        // + cmdLine);
-                    processCommand(cpH);
-                    mCommandHistory.addCommand(cpH, cmdLine);
-                } else {
-                    if (mCommandHistory.size() > 0) {
-                        Log.e("Command index " + cmdNum
-                                + " is out of command history range [0,"
-                                + (mCommandHistory.size() - 1) + "].", null);
-                    } else {
-                        Log.e("No command exists in command history.", null);
-                    }
-                }
-            } else if ((cp.getOptionSize() == 0)
-                    && (cp.getActionValues().size() == 1)) {
-                int cmdCount = Integer.parseInt(cp.getActionValues().iterator()
-                        .next());
-                if (cmdCount < 0 || cmdCount > mCommandHistory.size()) {
-                    cmdCount = mCommandHistory.size();
-                }
-                mCommandHistory.show(cmdCount);
-            } else {
-                showHistoryCmdHelp();
-            }
-
-        } catch (NumberFormatException e) {
-            showHistoryCmdHelp();
-        }
-    }
-
-    /**
-     * List a single plan by the plan name given.
-     *
-     * @param name The plan name.
-     */
-    private void listSinglePlan(String name) throws SAXException, IOException,
-            ParserConfigurationException {
-        String planName = null;
-        for (String str : mHost.getPlanRepository().getAllPlanNames()) {
-            if (str.startsWith(name)) {
-                planName = str;
-                break;
-            }
-        }
-
-        if (planName == null) {
-            Log.e("No plan named " + name + " in repository!", null);
-            return;
-        }
-
-        String planPath = mHost.getPlanRepository().getPlanPath(planName);
-        ArrayList<String> removedPkgList = new ArrayList<String>();
-        Collection<String> pkgNames = TestPlan.getEntries(planPath, removedPkgList);
-
-        if (removedPkgList.size() != 0) {
-            CUIOutputStream.println("The following package(s) contained in plan "
-                    + planName + " have been removed:");
-            for (String pkgName : removedPkgList) {
-                CUIOutputStream.println("    " + pkgName);
-            }
-        }
-
-        if (pkgNames.size() > 0) {
-            CUIOutputStream.println("Packages of plan " + planName
-                    + " (" + pkgNames.size() + " in total):");
-            CUIOutputStream.println(LS_PLAN_SEPARATOR);
-            for (String pkgName : pkgNames) {
-                CUIOutputStream.println(pkgName);
-            }
-        }
-    }
-
-    /**
-     * Create test plan via the test session and result type given.
-     *
-     * @param name The test plan name.
-     * @param ts The test session.
-     * @param resultType The result type.
-     */
-    private void createPlanFromSession(final String name, TestSession ts, final String resultType)
-            throws FileNotFoundException, IOException, ParserConfigurationException,
-            TransformerFactoryConfigurationError, TransformerException {
-
-        HashMap<String, ArrayList<String>> selectedResult =
-            new HashMap<String, ArrayList<String>>();
-        ArrayList<String> packageNames = new ArrayList<String>();
-
-        for (TestPackage pkg : ts.getSessionLog().getTestPackages()) {
-            String pkgName = pkg.getAppPackageName();
-            ArrayList<String> excludedList = pkg.getExcludedList(resultType);
-            if (excludedList != null) {
-                packageNames.add(pkgName);
-                selectedResult.put(pkgName, excludedList);
-            }
-        }
-
-        if ((selectedResult != null) && (selectedResult.size() > 0)) {
-            TestSessionBuilder.getInstance().serialize(name, packageNames, selectedResult);
-        } else {
-            if (resultType == null) {
-                Log.i("All tests of session " + ts.getId()
-                        + " have passed execution. The plan is not created!");
-            } else {
-                Log.i("No " + resultType +  " tests of session " + ts.getId()
-                        + ". The plan is not created!");
-            }
-        }
-    }
-
-    /**
-     * Add a derived plan from a given session.
-     *
-     * @param cp Command container.
-     * @param name The plan name.
-     * @param packageNames The package name list.
-     */
-    private void addDerivedPlan(final CommandParser cp, final String name,
-            ArrayList<String> packageNames) {
-
-        try {
-            String sessionId = null;
-            String resultType = null;
-            int id = TestSession.getLastSessionId();
-
-            if (cp.containsKey(CTSCommand.OPTION_SESSION)) {
-                sessionId = cp.getValue(CTSCommand.OPTION_SESSION);
-                id = Integer.parseInt(sessionId);
-            }
-            TestSession ts = mHost.getSession(id);
-            if (ts == null) {
-                Log.e("The session ID of " + id + " doesn't exist.", null);
-                return;
-            }
-
-            if (cp.containsKey(CTSCommand.OPTION_RESULT)) {
-                resultType = cp.getValue(CTSCommand.OPTION_RESULT);
-                if (!CtsTestResult.isValidResultType(resultType)) {
-                    Log.e("The following result type is invalid: " + resultType, null);
-                    return;
-                }
-            }
-            createPlanFromSession(name, ts, resultType);
-        } catch (Exception e) {
-            Log.e("Got exception while trying to add a plan!", e);
-            return;
-        }
-    }
-
-    /**
-     * Add a plan by the plan name given.
-     *
-     * @param cp Command container.
-     * @param name The plan name.
-     * @param packageNames The package name list.
-     */
-    private void addPlan(final CommandParser cp, final String name,
-            ArrayList<String> packageNames) {
-
-        try {
-            PlanBuilder planBuilder = new PlanBuilder(packageNames);
-
-            if (mOsName.equals(OS_NAME_LINUX)) {
-                // planBuilder.setInputStream(sConsoleReader);
-            } else {
-                planBuilder.setInputStream(mCommandInput);
-            }
-
-            HashMap<String, ArrayList<String>> selectedResult = planBuilder.doSelect();
-            if (selectedResult != null) {
-                TestSessionBuilder.getInstance().serialize(name, packageNames, selectedResult);
-            } else {
-                Log.i("Selected nothing for the plan of " + name + ". The plan is not created!");
-            }
-        } catch (Exception e) {
-            Log.e("Got exception while trying to add a plan!", e);
-            return;
-        }
-    }
-
-    /**
-     * Create a plan.
-     *
-     * @param cp Command container.
-     * @param type the action type.
-     */
-    private void createPlan(final CommandParser cp, final String type) {
-        String name = null;
-        if (CTSCommand.OPTION_PLAN.equals(type)) {
-            name = cp.getValue(CTSCommand.OPTION_PLAN);
-        } else if (CTSCommand.OPTION_DERIVED_PLAN.equals(type)) {
-            name = cp.getValue(CTSCommand.OPTION_DERIVED_PLAN);
-        } else {
-            return;
-        }
-
-        if (HostUtils.isFileExist(HostConfig.getInstance().getPlanRepository()
-                .getPlanPath(name)) == true) {
-            Log.e("Plan " + name + " already exist, please use another name!", null);
-            return;
-        }
-
-        try {
-            if ((name != null) && (!name.matches("\\w+"))) {
-                CUIOutputStream.println("Only letter of the alphabet, number and '_'"
-                        + " are available for test plan name");
-                return;
-            }
-
-            ArrayList<String> packageNames =
-                HostConfig.getInstance().getCaseRepository().getPackageNames();
-            Collection<TestPackage> testPackages = HostConfig.getInstance().getTestPackages();
-            if (testPackages.size() == 0) {
-                CUIOutputStream.println("No package found in repository, please add package first!");
-                return;
-            }
-            if (CTSCommand.OPTION_PLAN.equals(type)) {
-                addPlan(cp, name, packageNames);
-            } else if (CTSCommand.OPTION_DERIVED_PLAN.equals(type)) {
-                addDerivedPlan(cp, name, packageNames);
-            }
-        } catch (Exception e) {
-            Log.e("Got exception while trying to add a plan!", e);
-            return;
-        }
-    }
-
-    /**
-     * List all of the plans in the plan repository.
-     */
-    private void listPlans() {
-        ArrayList<String> plans = mHost.getPlanRepository().getAllPlanNames();
-
-        if (plans.size() == 0) {
-            CUIOutputStream.println("No plan created!");
-        } else {
-            CUIOutputStream.println("List of plans (" + plans.size() + " in total):");
-            for (String name : plans) {
-                CUIOutputStream.println(name);
-            }
-        }
-    }
-
-    /**
-     * List detailed case result of specified session. The result can be
-     * filtered, if resultType isn't null, by the specified resultType.
-     *
-     * @param idStr the session id.
-     * @param resultType the type of result, [pass, fail, notExecuted, timeout, null].
-     */
-    private void listSessionResult(final String idStr, final Integer resultType) {
-        if (!idStr.matches("\\d+")) {
-            showResultCmdHelp();
-            return;
-        }
-
-        int sessionId = Integer.parseInt(idStr);
-
-        TestSession ts = mHost.getSession(sessionId);
-        if (null == ts) {
-            Log.e("Can't find specified session", null);
-            return;
-        }
-
-        TestSessionLog log = ts.getSessionLog();
-        CUIOutputStream.println("Result of session " + ts.getId());
-        CUIOutputStream.println("Result\t\tCase name");
-        CUIOutputStream
-                .println("==============================================================");
-        for (Test test : log.getAllResults()) {
-            CtsTestResult result = test.getResult();
-            if ((resultType != null) && (result.getResultCode() != resultType.intValue())) {
-                continue;
-            }
-            CUIOutputStream.println(result.getResultString() + "\t\t"
-                    + test.getFullName());
-        }
-    }
-
-    /**
-     * List all of the test results.
-     */
-    private void listResults() {
-        Collection<TestSession> sessions = mHost.getSessions();
-        if (sessions.isEmpty()) {
-            CUIOutputStream.println("There aren't any test results!");
-        } else {
-            CUIOutputStream.println("List of all results: ");
-            CUIOutputStream.println("Session\t\tTest result\t\t\t\tStart time\t\tEnd time\t"
-                    + "\tTest plan name\t");
-            CUIOutputStream.println("\t\tPass\tFail\tTimeout\tNotExecuted");
-
-            for (TestSession session : sessions) {
-                TestSessionLog log = session.getSessionLog();
-                int passNum = log.getTestList(
-                        CtsTestResult.CODE_PASS).size();
-                int failNum = log.getTestList(
-                        CtsTestResult.CODE_FAIL).size();
-                int notExecutedNum = log.getTestList(
-                        CtsTestResult.CODE_NOT_EXECUTED).size();
-                int timeOutNum = log.getTestList(
-                        CtsTestResult.CODE_TIMEOUT).size();
-
-                String resStr = Long.toString(passNum) + "\t" + failNum;
-                resStr += "\t" + timeOutNum;
-                resStr += "\t" + notExecutedNum;
-
-                String startTimeStr =
-                    HostUtils.getFormattedTimeString(log.getStartTime().getTime(), " ", ".", ":");
-                String endTimeStr =
-                    HostUtils.getFormattedTimeString(log.getEndTime().getTime(), " ", ".", ":");
-                CUIOutputStream.println(Long.toString(session.getId()) + "\t\t"
-                        + resStr + "\t\t" + startTimeStr
-                        + "\t" + endTimeStr
-                        + "\t" + log.getTestPlanName());
-
-            }
-        }
-    }
-
-    /**
-     * Add a package by the path and package name.
-     *
-     * @param cp Command container.
-     */
-    private void addPackage(final CommandParser cp) throws IOException,
-            IndexOutOfBoundsException, NoSuchAlgorithmException {
-        if (cp.getActionValues().size() != 0 || cp.getOptionSize() != 1) {
-            showPackageCmdHelp();
-            return;
-        }
-        String pathName = cp.getValue(CTSCommand.OPTION_PACKAGE);
-        mHost.addPackage(pathName);
-    }
-
-    /**
-     * List current package in the case repository.
-     *
-     * @param cp Command container
-     */
-    private void listPackages(final CommandParser cp) {
-        // walk through the case root path
-        // and list available packages
-        String expectPackage = cp.getValue(CTSCommand.OPTION_PACKAGE);
-        String caseRoot = mHost.getCaseRepository().getRoot();
-        if (caseRoot == null) {
-            Log.e("Case repository is null", null);
-            return;
-        }
-
-        File root = new File(caseRoot);
-        if (!root.isDirectory()) {
-            Log.e("Case repository must be a directory!", null);
-            return;
-        }
-
-        Collection<TestPackage> testPackages = HostConfig.getInstance().getTestPackages();
-
-        if (testPackages.size() == 0) {
-            CUIOutputStream
-                    .println("No package available under case repository!");
-        } else {
-            if (expectPackage.equals("")) {
-                CUIOutputStream.println("Available packages ("
-                        + testPackages.size() + " in total):");
-                for (TestPackage pkg : testPackages) {
-                    CUIOutputStream.println(pkg.getAppPackageName());
-                }
-            } else {
-                List<ArrayList<String>> list = mHost.getCaseRepository()
-                        .listAvailablePackage(expectPackage);
-                ArrayList<String> packageList = list.get(0);
-                ArrayList<String> suiteList = list.get(1);
-                ArrayList<String> caseList = list.get(2);
-                ArrayList<String> testList = list.get(3);
-                if ((packageList.size() == 0) && (suiteList.size() == 0)
-                        && (caseList.size() == 0) && (testList.size() == 0)) {
-                    CUIOutputStream
-                            .println("Not available test package, suite, cases or tests: "
-                                    + expectPackage);
-                } else {
-                    if (packageList.size() != 0) {
-                        CUIOutputStream.println(
-                                "Test packages (" + packageList.size() + " in total):");
-                        for (String packageName : packageList) {
-                            CUIOutputStream.println(packageName);
-                        }
-                    }
-                    if (suiteList.size() != 0) {
-                        CUIOutputStream.println(
-                                "Test suites (" + suiteList.size() + " in total):");
-                        for (String suiteName : suiteList) {
-                            CUIOutputStream.println(suiteName);
-                        }
-                    }
-                    if (caseList.size() != 0) {
-                        CUIOutputStream.println("Test cases (" + caseList.size() + " in total):");
-                        for (String caseName : caseList) {
-                            CUIOutputStream.println(caseName);
-                        }
-                    }
-                    if (testList.size() != 0) {
-                        CUIOutputStream.println("Tests (" + testList.size() + " in total):");
-                        for (String testName : testList) {
-                            CUIOutputStream.println(testName);
-                        }
-                    }
-                }
-            }
-        }
-    }
-
-    /**
-     * List all of the devices connected.
-     */
-    private void listDevices() {
-        String[] deviceNames = mHost.listDevices();
-        if (deviceNames.length == 0) {
-            CUIOutputStream.println("No device connected.");
-            return;
-        }
-
-        CUIOutputStream.println("Id\t\tDevice Name\t\tStatus");
-
-        for (int i = 0; i < deviceNames.length; i++) {
-            CUIOutputStream.println(i + "\t\t" + deviceNames[i]);
-        }
-    }
-}
diff --git a/tools/host/src/com/android/cts/CtsTestResult.java b/tools/host/src/com/android/cts/CtsTestResult.java
deleted file mode 100644
index b64863d..0000000
--- a/tools/host/src/com/android/cts/CtsTestResult.java
+++ /dev/null
@@ -1,206 +0,0 @@
-/*
- * Copyright (C) 2009 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.cts;
-
-import junit.framework.TestFailure;
-import junit.framework.TestResult;
-
-import java.util.Enumeration;
-import java.util.HashMap;
-
-
-/**
- * Store the result of a specific test.
- */
-public class CtsTestResult {
-    private int mResultCode;
-    private String mFailedMessage;
-    private String mStackTrace;
-
-    public static final int CODE_INIT = -1;
-    public static final int CODE_NOT_EXECUTED = 0;
-    public static final int CODE_PASS = 1;
-    public static final int CODE_FAIL = 2;
-    public static final int CODE_ERROR = 3;
-    public static final int CODE_TIMEOUT = 4;
-    public static final int CODE_FIRST = CODE_INIT;
-    public static final int CODE_LAST = CODE_TIMEOUT;
-
-    public static final String STR_ERROR = "error";
-    public static final String STR_TIMEOUT = "timeout";
-    public static final String STR_NOT_EXECUTED = "notExecuted";
-    public static final String STR_FAIL = "fail";
-    public static final String STR_PASS = "pass";
-
-    private static HashMap<Integer, String> sCodeToResultMap;
-    private static HashMap<String, Integer> sResultToCodeMap;
-    static {
-        sCodeToResultMap = new HashMap<Integer, String>();
-        sCodeToResultMap.put(CODE_NOT_EXECUTED, STR_NOT_EXECUTED);
-        sCodeToResultMap.put(CODE_PASS, STR_PASS);
-        sCodeToResultMap.put(CODE_FAIL, STR_FAIL);
-        sCodeToResultMap.put(CODE_ERROR, STR_ERROR);
-        sCodeToResultMap.put(CODE_TIMEOUT, STR_TIMEOUT);
-        sResultToCodeMap = new HashMap<String, Integer>();
-        for (int code : sCodeToResultMap.keySet()) {
-            sResultToCodeMap.put(sCodeToResultMap.get(code), code);
-        }
-    }
-
-    public CtsTestResult(int resCode) {
-        mResultCode = resCode;
-    }
-
-    public CtsTestResult(int resCode, final String failedMessage, final String stackTrace) {
-        mResultCode = resCode;
-        mFailedMessage = failedMessage;
-        mStackTrace = stackTrace;
-    }
-
-    public CtsTestResult(final String result, final String failedMessage,
-            final String stackTrace) throws InvalidTestResultStringException {
-        if (!sResultToCodeMap.containsKey(result)) {
-            throw new InvalidTestResultStringException(result);
-        }
-
-        mResultCode = sResultToCodeMap.get(result);
-        mFailedMessage = failedMessage;
-        mStackTrace = stackTrace;
-    }
-
-    /**
-     * Check if the result indicates failure.
-     *
-     * @return If failed, return true; else, return false.
-     */
-    public boolean isFail() {
-        return mResultCode == CODE_FAIL;
-    }
-
-    /**
-     * Check if the result indicates pass.
-     *
-     * @return If pass, return true; else, return false.
-     */
-    public boolean isPass() {
-        return mResultCode == CODE_PASS;
-    }
-
-    /**
-     * Check if the result indicates not executed.
-     *
-     * @return If not executed, return true; else, return false.
-     */
-    public boolean isNotExecuted() {
-        return mResultCode == CODE_NOT_EXECUTED;
-    }
-
-    /**
-     * Get result code of the test.
-     *
-     * @return The result code of the test.
-     *         The following is the possible result codes:
-     * <ul>
-     *    <li> notExecuted
-     *    <li> pass
-     *    <li> fail
-     *    <li> error
-     *    <li> timeout
-     * </ul>
-     */
-    public int getResultCode() {
-        return mResultCode;
-    }
-
-    /**
-     * Get the failed message.
-     *
-     * @return The failed message.
-     */
-    public String getFailedMessage() {
-        return mFailedMessage;
-    }
-
-    /**
-     * Get the stack trace.
-     *
-     * @return The stack trace.
-     */
-    public String getStackTrace() {
-        return mStackTrace;
-    }
-
-    /**
-     * Set the result.
-     *
-     * @param testResult The result in the form of JUnit test result.
-     */
-    @SuppressWarnings("unchecked")
-    public void setResult(TestResult testResult) {
-        int resCode = CODE_PASS;
-        String failedMessage = null;
-        String stackTrace = null;
-        if ((testResult != null) && (testResult.failureCount() > 0 || testResult.errorCount() > 0)) {
-            resCode = CODE_FAIL;
-            Enumeration<TestFailure> failures = testResult.failures();
-            while (failures.hasMoreElements()) {
-                TestFailure failure = failures.nextElement();
-                failedMessage += failure.exceptionMessage();
-                stackTrace += failure.trace();
-            }
-            Enumeration<TestFailure> errors = testResult.errors();
-            while (errors.hasMoreElements()) {
-                TestFailure failure = errors.nextElement();
-                failedMessage += failure.exceptionMessage();
-                stackTrace += failure.trace();
-            }
-        }
-        mResultCode = resCode;
-        mFailedMessage = failedMessage;
-        mStackTrace = stackTrace;
-    }
-
-    /**
-     * Reverse the result code.
-     */
-    public void reverse() {
-        if (isPass()) {
-            mResultCode = CtsTestResult.CODE_FAIL;
-        } else if (isFail()){
-            mResultCode = CtsTestResult.CODE_PASS;
-        }
-    }
-
-    /**
-     * Get the test result as string.
-     *
-     * @return The readable result string.
-     */
-    public String getResultString() {
-        return sCodeToResultMap.get(mResultCode);
-    }
-
-    /**
-     * Check if the given resultType is a valid result type defined..
-     *
-     * @param resultType The result type to be checked.
-     * @return If valid, return true; else, return false.
-     */
-    static public boolean isValidResultType(final String resultType) {
-        return sResultToCodeMap.containsKey(resultType);
-    }
-}
diff --git a/tools/host/src/com/android/cts/DeviceDisconnectedException.java b/tools/host/src/com/android/cts/DeviceDisconnectedException.java
deleted file mode 100644
index 9a9c134..0000000
--- a/tools/host/src/com/android/cts/DeviceDisconnectedException.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright (C) 2008 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.cts;
-
-/**
- * Throw out DeviceDisconnectedException if detected that the device is disconnected.
- */
-public class DeviceDisconnectedException extends Exception {
-
-    public DeviceDisconnectedException(String message) {
-        super(message);
-    }
-}
diff --git a/tools/host/src/com/android/cts/DeviceManager.java b/tools/host/src/com/android/cts/DeviceManager.java
deleted file mode 100644
index 410ac7b..0000000
--- a/tools/host/src/com/android/cts/DeviceManager.java
+++ /dev/null
@@ -1,416 +0,0 @@
-/*
- * Copyright (C) 2008 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.cts;
-
-import com.android.ddmlib.AdbCommandRejectedException;
-import com.android.ddmlib.AndroidDebugBridge;
-import com.android.ddmlib.IDevice;
-import com.android.ddmlib.TimeoutException;
-import com.android.ddmlib.AndroidDebugBridge.IDeviceChangeListener;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.concurrent.Semaphore;
-import java.util.concurrent.TimeUnit;
-
-/**
- * Initializing and managing devices.
- */
-public class DeviceManager implements IDeviceChangeListener {
-
-    private static final int SHORT_DELAY = 1000 * 15; // 15 seconds
-    private static final int LONG_DELAY = 1000 * 60 * 10; // 10 minutes
-    /** Time to wait after issuing reboot command  */
-    private static final int REBOOT_DELAY = 5 * 1000; // 5 seconds
-    /** Time to wait after device reports that boot is complete. */
-    private static final int POST_BOOT_DELAY = 1000 * 60; // 1 minute
-    /** Maximal number of attempts to restart ADB connection. */
-    private static final int MAX_ADB_RESTART_ATTEMPTS = 10;
-    ArrayList<TestDevice> mDevices;
-    /** This is used during device restart for blocking until the device has been reconnected. */
-    private Semaphore mSemaphore = new Semaphore(0);
-
-    public DeviceManager() {
-        mDevices = new ArrayList<TestDevice>();
-    }
-
-    /**
-     * Initialize Android debug bridge. This function should be called after
-     * {@link DeviceManager} initialized.
-     */
-    public void initAdb() {
-        String adbLocation = getAdbLocation();
-
-        Log.d("init adb...");
-        AndroidDebugBridge.init(true);
-        AndroidDebugBridge.addDeviceChangeListener(this);
-        AndroidDebugBridge.createBridge(adbLocation, true);
-    }
-
-    /**
-     * Get the location of the adb command.
-     *
-     * @return The location of the adb location.
-     */
-    public static String getAdbLocation() {
-        return "adb";
-    }
-
-    /**
-     * Allocate devices by specified number for testing.
-     * @param num the number of required device
-     * @return the specified number of devices.
-     */
-    public TestDevice[] allocateDevices(final int num) throws DeviceNotAvailableException {
-
-        ArrayList<TestDevice> deviceList;
-        TestDevice td;
-        int index = 0;
-
-        if (num < 0) {
-            throw new IllegalArgumentException();
-        }
-        if (num > mDevices.size()) {
-            throw new DeviceNotAvailableException("The number of connected device("
-                    + mDevices.size() + " is less than the specified number("
-                    + num + "). Please plug in enough devices");
-        }
-        deviceList = new ArrayList<TestDevice>();
-
-        while (index < mDevices.size() && deviceList.size() != num) {
-            td = mDevices.get(index);
-            if (td.getStatus() == TestDevice.STATUS_IDLE) {
-                deviceList.add(td);
-            }
-            index++;
-        }
-        if (deviceList.size() != num) {
-            throw new DeviceNotAvailableException("Can't get the specified number("
-                    + num + ") of idle device(s).");
-        }
-        return deviceList.toArray(new TestDevice[num]);
-    }
-
-    /**
-     * Get TestDevice list that available for executing tests.
-     *
-     * @return The device list.
-     */
-    public final TestDevice[] getDeviceList() {
-        return mDevices.toArray(new TestDevice[mDevices.size()]);
-    }
-
-    /**
-     * Get the number of all free devices.
-     *
-     * @return the number of all free devices
-     */
-    public int getCountOfFreeDevices() {
-        int count = 0;
-        for (TestDevice td : mDevices) {
-            if (td.getStatus() == TestDevice.STATUS_IDLE) {
-                count++;
-            }
-        }
-        return count;
-    }
-
-    /**
-     * Append the device to the device list.
-     *
-     * @param device The device to be appended to the device list.
-     */
-    private void appendDevice(final IDevice device) {
-        if (-1 == getDeviceIndex(device)) {
-            TestDevice td = new TestDevice(device);
-            mDevices.add(td);
-        }
-    }
-
-    /**
-     * Remove specified TestDevice from managed list.
-     *
-     * @param device The device to be removed from the device list.
-     */
-    private void removeDevice(final IDevice device) {
-        int index = getDeviceIndex(device);
-        if (index == -1) {
-            Log.d("Can't find " + device + " in device list of DeviceManager");
-            return;
-        }
-        mDevices.get(index).disconnected();
-        mDevices.remove(index);
-    }
-
-    /**
-     * Get the index of the specified device in the device array.
-     *
-     * @param device The device to be found.
-     * @return The index of the device if it exists; else -1.
-     */
-    private int getDeviceIndex(final IDevice device) {
-        TestDevice td;
-
-        for (int index = 0; index < mDevices.size(); index++) {
-            td = mDevices.get(index);
-            if (td.getSerialNumber().equals(device.getSerialNumber())) {
-                return index;
-            }
-        }
-        return -1;
-    }
-
-    /**
-     * Search a <code>TestDevice</code> by serial number.
-     *
-     * @param deviceSerialNumber The serial number of the device to be found.
-     * @return The test device, if it exists, otherwise null.
-     */
-    private TestDevice searchTestDevice(final String deviceSerialNumber) {
-        for (TestDevice td : mDevices) {
-            if (td.getSerialNumber().equals(deviceSerialNumber)) {
-                return td;
-            }
-        }
-        return null;
-    }
-
-    /** {@inheritDoc} */
-    public void deviceChanged(IDevice device, int changeMask) {
-        Log.d("device " + device.getSerialNumber() + " changed with changeMask=" + changeMask);
-        Log.d("Device state:" + device.getState());
-    }
-
-    /** {@inheritDoc} */
-    public void deviceConnected(IDevice device) {
-        new DeviceServiceMonitor(device).start();
-    }
-
-    /**
-     * To make sure that connection between {@link AndroidDebugBridge}
-     * and {@link IDevice} is initialized properly. In fact, it just make sure
-     * the sync service isn't null and device's build values are collected
-     * before appending device.
-     */
-    private class DeviceServiceMonitor extends Thread {
-        private IDevice mDevice;
-
-        public DeviceServiceMonitor(IDevice device) {
-            mDevice = device;
-        }
-
-        @Override
-        public void run() {
-            while (true) {
-                try {
-                    if ((mDevice.getSyncService() != null) && (mDevice.getPropertyCount() != 0)) {
-                        break;
-                    }
-                } catch (IOException e) {
-                    Log.e("Failed to connect to device", e);
-                } catch (TimeoutException e) {
-                    Log.e("Failed to connect to device", e);
-                } catch (AdbCommandRejectedException e) {
-                    Log.e("Failed to connect to device", e);
-                }
-                try {
-                    Thread.sleep(100);
-                } catch (InterruptedException e) {
-                    Log.d("polling for device sync service interrupted");
-                }
-            }
-            CUIOutputStream.println("Device(" + mDevice + ") connected");
-            if (!TestSession.isADBServerRestartedMode()) {
-                CUIOutputStream.printPrompt();
-            }
-            appendDevice(mDevice);
-            // increment the counter semaphore to unblock threads waiting for devices
-            mSemaphore.release();
-        }
-    }
-
-    /** {@inheritDoc} */
-    public void deviceDisconnected(IDevice device) {
-        removeDevice(device);
-    }
-
-    /**
-     * Allocate device by specified Id for testing.
-     * @param deviceId the ID of the test device.
-     * @return a {@link TestDevice} if the specified device is free.
-     */
-    public TestDevice allocateFreeDeviceById(String deviceId) throws DeviceNotAvailableException {
-        for (TestDevice td : mDevices) {
-            if (td.getSerialNumber().equals(deviceId)) {
-                if (td.getStatus() != TestDevice.STATUS_IDLE) {
-                    String msg = "The specifed device(" + deviceId + ") is " +
-                    td.getStatusAsString();
-                    throw new DeviceNotAvailableException(msg);
-                }
-                return td;
-            }
-        }
-        throw new DeviceNotAvailableException("The specified device(" +
-                deviceId + "cannot be found");
-    }
-
-    /**
-     * Reset the online {@link TestDevice} to STATUS_IDLE
-     *
-     * @param device of the specified {@link TestDevice}
-     */
-    public void resetTestDevice(final TestDevice device) {
-        if (device.getStatus() != TestDevice.STATUS_OFFLINE) {
-            device.setStatus(TestDevice.STATUS_IDLE);
-        }
-    }
-
-    /**
-     * Restart ADB server.
-     *
-     * @param ts The test session.
-     */
-    public void restartADBServer(TestSession ts) throws DeviceDisconnectedException {
-        try {
-            Thread.sleep(SHORT_DELAY); // time to collect outstanding logs
-            Log.i("Restarting device ...");
-            rebootDevice(ts);
-            Log.i("Restart complete.");
-        } catch (InterruptedException e) {
-            e.printStackTrace();
-        }
-    }
-
-    /**
-     * Reboot the device.
-     *
-     * @param ts The test session.
-     */
-    private void rebootDevice(TestSession ts) throws InterruptedException,
-                DeviceDisconnectedException {
-
-        String deviceSerialNumber = ts.getDeviceId();
-        if (!deviceSerialNumber.toLowerCase().startsWith("emulator")) {
-            // try to reboot the device using the command line adb
-            // TODO: do we need logic to retry this
-            executeCommand("adb -s " + deviceSerialNumber + " reboot");
-            // wait to make sure the reboot gets through before we tear down the connection
-
-            // TODO: this is flaky, no guarantee device has actually rebooted, host should wait till
-            // device goes offline
-            Thread.sleep(REBOOT_DELAY);
-        } else {
-            executeCommand("killall emulator");
-            executeCommand("killall emulator-x86");
-            executeCommand("killall emulator-arm");
-        }
-
-        int attempts = 0;
-        boolean deviceConnected = false;
-        while (!deviceConnected && (attempts < MAX_ADB_RESTART_ATTEMPTS)) {
-            AndroidDebugBridge.disconnectBridge();
-
-            // kill the server while the device is rebooting
-            executeCommand("adb kill-server");
-
-            // Reset the device counter semaphore. We will wait below until at least one device
-            // has come online. This can happen any time during or after the call to
-            // createBridge(). The counter gets increased by the DeviceServiceMonitor when a
-            // device is added.
-            mSemaphore.drainPermits();
-            AndroidDebugBridge.createBridge(getAdbLocation(), true);
-
-            boolean deviceFound = false;
-            while (!deviceFound) {
-                // wait until at least one device has been added
-                mSemaphore.tryAcquire(LONG_DELAY, TimeUnit.MILLISECONDS);
-                TestDevice device = searchTestDevice(deviceSerialNumber);
-                if (device != null) {
-                    ts.setTestDevice(device);
-                    deviceFound = true;
-                    deviceConnected = device.waitForBootComplete();
-                    // After boot is complete, the ADB connection sometimes drops
-                    // for a short time. Wait for things to stabilize.
-                    try {
-                        Thread.sleep(POST_BOOT_DELAY);
-                    } catch (InterruptedException ignored) {
-                        // ignore
-                    }
-                    // If the connection dropped during the sleep above, the TestDevice
-                    // instance is no longer valid.
-                    TestDevice newDevice = searchTestDevice(deviceSerialNumber);
-                    if (newDevice != null) {
-                        ts.setTestDevice(newDevice);
-                        if (newDevice != device) {
-                            // the connection was dropped or a second reboot occurred
-                            // TODO: replace the hardcoded /sdcard
-                            String cmd = String.format("adb -s %s shell bugreport -o " +
-                                        "/sdcard/bugreports/doubleReboot", deviceSerialNumber);
-                            executeCommand(cmd);
-                        }
-                    } else {
-                        // connection dropped and has not come back up
-                        deviceFound = false; // go wait for next semaphore permit
-                    }
-                }
-            }
-            attempts += 1;
-        }
-    }
-
-    /**
-     * Execute the given command and wait for its completion.
-     *
-     * @param command The command to be executed.
-     * @return True if the command was executed successfully, otherwise false.
-     */
-    private boolean executeCommand(String command) {
-        Log.d("executeCommand(): cmd=" + command);
-        try {
-            Process proc = Runtime.getRuntime().exec(command);
-            TimeoutThread tt = new TimeoutThread(proc, SHORT_DELAY);
-            tt.start();
-            proc.waitFor(); // ignore exit value
-            tt.interrupt(); // wake timeout thread
-        } catch (Exception e) {
-            return false;
-        }
-        return true;
-    }
-
-    class TimeoutThread extends Thread {
-        Process mProcess;
-        long mTimeout;
-
-        TimeoutThread(Process process, long timeout) {
-            mProcess = process;
-            mTimeout = timeout;
-        }
-
-        @Override
-        public void run() {
-            try {
-                Thread.sleep(mTimeout);
-            } catch (InterruptedException e) {
-                // process has already completed
-                return;
-            }
-            // destroy process and wake up thread waiting for its completion
-            mProcess.destroy();
-        }
-    }
-}
diff --git a/tools/host/src/com/android/cts/DeviceNotAvailableException.java b/tools/host/src/com/android/cts/DeviceNotAvailableException.java
deleted file mode 100644
index 416950b..0000000
--- a/tools/host/src/com/android/cts/DeviceNotAvailableException.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (C) 2008 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
- *
- *      httprunPackage://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.cts;
-
-/**
- * Exception reporting that the device is not available.
- *
- */
-public class DeviceNotAvailableException extends Exception {
-
-    private static final long serialVersionUID = -5747916746880520094L;
-
-    public DeviceNotAvailableException() {
-        super();
-    }
-
-    public DeviceNotAvailableException(final String msg) {
-        super(msg);
-    }
-
-}
diff --git a/tools/host/src/com/android/cts/DeviceObserver.java b/tools/host/src/com/android/cts/DeviceObserver.java
deleted file mode 100644
index 7e6b7a6..0000000
--- a/tools/host/src/com/android/cts/DeviceObserver.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (C) 2008 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.cts;
-
-public interface DeviceObserver {
-
-    /**
-     * Indicate the status of installing/uninstalling action:
-     * <ul>
-     *     <li>FAIL: indicate that the action is failed.
-     *     <li>SUCCESS: indicates that the action is success.
-     * </ul>
-     */
-    public static final int FAIL = -1;
-    public static final int SUCCESS = 1;
-
-    /**
-     * Notify after installing apk complete on the {@link TestDevice}
-     * no matter succeeded or failed.
-     *
-     * @param resultCode the result code of installation.
-     */
-    void notifyInstallingComplete(final int resultCode);
-
-    /**
-     * Notify after uninstalling apk complete on the {@link TestDevice}.
-     *
-     * @param resultCode the result code of uninstallation.
-     */
-    void notifyUninstallingComplete(final int resultCode);
-
-    /**
-     * Notify after installing apk timeout on the {@link TestDevice}
-     *
-     * @param testDevice the {@link TestDevice} whose install action timeout.
-     */
-    void notifyInstallingTimeout(final TestDevice testDevice);
-
-    /**
-     * Notify after uninstalling apk timeout.
-     *
-     * @param testDevice the {@link TestDevice} whose install action timeout
-     */
-    void notifyUninstallingTimeout(final TestDevice testDevice);
-
-    /**
-     * Notify after a {@link TestDevice}, which is used in testing,
-     * is disconnected to the {@link TestHost}.
-     *
-     */
-    void notifyTestingDeviceDisconnected();
-}
diff --git a/tools/host/src/com/android/cts/HostConfig.java b/tools/host/src/com/android/cts/HostConfig.java
deleted file mode 100644
index d42dcf4..0000000
--- a/tools/host/src/com/android/cts/HostConfig.java
+++ /dev/null
@@ -1,1101 +0,0 @@
-/*
- * Copyright (C) 2008 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.cts;
-
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.security.NoSuchAlgorithmException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.List;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipFile;
-
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.xml.sax.SAXException;
-
-/**
- * Holds CTS host configuration information, such as:
- * <ul>
- *    <li> test case repository
- *    <li> test plan repository
- *    <li> test result repository
- * </ul>
- */
-public class HostConfig extends XMLResourceHandler {
-    public static boolean DEBUG = false;
-
-    public static final String ALL = "all";
-
-    static final String SIGNATURE_TEST_PACKAGE_NAME = "SignatureTest";
-    static final String DEFAULT_HOST_CONFIG_FILE_NAME = "host_config.xml";
-    static final String FILE_SUFFIX_XML = ".xml";
-    static final String FILE_SUFFIX_APK = ".apk";
-    static final String FILE_SUFFIX_ZIP = ".zip";
-    static final String FILE_SUFFIX_JAR = ".jar";
-    static final String[] CTS_RESULT_RESOURCES = {"cts_result.xsl", "cts_result.css",
-                                                  "logo.gif", "newrule-green.png"};
-
-    private String mConfigRoot;
-    private String mLogRoot;
-    private CaseRepository mCaseRepos;
-    private ResultRepository mResultRepos;
-    private PlanRepository mPlanRepos;
-
-    // key: app package name
-    // value: TestPackage
-    private HashMap<String, TestPackage> mTestPackageMap;
-
-    enum Ints {
-        // Number of tests executed between reboots. A value <= 0 disables reboots.
-        maxTestCount (200),
-        // Max size [tests] for a package to be run in batch mode
-        maxTestsInBatchMode (0),
-        // Max time [ms] between test status updates for both individual and batch mode.
-        testStatusTimeoutMs (5 * 60 * 1000),
-        // Max time [ms] from start of package in batch mode and the first test status update.
-        batchStartTimeoutMs (30 * 60 * 1000),
-        // Max time [ms] from start of test in individual mode to the first test status update.
-        individualStartTimeoutMs (5 * 60 * 1000),
-        // Timeout [ms] for the signature check
-        signatureTestTimeoutMs (10 * 60 * 1000),
-        // Timeout [ms] for package installations
-        packageInstallTimeoutMs (2 * 60 * 1000),
-        // Time to wait [ms] after a package installation or removal
-        postInstallWaitMs (30 * 1000);
-
-        private int value;
-
-        Ints(int value) {
-            this.value = value;
-        }
-
-        int value() {
-            return value;
-        }
-
-        void setValue(int value) {
-            this.value = value;
-        }
-    }
-
-    private final static HostConfig sInstance = new HostConfig();
-
-    private HostConfig() {
-        mTestPackageMap = new HashMap<String, TestPackage>();
-    }
-
-    public static HostConfig getInstance() {
-        return sInstance;
-    }
-
-    /**
-     * Returns the max number of tests to run between reboots. A value of 0 or smaller indicates
-     * that reboots should not be used.
-     */
-    public static int getMaxTestCount() {
-        return Ints.maxTestCount.value();
-    }
-
-    /**
-     * Load configuration.
-     *
-     * @param configPath The configuration path.
-     * @return If succeed in loading, return true; else, return false.
-     */
-    public boolean load(String configPath) throws SAXException, IOException,
-            ParserConfigurationException {
-
-        String fileName = null;
-        String[] subDirs = configPath.split("\\" + File.separator);
-        for (String d : subDirs) {
-            if (d.contains(FILE_SUFFIX_XML)) {
-                fileName = d;
-            }
-        }
-
-        String configFile = null;
-        if (fileName == null) {
-            //remove the possible trailing "/" of the path
-            if (File.separatorChar == configPath.charAt(configPath.length() - 1)) {
-                configPath = configPath.substring(0, configPath.length() - 1);
-            }
-            mConfigRoot = configPath;
-            fileName = DEFAULT_HOST_CONFIG_FILE_NAME;
-        } else {
-            mConfigRoot = configPath.substring(0, configPath.length() - fileName.length() - 1);
-        }
-        configFile = mConfigRoot + File.separator + fileName;
-
-        Document doc = DocumentBuilderFactory.newInstance()
-                .newDocumentBuilder().parse(new File(configFile));
-
-        String repositoryRoot = getStringAttributeValue(doc
-                .getElementsByTagName("Repository").item(0), "root");
-        if ((null == repositoryRoot) || (repositoryRoot.length() == 0)) {
-            repositoryRoot = mConfigRoot;
-        }
-
-        String caseCfg = getStringAttributeValue(doc, "TestCase", "path", fileName);
-        String planCfg = getStringAttributeValue(doc, "TestPlan", "path", fileName);
-        String resCfg = getStringAttributeValue(doc, "TestResult", "path", fileName);
-        if ((caseCfg == null) || (planCfg == null) || (resCfg == null)) {
-            return false;
-        }
-
-        getConfigValues(doc);
-
-        String caseRoot = repositoryRoot + File.separator + caseCfg;
-        String planRoot = repositoryRoot + File.separator + planCfg;
-        String resRoot = repositoryRoot + File.separator + resCfg;
-
-        String logCfg = getStringAttributeValueOpt(doc, "TestLog", "path", fileName);
-        if (null == logCfg) {
-            mLogRoot = mConfigRoot;
-        } else {
-            mLogRoot = repositoryRoot + File.separator + logCfg;
-        }
-
-        boolean validCase = true;
-        if (!validateDirectory(caseRoot)) {
-            validCase = new File(caseRoot).mkdirs();
-        }
-        boolean validRes = true;
-        if (!validateDirectory(resRoot)) {
-            validRes = new File(resRoot).mkdirs();
-        }
-        if (validRes) {
-            extractResultResources(resRoot);
-        }
-        boolean validPlan = true;
-        if (!validateDirectory(planRoot)) {
-            validPlan = new File(planRoot).mkdirs();
-        }
-        boolean validLog = true;
-        if (!validateDirectory(mLogRoot)) {
-            validLog = new File(mLogRoot).mkdirs();
-        }
-
-        mCaseRepos = new CaseRepository(caseRoot);
-        mResultRepos = new ResultRepository(resRoot);
-        mPlanRepos = new PlanRepository(planRoot);
-
-        return validCase && validRes && validPlan && validLog;
-    }
-
-    /**
-     * Extract the result resources into the specified directory.
-     *
-     * @param resRoot the directory to extract the resources into.
-     */
-    public void extractResultResources(String resRoot) {
-        for (String res: CTS_RESULT_RESOURCES) {
-            extractResource(res, resRoot);
-        }
-    }
-
-    /**
-     * Get the test packages.
-     *
-     * @return The test packages.
-     */
-    public Collection<TestPackage> getTestPackages() {
-        return mTestPackageMap.values();
-    }
-
-    /**
-     * Get the test package by the name of the test package.
-     *
-     * @param packageName The package name.
-     * @return The test package.
-     */
-    public TestPackage getTestPackage(final String packageName) {
-        return mTestPackageMap.get(packageName);
-    }
-
-    /**
-     * Load repositories.
-     */
-    public void loadRepositories(boolean quick) throws NoSuchAlgorithmException {
-        loadTestPackages();
-        if (!quick) {
-            loadTestResults();
-        }
-    }
-
-    /**
-     * Load test results to create session accordingly.
-     */
-    private void loadTestResults() {
-        getResultRepository().loadTestResults();
-    }
-
-    /**
-     * Load all of the test packages.
-     */
-    public void loadTestPackages() throws NoSuchAlgorithmException {
-        if (mTestPackageMap.size() == 0) {
-            mCaseRepos.loadTestPackages();
-        }
-    }
-
-    /**
-     * Remove all of the test packages.
-     */
-    public void removeTestPacakges() {
-        mTestPackageMap.clear();
-    }
-
-    /**
-     * Get the package binary name.
-     *
-     * @param appPackageName The package name.
-     * @return The binary name of the package.
-     */
-    public String getPackageBinaryName(String appPackageName) {
-
-        for (TestPackage pkg : mTestPackageMap.values()) {
-            if (appPackageName.equals(pkg.getAppPackageName())) {
-                return pkg.getAppBinaryName();
-            }
-        }
-
-        return null;
-    }
-
-    /**
-     * Get the root directory of configuration.
-     *
-     * @return The root directory of configuration.
-     */
-    public String getConfigRoot() {
-        return mConfigRoot;
-    }
-
-    /**
-     * Get the root directory of log files.
-     *
-     * @return the root directory of log files.
-     */
-    public String getLogRoot() {
-        return mLogRoot;
-    }
-
-    /**
-     * Get string attribute value.
-     *
-     * @param doc The document.
-     * @param tagName The tag name.
-     * @param attrName The attribute name.
-     * @param fileName The file name.
-     * @return The attribute value.
-     */
-    private String getStringAttributeValue(final Document doc,
-            final String tagName, final String attrName, final String fileName) {
-
-        String cfgStr = null;
-        try {
-            cfgStr = getStringAttributeValue(doc
-                    .getElementsByTagName(tagName).item(0), attrName);
-            if ((null == cfgStr) || (cfgStr.length() == 0)) {
-                Log.e("Configure error (in " + fileName
-                        + "), pls make sure <" + tagName + ">'s attribute <"
-                        + attrName + ">'s value is correctly set.", null);
-                return null;
-            }
-        } catch (Exception e) {
-            Log.e("Configure error (in " + fileName
-                    + "), pls make sure <" + tagName
-                    + ">'s value is correctly set.", null);
-            return null;
-        }
-
-        return cfgStr;
-    }
-
-    /**
-     * Get string attribute value if it exists.
-     *
-     * @param doc The document.
-     * @param tagName The tag name.
-     * @param attrName The attribute name.
-     * @param fileName The file name.
-     * @return The attribute value.
-     */
-    private String getStringAttributeValueOpt(final Document doc,
-            final String tagName, final String attrName, final String fileName) {
-
-        String cfgStr = null;
-        try {
-            cfgStr = getStringAttributeValue(doc
-                    .getElementsByTagName(tagName).item(0), attrName);
-        } catch (Exception e) {
-            return null;
-        }
-
-        return cfgStr;
-    }
-
-    /**
-     * Load configuration values from config file.
-     *
-     * @param doc The document from which to load the values.
-     */
-    private void getConfigValues(final Document doc) {
-        NodeList intValues = doc.getElementsByTagName("IntValue");
-        for (int i = 0; i < intValues.getLength(); i++) {
-            Node n = intValues.item(i);
-            String name = getStringAttributeValue(n, "name");
-            String value = getStringAttributeValue(n, "value");
-            try {
-                Integer v = Integer.parseInt(value);
-                Ints.valueOf(name).setValue(v);
-            } catch (NumberFormatException e) {
-                Log.e("Configuration error. Illegal value for " + name, e);
-            } catch (IllegalArgumentException e) {
-                Log.e("Unknown configuration value " + name, e);
-            }
-        }
-    }
-
-    /**
-     * Validate the directory.
-     *
-     * @param path The path to be validated.
-     * @return If valid directory, return true; else, return false.
-     */
-    private boolean validateDirectory(final String path) {
-
-        File pathFile = new File(path);
-        if ((null == pathFile) || (pathFile.exists() == false)
-                || (pathFile.isDirectory() == false)) {
-            return false;
-        }
-
-        return true;
-    }
-
-    /**
-     * Extract a resource into the given destination directory. This is used
-     * for resource files such as images and CSS.
-     *
-     * @param name The name of the resource.
-     * @param dest The directory the resource should be extracted to.
-     * @return true, if successful, or the file already existed.
-     */
-    private boolean extractResource(String name, String dest) {
-        File file = new File(dest, name);
-        if (!file.exists()) {
-            // do not extract again if the file is already there
-            InputStream in = getClass().getResourceAsStream(File.separator + name);
-            if (in != null) {
-                try {
-                    FileOutputStream fout = new FileOutputStream(file);
-                    byte[] data = new byte[512];
-                    int len = in.read(data);
-                    while (len > 0) {
-                        fout.write(data, 0, len);
-                        len = in.read(data);
-                    }
-                    fout.flush();
-                    fout.close();
-                    in.close();
-                } catch (FileNotFoundException e) {
-                    return false;
-                } catch (IOException e) {
-                    return false;
-                }
-            }
-        }
-        return true;
-    }
-
-    /**
-     * Get the case repository.
-     *
-     * @return The case repository.
-     */
-    public CaseRepository getCaseRepository() {
-        return mCaseRepos;
-    }
-
-    /**
-     * Get the plan repository.
-     *
-     * @return The plan repository.
-     */
-    public PlanRepository getPlanRepository() {
-        return mPlanRepos;
-    }
-
-    /**
-     * Get the result repository.
-     *
-     * @return The result repository.
-     */
-    public ResultRepository getResultRepository() {
-        return mResultRepos;
-    }
-
-    /**
-     * Storing the root information of some repository.
-     *
-     */
-    class Repository {
-        protected String mRoot;
-
-        Repository(String root) {
-            mRoot = root;
-        }
-
-        /**
-         * Get the root of the repository.
-         *
-         * @return The root of the repository.
-         */
-        public String getRoot() {
-            return mRoot;
-        }
-
-        /**
-         * Check if the specified file is a valid XML file.
-         *
-         * @param f The file to be valid.
-         * @return If valid XML file, return true; else, return false.
-         */
-        public boolean isValidXmlFile(File f) {
-            if (f.getPath().endsWith(FILE_SUFFIX_XML)) {
-                return true;
-            }
-
-            return false;
-        }
-    }
-
-    /**
-     * Storing the information of result repository.
-     */
-    class ResultRepository extends Repository {
-
-        ResultRepository(String root) {
-            super(root);
-        }
-
-        /**
-         * Load test results to create session accordingly.
-         */
-        public void loadTestResults() {
-
-            for (File f : new File(mRoot).listFiles()) {
-                if (f.isDirectory()) {
-                    String pathName = mRoot + File.separator + f.getName()
-                                + File.separator + TestSessionLog.CTS_RESULT_FILE_NAME;
-                    if (HostUtils.isFileExist(pathName)) {
-                        try {
-                            TestSessionLog log =
-                                TestSessionLogBuilder.getInstance().build(pathName);
-                            TestSession ts = TestSessionBuilder.getInstance().build(log);
-                            if (ts != null) {
-                                TestHost.getInstance().addSession(ts);
-                            }
-                        } catch (Exception e) {
-                            Log.e("Error importing existing result from " + pathName, e);
-                        }
-                    }
-                }
-            }
-        }
-    }
-
-    /**
-     * Storing the information of case repository.
-     */
-    class CaseRepository extends Repository {
-        CaseRepository(String root) {
-            super(root);
-        }
-
-        /**
-         * Get package names.
-         *
-         * @return The package names.
-         */
-        public ArrayList<String> getPackageNames() {
-            ArrayList<String> packageNames = new ArrayList<String>();
-            for (TestPackage pkg : mTestPackageMap.values()) {
-                String binaryName = pkg.getAppBinaryName();
-                if (binaryName.equals(SIGNATURE_TEST_PACKAGE_NAME)) {
-                    packageNames.add(0, binaryName);
-                } else {
-                    packageNames.add(pkg.getAppPackageName());
-                }
-            }
-
-            return packageNames;
-        }
-
-        /**
-         * Get package binary names.
-         *
-         * @return The package binary names.
-         */
-        public ArrayList<String> getPackageBinaryNames() {
-            ArrayList<String> pkgBinaryNames = new ArrayList<String>();
-            for (TestPackage pkg : mTestPackageMap.values()) {
-                String pkgBinaryName = pkg.getAppBinaryName();
-                if (pkgBinaryName.equals(SIGNATURE_TEST_PACKAGE_NAME)) {
-                    pkgBinaryNames.add(0, pkgBinaryName);
-                } else {
-                    pkgBinaryNames.add(pkg.getAppBinaryName());
-                }
-            }
-
-            return pkgBinaryNames;
-        }
-
-        /**
-         * Load package XML file names.
-         *
-         * @return The package XML file names.
-         */
-        public List<String> loadPackageXmlFileNames() {
-            ArrayList<String> packageXmlFileNames = new ArrayList<String>();
-
-            for (File f : new File(mRoot).listFiles()) {
-                if (isValidXmlFile(f)) {
-                    String fileName = f.getName();
-                    String name = fileName.substring(0, fileName.lastIndexOf("."));
-                    packageXmlFileNames.add(name);
-                }
-            }
-
-            return packageXmlFileNames;
-        }
-
-        /**
-         * Load test packages.
-         */
-        public void loadTestPackages() throws NoSuchAlgorithmException {
-            List<String> pkgXmlFileNameList = loadPackageXmlFileNames();
-            for (String pkgXmlFileName : pkgXmlFileNameList) {
-                String xmlPath = getRoot() + File.separator
-                        + pkgXmlFileName + FILE_SUFFIX_XML;
-                TestPackage pkg = loadPackage(xmlPath);
-                if (isValidPackage(pkg)) {
-                    mTestPackageMap.put(pkg.getAppPackageName(), pkg);
-                }
-            }
-        }
-
-        /**
-         * Get package binary name.
-         *
-         * @param packagePath The package path.
-         * @return The package binary name.
-         */
-        private String getPackageBinaryName(String packagePath) {
-            return packagePath.substring(packagePath.lastIndexOf(File.separator) + 1,
-                    packagePath.lastIndexOf("."));
-        }
-
-        /**
-         * Check if the specified package is a valid package.
-         *
-         * @param pkg The specified package to be checked.
-         * @return If valid package, return true; else, return false.
-         */
-        private boolean isValidPackage(TestPackage pkg) {
-            if (pkg == null) {
-                return false;
-            }
-
-            String pkgFileName = pkg.getAppBinaryName();
-            String apkFilePath = mRoot + File.separator + pkgFileName + FILE_SUFFIX_APK;
-            String xmlFilePath = mRoot + File.separator + pkgFileName + FILE_SUFFIX_XML;
-            File xmlFile = new File(xmlFilePath);
-            if (pkg.isHostSideOnly()) {
-                if (xmlFile.exists() && xmlFile.isFile()) {
-                    return true;
-                }
-            } else {
-                File apkFile = new File(apkFilePath);
-                if (xmlFile.exists() && xmlFile.isFile()
-                        && apkFile.exists() && apkFile.isFile()) {
-                    return true;
-                }
-            }
-
-            return false;
-        }
-
-        /**
-         * Add package to case repository.
-         *
-         * @param packagePath The package to be added.
-         * @return If valid package and succeed in add it, return true; else, return false.
-         */
-        public boolean addPackage(String packagePath) throws FileNotFoundException,
-                IOException, NoSuchAlgorithmException {
-            ZipFile zipFile = new ZipFile(packagePath);
-            Enumeration<? extends ZipEntry> entries = zipFile.entries();
-
-            ArrayList<String> filePathList = new ArrayList<String>();
-            String xmlFilePath = null;
-            while (entries.hasMoreElements()) {
-                ZipEntry entry = entries.nextElement();
-
-                String name = entry.getName();
-                if (name.endsWith(FILE_SUFFIX_APK)
-                        || name.endsWith(FILE_SUFFIX_XML)
-                        || name.endsWith(FILE_SUFFIX_JAR)) {
-                    int index = name.lastIndexOf(File.separator);
-                    String fileName = name;
-                    if (index != -1) {
-                        fileName = name.substring(index + 1);
-                    }
-                    String filePath = mRoot + File.separator + fileName;
-                    writeToFile(zipFile.getInputStream(entry), filePath);
-                    filePathList.add(filePath);
-                    if (name.endsWith(FILE_SUFFIX_XML)) {
-                        xmlFilePath = filePath;
-                    }
-                }
-            }
-
-            String packageName = getPackageBinaryName(packagePath);
-            PackageZipFileValidator zipValidator = new PackageZipFileValidator();
-            if (zipValidator.validate(filePathList, packageName, xmlFilePath) == false) {
-                for (String filePath : filePathList) {
-                    deleteFile(filePath);
-                }
-                return false;
-            }
-
-            TestPackage pkg = loadPackage(xmlFilePath);
-            if (pkg != null) {
-                mTestPackageMap.put(pkg.getAppPackageName(), pkg);
-            }
-
-            return true;
-        }
-
-        /**
-         * Load the package from the package description XML file.
-         *
-         * @param xmlFileName The package description XML file.
-         * @return The TestPackage.
-         */
-        private TestPackage loadPackage(String xmlFileName) throws NoSuchAlgorithmException {
-            if ((xmlFileName == null) || (xmlFileName.length() == 0)) {
-                return null;
-            }
-
-            File xmlFile = new File(xmlFileName);
-            TestSessionBuilder sessionBuilder;
-            TestPackage pkg = null;
-            try {
-                sessionBuilder = TestSessionBuilder.getInstance();
-                pkg = sessionBuilder.loadPackage(xmlFile, null);
-            } catch (ParserConfigurationException e) {
-            } catch (SAXException e) {
-            } catch (IOException e) {
-            }
-            return pkg;
-        }
-
-        /**
-         * check if the packagePath is valid against the case repository
-         *
-         * @param packagePath the path to be checked
-         * @return if the path isn't suffixed with .zip, return false;
-         *         if the package name exists in case repository, return false;
-         *         for other conditions, return true;
-         */
-        public boolean isValidPackageName(String packagePath) {
-            if (!packagePath.endsWith(FILE_SUFFIX_ZIP)) {
-                Log.e("Package error: package name " + packagePath + " is not a zip file.", null);
-                return false;
-            }
-
-            String fileName = packagePath.substring(packagePath.lastIndexOf(File.separator) + 1,
-                       packagePath.length() - FILE_SUFFIX_ZIP.length());
-
-            String path = mRoot + File.separator + fileName;
-            if (HostUtils.isFileExist(path + FILE_SUFFIX_APK)
-                    || HostUtils.isFileExist(path + FILE_SUFFIX_XML)) {
-                Log.e("Package error: package name " + fileName + " exists already.", null);
-                return false;
-            }
-
-            return true;
-        }
-
-        /**
-         * Validate zipped package file against package logic
-         */
-        class PackageZipFileValidator {
-            /**
-             * validate the package content to see if it contains enough data
-             **
-             * @param filePathList The file path list contained in the package zip file.
-             * @param packageName The package name.
-             * @param xmlFilePath The description XML file path.
-             * @return If valid, return true; else, return false.
-             */
-            public boolean validate(ArrayList<String> filePathList, String packageName,
-                    String xmlFilePath) throws NoSuchAlgorithmException {
-                if (xmlFilePath == null) {
-                    Log.e("Package error: package doesn't contain XML file: "
-                            + packageName + FILE_SUFFIX_XML, null);
-                    return false;
-                } else {
-                    TestPackage pkg = loadPackage(xmlFilePath);
-                    if (pkg == null) {
-                        Log.e("Package error: the description XML file contained in : "
-                                + packageName + FILE_SUFFIX_APK + " is invalid.", null);
-                        return false;
-                    } else {
-                        if (!validateTargetApk(filePathList, pkg.getTargetBinaryName())) {
-                            return false;
-                        }
-
-                        if (!validateHostControllerJar(filePathList, pkg.getJarPath())) {
-                            return false;
-                        }
-
-                        String apkFilePath = mRoot + File.separator
-                                + packageName + FILE_SUFFIX_APK;
-                        if (!filePathList.contains(apkFilePath)) {
-                            Log.e("Package error: package doesn't contain APK file: "
-                                            + packageName + FILE_SUFFIX_APK, null);
-                            return false;
-                        }
-                    }
-                }
-
-                return true;
-            }
-
-            /**
-             * Validate host controller jar file described in the package description XML file.
-             *
-             * @param filePathList  The files contained in the zipped package file.
-             * @param hostControllerJarPath The host controller jar file path.
-             * @return If the host controller jar file contained in the zipped package,
-             *         return true; else, return false.
-             */
-            private boolean validateHostControllerJar(ArrayList<String> filePathList,
-                    String hostControllerJarPath) {
-                if ((hostControllerJarPath != null) && (hostControllerJarPath.length() != 0)) {
-                    String targetFilePath =
-                        mRoot + File.separator + hostControllerJarPath + FILE_SUFFIX_JAR;
-                    if (filePathList.contains(targetFilePath)) {
-                        return true;
-                    }
-                } else {
-                    return true;
-                }
-
-                //String jarFileName = getPackageName(hostControllerJarPath);
-                Log.e("Package error: host controler jar file "
-                        + hostControllerJarPath + FILE_SUFFIX_JAR
-                        + " is not contained in the package zip file.", null);
-                return false;
-            }
-
-            /**
-             * Validate target APK file described in the package description XML file.
-             *
-             * @param filePathList The files contained in the zipped package file.
-             * @param targetName The target APK name.
-             * @return If the target APK file contained in the zipped package file, return true;
-             *         else, return false.
-             */
-            private boolean validateTargetApk(ArrayList<String> filePathList, String targetName) {
-                if ((targetName != null) && (targetName.length() != 0)) {
-                    String targetFileName = mRoot + File.separator + targetName + FILE_SUFFIX_APK;
-                    if (filePathList.contains(targetFileName)) {
-                        return true;
-                    }
-                } else {
-                    return true;
-                }
-
-                Log.e("Package error: target file " + targetName + FILE_SUFFIX_APK
-                        + " is not contained in the package zip file.", null);
-                return false;
-            }
-        }
-
-        /**
-         * Write the input stream to file.
-         *
-         * @param in The input stream.
-         * @param path The file to write to.
-         */
-        private void writeToFile(InputStream in, String path) throws IOException {
-            OutputStream out = new BufferedOutputStream(new FileOutputStream(path));
-            byte[] buffer = new byte[1024];
-            int len;
-
-            while ((len = in.read(buffer)) >= 0) {
-                out.write(buffer, 0, len);
-            }
-
-            in.close();
-            out.close();
-        }
-
-        /**
-         * Remove packages from case repository.
-         *
-         * @param packageName Package to be removed.
-         */
-        public void removePackages(String packageName) {
-            if ((packageName == null) || (packageName.length() == 0)) {
-                return;
-            }
-
-            if (packageName.equals(ALL)) {
-                ArrayList<String> packageNames = getCaseRepository().getPackageNames();
-                for (String pkgName : packageNames) {
-                    removePackage(pkgName);
-                }
-            } else {
-                if (!getPackageNames().contains(packageName)) {
-                    Log.e("Package " + packageName + " doesn't exist in repository!", null);
-                    return;
-                }
-                removePackage(packageName);
-            }
-        }
-
-        /**
-         * Remove the specified package.
-         *
-         * @param packageName The package name.
-         */
-        private void removePackage(String packageName) {
-            TestPackage pkg = getTestPackage(packageName);
-            if (pkg != null) {
-                ArrayList<String> targetBinaryNames = getTargetBinaryNames();
-                String targetBinaryName = pkg.getTargetBinaryName();
-                if ((targetBinaryName != null) && (targetBinaryName.length() != 0)
-                        && (getReferenceCount(targetBinaryNames, targetBinaryName) == 1)) {
-                    String targetBinaryFileName = mRoot + File.separator + targetBinaryName
-                            + FILE_SUFFIX_APK;
-                    deleteFile(targetBinaryFileName);
-                }
-
-                ArrayList<String> hostControllers = getHostControllers();
-                String hostControllerPath = pkg.getJarPath();
-                if ((hostControllerPath != null) && (hostControllerPath.length() != 0)
-                        && (getReferenceCount(hostControllers, hostControllerPath) == 1)) {
-                    String jarFilePath = mRoot + File.separator
-                            + hostControllerPath + FILE_SUFFIX_JAR;
-                    deleteFile(jarFilePath);
-                }
-            }
-
-            String packageBinaryName = pkg.getAppBinaryName();
-            mTestPackageMap.remove(pkg.getAppPackageName());
-
-            String apkPath = mRoot + File.separator + packageBinaryName + FILE_SUFFIX_APK;
-            String xmlPath = mRoot + File.separator + packageBinaryName + FILE_SUFFIX_XML;
-            deleteFile(apkPath);
-            deleteFile(xmlPath);
-        }
-
-        /**
-         * Get the reference count of the specific value against the value list.
-         *
-         * @param list The value list to be checked against.
-         * @param value The value to be checked.
-         * @return The reference count.
-         */
-        private int getReferenceCount(ArrayList<String> list, String value) {
-            if ((list == null) || (list.size() == 0) || (value == null)) {
-                return 0;
-            }
-
-            int count = 0;
-            for (String str : list) {
-                if (value.equals(str)) {
-                    count ++;
-                }
-            }
-
-            return count;
-        }
-
-        /**
-         * Get the target binary names contained with the test package description XML files.
-         *
-         * @return The target binary names.
-         */
-        private ArrayList<String> getTargetBinaryNames() {
-            ArrayList<String> targetBinaryNames = new ArrayList<String>();
-            for (TestPackage pkg : mTestPackageMap.values()) {
-                targetBinaryNames.add(pkg.getTargetBinaryName());
-            }
-            return targetBinaryNames;
-        }
-
-        /**
-         * Get the host controllers contained with the test package description XML files.
-         *
-         * @return The host controllers.
-         */
-        private ArrayList<String> getHostControllers() {
-            ArrayList<String> hostControllers = new ArrayList<String>();
-            for (TestPackage pkg : mTestPackageMap.values()) {
-                hostControllers.add(pkg.getJarPath());
-            }
-            return hostControllers;
-        }
-
-        /**
-         * Delete the specific file.
-         *
-         * @param filepath The file to be deleted.
-         */
-        private void deleteFile(String filepath) {
-            File file = new File(filepath);
-            if (file.exists() && file.isFile()) {
-                file.delete();
-            }
-        }
-
-        /**
-         * Get package's APK file path via the package name.
-         *
-         * @param packageName The package name.
-         * @return The package's APK file path.
-         */
-        public String getApkPath(String packageName) {
-            return mRoot + File.separator + packageName + FILE_SUFFIX_APK;
-        }
-
-        /**
-         * Get package's XML file path via the package name.
-         * @param packageName The package name.
-         * @return The package's XML file path.
-         */
-        public String getXmlPath(String packageName) {
-            return mRoot + File.separator + packageName + FILE_SUFFIX_XML;
-        }
-
-        /**
-         * List available package and suite.
-         *
-         * @param expectPackage expected package name
-         * @return list which contains available packages, suites and cases.
-         */
-        @SuppressWarnings("unchecked")
-        public List<ArrayList<String>> listAvailablePackage(String expectPackage) {
-            ArrayList<String> packageList = new ArrayList<String>();
-            ArrayList<String> suiteList = new ArrayList<String>();
-            ArrayList<String> caseList = new ArrayList<String>();
-            ArrayList<String> testList = new ArrayList<String>();
-
-            for (TestPackage testPackage : mTestPackageMap.values()) {
-                String appPackageName = testPackage.getAppPackageName();
-                if (expectPackage.equals(appPackageName)) {
-                    testPackage.getTestSuiteNames(appPackageName, suiteList, caseList);
-                } else if (appPackageName.startsWith(expectPackage)) {
-                    packageList.add(appPackageName);
-                } else {
-                    if (expectPackage.indexOf(Test.METHOD_SEPARATOR) == -1) {
-                        testPackage.getTestCaseNames(expectPackage, caseList, testList);
-                    } else {
-                        testPackage.getTestNames(expectPackage, testList);
-                    }
-                }
-            }
-
-            return Arrays.asList(packageList, suiteList, caseList, testList);
-        }
-    }
-
-    /**
-     * Storing information of test plans.
-     *
-     */
-    class PlanRepository extends Repository {
-
-        PlanRepository(String root) {
-            super(root);
-        }
-
-        /**
-         * Get the path of the specified plan.
-         *
-         * @param name The plan name.
-         * @return The plan path.
-         */
-        public String getPlanPath(String name) {
-            if (mRoot == null) {
-                Log.e("Repository uninitialized!", null);
-                return null;
-            }
-
-            return mRoot + File.separator + name + FILE_SUFFIX_XML;
-        }
-
-        /**
-         * Get all plan names in the plan repository.
-         * @return Plan names.
-         */
-        public ArrayList<String> getAllPlanNames() {
-            ArrayList<String> plans = new ArrayList<String>();
-
-            if (mRoot == null) {
-                Log.e("Not specify repository, please check your cts config",
-                        null);
-                return plans;
-            }
-
-            File planRepository = new File(mRoot);
-            if (!planRepository.exists()) {
-                Log.e("Plan Repository doesn't exist: " + mRoot, null);
-                return null;
-            }
-
-            for (File f : planRepository.listFiles()) {
-                String name = f.getName();
-
-                if (name.endsWith(FILE_SUFFIX_XML)) {
-                    plans.add(name.substring(0, name.length() - FILE_SUFFIX_XML.length()));
-                }
-            }
-
-            return plans;
-        }
-    }
-}
diff --git a/tools/host/src/com/android/cts/HostLock.java b/tools/host/src/com/android/cts/HostLock.java
deleted file mode 100644
index 16750bf..0000000
--- a/tools/host/src/com/android/cts/HostLock.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright (C) 2008 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.cts;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.nio.channels.FileLock;
-
-/**
- * Host lock to make sure just one CTS host is running.
- */
-public class HostLock {
-    private static FileOutputStream mFileOs;
-    private static FileLock mLock;
-    private static File mFile;
-
-    /**
-     * Lock the host.
-     *
-     * @return If succeed in locking the host, return true; else , return false.
-     */
-    public static boolean lock() {
-        try {
-            String tmpdir = System.getProperty("java.io.tmpdir");
-            mFile = new File(tmpdir + File.separator + "ctsLockFile.txt");
-            mFileOs = new FileOutputStream(mFile);
-            mLock = mFileOs.getChannel().tryLock();
-            if (mLock != null) {
-                return true;
-            } else {
-                return false;
-            }
-        } catch (FileNotFoundException e1) {
-            return false;
-        }catch (IOException e1) {
-            return false;
-        }
-    }
-
-    /**
-     * Release the host lock.
-     */
-    public static void release() {
-        try {
-            if (mLock != null) {
-                mLock.release();
-            }
-
-            if (mFileOs != null) {
-                mFileOs.close();
-            }
-            // On systems with permissions, it's possible for this lock file
-            // (depending on the default permissions set) to lock other users 
-            // out from using CTS on the same host.  So remove the file and 
-            // play nice with others.
-            mFile.delete();
-        } catch (IOException e) {
-        }
-    }
-}
diff --git a/tools/host/src/com/android/cts/HostSideOnlyPackage.java b/tools/host/src/com/android/cts/HostSideOnlyPackage.java
deleted file mode 100644
index 7ed31d5..0000000
--- a/tools/host/src/com/android/cts/HostSideOnlyPackage.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright (C) 2009 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.cts;
-
-import java.io.IOException;
-
-/**
- * The host side only package.
- */
-public class HostSideOnlyPackage extends TestPackage {
-
-    /**
-     * Construct a host side only package with given necessary information.
-     *
-     * @param testPkgBinaryName The binary name of the TestPackage.
-     * @param version The version of the CTS Host allowed.
-     * @param androidVersion The version of the Android platform allowed.
-     * @param jarPath The host controller's jar path and file.
-     * @param appPackageName The Java package name of the test package.
-     */
-    public HostSideOnlyPackage(final String testPkgBinaryName, final String version,
-            final String androidVersion, final String jarPath,
-            final String appPackageName) {
-        super(null, testPkgBinaryName, null, null, version,
-                androidVersion, jarPath, null, appPackageName, null);
-    }
-
-    /** {@inheritDoc} */
-    @Override
-    public boolean isHostSideOnly() {
-        return true;
-    }
-
-    /** {@inheritDoc} */
-    @Override
-    protected void runImpl(final String javaPkgName)
-            throws IOException, DeviceDisconnectedException, ADBServerNeedRestartException {
-        try {
-            if (!mTestStop) {
-                Log.d("run in individual mode...");
-                runInIndividualMode(javaPkgName);
-            }
-        } catch (DeviceDisconnectedException e) {
-            cleanUp();
-            throw e;
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override
-    protected void runTestImpl(final Test test) throws DeviceDisconnectedException,
-                ADBServerNeedRestartException {
-        try {
-            if (!mTestStop) {
-                mCurrentTestSuite = test.getTestSuite();
-                mCurrentTestSuite.run(mDevice, test);
-            }
-        } catch (DeviceDisconnectedException e) {
-            cleanUp();
-            throw e;
-        }
-    }
-}
diff --git a/tools/host/src/com/android/cts/HostSideOnlyTest.java b/tools/host/src/com/android/cts/HostSideOnlyTest.java
deleted file mode 100644
index 187fc53..0000000
--- a/tools/host/src/com/android/cts/HostSideOnlyTest.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright (C) 2009 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.cts;
-
-import java.io.IOException;
-
-import junit.framework.TestResult;
-
-/**
- * Host side only test.
- */
-public class HostSideOnlyTest extends Test {
-    private HostSideTestRunner mHostSideTestRunner;
-
-    public HostSideOnlyTest(final TestCase parentCase, final String name,
-            final String type, final String knownFailure, final int resCode) {
-
-        super(parentCase, name, type, knownFailure, resCode);
-        mHostSideTestRunner = null;
-    }
-
-    /**
-     * The Thread to be run host side unit test.
-     */
-    class HostSideTestRunner extends Thread {
-
-        private HostSideOnlyTest mTest;
-
-        public HostSideTestRunner(final HostSideOnlyTest test) {
-            mTest = test;
-        }
-
-        @Override
-        public void run() {
-            HostUnitTestRunner runner = new HostUnitTestRunner(mTest);
-            TestController controller = mTest.getTestController();
-            TestResult testResult = null;
-            try {
-                testResult = runner.runTest(controller.getJarPath(),
-                        controller.getPackageName(), controller.getClassName(),
-                        controller.getMethodName());
-            } catch (IOException e) {
-                Log.e("IOException while running test from " +
-                      controller.getJarPath(), e);
-            } catch (ClassNotFoundException e) {
-                Log.e("The host controller JAR (" + controller.getJarPath() +
-                        ") file doesn't contain class: "
-                        + controller.getPackageName() + "."
-                        + controller.getClassName(), e);
-            }
-
-            synchronized (mTimeOutTimer) {
-                mResult.setResult(testResult);
-
-                if (!mTimeOutTimer.isTimeOut()) {
-                    Log.d("HostSideTestRunnerThread() detects that it needs to "
-                            + "cancel mTimeOutTimer");
-                    mTimeOutTimer.sendNotify();
-                }
-            }
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override
-    protected void runImpl() {
-        mHostSideTestRunner = new HostSideTestRunner(this);
-        mHostSideTestRunner.start();
-    }
-}
diff --git a/tools/host/src/com/android/cts/HostTimer.java b/tools/host/src/com/android/cts/HostTimer.java
deleted file mode 100644
index f2181a9..0000000
--- a/tools/host/src/com/android/cts/HostTimer.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * Copyright (C) 2008 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.cts;
-
-import java.util.Timer;
-import java.util.TimerTask;
-
-/**
- * Host timer.
- * Generally, there are two use cases of this general host timer:
- * <ul>
- *    <li> Use it as general timer to guard host from running for
- *         too long under some situations.
- *    <li> Use it as special timer where host needs to run very
- *         long to communicate with device to fetch result section
- *         by section which requires restarting the timer.
- * </ul>
- */
-public class HostTimer {
-    private final static int INIT = 0;
-    private final static int RUNNING = 1;
-    private final static int CANCELLED = 2;
-    private final static int TIMEOUT = 3;
-
-    private boolean mIsNotified;
-    private int mStatus;
-    private int mDelay;
-    private TimerTask mTimerTask;
-    private Timer mTimer;
-
-    public HostTimer(TimerTask task, int delay) {
-        mDelay = delay;
-        mTimerTask = task;
-        mStatus = INIT;
-        mIsNotified = false;
-        mTimer = null;
-    }
-
-    /**
-     * Mark notified.
-     */
-    public void setNotified() {
-        mIsNotified = true;
-    }
-
-    /**
-     * Get the notification status.
-     *
-     * @return The notification status.
-     */
-    public boolean isNotified() {
-        return mIsNotified;
-    }
-
-    /**
-     * Clear the status of notification.
-     */
-    public void resetNotified() {
-        mIsNotified = false;
-    }
-
-    /**
-     * Wait on.
-     */
-    public void waitOn() throws InterruptedException {
-        Log.d("HostTimer.waitOn(): mIsNotified=" + mIsNotified + ", this=" + this);
-        if (!mIsNotified) {
-            wait();
-        }
-        mIsNotified = false;
-    }
-
-    /**
-     * Set the time to delay.
-     *
-     * @param delay The time to delay.
-     */
-    public void setDelay(int delay) {
-        mDelay = delay;
-    }
-
-    /**
-     * Set the timer task.
-     *
-     * @param task The timer task.
-     */
-    public void setTimerTask(TimerTask task) {
-        mTimerTask = task;
-    }
-
-    /**
-     * Check if the watch dog timer timed out.
-     *
-     * @return If timeout, return true; else return false.
-     */
-    public boolean isTimeOut() {
-        return (mStatus == TIMEOUT);
-    }
-
-    /**
-     * Start the watch dog timer.
-     */
-    public void start() {
-        mTimer = new Timer();
-        mTimer.schedule(mTimerTask, mDelay);
-        mStatus = RUNNING;
-    }
-
-    /**
-     * Restart the watch dog timer.
-     */
-    public void restart(TimerTask task, int delay) {
-        mTimer.cancel();
-        mTimerTask = task;
-        mDelay = delay;
-        start();
-    }
-
-    /**
-     * Send notify to thread waiting on this object.
-     */
-    public void sendNotify() {
-        Log.d("HostTimer.sendNotify(): mIsNotified=" + mIsNotified + ", this=" + this);
-        mIsNotified = true;
-        notify();
-    }
-
-    /**
-     * Cancel the timer. To keep the status info, call this
-     * cancel in stead of the one inherited from parent.
-     *
-     * @param timeout If true, the cancellation is caused by timer timing out;
-     *                If false, the cancellation is no caused by timer timing out.
-     */
-    public void cancel(boolean timeout) {
-        if (mTimer != null) {
-            mTimer.cancel();
-        }
-        if (mStatus == RUNNING) {
-            if (timeout) {
-                mStatus = TIMEOUT;
-            } else {
-                mStatus = CANCELLED;
-            }
-        }
-    }
-}
diff --git a/tools/host/src/com/android/cts/HostUnitTestRunner.java b/tools/host/src/com/android/cts/HostUnitTestRunner.java
deleted file mode 100644
index 747e500..0000000
--- a/tools/host/src/com/android/cts/HostUnitTestRunner.java
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
- * Copyright (C) 2008 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.cts;
-
-import com.android.hosttest.DeviceTest;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.URL;
-import java.net.URLClassLoader;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestResult;
-import junit.runner.BaseTestRunner;
-
-/**
- * Unit test runner running host side unit test.
- *
- */
-public class HostUnitTestRunner extends BaseTestRunner{
-    private static String JAR_SUFFIX = ".jar";
-
-    private TestCase mTestCase;
-    private HostSideOnlyTest mTest;
-
-    public HostUnitTestRunner(HostSideOnlyTest test) {
-        mTestCase = null;
-        mTest = test;
-    }
-
-    /**
-     * Run the specified test.
-     *
-     * @param jarPath The jar file.
-     * @param testPkgName The package name.
-     * @param testClassName The class name.
-     * @param testMethodName The method name.
-     * @return The test result.
-     */
-    public TestResult runTest(final String jarPath, final String testPkgName,
-            String testClassName, String testMethodName)
-            throws ClassNotFoundException, IOException {
-
-        TestResult result = new TestResult();
-        loadTestCase(jarPath, testPkgName, testClassName, testMethodName);
-
-        if (mTestCase != null) {
-            if (mTestCase instanceof DeviceTest) {
-                DeviceTest deviceTest = (DeviceTest) mTestCase;
-                deviceTest.setDevice(mTest.mDevice.getDevice());
-                deviceTest.setTestAppPath(HostConfig.getInstance().getCaseRepository().getRoot());
-            }
-            mTestCase.run(result);
-        }
-        return result;
-    }
-
-    /**
-     * Load test case via test class name and test method.
-     *
-     * @param testClassName The class name.
-     * @param testMethodName The method name.
-     */
-    @SuppressWarnings("unchecked")
-    public TestCase loadTestCase(final String jarPath,
-            final String testPkgName, final String testClassName,
-            final String testMethodName) throws ClassNotFoundException, IOException {
-
-        Log.d("jarPath=" + jarPath + ",testPkgName=" + testPkgName
-                + ",testClassName=" + testClassName);
-
-        Class testClass = null;
-        if ((jarPath != null) && (jarPath.endsWith(JAR_SUFFIX))) {
-            testClass = loadClass(jarPath, testPkgName, testClassName);
-        } else {
-            testClass = Class.forName(testPkgName + "." + testClassName);
-        }
-
-        if ((testMethodName != null) && TestCase.class.isAssignableFrom(testClass)) {
-            mTestCase = buildTestMethod(testClass, testMethodName);
-        }
-
-        return mTestCase;
-    }
-
-    /**
-     * Load class from jar file.
-     *
-     * @param jarPath The jar file.
-     * @param testPkgName The package name.
-     * @param testClassName The class name.
-     * @return The class.
-     */
-    @SuppressWarnings("unchecked")
-    public Class loadClass(final String jarPath,
-            final String testPkgName, final String testClassName)
-            throws ClassNotFoundException, IOException {
-
-        URL urls[] = { new File(jarPath).getCanonicalFile().toURI().toURL() };
-        URLClassLoader cl = new URLClassLoader(urls);
-        Class testClass = cl.loadClass(testPkgName + "." + testClassName);
-        Log.d("succeed in load jarred class: " + jarPath + "." + testPkgName
-                + "." + testClassName);
-
-        return testClass;
-    }
-
-    /**
-     * Build test method.
-     *
-     * @param testClass The test class.
-     * @param testMethodName The method name.
-     * @return The test case.
-     */
-    @SuppressWarnings("unchecked")
-    private TestCase buildTestMethod(Class testClass,
-            String testMethodName) {
-        try {
-            TestCase testCase = (TestCase) testClass.newInstance();
-            testCase.setName(testMethodName);
-            return testCase;
-        } catch (IllegalAccessException e) {
-            runFailed("Could not access test class. Class: "
-                    + testClass.getName());
-        } catch (InstantiationException e) {
-            runFailed("Could not instantiate test class. Class: "
-                    + testClass.getName());
-        }
-
-        return null;
-    }
-
-    /** {@inheritDoc} */
-    @Override
-    public void testStarted(String testName) {
-
-    }
-
-    /** {@inheritDoc} */
-    @Override
-    public void testEnded(String testName) {
-
-    }
-
-    /** {@inheritDoc} */
-    @Override
-    public void testFailed(int status, Test test, Throwable t) {
-    }
-
-    /** {@inheritDoc} */
-    @Override
-    protected void runFailed(String message) {
-        throw new RuntimeException(message);
-    }
-
-}
diff --git a/tools/host/src/com/android/cts/HostUtils.java b/tools/host/src/com/android/cts/HostUtils.java
deleted file mode 100644
index 37222cc..0000000
--- a/tools/host/src/com/android/cts/HostUtils.java
+++ /dev/null
@@ -1,321 +0,0 @@
-/*
- * Copyright (C) 2008 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.cts;
-
-import com.android.ddmlib.RawImage;
-
-import java.awt.image.BufferedImage;
-import java.awt.image.DataBuffer;
-import java.awt.image.DataBufferUShort;
-import java.awt.image.Raster;
-import java.awt.image.SampleModel;
-import java.awt.image.SinglePixelPackedSampleModel;
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.FilenameFilter;
-import java.io.IOException;
-import java.io.InputStream;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.Formatter;
-import java.util.Locale;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipOutputStream;
-
-/**
- * Utilities for CTS host.
- *
- */
-public class HostUtils {
-
-    private static SimpleDateFormat dateFormat = new SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy",
-            Locale.ENGLISH);
-
-    /**
-     * Check if the given file exists
-     *
-     * @param name the file name to be checked
-     * @return if the file exists, return true;
-     *         else, return false
-     */
-    public static boolean isFileExist(final String name) {
-        return new File(name).exists();
-    }
-
-    /**
-     * Convert a 16bpp RawImage into a BufferedImage.
-     *
-     * @param rawImage the image to convert.
-     * @return the BufferedImage.
-     */
-    public static BufferedImage convertRawImageToBufferedImage(RawImage rawImage) {
-        assert rawImage.bpp == 16;
-
-        BufferedImage im = new BufferedImage(rawImage.width,
-                rawImage.height, BufferedImage.TYPE_USHORT_565_RGB);
-        SampleModel sampleModel = new SinglePixelPackedSampleModel(DataBuffer.TYPE_USHORT,
-                rawImage.width,
-                rawImage.height,
-                // RGB565
-                new int[] { 0xf800, 0x07e0, 0x001f });
-
-        // It would be more efficient to just subclass DataBuffer and provide a
-        // TYPE_USHORT interface to the byte array.  But Raster.createRaster at
-        // some point uses instanceof(DataBufferUShort) to verify that the DataBuffer
-        // is of the right type (instead of just checking DataBuffer.getDataType).
-        // And since DataBufferUShort is final, it can't be subclassed to get around
-        // the check either.  So copy the data into a short[] instead to work around the problem.
-        short shortData[] = new short[rawImage.size / 2];
-        for (int x = 0; x < shortData.length; x++) {
-            int rawImageOffset = x * 2;
-            int a = 0xff & rawImage.data[rawImageOffset];
-            int b = 0xff & rawImage.data[rawImageOffset + 1];
-            shortData[x] = (short)((b << 8) | a);
-        }
-        DataBuffer db = new DataBufferUShort(shortData, shortData.length);
-        Raster raster = Raster.createRaster(sampleModel,
-                db, null);
-        im.setData(raster);
-        return im;
-    }
-
-    /**
-     * Interface used with visitAllFilesUnder
-     */
-    public interface FileVisitor {
-        /**
-         * Gets called on every file visited.
-         * @param f the File for the file being visited.
-         */
-        void visitFile(File f);
-    }
-
-    /**
-     * Recursively visit all files under a given path.
-     *
-     * @param root the path to start at.
-     * @param filter the file filter to match.  null means to visit all files.
-     * @param visitor the visitor to visit with.
-     */
-    public static void visitAllFilesUnder(File root, FilenameFilter filter, FileVisitor visitor) {
-        File[] files = root.listFiles(filter);
-        // A null file may indicate not having enough permissions to view that directory
-        if (files != null) {
-            for (File f : files) {
-                visitor.visitFile(f);
-
-                if (f.isDirectory()) {
-                    visitAllFilesUnder(f, filter, visitor);
-                }
-            }
-        }
-    }
-
-    /**
-     * Recursively visit all files under a given path.
-     *
-     * @param path the path to start at.
-     * @param filter the file filter to match.  null means to visit all files.
-     * @param visitor the visitor to visit with.
-     */
-    public static void visitAllFilesUnder(String path, FilenameFilter filter, FileVisitor visitor) {
-        visitAllFilesUnder(new File(path), filter, visitor);
-    }
-
-    // Private class to help zipUpDirectory
-    private static class ZipFileVisitor implements FileVisitor {
-        private final ZipOutputStream zipOutputStream;
-        private boolean ok = true;
-        private IOException caughtException;
-        private final ZipFilenameTransformer transformer;
-
-        public ZipFileVisitor(ZipOutputStream zipOutputStream,
-                ZipFilenameTransformer transformer) {
-            this.zipOutputStream = zipOutputStream;
-            this.transformer = transformer;
-        }
-
-        public void visitFile(File f) {
-            String path = f.getPath();
-            if (transformer != null) {
-                path = transformer.transform(path);
-            }
-            ZipEntry ze = new ZipEntry(path);
-            try {
-                zipOutputStream.putNextEntry(ze);
-                InputStream is = null;
-                try {
-                    is = new BufferedInputStream(new FileInputStream(f));
-                    byte[] buffer = new byte[4096];
-                    int bytesRead = is.read(buffer);
-                    while (bytesRead > 0) {
-                        zipOutputStream.write(buffer, 0, bytesRead);
-                        bytesRead = is.read(buffer);
-                    }
-                    zipOutputStream.closeEntry();
-                } finally {
-                    if (is != null) {
-                        is.close();
-                    }
-                }
-            } catch (IOException e) {
-                ok = false;
-                caughtException = e;
-            }
-        }
-
-        /**
-         * Indicates that the visitor ran without errors
-         * @return true if everything ran OK.
-         */
-        boolean isOk() {
-            return ok;
-        }
-
-        /**
-         * If an IOException was thrown while zipping, it gets kept here.
-         *
-         * @return the IOException that was caught, or null if none was.
-         */
-        IOException getCaughtException() {
-            return caughtException;
-        }
-
-    }
-
-    /**
-     * Indicates some issue with zipping up the file.
-     */
-    static class ZipFileException extends Exception {
-        ZipFileException(IOException ioException) {
-            super("Caught wrapped exception", ioException);
-        }
-    }
-
-    /**
-     * Interface provided to rename files before they get zipped.
-     */
-    public interface ZipFilenameTransformer {
-        /**
-         * Transform a local filesystem filename into a zipfile filename.
-         *
-         * @param filename the input filename
-         * @return the filename to be saved to the zipfile as.
-         */
-        String transform(String filename);
-    }
-
-    /**
-     * Recursively zip up a directory into a zip file.
-     *
-     * @param sourceDir the directory to zip up
-     * @param outputFilePath the zipfile to create.
-     * @param transformer filepath transformer.  can be null.
-     * @throws IOException if there were issues writing the zipfile.
-     */
-    public static void zipUpDirectory(String sourceDir,
-            String outputFilePath,
-            ZipFilenameTransformer transformer)
-    throws IOException, ZipFileException {
-        // I <3 abstractions
-        FileOutputStream fileOut = new FileOutputStream(outputFilePath);
-        BufferedOutputStream bufOut = new BufferedOutputStream(fileOut);
-        final ZipOutputStream zipOutputStream = new ZipOutputStream(bufOut);
-
-        ZipFileVisitor zfv = new ZipFileVisitor(zipOutputStream, transformer);
-        visitAllFilesUnder(sourceDir, null, zfv);
-        zipOutputStream.close();
-        if (!zfv.isOk()) {
-            throw new ZipFileException(zfv.getCaughtException());
-        }
-    }
-
-    /**
-     * Get the formatted time string.
-     *
-     * @param milliSec The time in milliseconds.
-     * @param separator The separator between the date information and time information.
-     * @param dateSeparator The date separator separating the date information nibbles.
-     * @param timeSeparator The time separator separating the time information nibbles.
-     * @return The formated time string.
-     */
-    public static String getFormattedTimeString(long milliSec, String separator,
-            String dateSeparator, String timeSeparator) {
-        Calendar cal = Calendar.getInstance();
-        cal.setTimeInMillis(milliSec);
-        int year  = cal.get(Calendar.YEAR);
-        int month = cal.get(Calendar.MONTH) + 1;
-        int date  = cal.get(Calendar.DATE);
-        int hour  = cal.get(Calendar.HOUR_OF_DAY);
-        int min   = cal.get(Calendar.MINUTE);
-        int sec   = cal.get(Calendar.SECOND);
-
-        Formatter fmt = new Formatter();
-        if ((separator == null) || (separator.length() == 0)) {
-            separator = "_";
-        }
-
-        if ((dateSeparator == null) || (dateSeparator.length() == 0)) {
-            dateSeparator = ".";
-        }
-
-        if ((timeSeparator == null) || (timeSeparator.length() == 0)) {
-            timeSeparator = ".";
-        }
-
-        final String formatStr = "%4d" + dateSeparator + "%02d" + dateSeparator + "%02d"
-                         + separator + "%02d" + timeSeparator + "%02d" + timeSeparator + "%02d";
-        fmt.format(formatStr, year, month, date, hour, min, sec);
-
-        return fmt.toString();
-    }
-
-    /**
-     * Convert the given byte array into a lowercase hex string.
-     *
-     * @param arr The array to convert.
-     * @return The hex encoded string.
-     */
-    public static String toHexString(byte[] arr) {
-        StringBuffer buf = new StringBuffer(arr.length * 2);
-        for (byte b : arr) {
-            buf.append(String.format("%02x", b & 0xFF));
-        }
-        return buf.toString();
-    }
-
-    /**
-     * Strip control characters from the given string.
-     */
-    public static String replaceControlChars(String s) {
-        // Replace any character < 0x20, except for tab, lf and cr
-        return s.replaceAll("[\\x00-\\x1f&&[^\t\n\r]]", "?");
-    }
-
-    public static Date dateFromString(String s) throws ParseException {
-        return dateFormat.parse(s);
-    }
-
-    public static String dateToString(Date d) {
-        return dateFormat.format(d);
-    }
-}
diff --git a/tools/host/src/com/android/cts/IllegalTestNameException.java b/tools/host/src/com/android/cts/IllegalTestNameException.java
deleted file mode 100644
index ac016fd..0000000
--- a/tools/host/src/com/android/cts/IllegalTestNameException.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (C) 2008 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
- *
- *      httprunPackage://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.cts;
-
-/**
- * Exception when user input illegal test name
- */
-public class IllegalTestNameException extends Exception {
-
-    private static final long serialVersionUID = -6128222419050301306L;
-
-    public IllegalTestNameException() {
-        super();
-    }
-
-    public IllegalTestNameException(String message) {
-        super(message);
-    }
-
-}
diff --git a/tools/host/src/com/android/cts/InvalidApkPathException.java b/tools/host/src/com/android/cts/InvalidApkPathException.java
deleted file mode 100644
index b966265..0000000
--- a/tools/host/src/com/android/cts/InvalidApkPathException.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (C) 2009 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.cts;
-
-/**
- * Thrown to indicate that the it's invalid APK path.
- */
-@SuppressWarnings("serial")
-public class InvalidApkPathException extends Exception {
-	private String mPath;
-
-    public InvalidApkPathException(String path) {
-        super();
-
-        mPath = path;
-    }
-
-    /** {@inheritDoc} */
-    @Override
-    public String getMessage() {
-        return "Invalid APK path: " + mPath;
-    }
-}
diff --git a/tools/host/src/com/android/cts/InvalidDeviceException.java b/tools/host/src/com/android/cts/InvalidDeviceException.java
deleted file mode 100644
index da1803c..0000000
--- a/tools/host/src/com/android/cts/InvalidDeviceException.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (C) 2008 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
- *
- *      httprunPackage://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.cts;
-
-/**
- * Exception reporting that the device is invalid.
- *
- */
-public class InvalidDeviceException extends Exception {
-
-    private static final long serialVersionUID = 0L;
-
-    public InvalidDeviceException() {
-        super();
-    }
-
-    public InvalidDeviceException(final String msg) {
-        super(msg);
-    }
-}
diff --git a/tools/host/src/com/android/cts/InvalidNameSpaceException.java b/tools/host/src/com/android/cts/InvalidNameSpaceException.java
deleted file mode 100644
index 03ea2ee..0000000
--- a/tools/host/src/com/android/cts/InvalidNameSpaceException.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (C) 2009 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.cts;
-
-/**
- * Thrown out to indicate that the name space is invalid.
- */
-@SuppressWarnings("serial")
-public class InvalidNameSpaceException extends Exception {
-	private String mNamespace;
-
-    public InvalidNameSpaceException(String namespace) {
-        super();
-
-        mNamespace = namespace;
-    }
-
-    /** {@inheritDoc} */
-    @Override
-    public String getMessage() {
-        return "Invalid namespace: " + mNamespace;
-    }
-}
diff --git a/tools/host/src/com/android/cts/InvalidTestResultStringException.java b/tools/host/src/com/android/cts/InvalidTestResultStringException.java
deleted file mode 100644
index 4ac667f..0000000
--- a/tools/host/src/com/android/cts/InvalidTestResultStringException.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (C) 2009 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.cts;
-
-/**
- * Thrown to indicate that the test result string is not valid.
- */
-public class InvalidTestResultStringException extends Exception {
-    private String mTestResultString;
-
-    public InvalidTestResultStringException(String resultString) {
-        super();
-
-        mTestResultString = resultString;
-    }
-
-    /** {@inheritDoc} */
-    @Override
-    public String getMessage() {
-        return "Invalid test result string: " + mTestResultString;
-    }
-}
diff --git a/tools/host/src/com/android/cts/Log.java b/tools/host/src/com/android/cts/Log.java
deleted file mode 100644
index 4c6e2c8..0000000
--- a/tools/host/src/com/android/cts/Log.java
+++ /dev/null
@@ -1,202 +0,0 @@
-/*
- * Copyright (C) 2008 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.cts;
-
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.PrintStream;
-
-/**
- * Utility class to help the CTS logging
- */
-public class Log {
-    private static final String INFO_PREFIX = "\nCTS_INFO >>> ";
-    private static final String ERROR_PREFIX = "\nCTS_ERROR >>> ";
-    private static final String DEBUG_PREFIX = "\nCTS_DEBUG >>> ";
-    private static final String LOG_FNAME_PREFIX = "log_";
-    private static final String LOG_FNAME_SURFIX = "_.txt";
-
-    private static PrintStream mOut = System.err;
-
-    private static boolean TRACE = true;
-    private static BufferedWriter mTraceOutput = null;
-
-    private static boolean LOG = true;
-    private static BufferedWriter mLogOutput = null;
-    private static String mLogFileName;
-
-    /**
-     * Print the message to the information stream without adding prefix.
-     *
-     * @param msg The message to be printed.
-     */
-    public static void println(final String msg) {
-        log(INFO_PREFIX + msg);
-        mOut.println(msg);
-    }
-
-    /**
-     * Add the message to the information stream.
-     *
-     * @param msg the message to be added to the information stream.
-     */
-    public static void i(final String msg) {
-        log(INFO_PREFIX + msg);
-
-        mOut.println(INFO_PREFIX + msg);
-    }
-
-    /**
-     * Add the message to the error message stream.
-     * @param msg The message to be added to the error message stream.
-     * @param e The exception.
-     */
-    public static void e(final String msg, Exception e) {
-        log(ERROR_PREFIX + msg);
-
-        if (!HostConfig.DEBUG) {
-            CUIOutputStream.println(ERROR_PREFIX + msg);
-            if (e != null) {
-                CUIOutputStream.println(e.toString());
-            }
-            return;
-        }
-
-        mOut.println(ERROR_PREFIX + msg);
-        if (e != null) {
-            e.printStackTrace();
-        }
-    }
-
-    /**
-     * Add the message to the debugging stream.
-     *
-     * @param msg The message to be added to the debugging stream.
-     */
-    public static void d(final String msg) {
-        log(DEBUG_PREFIX + System.currentTimeMillis() + " " + msg);
-
-        if (HostConfig.DEBUG) {
-            mOut.println(DEBUG_PREFIX + msg);
-        }
-    }
-
-    /**
-     * Set the output stream.
-     *
-     * @param out The output stream.
-     */
-    public static void setOutput(PrintStream out) {
-        if (out != null) {
-            mOut = out;
-        }
-    }
-
-    /**
-     * Reset the output stream.
-     */
-    public static void resetOutput() {
-        mOut = System.out;
-    }
-
-    /**
-     * Initialize the log stream.
-     *
-     * @param path The path to add the log file.
-     */
-    public static void initLog(String path) {
-        mLogFileName = path + File.separator + LOG_FNAME_PREFIX
-            + HostUtils.getFormattedTimeString(System.currentTimeMillis(), "_", ".", ".")
-            + LOG_FNAME_SURFIX;
-        try {
-            if (mLogOutput == null) {
-                mLogOutput = new BufferedWriter(new FileWriter(mLogFileName));
-            }
-        } catch (IOException e) {
-            e.printStackTrace();
-        }
-    }
-
-    /**
-     * Close the log stream.
-     */
-    public static void closeLog() {
-        if (mLogOutput != null) {
-            try {
-                mLogOutput.close();
-                mLogOutput = null;
-            } catch (IOException e) {
-                e.printStackTrace();
-            }
-        }
-    }
-
-    /**
-     * Log the message.
-     *
-     * @param msg The message to be logged.
-     */
-    public static void log(String msg) {
-        if (LOG && (mLogOutput != null)) {
-            try {
-                if (msg != null) {
-                    mLogOutput.write(msg + "\n");
-                    mLogOutput.flush();
-                }
-            } catch (IOException e) {
-                e.printStackTrace();
-            }
-        }
-    }
-
-    /**
-     * Add the message to the trace stream.
-     *
-     * @param msg The message to be added to the trace stream.
-     */
-    public static void t(String msg) {
-        if (TRACE) {
-            try {
-                if (mTraceOutput == null) {
-                    mTraceOutput = new BufferedWriter(new FileWriter("debug.txt"));
-                }
-                if (msg != null) {
-                    mTraceOutput.write(msg + "\n");
-                    mTraceOutput.flush();
-                }
-            } catch (IOException e) {
-                e.printStackTrace();
-            }
-        }
-    }
-
-    /**
-     * Close the trace stream.
-     */
-    public static void closeTrace() {
-        if (mTraceOutput != null) {
-            try {
-                mTraceOutput.close();
-                mTraceOutput = null;
-            } catch (IOException e) {
-                e.printStackTrace();
-            }
-        }
-    }
-}
diff --git a/tools/host/src/com/android/cts/MultiplexingLogListener.java b/tools/host/src/com/android/cts/MultiplexingLogListener.java
deleted file mode 100644
index 22ce13c..0000000
--- a/tools/host/src/com/android/cts/MultiplexingLogListener.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (C) 2009 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.cts;
-
-import com.android.ddmlib.log.LogReceiver.ILogListener;
-import com.android.ddmlib.log.LogReceiver.LogEntry;
-
-import java.util.ArrayList;
-
-/**
- * This class allows multiplexing of log listeners onto a single device.
- */
-public class MultiplexingLogListener implements ILogListener {
-    private ArrayList<ILogListener> listeners = new ArrayList<ILogListener>();
-
-    /**
-     * Add a new listener.
-     *
-     * @param listener the listener
-     */
-    public void addListener(ILogListener listener) {
-        listeners.add(listener);
-    }
-
-    /**
-     * Remove an existing listener.
-     *
-     * @param listener the listener to remove.
-     */
-    public void removeListener(ILogListener listener) {
-        listeners.remove(listener);
-    }
-
-
-    /** {@inheritDoc} */
-    public void newData(byte[] data, int offset, int length) {
-        for (ILogListener listener : listeners) {
-            listener.newData(data, offset, length);
-        }
-    }
-
-    /** {@inheritDoc} */
-    public void newEntry(LogEntry entry) {
-        for (ILogListener listener : listeners) {
-            listener.newEntry(entry);
-        }
-    }
-}
diff --git a/tools/host/src/com/android/cts/ProgressObserver.java b/tools/host/src/com/android/cts/ProgressObserver.java
deleted file mode 100644
index d7110fe..0000000
--- a/tools/host/src/com/android/cts/ProgressObserver.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (C) 2008 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.cts;
-
-import java.util.Timer;
-import java.util.TimerTask;
-
-/**
- * Observes test progressing status.
- *
- */
-public class ProgressObserver {
-    private Timer mNotifyTimer;
-
-    /**
-     * Start a process displayer.
-     */
-    public void start() {
-        mNotifyTimer = new Timer();
-        mNotifyTimer.schedule(new ProgressPrinter(),
-                ProgressPrinter.DELAY, ProgressPrinter.TIMEOUT);
-    }
-
-    /**
-     * Stop a process displayer.
-     */
-    public void stop() {
-        if (mNotifyTimer != null) {
-            mNotifyTimer.cancel();
-        }
-        mNotifyTimer = null;
-    }
-
-    /**
-     * Display running notification when a test/package is executing, </br>
-     * especially for the ones running for a very long time.
-     */
-    class ProgressPrinter extends TimerTask {
-        public final static int DELAY = 2000;
-        public final static int TIMEOUT = 2000;
-
-        /** {@inheritDoc} */
-        @Override
-        public void run() {
-            CUIOutputStream.print(".");
-        }
-    }
-}
diff --git a/tools/host/src/com/android/cts/ReferenceAppTestPackage.java b/tools/host/src/com/android/cts/ReferenceAppTestPackage.java
deleted file mode 100644
index 3a14855..0000000
--- a/tools/host/src/com/android/cts/ReferenceAppTestPackage.java
+++ /dev/null
@@ -1,252 +0,0 @@
-/*
- * Copyright (C) 2008 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.cts;
-
-import com.android.ddmlib.AdbCommandRejectedException;
-import com.android.ddmlib.MultiLineReceiver;
-import com.android.ddmlib.RawImage;
-import com.android.ddmlib.TimeoutException;
-import com.android.ddmlib.log.LogReceiver.ILogListener;
-import com.android.ddmlib.log.LogReceiver.LogEntry;
-
-import java.awt.image.BufferedImage;
-import java.io.File;
-import java.io.IOException;
-import java.security.NoSuchAlgorithmException;
-import java.util.ArrayList;
-
-import javax.imageio.ImageIO;
-
-/**
- * TestPackage for Reference Application Testing.
- */
-public class ReferenceAppTestPackage extends TestPackage {
-
-    private static final String ACTION_REFERENCE_APP_TEST = "ReferenceAppTest";
-    private final String apkToTestName;
-    private final String packageUnderTest;
-    private ArrayList<String> testOutputLines = new ArrayList<String>();
-
-    /**
-     * Construct a ReferenceAppTest package with given necessary information.
-     *
-     * @param instrumentationRunner The instrumentation runner.
-     * @param testPkgBinaryName The binary name of the TestPackage.
-     * @param targetNameSpace The package name space of the dependent package, if available.
-     * @param targetBinaryName The binary name of the dependent package, if available.
-     * @param version The version of the CTS Host allowed.
-     * @param androidVersion The version of the Android platform allowed.
-     * @param jarPath The host controller's jar path and file.
-     * @param appNameSpace The package name space used to uninstall the TestPackage.
-     * @param appPackageName The Java package name of the test package.
-     * @param apkToTestName the apk package that contains the ReferenceApp to be tested.
-     * @param packageUnderTest the Java package name of the ReferenceApp to be tested.
-     * @throws NoSuchAlgorithmException
-     */
-    public ReferenceAppTestPackage(String instrumentationRunner,
-            String testPkgBinaryName, String targetNameSpace,
-            String targetBinaryName, String version,
-            String androidVersion, String jarPath,
-            String appNameSpace, String appPackageName,
-            String apkToTestName, String packageUnderTest) throws NoSuchAlgorithmException {
-        super(instrumentationRunner, testPkgBinaryName, targetNameSpace, targetBinaryName, version,
-                androidVersion, jarPath, appNameSpace, appPackageName, null);
-        this.apkToTestName = apkToTestName;
-        this.packageUnderTest = packageUnderTest;
-    }
-
-    /**
-     * Run the package over the device.
-     *
-     * @param device The device to run the package.
-     * @param javaPkgName The java package name.
-     * @param testSessionLog The TestSessionLog for this TestSession.
-     * @throws DeviceDisconnectedException if the device disconnects during the test
-     */
-    @Override
-    public void run(final TestDevice device, final String javaPkgName,
-            TestSessionLog testSessionLog) throws DeviceDisconnectedException,
-            InvalidApkPathException, InvalidNameSpaceException {
-        Test test = getTests().iterator().next();
-        if ((test != null) && (test.getResult().isNotExecuted())) {
-            String appToTestApkPath =
-                HostConfig.getInstance().getCaseRepository().getApkPath(apkToTestName);
-
-            // TODO: This is non-obvious and should be cleaned up
-            device.setRuntimeListener(device);
-
-            // Install the Reference App
-            device.installAPK(appToTestApkPath);
-            device.waitForCommandFinish();
-
-            // Install the Reference App Tests
-            String testApkPath = HostConfig.getInstance().getCaseRepository()
-                    .getApkPath(getAppBinaryName());
-            device.installAPK(testApkPath);
-            device.waitForCommandFinish();
-
-            runTests(device, testSessionLog);
-
-            // Uninstall the Reference App Tests
-            device.uninstallAPK(getAppPackageName());
-            device.waitForCommandFinish();
-
-            // Uninstall the Reference App
-            device.uninstallAPK(packageUnderTest);
-            device.waitForCommandFinish();
-
-            verifyTestResults(test);
-        }
-    }
-
-    private void verifyTestResults(Test test) {
-        // Now go through the results of the test and see if it ran OK
-        boolean testRanOk = false;
-        String numberOfTestsRan = "unknown";
-        for (String line : testOutputLines) {
-            if (line.startsWith("OK")) {
-                testRanOk = true;
-                int startIndex = 4; // OK (5 tests)
-                int endIndex = line.indexOf(' ', 4);
-                numberOfTestsRan = line.substring(4, endIndex);
-                break;
-            }
-        }
-        if (!testRanOk) {
-            test.setResult(new CtsTestResult(CtsTestResult.CODE_FAIL, null, null));
-        } else {
-            test.setResult(new CtsTestResult(CtsTestResult.CODE_PASS,
-                            numberOfTestsRan + " tests passed", null));
-        }
-    }
-
-    private static final String REF_APP_COMMAND_COMPONENT = "ReferenceAppTestCase";
-    private static final String TAKE_SNAPSHOT_CMD = "takeSnapshot";
-
-    /**
-     * Run the tests for this test package.
-     *
-     * @param device the device under test.
-     * @param testSessionLog the TestSessionLog for this test
-     * @throws DeviceDisconnectedException if the device disconnects.
-     */
-    private void runTests(final TestDevice device,
-            final TestSessionLog testSessionLog) throws DeviceDisconnectedException {
-        Log.i("Running reference tests for " + apkToTestName);
-
-        device.addMainLogListener(new ILogListener() {
-            public void newData(byte[] data, int offset, int length) {
-                // use newEntry instead
-            }
-
-            public void newEntry(LogEntry entry) {
-                // skip first bytes, its the log level
-                String component = "";
-                String msg = "";
-                for (int i = 1; i < entry.len; i++) {
-                    if (entry.data[i] == 0) {
-                        component = new String(entry.data, 1, i - 1);
-                        msg = new String(entry.data, i + 1, entry.len - i - 2);
-                        // clean up any trailing newlines
-                        if (msg.endsWith("\n")) {
-                            msg = msg.substring(0, msg.length() - 1);
-                        }
-                        break;
-                    }
-                }
-                if (REF_APP_COMMAND_COMPONENT.equals(component)) {
-                    String[] parts = msg.split(":", 2);
-                    if (parts == null ||
-                        parts.length != 2) {
-                        Log.e("Got reference app command component with invalid cmd: " + msg,
-                                null);
-                        return;
-                    }
-
-                    String cmd = parts[0];
-                    String cmdArgs = parts[1];
-                    if (TAKE_SNAPSHOT_CMD.equals(cmd)) {
-                        takeSnapshot(device, testSessionLog, cmdArgs);
-                    }
-                }
-            }
-
-            private void takeSnapshot(TestDevice device,
-                                      TestSessionLog testSessionLog,
-                                      String cmdArgs) {
-                try {
-                    RawImage rawImage = device.getScreenshot();
-                    if (rawImage != null) {
-                    String outputFilename = testSessionLog.getResultDir() +
-                        File.separator + cmdArgs + ".png";
-                    File output = new File(outputFilename);
-                    BufferedImage im = HostUtils.convertRawImageToBufferedImage(rawImage);
-                    ImageIO.write(im, "png", output);
-                    } else {
-                        Log.e("getScreenshot returned a null image", null);
-                    }
-                } catch (IOException e) {
-                    Log.e("Error taking snapshot! " + cmdArgs, e);
-                } catch (TimeoutException e) {
-                    Log.e("Error taking snapshot! " + cmdArgs, e);
-                } catch (AdbCommandRejectedException e) {
-                    Log.e("Error taking snapshot! " + cmdArgs, e);
-                }
-            }
-        });
-
-        final String commandStr = "am instrument -w -e package "+ getAppPackageName() + " "
-        + getAppPackageName() + "/" + getInstrumentationRunner();
-        Log.d(commandStr);
-
-        device.startActionTimer(ACTION_REFERENCE_APP_TEST);
-        device.executeShellCommand(commandStr, new ReferenceAppResultsObserver(device));
-        device.waitForCommandFinish();
-    }
-
-    /**
-     * Reference app result observer.
-     */
-    class ReferenceAppResultsObserver extends MultiLineReceiver {
-
-        private final TestDevice device;
-
-        public ReferenceAppResultsObserver(TestDevice td) {
-            this.device = td;
-        }
-
-        /** {@inheritDoc} */
-        @Override
-        public void processNewLines(String[] lines) {
-            for (String line : lines) {
-                testOutputLines.add(line);
-            }
-        }
-
-        /** {@inheritDoc} */
-        public boolean isCancelled() {
-            return false;
-        }
-
-        /** {@inheritDoc} */
-        @Override
-        public void done() {
-            device.stopActionTimer();
-            device.notifyExternalTestComplete();
-        }
-    }
-}
diff --git a/tools/host/src/com/android/cts/Selector.java b/tools/host/src/com/android/cts/Selector.java
deleted file mode 100644
index ce80e1d..0000000
--- a/tools/host/src/com/android/cts/Selector.java
+++ /dev/null
@@ -1,359 +0,0 @@
-/*
- * Copyright (C) 2008 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.cts;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-
-/**
- * Interact with user to select from optional items.
- *
- */
-abstract public class Selector {
-    public static final String PACKAGE_SELECTOR = "packageSelector";
-    public static final String SUITE_SELECTOR   = "suiteSelector";
-    public static final String CASE_SELECTOR    = "caseSelector";
-    public static final String TEST_SELECTOR    = "testSelector";
-
-    public static final String PACKAGE_HDR  = "[Choose package] ";
-    public static final String PACKAGE_TAIL =
-        ": select[Y], reject[n], or choose suite in it[m]?  [Y/n/m] ";
-
-    public static final String SUITE_HDR    = "[Choose suite]   ";
-    public static final String SUITE_TAIL   =
-        ": select[Y], reject[n], or choose case in it[m]?  [Y/n/m] ";
-
-    public static final String CASE_HDR  = "[Choose case]    ";
-    public static final String CASE_TAIL =
-        ": select[Y], reject[n], or choose method in it[m]?  [Y/n/m] ";
-
-    public static final String TEST_HDR     = "[Choose test]    ";
-    public static final String TEST_TAIL    = "?: [Y/n] ";
-
-    /**
-     * Define user's possible selections.
-     *
-     */
-    public enum Selection {
-        ACCEPT, REJECT, MORE
-    }
-
-    public List<String> mRecords;
-
-    public String mHdr;
-    public String mTail;
-    public String mType;
-
-    public BufferedReader mBufferedReader;
-
-    public Selector(String type, List<String> records) {
-        mRecords = records;
-        Collections.sort(mRecords);
-        mBufferedReader = null;
-        mType = type;
-
-        if (type.equals(PACKAGE_SELECTOR)) {
-            mHdr  = PACKAGE_HDR;
-            mTail = PACKAGE_TAIL;
-        } else if (type.equals(SUITE_SELECTOR)) {
-            mHdr  = SUITE_HDR;
-            mTail = SUITE_TAIL;
-        } else if (type.equals(CASE_SELECTOR)) {
-            mHdr  = CASE_HDR;
-            mTail = CASE_TAIL;
-        } else if (type.equals(TEST_SELECTOR)) {
-            mHdr  = TEST_HDR;
-            mTail = TEST_TAIL;
-        }
-    }
-
-    /**
-     * Set the input stream of BufferedReader type.
-     *
-     * @param in The input stream.
-     */
-    public void setInputStream(BufferedReader in) {
-        mBufferedReader = in;
-    }
-
-    /**
-     * Read a specific line from the input stream.
-     *
-     * @param prompt The prompt displayed on the console to notify the user.
-     * @return The string the user typed in over the console.
-     */
-    public String readLine(String prompt) throws IOException {
-        String str = null;
-        if (mBufferedReader != null) {
-            CUIOutputStream.print(prompt);
-            str = mBufferedReader.readLine().trim();
-        }
-
-        return str;
-    }
-
-    /**
-     * Interact with the user to decide what are included and what
-     * others are not.
-     *
-     * @param name The specific name.
-     * @return The selection by the user.
-     */
-    public Selection doAccept(final String name) throws IOException {
-        Selection selection = Selection.REJECT;
-
-        if (mType.equals(TEST_SELECTOR)) {
-            String prompt = mHdr + "Include " + name + mTail;
-            String answer = readLine(prompt);
-            while (!answer.matches("[yn]?")) {
-                CUIOutputStream.println(
-                           "Invalid input. Please chose 'y' or 'n' (default is 'y')");
-                answer = readLine(prompt);
-            }
-
-            if (ConsoleUi.isConfirmation(answer, true)) {
-                selection = Selection.ACCEPT;
-            }
-        } else {
-            String prompt = mHdr + name + mTail;
-            String answer = readLine(prompt);
-            while (!answer.matches("[ynm]?")) {
-                CUIOutputStream.println(
-                           "Invalid input. Please chose 'y', 'n', or 'm' (default is 'y')");
-                answer = readLine(prompt);
-            }
-
-            if (ConsoleUi.isConfirmation(answer, true)) {
-                selection = Selection.ACCEPT;
-            } else if (0 == "m".compareToIgnoreCase(answer)) {
-                selection = Selection.MORE;
-            }
-        }
-
-        return selection;
-    }
-
-    /**
-     * Check if the specified name has been selected against the selected list.
-     *
-     * @param selectedList The selected list.
-     * @param name The specified name to be checked.
-     * @return If selected, return true; else, return false.
-     */
-    public boolean isSelected(ArrayList<String> selectedList, String name) {
-        for (String str : selectedList) {
-            if (name.equals(str) || isSubName(str, name)) {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    /**
-     * Check whether a package name is a sub-package name of parent name.
-     *
-     * @param parent The parent package name.
-     * @param name The package name.
-     * @return True if it's a sub-package name of parent.
-     */
-     private boolean isSubName(String parent, String name) {
-        return name.startsWith(parent + ".");
-    }
-}
-
-/**
- * Building the specific plan by following user's selection.
- */
-class PlanBuilder extends Selector{
-    private SuiteSelector mSuiteSelector;
-
-    public PlanBuilder(List<String> records) {
-        super(PACKAGE_SELECTOR, records);
-    }
-
-    /**
-     * Interact with user to select over packages.
-     *
-     * @return The selected result with excluded lists.
-     */
-    public HashMap<String, ArrayList<String>> doSelect() throws IOException {
-        HashMap<String, ArrayList<String>> packages = new HashMap<String, ArrayList<String>>();
-        for (String javaPkgName : mRecords) {
-            Selection select = doAccept(javaPkgName);
-            TestPackage testPackage =
-                HostConfig.getInstance().getTestPackage(javaPkgName);
-            if (select == Selection.ACCEPT) {
-                packages.put(javaPkgName, null);
-            } else if (select == Selection.MORE) {
-                List<String> suiteNames = testPackage.getAllTestSuiteNames();
-                mSuiteSelector = new SuiteSelector(suiteNames, testPackage);
-
-                if (mBufferedReader != null) {
-                    mSuiteSelector.setInputStream(mBufferedReader);
-                }
-
-                ArrayList<String> excludedSuites = new ArrayList<String>();
-                ArrayList<String> excludedCases = new ArrayList<String>();
-                mSuiteSelector.doSelect(excludedSuites, excludedCases);
-                if (suiteNames.size() == excludedSuites.size()) {
-                    Log.i("package=" + javaPkgName + " has been removed all.");
-                } else {
-                    excludedSuites.addAll(excludedCases);
-                    packages.put(javaPkgName, excludedSuites);
-                }
-            }
-        }
-
-        if (packages.size() == 0) {
-            return null;
-        } else {
-            return packages;
-        }
-    }
-
-    /**
-     * Suite selector.
-     *
-     */
-    class SuiteSelector extends Selector {
-        private TestCaseSelector mCaseSelector;
-        private TestPackage mTestPackage;
-
-        public SuiteSelector(List<String> suites, TestPackage testPackage) {
-            super(SUITE_SELECTOR, suites);
-            mTestPackage = testPackage;
-        }
-
-        /**
-         * Interact with user to select over suites.
-         *
-         * @param excludedTestSuites The fully excluded test suite list.
-         * @param excludedTestCases The excluded test case list.
-         */
-        public void doSelect(ArrayList<String> excludedTestSuites,
-                ArrayList<String> excludedTestCases) throws IOException {
-            ArrayList<String> selectedList = new ArrayList<String>();
-            for (String suiteName : mRecords) {
-                if (!isSelected(selectedList, suiteName)) {
-                    Selection select = doAccept(suiteName);
-                    if (select == Selection.REJECT) {
-                        excludedTestSuites.add(suiteName);
-                    } else if (select == Selection.MORE) {
-                        List<String> testCaseNames =
-                            mTestPackage.getAllTestCaseNames(suiteName);
-                        mCaseSelector = new TestCaseSelector(testCaseNames, mTestPackage);
-
-                        if (mBufferedReader != null) {
-                            mCaseSelector.setInputStream(mBufferedReader);
-                        }
-
-                        ArrayList<String> notIncludedTestCases = new ArrayList<String>();
-                        ArrayList<String> notIncludedTests = new ArrayList<String>();
-                        mCaseSelector.doSelect(notIncludedTestCases, notIncludedTests);
-                        if (testCaseNames.size() == notIncludedTestCases.size()) {
-                            Log.i("suite=" + suiteName + " has been removed all");
-                            excludedTestSuites.add(suiteName);
-                        } else {
-                            excludedTestCases.addAll(notIncludedTestCases);
-                            excludedTestCases.addAll(notIncludedTests);
-                        }
-                    }
-                    selectedList.add(suiteName);
-                }
-            }
-        }
-    }
-
-    /**
-     * TestCase selector.
-     */
-    class TestCaseSelector extends Selector {
-        private TestSelector mTestSelector;
-        private TestPackage mTestPackage;
-
-        public TestCaseSelector(List<String> testCases, TestPackage testPackage) {
-            super(CASE_SELECTOR, testCases);
-            mTestPackage = testPackage;
-        }
-
-        /**
-         * Interact with user to select over test cases.
-         *
-         * @param excludedTestCases The fully excluded test case list.
-         * @param excludedTests The excluded test list.
-         */
-        public void doSelect(ArrayList<String> excludedTestCases,
-                ArrayList<String> excludedTests) throws IOException {
-            ArrayList<String> selectedList = new ArrayList<String>();
-            for (String testCaseName : mRecords) {
-                if (!isSelected(selectedList, testCaseName)) {
-                    Selection select = doAccept(testCaseName);
-                    if (select == Selection.REJECT) {
-                        excludedTestCases.add(testCaseName);
-                    } else if (select == Selection.MORE) {
-                        List<String> testNames = mTestPackage.getAllTestNames(testCaseName);
-                        mTestSelector = new TestSelector(testNames);
-
-                        if (mBufferedReader != null) {
-                            mTestSelector.setInputStream(mBufferedReader);
-                        }
-
-                        ArrayList<String> notIncludedTests = mTestSelector.doSelect();
-                        if (notIncludedTests.size() == testNames.size()) {
-                            Log.i("testCase=" + testCaseName + " has been removed all");
-                            excludedTestCases.add(testCaseName);
-                        } else {
-                            excludedTests.addAll(notIncludedTests);
-                        }
-                    }
-                    selectedList.add(testCaseName);
-                }
-            }
-        }
-    }
-
-    /**
-     * Test selector.
-     *
-     */
-    class TestSelector extends Selector {
-        public TestSelector(List<String> records) {
-            super(TEST_SELECTOR, records);
-        }
-
-        /**
-         * Interact with user to select over tests.
-         *
-         * @return The selected result with excluded lists.
-         */
-        public ArrayList<String> doSelect() throws IOException {
-            ArrayList<String> records = new ArrayList<String>();
-            for (String test : mRecords) {
-                Selection select = doAccept(test);
-                if (select == Selection.REJECT) {
-                    records.add(test);
-                }
-            }
-
-            return records;
-        }
-    }
-}
diff --git a/tools/host/src/com/android/cts/SessionObserver.java b/tools/host/src/com/android/cts/SessionObserver.java
deleted file mode 100644
index 788483f..0000000
--- a/tools/host/src/com/android/cts/SessionObserver.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Copyright (C) 2008 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.cts;
-
-public interface SessionObserver {
-    public void notifyFinished(TestSession ts);
-}
diff --git a/tools/host/src/com/android/cts/SignatureCheckPackage.java b/tools/host/src/com/android/cts/SignatureCheckPackage.java
deleted file mode 100644
index 485530e..0000000
--- a/tools/host/src/com/android/cts/SignatureCheckPackage.java
+++ /dev/null
@@ -1,254 +0,0 @@
-/*
- * Copyright (C) 2008 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.cts;
-
-import com.android.ddmlib.MultiLineReceiver;
-
-import java.security.NoSuchAlgorithmException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.regex.Matcher;
-
-/**
- * Class which holds signature check package content.
- */
-public class SignatureCheckPackage extends TestPackage {
-
-    private static final String CHECK_API_APP_PACKAGE_NAME = "android.tests.sigtest";
-    private static final String MISMATCH_CLASS_SIGNATURE = "mismatch_class_signature";
-    private static final String MISSING_INTERFACE = "missing_interface";
-    private static final String MISSING_FIELD = "missing_field";
-    private static final String MISMATCH_INTERFACE_SIGNATURE = "mismatch_interface_signature";
-    private static final String MISMATCH_FIELD_SIGNATURE = "mismatch_field_signature";
-    private static final String MISSING_METHOD = "missing_method";
-    private static final String MISMATCH_METHOD_SIGNATURE = "mismatch_method_signature";
-    private static final String MISSING_CLASS = "missing_class";
-    private static final String CAUGHT_EXCEPTION = "caught_exception";
-    private static final String ACTION_CHECKAPI = "checkapi";
-
-    private ArrayList<String> mAPICheckResult;
-
-    /**
-     * Construct a Signature check package with given necessary information.
-     *
-     * @param instrumentationRunner The instrumentation runner.
-     * @param testPkgBinaryName The binary name of the TestPackage.
-     * @param targetNameSpace The package name space of the dependent package, if available.
-     * @param targetBinaryName The binary name of the dependent package, if available.
-     * @param version The version of the CTS Host allowed.
-     * @param androidVersion The version of the Android platform allowed.
-     * @param jarPath The host controller's jar path and file.
-     * @param appNameSpace The package name space used to uninstall the TestPackage.
-     * @param appPackageName The Java package name of the test package.
-     */
-    public SignatureCheckPackage(final String instrumentationRunner,
-            final String testPkgBinaryName, final String targetNameSpace,
-            final String targetBinaryName, final String version,
-            final String androidVersion, final String jarPath, final String appNameSpace,
-            final String appPackageName) throws NoSuchAlgorithmException {
-        super(instrumentationRunner, testPkgBinaryName, targetNameSpace, targetBinaryName, version,
-                androidVersion, jarPath, appNameSpace, appPackageName, null);
-    }
-
-    /**
-     * Run the package over the device.
-     *
-     * @param device The device to run the package.
-     * @param javaPkgName The java package name.
-     * @param testSesssionLog the TestSessionLog for this TestSession.
-     */
-    @Override
-    public void run(final TestDevice device, final String javaPkgName,
-            TestSessionLog testSesssionLog) throws DeviceDisconnectedException,
-            InvalidNameSpaceException, InvalidApkPathException {
-        Test test = getTests().iterator().next();
-        if ((test != null) && (test.getResult().isNotExecuted())) {
-
-            ArrayList<String> result = startSignatureTest(device);
-            if (result != null) {
-                StringBuffer formattedResult = new StringBuffer();
-                int resultCode = processSignatureResult(result, formattedResult);
-
-                String resultStr = formattedResult.toString();
-                if (resultCode == CtsTestResult.CODE_PASS) {
-                    resultStr = null;
-                }
-
-                test.setResult(new CtsTestResult(resultCode, resultStr, null));
-            }
-        }
-    }
-
-
-    /**
-     * Start signature test.
-     *
-     * @param device the device under test.
-     * @return test result
-     */
-    public ArrayList<String> startSignatureTest(TestDevice device)
-                throws DeviceDisconnectedException, InvalidNameSpaceException,
-                InvalidApkPathException {
-        Log.d("installing APICheck apk");
-        mAPICheckResult = new ArrayList<String>();
-        // TODO: This is non-obvious and should be cleaned up
-        device.setRuntimeListener(device);
-
-        String apkPath =
-            HostConfig.getInstance().getCaseRepository().getApkPath(getAppBinaryName());
-        if (!HostUtils.isFileExist(apkPath)) {
-            Log.e("File doesn't exist: " + apkPath, null);
-            return null;
-        }
-
-        device.installAPK(apkPath);
-        device.waitForCommandFinish();
-
-        runSignatureTestCommand(device);
-        device.waitForCommandFinish();
-
-        device.uninstallAPK(CHECK_API_APP_PACKAGE_NAME);
-        device.waitForCommandFinish();
-
-        device.removeRuntimeListener();
-
-        return mAPICheckResult;
-    }
-
-    /**
-     * Run signature test command.
-     *
-     * @param device the device to run against.
-     */
-    private void runSignatureTestCommand(TestDevice device)
-                throws DeviceDisconnectedException {
-        Log.i("Checking API... ");
-        Log.i("This might take several minutes, please be patient...");
-
-        final String commandStr = "am instrument -w -e bundle true "
-            + getAppPackageName() + "/" + getInstrumentationRunner();
-        Log.d(commandStr);
-
-        device.startActionTimer(ACTION_CHECKAPI,
-                HostConfig.Ints.signatureTestTimeoutMs.value());
-        device.executeShellCommand(commandStr, new SignatureTestResultObserver(device));
-    }
-
-    /**
-     * Signature result observer.
-     */
-    class SignatureTestResultObserver extends MultiLineReceiver {
-
-        private final TestDevice device;
-
-        public SignatureTestResultObserver(TestDevice td) {
-            this.device = td;
-        }
-
-        /** {@inheritDoc} */
-        @Override
-        public void processNewLines(String[] lines) {
-            for (int i = 0; i < lines.length; i++) {
-                mAPICheckResult.add(lines[i]);
-            }
-        }
-
-        /** {@inheritDoc} */
-        public boolean isCancelled() {
-            return false;
-        }
-
-        /** {@inheritDoc} */
-        @Override
-        public void done() {
-            device.stopActionTimer();
-            device.notifyExternalTestComplete();
-        }
-    }
-
-    /**
-     * Process signature result.
-     *
-     * @param apiCheckResult The result of API checking.
-     * @param formattedResult The formated result of API checking.
-     * @return  PASS or FAIL according to the check result.
-     */
-    public int processSignatureResult(ArrayList<String> apiCheckResult,
-                StringBuffer formattedResult) {
-
-        HashMap<String, String> resMap = new HashMap<String, String>();
-        for (String res : apiCheckResult) {
-            Matcher matcher = TestDevice.INSTRUMENT_RESULT_PATTERN.matcher(res);
-            if (matcher.matches()) {
-                resMap.put(matcher.group(1), matcher.group(2));
-            }
-        }
-
-        String result = resMap.get("result");
-        if (result == null) {
-            CUIOutputStream.println("API Check TIMEOUT.");
-            return CtsTestResult.CODE_TIMEOUT;
-        }
-
-        if (result.equals("true")) {
-            CUIOutputStream.println("API Check PASS.");
-            return CtsTestResult.CODE_PASS;
-        }
-
-        CUIOutputStream.println("API Check FAIL!");
-        final String leadingSpace = "      ";
-        for (String key : resMap.keySet()) {
-            if (key.equals("result")) {
-                // ignore the result string
-                continue;
-            }
-
-            String resStr = resMap.get(key);
-            if ((resStr != null) && (resStr.length() > 2)) {
-                formattedResult.append(key +":\n");
-                if (MISMATCH_CLASS_SIGNATURE.equals(key)
-                        || MISMATCH_INTERFACE_SIGNATURE.equals(key)
-                        || MISMATCH_FIELD_SIGNATURE.equals(key)
-                        || MISSING_FIELD.equals(key)
-                        || MISSING_METHOD.equals(key)
-                        || MISMATCH_METHOD_SIGNATURE.equals(key)) {
-                    resStr = resStr.substring(1, resStr.length() - 1);
-                    String[] details = resStr.split("\\), ");
-                    for (String detail : details) {
-                        formattedResult.append(leadingSpace + detail + ")\n");
-                    }
-                    formattedResult.append("\n");
-                } else if (MISSING_INTERFACE.equals(key)
-                        || MISSING_CLASS.equals(key)) {
-                    resStr = resStr.substring(1, resStr.length() - 1);
-                    String[] details = resStr.split(", ");
-                    for (String detail : details) {
-                        formattedResult.append(leadingSpace + detail + "\n");
-                    }
-                    formattedResult.append("\n");
-                } else if (CAUGHT_EXCEPTION.equals(key)) {
-                    resStr = resStr.substring(1, resStr.length() - 1);
-                    formattedResult.append(resStr);
-                    formattedResult.append("\n");
-                }
-            }
-        }
-
-        return CtsTestResult.CODE_FAIL;
-    }
-}
-
diff --git a/tools/host/src/com/android/cts/Test.java b/tools/host/src/com/android/cts/Test.java
deleted file mode 100644
index 2cd119b..0000000
--- a/tools/host/src/com/android/cts/Test.java
+++ /dev/null
@@ -1,428 +0,0 @@
-/*
- * Copyright (C) 2008 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.cts;
-
-import com.android.cts.TestSession.ResultObserver;
-
-import java.util.TimerTask;
-
-/**
- * Correspond to junit's test method, provide functions on storing
- * and executing a test from CTS test harness.
- */
-public class Test implements DeviceObserver {
-    public static final String METHOD_SEPARATOR = "#";
-
-    private TestController mTestController;
-    private TestCase mParentCase;
-    private String mName;
-    private String mType;
-    private String mKnownFailure;
-    private long mStartTime;
-    private long mEndTime;
-
-    protected boolean mTestStop;
-    protected TestDevice mDevice;
-    protected HostTimer mTimeOutTimer;
-    protected ProgressObserver mProgressObserver;
-    protected CtsTestResult mResult;
-
-    public Test(final TestCase parentCase, final String name,
-            final String type, final String knownFailure, final int resCode) {
-        mParentCase = parentCase;
-        mName = name;
-        mType = type;
-        mKnownFailure = knownFailure;
-        mResult = new CtsTestResult(resCode);
-
-        mTestController = null;
-        mProgressObserver = null;
-        mTestStop = false;
-    }
-
-    /**
-     * Check if it's known failure test.
-     *
-     * @return If known failure test, return true; else, return false.
-     */
-    public boolean isKnownFailure() {
-        return (mKnownFailure != null);
-    }
-
-    /**
-     * Get the known failure description.
-     *
-     * @return The known failure description.
-     */
-    public String getKnownFailure() {
-        return mKnownFailure;
-    }
-
-    /**
-     * Set the test controller.
-     *
-     * @param testController The test controller.
-     */
-    public void setTestController(final TestController testController) {
-        mTestController = testController;
-    }
-
-    /**
-     * Get the test controller.
-     *
-     * @return The test controller.
-     */
-    public TestController getTestController() {
-        return mTestController;
-    }
-
-    /**
-     * Get the instrumentation runner.
-     *
-     * @return The instrumentation runner.
-     */
-    public String getInstrumentationRunner() {
-        TestPackage pkg = mParentCase.getParent().getParent();
-        return pkg.getInstrumentationRunner();
-    }
-
-    /**
-     * Get the test name of this test.
-     *
-     * @return The test name of this test.
-     */
-    public String getName() {
-        return mName;
-    }
-
-    /**
-     * Get the test type of this test.
-     *
-     * @return The test type of this test.
-     */
-    public String getType() {
-        return mType;
-    }
-
-    /**
-     * Get the parent TestCase containing the test.
-     *
-     * @return The parent TestCase.
-     */
-    public TestCase getTestCase() {
-        return mParentCase;
-    }
-
-    /**
-     * Get the parent TestSuite containing the test.
-     *
-     * @return The parent TestSuite.
-     */
-    public TestSuite getTestSuite() {
-        return mParentCase.getParent();
-    }
-
-    /**
-     * Get the parent TestPackage containing the test.
-     *
-     * @return The parent TestPackage.
-     */
-    public TestPackage getTestPackage() {
-        return mParentCase.getParent().getParent();
-    }
-
-    /**
-     * Get the app package name space of this test.
-     *
-     * @return The app package name space of this test.
-     */
-    public String getAppNameSpace() {
-        TestPackage pkg = mParentCase.getParent().getParent();
-        return pkg.getAppNameSpace();
-    }
-
-    /**
-     * Get the full name of this test.
-     *
-     * @return The full name of this test.
-     */
-    public String getFullName() {
-        TestSuite suite = mParentCase.getParent();
-        return suite.getFullName() + "." + mParentCase.getName()
-                + METHOD_SEPARATOR + mName;
-    }
-
-    /**
-     * Set test result.
-     *
-     * @param result The result.
-     */
-    public void setResult(CtsTestResult result) {
-        if (isKnownFailure()) {
-            result.reverse();
-        }
-        mResult = result;
-        CUIOutputStream.println("(" + mResult.getResultString() + ")");
-        if (!mResult.isPass()) {
-            String failedMessage = result.getFailedMessage();
-            String stackTrace = result.getStackTrace();
-            if (failedMessage != null) {
-                CUIOutputStream.println(failedMessage);
-            }
-            if (stackTrace != null) {
-                CUIOutputStream.println(stackTrace);
-            }
-        }
-        setEndTime(System.currentTimeMillis());
-
-        ResultObserver.getInstance().notifyUpdate();
-    }
-
-    /**
-     * Add test result.
-     *
-     * @param result The result.
-     */
-    public void addResult(CtsTestResult result) {
-        if (isKnownFailure()) {
-            result.reverse();
-        }
-        mResult = result;
-    }
-
-    /**
-     * Get the result.
-     *
-     * @return the result.
-     */
-    public CtsTestResult getResult() {
-        return mResult;
-    }
-
-    /**
-     * Set start Test time.
-     *
-     * @param time The start time.
-     */
-    public void setStartTime(final long time) {
-        mStartTime = time;
-    }
-
-    /**
-     * Set end Test time.
-     *
-     * @param time The end time.
-     */
-    public void setEndTime(final long time) {
-        mEndTime = time;
-    }
-
-    /**
-     * Get Test start time.
-     *
-     * @return The start time.
-     */
-    public long getStartTime() {
-        return mStartTime;
-    }
-
-    /**
-     * Get Test end time.
-     *
-     * @return The end time.
-     */
-    public long getEndTime() {
-        return mEndTime;
-    }
-
-    /**
-     * Print the message without appending the new line mark.
-     *
-     * @param msg the message to be print.
-     */
-    protected void print(final String msg) {
-        if (!mTestStop) {
-            CUIOutputStream.print(msg);
-        }
-    }
-
-    /**
-     * The timer task which aids in guarding the running test
-     * with the guarding timer. If the executing of the test
-     * is not finished, and the guarding timer is expired,
-     * this task will be executed to force the finish of the
-     * running test.
-     */
-    class TimeOutTask extends TimerTask {
-        private Test mTest;
-
-        public TimeOutTask(final Test testResult) {
-            mTest = testResult;
-        }
-
-        /** {@inheritDoc} */
-        @Override
-        public void run() {
-            mProgressObserver.stop();
-            synchronized (mTimeOutTimer) {
-                mTimeOutTimer.cancel(true);
-                mTimeOutTimer.sendNotify();
-            }
-
-            Log.d("mTimeOutTimer timed out");
-
-            if (!mTestStop) {
-                mTest.setResult(
-                        new CtsTestResult(CtsTestResult.CODE_TIMEOUT, null, null));
-            }
-
-            killDeviceProcess(mTest.getAppNameSpace());
-        }
-    }
-
-    /**
-     * Kill the device process.
-     *
-     * @param packageName The package name.
-     */
-    private void killDeviceProcess(final String packageName) {
-        mDevice.killProcess(packageName);
-    }
-
-    /**
-     * Set test stopped.
-     *
-     * @param testStopped If true, it's stopped. Else, still running.
-     */
-    public void setTestStopped(final boolean testStopped) {
-        mTestStop = testStopped;
-    }
-
-    /**
-     * Run the test over device given.
-     *
-     * @param device the device to run the test.
-     */
-    public void run(final TestDevice device) throws DeviceDisconnectedException,
-            ADBServerNeedRestartException {
-
-        if ((getName() == null) || (getName().length() == 0)) {
-            return;
-        }
-
-        if (TestSession.exceedsMaxCount()) {
-            throw new ADBServerNeedRestartException("Test count reached overflow point");
-        } else {
-            TestSession.incTestCount();
-        }
-
-        mTestStop = false;
-        mDevice = device;
-        mTimeOutTimer = new HostTimer(new TimeOutTask(this),
-                HostConfig.Ints.individualStartTimeoutMs.value());
-        mTimeOutTimer.start();
-        mProgressObserver = new ProgressObserver();
-        mProgressObserver.start();
-
-        setStartTime(System.currentTimeMillis());
-        String testFullName = getFullName();
-        print(testFullName + "...");
-
-        runImpl();
-
-        synchronized (mTimeOutTimer) {
-            if (!mTestStop) {
-                try {
-                    mTimeOutTimer.waitOn();
-                } catch (InterruptedException e) {
-                    Log.d("time out object interrupted");
-                }
-            }
-
-            mProgressObserver.stop();
-            if (mTimeOutTimer.isTimeOut()) {
-                return;
-            } else {
-                //not caused by timer timing out
-                //need to cancel timer
-                mTimeOutTimer.cancel(false);
-            }
-        }
-
-        setResult(mResult);
-    }
-
-    /**
-     * Implementation of running test.
-     */
-    protected void runImpl() throws DeviceDisconnectedException {
-        mDevice.runTest(this);
-    }
-
-    /**
-     * Notify the result.
-     *
-     * @param result The result.
-     */
-    public void notifyResult(CtsTestResult result) {
-
-        Log.d("Test.notifyResult() is called. (Test.getFullName()=" + getFullName());
-        mResult = result;
-        if (mTimeOutTimer != null) {
-            synchronized (mTimeOutTimer) {
-                // set result again in case timeout just happened
-                mResult = result;
-                Log.d("notifyUpdateResult() detects that it needs to cancel mTimeOutTimer");
-                if (mTimeOutTimer != null) {
-                    mTimeOutTimer.sendNotify();
-                }
-            }
-        }
-    }
-
-    /** {@inheritDoc} */
-    public void notifyInstallingComplete(final int resultCode) {
-    }
-
-    /** {@inheritDoc} */
-    public void notifyUninstallingComplete(final int resultCode) {
-    }
-
-    /** {@inheritDoc} */
-    public void notifyInstallingTimeout(final TestDevice testDevice) {
-    }
-
-    /** {@inheritDoc} */
-    public void notifyUninstallingTimeout(final TestDevice testDevice) {
-    }
-
-    /** {@inheritDoc} */
-    public void notifyTestingDeviceDisconnected() {
-        Log.d("Test.notifyTestingDeviceDisconnected() is called");
-        if (mProgressObserver != null) {
-            mProgressObserver.stop();
-        }
-
-        if (mTimeOutTimer != null) {
-            synchronized (mTimeOutTimer) {
-                mTimeOutTimer.cancel(false);
-                mTimeOutTimer.sendNotify();
-            }
-        }
-    }
-}
-
diff --git a/tools/host/src/com/android/cts/TestCase.java b/tools/host/src/com/android/cts/TestCase.java
deleted file mode 100644
index 799dc15..0000000
--- a/tools/host/src/com/android/cts/TestCase.java
+++ /dev/null
@@ -1,253 +0,0 @@
-/*
- * Copyright (C) 2008 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.cts;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-
-/**
- * Correspond to junit's test case, provide functions on
- * storing and executing a test case from CTS test harness.
- */
-public class TestCase implements DeviceObserver {
-    private TestSuite mParentSuite;
-    private Collection<Test> mTests;
-    private String mName;
-    private String mPriority;
-
-    private Test mCurrentTest;
-    private boolean mTestStop;
-
-    public TestCase(final TestSuite suite, final String name, final String priority) {
-        mParentSuite = suite;
-        mName = name;
-        mPriority = priority;
-        mTests = new ArrayList<Test>();
-
-        mTestStop = false;
-        mCurrentTest = null;
-    }
-
-    /**
-     * Get parent suite;
-     *
-     * @return Parent suite.
-     */
-    public TestSuite getParent() {
-        return mParentSuite;
-    }
-
-    /**
-     * Get the case name of this case.
-     *
-     * @return The case name of this test case.
-     */
-    public String getName() {
-        return mName;
-    }
-
-    /**
-     * Get the full name of this test case.
-     *
-     * @return The full name of this test case.
-     */
-    public String getFullName() {
-        TestSuite suite = getParent();
-        return suite.getFullName() + "." + getName();
-    }
-
-    /**
-     * Get the priority of this test case.
-     *
-     * @return The priority of this test case.
-     */
-    public String getPriority() {
-        return mPriority;
-    }
-
-    /**
-     * Add a specific test.
-     *
-     * @param test The test to be added.
-     */
-    public void addTest(Test test) {
-        mTests.add(test);
-    }
-
-    /**
-     * Get the tests under this test case.
-     *
-     * @return The tests under this test case.
-     */
-    public Collection<Test> getTests() {
-        return mTests;
-    }
-
-    /**
-     * Get the excluded list according to the execution status of each test.
-     *
-     * @param resultType The result type to filter the tests.
-     * @return All excluded list.
-     */
-    public ArrayList<String> getExcludedList(final String resultType) {
-        ArrayList<String> excludedList = new ArrayList<String>();
-
-        for (Test test : getTests()) {
-            if (resultType == null) {
-                //all result type except PASS will be excluded
-                if (test.getResult().isPass()) {
-                    excludedList.add(test.getFullName());
-                }
-            } else {
-                //the result type given by resultType will be excluded
-                if (!test.getResult().getResultString().equals(resultType)) {
-                    excludedList.add(test.getFullName());
-                }
-            }
-        }
-
-        if (excludedList.size() == getTests().size()) {
-            //the whole case is excluded, just need to add the full case name
-            excludedList.removeAll(excludedList);
-            excludedList.add(getFullName());
-        }
-        return excludedList;
-    }
-
-    /**
-     * Get all test names contained in the test case.
-     *
-     * @return All test names.
-     */
-    public ArrayList<String> getAllTestNames() {
-        ArrayList<String> testNameList = new ArrayList<String>();
-        for (Test test : getTests()) {
-            testNameList.add(test.getFullName());
-        }
-        return testNameList;
-    }
-
-    /**
-     * Search test in this test case.
-     *
-     * @param testName The test name to be searched against.
-     * @return null if not found, or return founded test
-     */
-    public Test searchTest(final String testName) {
-        String sName = mParentSuite.getFullName();
-        String caseFullName = sName + "." + mName;
-        int index = 0;
-        int testNameStartIndex = testName.lastIndexOf('#') + 1;
-
-        Log.d("searchTest(): testName=" + testName + ",caseFullName=" + caseFullName);
-
-        if (testName.substring(index).startsWith(caseFullName + Test.METHOD_SEPARATOR)) {
-            index += caseFullName.length() + 1;
-        } else {
-            return null;
-        }
-
-        if (index == testNameStartIndex) {
-            String name = testName.substring(testNameStartIndex);
-            for (Test test : mTests) {
-                if (test.getName().equals(name)) {
-                    return test;
-                }
-            }
-        }
-
-        return null;
-    }
-
-    /**
-     * Set test stopped.
-     *
-     * @param testStopped If true, it's stopped. Else, still running.
-     */
-    public void setTestStopped(final boolean testStopped) {
-        mTestStop = testStopped;
-        if (mCurrentTest != null) {
-            mCurrentTest.setTestStopped(mTestStop);
-        }
-    }
-
-    /**
-     * Run the test case over device given.
-     *
-     * @param device The device to run the test case over.
-     */
-    public void run(final TestDevice device) throws DeviceDisconnectedException,
-            ADBServerNeedRestartException {
-        mTestStop = false;
-        Iterator<Test> tests = getTests().iterator();
-        while (tests.hasNext() && (!mTestStop)) {
-            mCurrentTest = tests.next();
-            if (mCurrentTest.getResult().isNotExecuted()) {
-                mCurrentTest.run(device);
-            }
-        }
-    }
-
-    /**
-     * Run the the specific test contained in the test case over device given.
-     *
-     * @param device The device to run the test over.
-     * @param test The specific test to be run.
-     */
-    public void run(final TestDevice device, final Test test)
-            throws DeviceDisconnectedException, ADBServerNeedRestartException {
-        mTestStop = false;
-        mCurrentTest = test;
-        mCurrentTest.run(device);
-    }
-
-    /** {@inheritDoc} */
-    public void notifyInstallingComplete(final int resultCode) {
-        if (mCurrentTest != null) {
-            mCurrentTest.notifyInstallingComplete(resultCode);
-        }
-    }
-
-    /** {@inheritDoc} */
-    public void notifyUninstallingComplete(final int resultCode) {
-        if (mCurrentTest != null) {
-            mCurrentTest.notifyUninstallingComplete(resultCode);
-        }
-    }
-
-    /** {@inheritDoc} */
-    public void notifyInstallingTimeout(final TestDevice testDevice) {
-        if (mCurrentTest != null) {
-            mCurrentTest.notifyInstallingTimeout(testDevice);
-        }
-    }
-
-    /** {@inheritDoc} */
-    public void notifyUninstallingTimeout(final TestDevice testDevice) {
-        if (mCurrentTest != null) {
-            mCurrentTest.notifyUninstallingTimeout(testDevice);
-        }
-    }
-
-    /** {@inheritDoc} */
-    public void notifyTestingDeviceDisconnected() {
-        if (mCurrentTest != null) {
-            mCurrentTest.notifyTestingDeviceDisconnected();
-        }
-    }
-}
diff --git a/tools/host/src/com/android/cts/TestController.java b/tools/host/src/com/android/cts/TestController.java
deleted file mode 100644
index d2943b0..0000000
--- a/tools/host/src/com/android/cts/TestController.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright (C) 2008 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.cts;
-
-/**
- * Store the information of a test controller.
- *
- */
-public class TestController {
-    private String mJarPath;
-    private String mPackageName;
-    private String mClassName;
-    private String mMethodName;
-
-    public TestController(final String jarPath, final String packageName,
-            final String className, final String methodName) {
-        mJarPath = jarPath;
-        mPackageName = packageName;
-        mClassName = className;
-        mMethodName = methodName;
-    }
-
-    /**
-     * Get the jar file path of the controller.
-     *
-     * @return The jar file path of the controller.
-     */
-    public String getJarPath() {
-        return mJarPath;
-    }
-
-    /**
-     * Get the package name.
-     *
-     * @return The package name.
-     */
-    public String getPackageName() {
-        return mPackageName;
-    }
-
-    /**
-     * Get the class name.
-     *
-     * @return The class name.
-     */
-    public String getClassName() {
-        return mClassName;
-    }
-
-    /**
-     * Get the method name.
-     *
-     * @return The method name.
-     */
-    public String getMethodName() {
-        return mMethodName;
-    }
-
-    /**
-     * Get the full name of this test controller.
-     *
-     * @return The case name of this test.
-     */
-    public String getFullName() {
-        return mPackageName + "." + mClassName + Test.METHOD_SEPARATOR + mMethodName;
-    }
-
-    /**
-     * Check if it's a valid test controller.
-     *
-     * @return true if it's valid, else return false.
-     */
-    public boolean isValid() {
-        if ((mJarPath == null) || (mJarPath.length() == 0)
-                || (mPackageName == null) || (mPackageName.length() == 0)
-                || (mClassName == null) || (mClassName.length() == 0)
-                || (mMethodName == null) || (mMethodName.length() == 0)) {
-            return false;
-        } else {
-            return true;
-        }
-    }
-}
diff --git a/tools/host/src/com/android/cts/TestDevice.java b/tools/host/src/com/android/cts/TestDevice.java
deleted file mode 100644
index dcedc02..0000000
--- a/tools/host/src/com/android/cts/TestDevice.java
+++ /dev/null
@@ -1,1937 +0,0 @@
-/*
-* Copyright (C) 2008 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.cts;
-
-import com.android.ddmlib.AdbCommandRejectedException;
-import com.android.ddmlib.Client;
-import com.android.ddmlib.ClientData;
-import com.android.ddmlib.IDevice;
-import com.android.ddmlib.IShellOutputReceiver;
-import com.android.ddmlib.MultiLineReceiver;
-import com.android.ddmlib.NullOutputReceiver;
-import com.android.ddmlib.RawImage;
-import com.android.ddmlib.ShellCommandUnresponsiveException;
-import com.android.ddmlib.SyncException;
-import com.android.ddmlib.SyncService;
-import com.android.ddmlib.TimeoutException;
-import com.android.ddmlib.SyncService.ISyncProgressMonitor;
-import com.android.ddmlib.log.LogReceiver;
-import com.android.ddmlib.log.LogReceiver.ILogListener;
-
-import android.tests.getinfo.DeviceInfoConstants;
-
-import java.io.BufferedReader;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Timer;
-import java.util.TimerTask;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * Manage the testing target device for<br>
- * <ul>
- *    <li> install/uninstall test package, and
- *    <li> execute command on device
- *    <li> get command feedback from standard output
- * </ul>
- */
-public class TestDevice implements DeviceObserver {
-    private static final String DEVICE_SETUP_APK = "TestDeviceSetup";
-    private static final String DEVICE_SETUP_APP_PACKAGE_NAME = "android.tests.devicesetup";
-    private static final String DEFAULT_TEST_RUNNER_NAME =
-                                  "android.test.InstrumentationTestRunner";
-    private static final String ACTION_INSTALL = "install";
-    private static final String ACTION_UNINSTALL = "uninstall";
-    private static final String ACTION_GET_DEV_INFO = "getDeviceInfo";
-    private static final String sInstrumentResultExpr = "INSTRUMENTATION_RESULT: (\\S+)=(.+)";
-
-    public static final int STATUS_IDLE = 0;
-    public static final int STATUS_BUSY = STATUS_IDLE + 1;
-    public static final int STATUS_OFFLINE = STATUS_IDLE + 2;
-    private static final String STATUS_STR_IDLE = "idle";
-    private static final String STATUS_STR_IN_USE = "in use";
-    private static final String STATUS_STR_OFFLINE = "offline";
-
-    /** Interval [ms] for polling a device until boot is completed. */
-    private static final int REBOOT_POLL_INTERVAL = 5000;
-    /** Number of times a booting device should be polled before we give up. */
-    private static final int REBOOT_POLL_COUNT = 10 * 60 * 1000 / REBOOT_POLL_INTERVAL;
-    /** Max time [ms] to wait for <code>adb shell getprop</code> to return a result. */
-    private static final int GETPROP_TIMEOUT = 5000;
-
-    public static final Pattern INSTRUMENT_RESULT_PATTERN;
-
-    private BatchModeResultParser mBatchModeResultParser;
-
-    private DeviceObserver mDeviceObserver;
-    private IDevice mDevice;
-    private DeviceParameterCollector mDeviceInfo;
-
-    private SyncService mSyncService;
-
-    private PackageActionObserver mUninstallObserver;
-
-    private int mStatus;
-    private static HashMap<Integer, String> mStatusMap;
-    private PackageActionTimer mPackageActionTimer;
-
-    private ObjectSync mObjectSync;
-
-    private MultiplexingLogListener logListener = new MultiplexingLogListener();
-    private LogReceiver logReceiver = new LogReceiver(logListener);
-
-    private class LogServiceThread extends Thread {
-        @Override
-        public void run() {
-            try {
-                mDevice.runLogService("main", logReceiver);
-            } catch (IOException e) {
-            } catch (TimeoutException e) {
-            } catch (AdbCommandRejectedException e) {
-            }
-        }
-
-        /**
-         * Cancel logging and exit this thread.
-         */
-        public void cancelLogService() {
-            // this will cause the loop in our run method to
-            // exit, terminating this thread.
-            logReceiver.cancel();
-        }
-    }
-
-    private LogServiceThread logServiceThread;
-
-    static {
-        INSTRUMENT_RESULT_PATTERN = Pattern.compile(sInstrumentResultExpr);
-        mStatusMap = new HashMap<Integer, String>();
-        mStatusMap.put(STATUS_IDLE, STATUS_STR_IDLE);
-        mStatusMap.put(STATUS_BUSY, STATUS_STR_IN_USE);
-        mStatusMap.put(STATUS_OFFLINE, STATUS_STR_OFFLINE);
-    }
-
-    // This constructor just for unit test
-    TestDevice(final String serialNumber) {
-        mDeviceInfo = new DeviceParameterCollector();
-        mDeviceInfo.setSerialNumber(serialNumber);
-    }
-
-    public TestDevice(IDevice device) {
-        mDevice = device;
-        try {
-            mSyncService = mDevice.getSyncService();
-        } catch (IOException e) {
-            // FIXME: handle failed connection.
-        } catch (TimeoutException e) {
-            // FIXME: handle failed connection.
-        } catch (AdbCommandRejectedException e) {
-            // FIXME: handle failed connection.
-        }
-        mBatchModeResultParser = null;
-        mUninstallObserver = new PackageActionObserver(ACTION_UNINSTALL);
-        mStatus = STATUS_IDLE;
-        mDeviceInfo = new DeviceParameterCollector();
-        mPackageActionTimer = new PackageActionTimer();
-        mObjectSync = new ObjectSync();
-    }
-
-    /**
-     * Gets this device's information.
-     *
-     * Assumes that the test device setup apk is already installed.
-     * See {@link #installDeviceSetupApp()}.
-     *
-     * @return information of this device.
-     */
-    public DeviceParameterCollector getDeviceInfo()
-                throws DeviceDisconnectedException, InvalidNameSpaceException,
-                InvalidApkPathException {
-        if (mDeviceInfo.size() == 0) {
-            logServiceThread = new LogServiceThread();
-            logServiceThread.start();
-            genDeviceInfo();
-        }
-        return mDeviceInfo;
-    }
-
-    /**
-     * Attempt to disable the screen guard on device.
-     *
-     * Assumes the test device setup apk is already installed.
-     * See {@link #installDeviceSetupApp()}.
-     *
-     * Note: uninstalling the device setup app {@link #uninstallDeviceSetupApp()} will re-enable
-     * keyguard.
-     *
-     * @throws DeviceDisconnectedException
-     */
-    public void disableKeyguard () throws DeviceDisconnectedException {
-        final String commandStr = "am broadcast -a android.tests.util.disablekeyguard";
-        Log.d(commandStr);
-
-        executeShellCommand(commandStr, new NullOutputReceiver());
-    }
-
-    /**
-     * Return the Device instance associated with this TestDevice.
-     */
-    public IDevice getDevice() {
-        return mDevice;
-    }
-
-    class RestartPropReceiver extends MultiLineReceiver {
-        private boolean mRestarted;
-        private boolean mCancelled;
-        private boolean mDone;
-
-        @Override
-        public void processNewLines(String[] lines) {
-            for (String line : lines) {
-                if (line.trim().equals("1")) {
-                    mRestarted = true;
-                }
-            }
-        }
-        @Override
-        public void done() {
-            synchronized(this) {
-                mDone = true;
-                this.notifyAll();
-            }
-        }
-
-        public boolean isCancelled() {
-            return mCancelled;
-        }
-
-        boolean hasRestarted(long timeout) {
-            try {
-                synchronized (this) {
-                    if (!mDone) {
-                        this.wait(timeout);
-                    }
-                }
-            } catch (InterruptedException e) {
-                // ignore
-            }
-            mCancelled = true;
-            return mRestarted;
-        }
-    }
-
-    /**
-     * Wait until device indicates that boot is complete.
-     *
-     * @return true if the device has completed the boot process, false if it does not, or the
-     * device does not respond.
-     */
-    public boolean waitForBootComplete() throws DeviceDisconnectedException {
-        Log.d("probe device status...");
-
-        mDeviceInfo.set(DeviceParameterCollector.SERIAL_NUMBER, getSerialNumber());
-        mObjectSync = new ObjectSync();
-
-        // reset device observer
-        DeviceObserver tmpDeviceObserver = mDeviceObserver;
-        mDeviceObserver = this;
-
-        int retries = 0;
-        boolean success = false;
-        while (!success && (retries < REBOOT_POLL_COUNT)) {
-            Log.d("Waiting for device to complete boot");
-            RestartPropReceiver rpr = new RestartPropReceiver();
-            this.executeShellCommand("getprop dev.bootcomplete", rpr);
-            success = rpr.hasRestarted(GETPROP_TIMEOUT);
-            if (!success) {
-                try {
-                    Thread.sleep(REBOOT_POLL_INTERVAL);
-                } catch (InterruptedException e) {
-                    // ignore and retry
-                }
-                retries += 1;
-            }
-        }
-        mDeviceObserver = tmpDeviceObserver;
-        if (success) {
-            Log.d("Device boot complete");
-        }
-        return success;
-    }
-
-    /**
-     * Run device information collector command to got the device info.
-     */
-    private void genDeviceInfo() throws DeviceDisconnectedException,
-                InvalidNameSpaceException, InvalidApkPathException {
-        mDeviceInfo.set(DeviceParameterCollector.SERIAL_NUMBER, getSerialNumber());
-        // run shell command to run device information collector
-        Log.d("run device information collector");
-        runDeviceInfoCollectorCommand();
-        waitForCommandFinish();
-    }
-
-    /**
-     * Uninstall the device setup apk from device.
-     *
-     * See {@link #installDeviceSetupApp}
-     *
-     * @throws DeviceDisconnectedException
-     * @throws InvalidNameSpaceException
-     */
-    public void uninstallDeviceSetupApp() throws DeviceDisconnectedException,
-            InvalidNameSpaceException {
-        // reset device observer
-        DeviceObserver tmpDeviceObserver = mDeviceObserver;
-        mDeviceObserver = this;
-        Log.d("uninstall get info ...");
-        uninstallAPK(DEVICE_SETUP_APP_PACKAGE_NAME);
-        waitForCommandFinish();
-        Log.d("uninstall device information collector successfully");
-        mDeviceObserver = tmpDeviceObserver;
-    }
-
-    /**
-     * Install the device setup apk on the device.
-     *
-     * @throws DeviceDisconnectedException
-     * @throws InvalidApkPathException
-     */
-    public void installDeviceSetupApp() throws DeviceDisconnectedException, InvalidApkPathException {
-        String apkPath = HostConfig.getInstance().getCaseRepository().getApkPath(DEVICE_SETUP_APK);
-        if (!HostUtils.isFileExist(apkPath)) {
-            Log.e("File doesn't exist: " + apkPath, null);
-            return;
-        }
-
-        Log.d("installing " + DEVICE_SETUP_APK + " apk");
-        mObjectSync = new ObjectSync();
-
-        // reset device observer
-        DeviceObserver tmpDeviceObserver = mDeviceObserver;
-        mDeviceObserver = this;
-
-        Log.d("install get info ...");
-        installAPK(apkPath);
-        waitForCommandFinish();
-        mDeviceObserver = tmpDeviceObserver;
-    }
-
-    /**
-     * Run command to collect device info.
-     */
-    private void runDeviceInfoCollectorCommand() throws DeviceDisconnectedException {
-        final String commandStr = "am instrument -w -e bundle true "
-            + String.format("%s/android.tests.getinfo.DeviceInfoInstrument",
-                    DEVICE_SETUP_APP_PACKAGE_NAME);
-        Log.d(commandStr);
-
-        mPackageActionTimer.start(ACTION_GET_DEV_INFO, this);
-        executeShellCommand(commandStr, new DeviceInfoReceiver(mDeviceInfo));
-    }
-
-    /**
-     * Receiver which receives and parses the device information.
-     */
-    final class DeviceInfoReceiver extends MultiLineReceiver {
-
-        private ArrayList<String> mResultLines = new ArrayList<String>();
-        private DeviceParameterCollector mDeviceParamCollector;
-
-        public DeviceInfoReceiver(DeviceParameterCollector paramCollector) {
-            super();
-            mDeviceParamCollector = paramCollector;
-            setTrimLine(false);
-        }
-
-        /** {@inheritDoc} */
-        @Override
-        public void processNewLines(String[] lines) {
-            for (String line : lines) {
-                mResultLines.add(line);
-            }
-        }
-
-        /** {@inheritDoc} */
-        public boolean isCancelled() {
-            return false;
-        }
-
-        /** {@inheritDoc} */
-        @Override
-        public void done() {
-            super.done();
-            String key, value;
-            for (String line : mResultLines) {
-                Matcher matcher = INSTRUMENT_RESULT_PATTERN.matcher(line);
-                if (matcher.matches()) {
-                    key = matcher.group(1);
-                    value = matcher.group(2);
-                    mDeviceParamCollector.set(key, value);
-                }
-            }
-
-            synchronized(mObjectSync) {
-                mObjectSync.sendNotify();
-            }
-        }
-
-    }
-
-    /**
-     * Store the build information of a device
-     */
-    public static final class DeviceParameterCollector implements DeviceInfoConstants {
-
-        private HashMap<String, String> mInfoMap;
-
-        public DeviceParameterCollector() {
-            mInfoMap = new HashMap<String, String>();
-        }
-
-        /**
-         * Set the pair of key and value of device information.
-         *
-         * @param key The key of the pair.
-         * @param value The value of the pair.
-         */
-        public void set(final String key, final String value) {
-            mInfoMap.put(key, value);
-        }
-
-        /**
-         * Return the number of device info items which stored in.
-         *
-         * @return the number of device info items which stored in.
-         */
-        public int size() {
-            return mInfoMap.size();
-        }
-
-        /**
-         * Set the build finger print.
-         *
-         * @param buildFingerPrint The build finger print.
-         */
-        public void setBuildFingerPrint(final String buildFingerPrint) {
-            mInfoMap.put(BUILD_FINGERPRINT, buildFingerPrint);
-        }
-
-        /**
-         * Set the build tags.
-         *
-         * @param buildTags The build tags.
-         */
-        public void setBuildTags(final String buildTags) {
-            mInfoMap.put(BUILD_TAGS, buildTags);
-        }
-
-        /**
-         * Set build type.
-         *
-         * @param buildType The build type.
-         */
-        public void setBuildType(final String buildType) {
-            mInfoMap.put(BUILD_TYPE, buildType);
-        }
-
-        /**
-         * Set the build model.
-         *
-         * @param buildModel The build model.
-         */
-        public void setBuildModel(final String buildModel) {
-            mInfoMap.put(BUILD_MODEL, buildModel);
-        }
-
-        /**
-         * Set the build brand.
-         *
-         * @param buildBrand The build brand.
-         */
-        public void setBuildBrand(final String buildBrand) {
-            mInfoMap.put(BUILD_BRAND, buildBrand);
-        }
-
-        /**
-         * Set the build board.
-         *
-         * @param buildBoard The build board.
-         */
-        public void setBuildBoard(final String buildBoard) {
-            mInfoMap.put(BUILD_BOARD, buildBoard);
-        }
-
-        /**
-         * Set the build device.
-         *
-         * @param buildDevice The build device.
-         */
-        public void setBuildDevice(final String buildDevice) {
-            mInfoMap.put(BUILD_DEVICE, buildDevice);
-        }
-
-        /**
-         * Set the build abi
-         *
-         * @param buildAbi The build ABI
-         */
-        public void setBuildAbi(final String buildAbi) {
-            mInfoMap.put(BUILD_ABI, buildAbi);
-        }
-
-        /**
-         * Set the build abi2
-         *
-         * @param buildAbi The build ABI2
-         */
-        public void setBuildAbi2(final String buildAbi2) {
-            mInfoMap.put(BUILD_ABI2, buildAbi2);
-        }
-
-        /**
-         * set the serialNumber of this device
-         *
-         * @param serialNumber The serial number.
-         */
-        public void setSerialNumber(final String serialNumber) {
-            mInfoMap.put(SERIAL_NUMBER, serialNumber);
-        }
-
-        /**
-         * set the build id
-         *
-         * @param bldId The build ID.
-         */
-        public void setBuildId(final String bldId) {
-            mInfoMap.put(BUILD_ID, bldId);
-        }
-
-        /**
-         * set the build version
-         *
-         * @param bldVer The build version.
-         */
-        public void setBuildVersion(final String bldVer) {
-            mInfoMap.put(BUILD_VERSION, bldVer);
-        }
-
-        /**
-         * set the product name
-         **
-         * @param productName The product name.
-         */
-        public void setProductName(final String productName) {
-            mInfoMap.put(PRODUCT_NAME, productName);
-        }
-
-        /**
-         * Get the build finger print.
-         *
-         * @return The build finger print.
-         */
-        public String getBuildFingerPrint() {
-            return mInfoMap.get(BUILD_FINGERPRINT);
-        }
-
-        /**
-         * Get the build tags.
-         *
-         * @return The build tags.
-         */
-        public String getBuildTags() {
-            return mInfoMap.get(BUILD_TAGS);
-        }
-
-        /**
-         * Get build type.
-         *
-         * @return The build type.
-         */
-        public String getBuildType() {
-            return mInfoMap.get(BUILD_TYPE);
-        }
-
-        /**
-         * Get the build model.
-         *
-         * @return The build model.
-         */
-        public String getBuildModel() {
-            return mInfoMap.get(BUILD_MODEL);
-        }
-
-        /**
-         * Get the build manufacturer.
-         *
-         * @return The build manufacturer.
-         */
-        public String getBuildManufacturer() {
-            return mInfoMap.get(BUILD_MANUFACTURER);
-        }
-
-        /**
-         * Get the build brand.
-         *
-         * @return The build brand.
-         */
-        public String getBuildBrand() {
-            return mInfoMap.get(BUILD_BRAND);
-        }
-
-        /**
-         * Get the build board.
-         *
-         * @return The build board.
-         */
-        public String getBuildBoard() {
-            return mInfoMap.get(BUILD_BOARD);
-        }
-
-        /**
-         * Get the build device.
-         *
-         * @return The build device.
-         */
-        public String getBuildDevice() {
-            return mInfoMap.get(BUILD_DEVICE);
-        }
-
-        /**
-         * Get the build ABI.
-         *
-         * @return The build ABI.
-         */
-        public String getBuildAbi() {
-            return mInfoMap.get(BUILD_ABI);
-        }
-
-        /**
-         * Get the build ABI2.
-         *
-         * @return The build ABI2.
-         */
-        public String getBuildAbi2() {
-            return mInfoMap.get(BUILD_ABI2);
-        }
-
-        /**
-         * get the build id
-         **
-         * @return The build ID.
-         */
-        public String getBuildId() {
-            return mInfoMap.get(BUILD_ID);
-        }
-
-        /**
-         * get the build version
-         **
-         * @return The build version.
-         */
-        public String getBuildVersion() {
-            return mInfoMap.get(BUILD_VERSION);
-        }
-
-        /**
-         * get the product name
-         *
-         * @return The product name.
-         */
-        public String getProductName() {
-            return mInfoMap.get(PRODUCT_NAME);
-        }
-
-        /**
-         * get the serial number
-         *
-         * @return The serial number.
-         */
-        public String getSerialNumber() {
-            return mInfoMap.get(SERIAL_NUMBER);
-        }
-
-        public String getScreenSize() {
-            return mInfoMap.get(SCREEN_SIZE);
-        }
-
-        /**
-         * Return screen resolution(width x height)
-         *
-         * @return The screen resolution.
-         */
-        public String getScreenResolution() {
-            return mInfoMap.get(RESOLUTION);
-        }
-
-        /**
-         * Return logical screen density
-         *
-         * @return The logical screen density.
-         */
-        public String getScreenDensity() {
-            return mInfoMap.get(SCREEN_DENSITY);
-        }
-
-        /**
-         * Return the probable screen density bucket
-         *
-         * @return The probable screen density bucket.
-         */
-        public String getScreenDensityBucket() {
-            return mInfoMap.get(SCREEN_DENSITY_BUCKET);
-        }
-
-        /**
-         * Get Android platform version.
-         *
-         * @return The Android platform version.
-         */
-        public String getAndroidPlatformVersion() {
-            return mInfoMap.get(VERSION_SDK);
-        }
-
-        /**
-         * Get supported locales.
-         *
-         * @return The supported locales.
-         */
-        public String getLocales() {
-            return mInfoMap.get(LOCALES);
-        }
-
-        /**
-         * Get x dip
-         *
-         * @return The X dip.
-         */
-        public String getXdpi() {
-            return mInfoMap.get(SCREEN_X_DENSITY);
-        }
-
-        /**
-         * Get y dip
-         *
-         * @return The y dip.
-         */
-        public String getYdpi() {
-            return mInfoMap.get(SCREEN_Y_DENSITY);
-        }
-
-        /**
-         * Get touch information
-         *
-         * @return The touch screen information.
-         */
-        public String getTouchInfo() {
-            return mInfoMap.get(TOUCH_SCREEN);
-        }
-
-        /**
-         * Get navigation information
-         *
-         * @return The navigation information.
-         */
-        public String getNavigation() {
-            return mInfoMap.get(NAVIGATION);
-        }
-
-        /**
-         * Get keypad information
-         *
-         * @return The keypad information.
-         */
-        public String getKeypad() {
-            return mInfoMap.get(KEYPAD);
-        }
-
-        /**
-         * Get network information
-         *
-         * @return The network information.
-         */
-        public String getNetwork() {
-            return mInfoMap.get(NETWORK);
-        }
-
-        /**
-         * Get IMEI
-         *
-         * @return IMEI.
-         */
-        public String getIMEI() {
-            return mInfoMap.get(IMEI);
-        }
-
-        /**
-         * Get IMSI
-         *
-         * @return IMSI.
-         */
-        public String getIMSI() {
-            return mInfoMap.get(IMSI);
-        }
-
-        /**
-         * Get phone number
-         *
-         * @return Phone number.
-         */
-        public String getPhoneNumber() {
-            return mInfoMap.get(PHONE_NUMBER);
-        }
-
-        /**
-         * Get features.
-         *
-         * @return Features.
-         */
-        public String getFeatures() {
-            return mInfoMap.get(FEATURES);
-        }
-
-        /**
-         * Get processes.
-         *
-         * @return Processes.
-         */
-        public String getProcesses() {
-            return mInfoMap.get(PROCESSES);
-        }
-
-        /**
-         * Get Open GL ES version.
-         *
-         * @return version or error message.
-         */
-        public String getOpenGlEsVersion() {
-            return mInfoMap.get(OPEN_GL_ES_VERSION);
-        }
-
-        /**
-         * Get partitions.
-         *
-         * @return partitions or error message.
-         */
-        public String getPartitions() {
-            return mInfoMap.get(PARTITIONS);
-        }
-    }
-
-    /**
-     * Get the serial number of the  {@link TestDevice}.
-     *
-     * @return the serial number of the {@link TestDevice}
-     */
-    public String getSerialNumber() {
-        if (mDevice == null) {
-            return mDeviceInfo.getSerialNumber();
-        }
-        return mDevice.getSerialNumber();
-    }
-
-    /**
-     * Run a specified test.
-     *
-     * @param test The test to be run.
-     */
-    public void runTest(Test test) throws DeviceDisconnectedException {
-
-        final String appNameSpace = test.getAppNameSpace();
-        String runner = test.getInstrumentationRunner();
-        if (runner == null) {
-            runner = DEFAULT_TEST_RUNNER_NAME;
-        }
-
-        // need to doubly escape any '$' chars in the name since this string is
-        // passed through two shells \\\$ -> \$ -> $
-        final String testName = test.getFullName().replaceAll("\\$", "\\\\\\$");
-
-        final String commandStr = "am instrument -w -r -e class " + testName
-                + " " + appNameSpace + "/" + runner;
-        Log.d(commandStr);
-        executeShellCommand(commandStr, new IndividualModeResultParser(test));
-    }
-
-    /**
-     * Run a test package in batch mode.
-     *
-     * @param testPackage The testPackage to be run.
-     * @param javaPkgName The java package name. If null, run the whole test package;
-     *              else, run the specified java package contained in the test package
-     */
-    public void runInBatchMode(TestPackage testPackage, final String javaPkgName)
-                throws DeviceDisconnectedException {
-        String appNameSpace = testPackage.getAppNameSpace();
-        String runner = testPackage.getInstrumentationRunner();
-        if (runner == null) {
-            runner = DEFAULT_TEST_RUNNER_NAME;
-        }
-
-        String name = testPackage.getAppPackageName();
-        if ((javaPkgName != null) && !javaPkgName.isEmpty()) {
-            name = javaPkgName;
-        }
-
-        String cmdHeader = "am instrument -w -r -e package " + name + " ";
-        final String commandStr = cmdHeader + appNameSpace + "/" + runner;
-        Log.d(commandStr);
-
-        mBatchModeResultParser = new BatchModeResultParser(testPackage);
-        executeShellCommand(commandStr, mBatchModeResultParser);
-    }
-
-    /**
-     * Run a in batch mode of a TestPackage.
-     *
-     * @param testPackage The testPackage to be run.
-     * @param javaClassName The java class name.
-     */
-    public void runTestCaseInBatchMode(TestPackage testPackage, final String javaClassName,
-            String profile) throws DeviceDisconnectedException {
-        if (javaClassName == null) {
-            return;
-        }
-
-        String appNameSpace = testPackage.getAppNameSpace();
-        String runner = testPackage.getInstrumentationRunner();
-        if (runner == null) {
-            runner = DEFAULT_TEST_RUNNER_NAME;
-        }
-
-        String cmdHeader = "am instrument -w -r -e class " + javaClassName
-                + " -e profile " + profile + " ";
-        final String commandStr = cmdHeader + appNameSpace + "/" + runner;
-        Log.d(commandStr);
-
-        mBatchModeResultParser = new BatchModeResultParser(testPackage);
-        executeShellCommand(commandStr, mBatchModeResultParser);
-    }
-
-    /**
-     * Get clients.
-     *
-     * @return The clients.
-     */
-    public Client[] getClients() {
-        return mDevice.getClients();
-    }
-
-    /**
-     * Push a file to a given path.
-     *
-     * @param localPath The local path.
-     * @param remotePath The remote path.
-     */
-    public void pushFile(String localPath, String remotePath) {
-        try {
-            mSyncService.pushFile(localPath, remotePath, new PushMonitor());
-        } catch (TimeoutException e) {
-            Log.e("Uploading file failed: timeout", null);
-        } catch (SyncException e) {
-            Log.e("Uploading file failed: " + e.getMessage(), null);
-        } catch (FileNotFoundException e) {
-            Log.e("Uploading file failed: " + e.getMessage(), null);
-        } catch (IOException e) {
-            Log.e("Uploading file failed: " + e.getMessage(), null);
-        }
-    }
-
-    /**
-     * Install a specified APK using adb command install.
-     *
-     * @param apkPath Name of the package to be installed.
-     */
-    public void installAPK(final String apkPath) throws DeviceDisconnectedException,
-                InvalidApkPathException {
-        if ((apkPath == null) || (apkPath.length() == 0) || (!HostUtils.isFileExist(apkPath))) {
-            throw new InvalidApkPathException(apkPath);
-        }
-
-        // Use re-install directly
-        final String cmd = DeviceManager.getAdbLocation() + " -s "
-                + getSerialNumber() + " install -r " + apkPath;
-        Log.d(cmd);
-
-        mPackageActionTimer.start(ACTION_INSTALL, this);
-        executeCommand(cmd, new PackageActionObserver(ACTION_INSTALL));
-    }
-
-    /**
-     * Execute the given command.
-     *
-     * @param command The command to be executed.
-     * @param stdOutReceiver The receiver for handling the output from the device.
-     */
-    private void executeCommand(String command, StdOutObserver stdOutReceiver)
-                    throws DeviceDisconnectedException {
-        if (mStatus != STATUS_OFFLINE) {
-            try {
-                Process proc = Runtime.getRuntime().exec(command);
-
-                if (stdOutReceiver != null) {
-                    stdOutReceiver.setInputStream(proc.getInputStream());
-                }
-            } catch (IOException e) {
-                e.printStackTrace();
-            }
-        } else {
-            throw new DeviceDisconnectedException(getSerialNumber());
-        }
-    }
-
-    /**
-     * Standard output observer.
-     *
-     */
-    interface StdOutObserver {
-        /**
-         * set the input Stream.
-         */
-        public void setInputStream(InputStream is);
-
-        /**
-         * Process lines.
-         */
-        public void processLines() throws IOException;
-    }
-
-    /**
-     * Un-install APK.
-     *
-     * @param packageName The package to be un-installed.
-     */
-    public void uninstallAPK(String packageName) throws DeviceDisconnectedException,
-                InvalidNameSpaceException {
-        if ((packageName == null) || (packageName.length() == 0)) {
-            throw new InvalidNameSpaceException(packageName);
-        }
-
-        uninstallAPKImpl(packageName, mUninstallObserver);
-    }
-
-    /**
-     * The implementation of uninstalling APK.
-     *
-     * @param packageName The package to be uninstalled.
-     * @param observer The uninstall observer
-     */
-    private void uninstallAPKImpl(final String packageName, final PackageActionObserver observer)
-                throws DeviceDisconnectedException {
-        final String cmdStr = DeviceManager.getAdbLocation() + " -s "
-                      + getSerialNumber() + " uninstall " + packageName;
-        Log.d(cmdStr);
-        mPackageActionTimer.start(ACTION_UNINSTALL, this);
-        executeCommand(cmdStr, observer);
-    }
-
-    /**
-     * Package action(install/uninstall) timeout task
-     */
-    class PackageActionTimeoutTask extends TimerTask {
-
-        private String mAction;
-        private TestDevice mTargetDevice;
-
-        /**
-         * Task of package action timeout.
-         *
-         * @param action string of action
-         * @param testDevice the {@TestDevice} which got the timeout.
-         */
-        public PackageActionTimeoutTask(final String action,
-                TestDevice testDevice) {
-            mAction = action;
-            mTargetDevice = testDevice;
-        }
-
-        /** {@inheritDoc}*/
-        @Override
-        public void run() {
-            Log.d("PackageActionTimeoutTask.run(): mAction=" + mAction);
-            synchronized (mObjectSync) {
-                mObjectSync.sendNotify();
-            }
-
-            if (mAction.toLowerCase().equals(ACTION_INSTALL)) {
-                mDeviceObserver.notifyInstallingTimeout(mTargetDevice);
-            } else if (mAction.toLowerCase().equals(ACTION_UNINSTALL)) {
-                mDeviceObserver.notifyUninstallingTimeout(mTargetDevice);
-            } else if (mAction.toLowerCase().equals(ACTION_GET_DEV_INFO)) {
-                Log.e("Get device information timeout", null);
-            } else {
-                Log.e("Timeout: " + mAction, null);
-            }
-        }
-    }
-
-    /**
-     * Package action timer monitors the package action.
-     *
-     */
-    class PackageActionTimer {
-        private Timer mTimer;
-
-        /**
-         * Start the timer while package install/uninstall/getDeviceInfo/checkAPI.
-         *
-         * @param action The action of package.
-         * @param device The TestDevice the action is taken over.
-         */
-        private void start(final String action, final TestDevice device) {
-            start(action, HostConfig.Ints.packageInstallTimeoutMs.value(), device);
-        }
-
-        /**
-         * Start the timer while package install/uninstall/getDeviceInfo/checkAPI with specific
-         * timeout.
-         *
-         * @param action The action of package
-         * @param timeout The specific timeout
-         * @param device The TestDevice under operation
-         */
-        private void start(final String action, final int timeout, final TestDevice device) {
-            Log.d("start(), action=" + action + ",mTimer=" + mTimer + ",timeout=" + timeout);
-            synchronized (this) {
-                if (mTimer != null) {
-                    mTimer.cancel();
-                }
-
-                mTimer = new Timer();
-                mTimer.schedule(new PackageActionTimeoutTask(action, device), timeout);
-            }
-        }
-
-        /**
-         * Stop the action timer.
-         */
-        private void stop() {
-            synchronized (this) {
-                Log.d("stop() , mTimer=" + mTimer);
-                if (mTimer != null) {
-                    mTimer.cancel();
-                    mTimer = null;
-                }
-            }
-        }
-    }
-
-    /**
-     * The observer of package action, currently including installing and uninstalling.
-     */
-    final class PackageActionObserver implements StdOutObserver, Runnable {
-
-        private BufferedReader mReader;
-        private String mAction;
-
-        public PackageActionObserver(final String action) {
-            mAction = action;
-        }
-
-        /** {@inheritDoc} */
-        public void run() {
-            try {
-                processLines();
-            } catch (IOException e) {
-                e.printStackTrace();
-            } finally {
-                try {
-                    mReader.close();
-                } catch (IOException e) {
-                    e.printStackTrace();
-                }
-            }
-        }
-
-        /**
-         * Parse the standard out to judge where the installation is complete.
-         */
-        public void processLines() throws IOException {
-            String line = mReader.readLine();
-            int statusCode = DeviceObserver.FAIL;
-            boolean gotResult = false;
-
-            while (line != null) {
-                line = line.toLowerCase();
-                if (line.indexOf("success") != -1) {
-                    statusCode = DeviceObserver.SUCCESS;
-                    gotResult = true;
-                } else if (line.indexOf("failure") != -1) {
-                    statusCode = DeviceObserver.FAIL;
-                    CUIOutputStream.println(mAction.toLowerCase() + " met " + line);
-                    gotResult = true;
-                } else if (line.indexOf("error") != -1) {
-                    CUIOutputStream.println(mAction.toLowerCase() + " met " + line);
-                    statusCode = DeviceObserver.FAIL;
-                    gotResult = true;
-                }
-
-                if (gotResult) {
-                    Log.d(mAction + " calls stopPackageActionTimer()");
-                    mPackageActionTimer.stop();
-
-                    if (mDeviceObserver != null) {
-                        mDeviceObserver.notifyInstallingComplete(statusCode);
-                    }
-                    break;
-                }
-                line = mReader.readLine();
-            }
-        }
-
-        /** {@inheritDoc} */
-        public void setInputStream(InputStream is) {
-            mReader = new BufferedReader(new InputStreamReader(is));
-            new Thread(this).start();
-        }
-    }
-
-    /**
-     * Raw mode result parser.
-     */
-    abstract class RawModeResultParser extends MultiLineReceiver {
-        public final static String EQ_MARK = "=";
-        public final static String COMMA_MARK = ":";
-        public final static String AT_MARK = "at ";
-
-        public final static String STATUS_STREAM = "INSTRUMENTATION_STATUS: stream=";
-        public final static String STATUS_TEST = "INSTRUMENTATION_STATUS: test=";
-        public final static String STATUS_CLASS = "INSTRUMENTATION_STATUS: class=";
-        public final static String STATUS_CODE = "INSTRUMENTATION_STATUS_CODE:";
-        public final static String STATUS_STACK = "INSTRUMENTATION_STATUS: stack=";
-        public final static String STATUS_CURRENT = "INSTRUMENTATION_STATUS: current=";
-        public final static String STATUS_NUM = "INSTRUMENTATION_STATUS: numtests=";
-        public final static String STATUS_ERROR_STR = "INSTRUMENTATION_STATUS: Error=";
-
-        public final static String FAILURE = "Failure in ";
-        public final static String ASSERTION = "junit.framework.Assertion";
-
-        public final static String RESULT_STREAM = "INSTRUMENTATION_RESULT: stream=";
-        public final static String RESULT_CODE = "INSTRUMENTATION_CODE:";
-        public final static String RESULT = "Test results";
-        public final static String RESULT_TIME = "Time:";
-        public final static String RESULT_SUMMARY = "Tests run:";
-
-        public final static int STATUS_STARTING = 1;
-        public final static int STATUS_PASS = 0;
-        public final static int STATUS_FAIL = -1;
-        public final static int STATUS_ERROR = -2;
-        public final static int STATUS_OMITTED = -3;
-
-        private ArrayList<String> mResultLines;
-
-        public String mStackTrace;
-        public String mFailedMsg;
-        public int mResultCode;
-
-        public Test mTest;
-
-        public RawModeResultParser(Test test) {
-            super();
-
-            setTrimLine(false);
-
-            mTest = test;
-            mResultLines = new ArrayList<String>();
-            mStackTrace = null;
-            mFailedMsg = null;
-            mResultCode = CtsTestResult.CODE_FAIL;
-        }
-
-        /** {@inheritDoc} */
-        @Override
-        public void processNewLines(String[] lines) {
-            for (String line : lines) {
-                processNewLine(line.trim());
-            }
-        }
-
-        /**
-         * Process the new line.
-         *
-         * @param line The new line.
-         */
-        abstract public void processNewLine(final String line);
-
-        /**
-         * Get the result lines.
-         *
-         * @return The result lines.
-         */
-        public ArrayList<String> getResultLines() {
-            return mResultLines;
-        }
-
-        /**
-         * Get the named string from the string containing the mark.
-         *
-         * @param mark The mark to search against the results.
-         * @return The test name.
-         */
-        public String getNamedString(String mark) {
-            for (String line : mResultLines) {
-                if (line.startsWith(mark)) {
-                    String name = line.substring(line.indexOf(EQ_MARK) + 1);
-                    return name.trim();
-                }
-            }
-
-            return null;
-        }
-
-        /**
-         * Parse the int from the string containing the mark.
-         *
-         * @param mark The mark to search against the results.
-         * @return The number.
-         */
-        public int parseIntWithMark(String mark) {
-            for (String line : mResultLines) {
-                if (line.startsWith(mark)) {
-                    String code = line.substring(line.indexOf(EQ_MARK) + 1);
-                    return Integer.parseInt(code.trim());
-                }
-            }
-
-            return 0;
-        }
-
-        /**
-         * Get failed message.
-         *
-         * @return The failed message.
-         */
-        public String getFailedMessage() {
-            Iterator<String> iterator = mResultLines.iterator();
-            while (iterator.hasNext()) {
-                String line = iterator.next();
-                if (line.startsWith(STATUS_STACK)) {
-                    String failedMsg = line.substring(STATUS_STACK.length());
-                    if (iterator.hasNext()) {
-                        failedMsg += " " + iterator.next();
-                    }
-                    return failedMsg;
-                }
-            }
-            return null;
-        }
-
-        /**
-         * Get stack trace from output result.
-         *
-         * @return The stack trace message.
-         */
-        public String getStackTrace() {
-            StringBuilder sb = new StringBuilder();
-            for (String line : mResultLines) {
-                line = line.trim();
-                if (line.startsWith(AT_MARK) && line.endsWith(")")) {
-                    sb.append(line + "\n");
-                }
-            }
-            return sb.toString();
-        }
-
-        /**
-         * Get the status code of the test result.
-         *
-         * @param line The string contains the status code of the test result.
-         * @return The status code of the test result.
-         */
-        public int getStatusCode(String line) {
-            String codeStr = line.substring(line.indexOf(COMMA_MARK) + 1);
-            return Integer.parseInt(codeStr.trim());
-        }
-
-        /** {@inheritDoc} */
-        public boolean isCancelled() {
-            return false;
-        }
-
-        /** {@inheritDoc} */
-        @Override
-        public void done() {
-            super.done();
-        }
-    }
-
-    /**
-     * Individual mode result parser. <br>
-     * Individual mode means that the host sends request
-     * to the device method by method. And the device
-     * reactions and outputs the result to each request.
-     */
-    final class IndividualModeResultParser extends RawModeResultParser {
-
-        public IndividualModeResultParser(Test test) {
-            super(test);
-        }
-
-        /**
-         * Process a new line.
-         *
-         * @param line The new line.
-         */
-        @Override
-        public void processNewLine(final String line) {
-            if ((line == null) || (line.trim().length() == 0)) {
-                return;
-            }
-
-            ArrayList<String> resultLines = getResultLines();
-            resultLines.add(line);
-
-            if (line.startsWith(STATUS_CODE)) {
-                int statusCode = getStatusCode(line);
-                processTestResult(statusCode);
-                resultLines.removeAll(resultLines);
-            }
-        }
-
-        /**
-         * Process the test result of a single test.
-         *
-         * @param statusCode The status code of a single test's test result.
-         */
-        public void processTestResult(int statusCode) {
-            String testName = getNamedString(STATUS_TEST);
-            String className = getNamedString(STATUS_CLASS);
-            String testFullName = className + Test.METHOD_SEPARATOR + testName;
-            String errorMessage = getNamedString(STATUS_ERROR_STR);
-
-            mFailedMsg = null;
-            mStackTrace = null;
-            if ((statusCode == STATUS_FAIL) || (statusCode == STATUS_ERROR)) {
-                mFailedMsg = getFailedMessage();
-                mStackTrace = getStackTrace();
-            }
-
-            if ((errorMessage != null) && (errorMessage.length() != 0)) {
-                if (mFailedMsg == null) {
-                    mFailedMsg = errorMessage;
-                } else {
-                    mFailedMsg += " : " + errorMessage;
-                }
-            }
-
-            Log.d(testFullName + "...(" + statusCode + ")");
-            Log.d("errorMessage= " + errorMessage);
-            Log.d("mFailedMsg=" + mFailedMsg);
-            Log.d("mStackTrace=" + mStackTrace);
-
-            switch (statusCode) {
-            case STATUS_STARTING:
-                break;
-
-            case STATUS_PASS:
-                mResultCode = CtsTestResult.CODE_PASS;
-                break;
-
-            case STATUS_FAIL:
-            case STATUS_ERROR:
-                mResultCode = CtsTestResult.CODE_FAIL;
-                break;
-            }
-        }
-
-        /** {@inheritDoc} */
-        @Override
-        public void done() {
-            mTest.notifyResult(new CtsTestResult(mResultCode, mFailedMsg, mStackTrace));
-            super.done();
-        }
-    }
-
-    /**
-     * Batch mode result parser.
-     * Batch mode means that the host sends only one request
-     * for all of the methods contained in the package to the
-     * device. And then, the device runs the method one by one
-     * and outputs the result method by method.
-     */
-    final class BatchModeResultParser extends RawModeResultParser {
-        private TestPackage mTestPackage;
-        private Collection<Test> mTests;
-        public int mCurrentTestNum;
-        public int mTotalNum;
-
-        public BatchModeResultParser(TestPackage testPackage) {
-            super(null);
-
-            mTestPackage = testPackage;
-            if (mTestPackage != null) {
-                mTests = mTestPackage.getTests();
-            }
-        }
-
-        /**
-         * Process a new line.
-         *
-         * @param line The new line.
-         */
-        @Override
-        public void processNewLine(final String line) {
-            if ((line == null) || (line.trim().length() == 0)) {
-                return;
-            }
-
-            ArrayList<String> resultLines = getResultLines();
-            resultLines.add(line);
-
-            if (line.startsWith(STATUS_CODE)) {
-                int statusCode = getStatusCode(line);
-                processTestResult(statusCode);
-                resultLines.removeAll(resultLines);
-            } else if (line.startsWith(RESULT_CODE)) {
-                int resultCode = getStatusCode(line);
-                switch(resultCode) {
-                case STATUS_STARTING:
-                    break;
-
-                case STATUS_FAIL:
-                case STATUS_ERROR:
-                    mResultCode = CtsTestResult.CODE_FAIL;
-                    break;
-
-                case STATUS_PASS:
-                    mResultCode = CtsTestResult.CODE_PASS;
-                    break;
-                }
-                resultLines.removeAll(resultLines);
-            }
-        }
-
-        /**
-         * Process the test result of a single test.
-         *
-         * @param statusCode The status code of a single test's test result.
-         */
-        public void processTestResult(int statusCode) {
-            String testName = getNamedString(STATUS_TEST);
-            String className = getNamedString(STATUS_CLASS);
-            String testFullName = className + Test.METHOD_SEPARATOR + testName;
-            mCurrentTestNum = parseIntWithMark(STATUS_CURRENT);
-            mTotalNum = parseIntWithMark(STATUS_NUM);
-
-            mFailedMsg = null;
-            mStackTrace = null;
-            if ((statusCode == STATUS_FAIL) || ((statusCode == STATUS_ERROR))) {
-                mFailedMsg = getFailedMessage();
-                mStackTrace = getStackTrace();
-            }
-
-            Log.d(testFullName + "...(" + statusCode + ")");
-            Log.d("mFailedMsg=" + mFailedMsg);
-            Log.d("mStackTrace=" + mStackTrace);
-
-            String status = TestPackage.FINISH;
-
-            if (statusCode == STATUS_STARTING) {
-                status = TestPackage.START;
-            }
-
-            mTest = searchTest(testFullName);
-            if (mTest != null) {
-                switch(statusCode) {
-                case STATUS_STARTING:
-                    status = TestPackage.START;
-                    break;
-
-                case STATUS_PASS:
-                    mTest.setResult(new CtsTestResult(
-                            CtsTestResult.CODE_PASS, null, null));
-                    break;
-
-                case STATUS_ERROR:
-                case STATUS_FAIL:
-                    mTest.setResult(new CtsTestResult(
-                            CtsTestResult.CODE_FAIL, mFailedMsg, mStackTrace));
-                    break;
-                }
-            }
-            // report status even if no matching test was found
-            mTestPackage.notifyTestStatus(mTest, status);
-        }
-
-        /**
-         * Search Test with given test full name.
-         *
-         * @param testFullName The test full name.
-         * @return The Test matches the test full name given.
-         */
-        private Test searchTest(String testFullName) {
-            for (Test test : mTests) {
-                if (testFullName.equals(test.getFullName())) {
-                    return test;
-                }
-            }
-            return null;
-        }
-
-        /** {@inheritDoc} */
-        @Override
-        public void done() {
-            mTestPackage.notifyBatchModeFinish();
-            super.done();
-        }
-    }
-
-    /**
-     * Remove the run time listener.
-     */
-    public void removeRuntimeListener() {
-        mDeviceObserver = null;
-    }
-
-    /**
-     * Set the run time listener.
-     *
-     * @param listener The run time listener.
-     */
-    public void setRuntimeListener(DeviceObserver listener) {
-        mDeviceObserver = listener;
-    }
-
-    /**
-     * Push monitor monitoring the status of pushing a file.
-     */
-    class PushMonitor implements ISyncProgressMonitor {
-
-        public PushMonitor() {
-        }
-
-        /** {@inheritDoc} */
-        public void advance(int arg0) {
-        }
-
-        /** {@inheritDoc} */
-        public boolean isCanceled() {
-            return false;
-        }
-
-        /** {@inheritDoc} */
-        public void start(int arg0) {
-        }
-
-        /** {@inheritDoc} */
-        public void startSubTask(String arg0) {
-        }
-
-        /** {@inheritDoc} */
-        public void stop() {
-        }
-    }
-
-    /**
-     * Add a new log listener.
-     *
-     * @param listener the listener
-     */
-    public void addMainLogListener(ILogListener listener) {
-        logListener.addListener(listener);
-    }
-
-    /**
-     * Remove an existing log listener.
-     *
-     * @param listener the listener to remove.
-     */
-    public void removeMainLogListener(ILogListener listener) {
-        logListener.removeListener(listener);
-    }
-
-    /**
-     * Execute Adb shell command on {@link IDevice}
-     *
-     * @param cmd the string of command.
-     * @param receiver {@link IShellOutputReceiver}
-     * @throws DeviceDisconnectedException if the device disconnects during the command
-     */
-    public void executeShellCommand(final String cmd,
-            final IShellOutputReceiver receiver) throws DeviceDisconnectedException {
-        executeShellCommand(cmd, receiver, null);
-    }
-
-    /**
-     * Execute Adb shell command on {@link IDevice}
-     *
-     * Note that the receivers run in a different thread than the caller.
-     *
-     * @param cmd the string of command.
-     * @param receiver {@link IShellOutputReceiver}
-     * @param logReceiver {@link LogReceiver}
-     * @throws DeviceDisconnectedException if the device disconnects during the command
-     */
-    public void executeShellCommand(final String cmd,
-            final IShellOutputReceiver receiver,
-            final LogReceiver logReceiver)
-            throws DeviceDisconnectedException {
-        if (mStatus == STATUS_OFFLINE) {
-            Log.d(String.format("device %s is offline when attempting to execute %s",
-                    getSerialNumber(), cmd));
-            throw new DeviceDisconnectedException(getSerialNumber());
-        }
-
-        new Thread() {
-            @Override
-            public void run() {
-                try {
-                    mDevice.executeShellCommand(cmd, receiver, 0);
-                } catch (IOException e) {
-                    Log.e(String.format("Failed to execute shell command %s on device %s", cmd,
-                            mDevice.getSerialNumber()), e);
-                } catch (TimeoutException e) {
-                    Log.e(String.format("Failed to execute shell command %s on device %s", cmd,
-                            mDevice.getSerialNumber()), e);
-                } catch (AdbCommandRejectedException e) {
-                    Log.e(String.format("Failed to execute shell command %s on device %s", cmd,
-                            mDevice.getSerialNumber()), e);
-                } catch (ShellCommandUnresponsiveException e) {
-                    Log.e(String.format("Failed to execute shell command %s on device %s", cmd,
-                            mDevice.getSerialNumber()), e);
-                }
-            }
-        }.start();
-    }
-
-    /**
-     * Kill {@link Client} which running the test on the {@link IDevice}
-     *
-     * @param packageName the test package name
-     */
-    public void killProcess(String packageName) {
-        if (mStatus == STATUS_OFFLINE) {
-            return;
-        }
-        Client[] clients = mDevice.getClients();
-
-        for (Client c : clients) {
-            ClientData cd = c.getClientData();
-            if (cd.getClientDescription() == null) {
-                continue;
-            }
-            if (cd.getClientDescription().equals(packageName)) {
-                c.kill();
-                break;
-            }
-        }
-    }
-
-    /**
-     * Called when the {@link TestDevice} disconnected.
-     */
-    public void disconnected() {
-        CUIOutputStream.println("Device(" + getSerialNumber() + ") disconnected");
-        mDevice = null;
-        mSyncService = null;
-
-        synchronized (mObjectSync) {
-            mObjectSync.sendNotify();
-            mPackageActionTimer.stop();
-        }
-
-        if (mStatus == STATUS_BUSY) {
-            Log.d("TestDevice.disconnected calls notifyTestingDeviceDisconnected");
-            mDeviceObserver.notifyTestingDeviceDisconnected();
-        } else {
-            if (!TestSession.isADBServerRestartedMode()) {
-                CUIOutputStream.printPrompt();
-            }
-        }
-        setStatus(STATUS_OFFLINE);
-        if (logServiceThread != null) {
-            logServiceThread.cancelLogService();
-        }
-    }
-
-    /**
-     * Set the status of the {@link TestDevice}
-     *
-     * @param statusCode the status code of {@link TestDevice}
-     */
-    public void setStatus(final int statusCode) {
-        if (statusCode != STATUS_IDLE && statusCode != STATUS_BUSY
-                && statusCode != STATUS_OFFLINE) {
-            throw new IllegalArgumentException("Invalid status code");
-        }
-        mStatus = statusCode;
-    }
-
-    /**
-     * Get the status code of the {@link TestDevice}.
-     *
-     * @return get the status code of the {@link TestDevice}
-     */
-    public int getStatus() {
-        return mStatus;
-    }
-
-    /**
-     * Get the status of the {@link TestDevice} as string.
-     *
-     * @return the status of the {@link TestDevice} as string.
-     */
-    public String getStatusAsString() {
-        return mStatusMap.get(mStatus);
-    }
-
-    /**
-     * Wait for command finish.
-     */
-    public void waitForCommandFinish() {
-        synchronized (mObjectSync) {
-            try {
-                mObjectSync.waitOn();
-            } catch (InterruptedException e) {
-            }
-        }
-    }
-
-    /**
-     * Start the action timer with specific timeout
-     *
-     * @param action the action to start the timer
-     * @param timeout the specific timeout
-     */
-    void startActionTimer(final String action, final int timeout) {
-        mPackageActionTimer.start(action, timeout, this);
-    }
-
-    /**
-     * Start the action timer.
-     *
-     * @param action the action to start the timer.
-     */
-    void startActionTimer(String action) {
-       mPackageActionTimer.start(action, this);
-    }
-
-    /**
-     * Stop the action timer.
-     */
-    void stopActionTimer() {
-        mPackageActionTimer.stop();
-    }
-
-    /**
-     * Allows an external test to signal that it's command is complete.
-     */
-    void notifyExternalTestComplete() {
-        synchronized (mObjectSync) {
-            mObjectSync.sendNotify();
-        }
-    }
-
-    /**
-     * Notify install complete.
-     */
-    public void notifyInstallingComplete(int resultCode) {
-        synchronized (mObjectSync) {
-            mObjectSync.sendNotify();
-            mPackageActionTimer.stop();
-        }
-    }
-
-    /** {@inheritDoc} */
-    public void notifyInstallingTimeout(TestDevice testDevice) {
-        synchronized (mObjectSync) {
-            mObjectSync.sendNotify();
-        }
-    }
-
-    /** {@inheritDoc} */
-    public void notifyTestingDeviceDisconnected() {
-        synchronized (mObjectSync) {
-            mObjectSync.sendNotify();
-            if (mPackageActionTimer != null) {
-                mPackageActionTimer.stop();
-            }
-        }
-    }
-
-    /** {@inheritDoc} */
-    public void notifyUninstallingComplete(int resultCode) {
-        synchronized (mObjectSync) {
-            mObjectSync.sendNotify();
-            mPackageActionTimer.stop();
-        }
-    }
-
-    /** {@inheritDoc} */
-    public void notifyUninstallingTimeout(TestDevice testDevice) {
-        synchronized (mObjectSync) {
-            mObjectSync.sendNotify();
-        }
-    }
-
-    /**
-     * Synchronization object for communication between threads.
-     */
-    class ObjectSync {
-        private boolean mNotifySent = false;
-
-        /**
-         * Send notify to the waiting thread.
-         */
-        public void sendNotify() {
-            Log.d("ObjectSync.sendNotify() is called, mNotifySent=" + mNotifySent);
-            mNotifySent = true;
-            notify();
-        }
-
-        /**
-         * Wait on.
-         */
-        public void waitOn() throws InterruptedException {
-            Log.d("ObjectSync.waitOn() is called, mNotifySent=" + mNotifySent);
-            if (!mNotifySent) {
-                wait();
-            }
-
-            mNotifySent = false;
-        }
-
-        /**
-         * Check if notify has been sent to the waiting thread.
-         *
-         * @return If sent, return true; else, return false.
-         */
-        public boolean isNotified() {
-            return mNotifySent;
-        }
-    }
-
-    /**
-     * Take a screenshot of the device under test.
-     *
-     * @return the screenshot
-     * @throws IOException
-     * @throws AdbCommandRejectedException
-     * @throws TimeoutException
-     */
-    public RawImage getScreenshot() throws IOException, TimeoutException,
-            AdbCommandRejectedException {
-        return mDevice.getScreenshot();
-    }
-}
diff --git a/tools/host/src/com/android/cts/TestHost.java b/tools/host/src/com/android/cts/TestHost.java
deleted file mode 100644
index f0857a5..0000000
--- a/tools/host/src/com/android/cts/TestHost.java
+++ /dev/null
@@ -1,715 +0,0 @@
-/*
- * Copyright (C) 2008 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
- *
- *      httprunPackage://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.cts;
-
-import com.android.cts.HostConfig.CaseRepository;
-import com.android.cts.HostConfig.PlanRepository;
-import com.android.ddmlib.AndroidDebugBridge;
-
-import org.xml.sax.SAXException;
-
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.security.NoSuchAlgorithmException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactoryConfigurationError;
-
-/**
- * Act as the host for the device connections, also provides management of
- * sessions.
- */
-public class TestHost extends XMLResourceHandler implements SessionObserver {
-    public static final String TEMP_PLAN_NAME = "tempPlan";
-
-    enum ActionType {
-        RUN_SINGLE_TEST, RUN_SINGLE_JAVA_PACKAGE, START_NEW_SESSION, RESUME_SESSION
-    }
-    /**
-     * Definition of the modes the TestHost will run with.
-     * <ul>
-     *    <li> RUN: For this mode, the TestHost will run the plan or
-     *              package directly without starting the UI.
-     *    <li> CONSOLE: For this mode, the TestHost will start the UI
-     *                  and wait for input from user.
-     * </ul>
-     */
-    enum MODE {
-        UNINITIALIZED, RUN, CONSOLE
-    }
-
-    static private ArrayList<TestSession> sSessions = new ArrayList<TestSession>();
-    static private DeviceManager sDeviceManager = new DeviceManager();
-    static private Object sTestSessionSync = new Object();
-
-    static private ConsoleUi sConsoleUi;
-
-    static private HostConfig sConfig;
-
-    private static TestHost sInstance;
-    static MODE sMode = MODE.UNINITIALIZED;
-    private static boolean sQuick = false;
-
-    public static void main(final String[] mainArgs) {
-        CUIOutputStream.println("Android CTS version " + Version.asString());
-
-        if (HostLock.lock() == false) {
-            Log.e("Error: CTS is being used at the moment."
-                    + " No more than one CTS instance is allowed simultaneously", null);
-            exit();
-        }
-
-        sDeviceManager.initAdb();
-
-        sConsoleUi = new ConsoleUi(getInstance());
-        CommandParser cp = init(sConsoleUi, mainArgs);
-
-        if (sMode == MODE.RUN) {
-            try {
-                /* After booting up, the connection between
-                 * CTS host and device isn't ready. It's needed
-                 * to wait for 3 seconds for device ready to
-                 * start the the mode of no console UI.
-                 */
-                Thread.sleep(3000);
-                cp.removeKey(CTSCommand.OPTION_CFG);
-                sConsoleUi.processCommand(cp);
-            } catch (InterruptedException e) {
-                Log.e("Met InterruptedException", e);
-            } catch (Exception e) {
-                Log.e("Met exception when processing command", e);
-            }
-        } else if (sMode == MODE.CONSOLE) {
-            sConsoleUi.startUi();
-        }
-
-        exit();
-    }
-
-    /**
-     * Release host lock and then exit.
-     */
-    private static void exit() {
-        Log.closeLog();
-        HostLock.release();
-        System.exit(-1);
-    }
-
-    /**
-     * Extract mode from the options used to activating CTS.
-     *
-     * @param cp Command container.
-     * @return The mode.
-     */
-    static private MODE getMode(final CommandParser cp) {
-        String action = cp.getAction();
-        if ((action != null) && (action.equals(CTSCommand.START))) {
-            return MODE.RUN;
-        } else {
-            return MODE.CONSOLE;
-        }
-    }
-
-    /**
-     * Start zipped package.
-     *
-     * @param pathName  The path name of the zipped package.
-     */
-    public void startZippedPackage(final String pathName)
-                throws FileNotFoundException,
-                       IOException,
-                       ParserConfigurationException,
-                       TransformerFactoryConfigurationError,
-                       TransformerException,
-                       DeviceNotAvailableException,
-                       TestNotFoundException,
-                       SAXException,
-                       TestPlanNotFoundException,
-                       IllegalTestNameException,
-                       InterruptedException, DeviceDisconnectedException,
-                       NoSuchAlgorithmException, InvalidNameSpaceException,
-                       InvalidApkPathException {
-
-        // step 1: add package
-        if (!addPackage(pathName)) {
-            return;
-        }
-
-        // step 2: create plan
-        ArrayList<String> packages = new ArrayList<String>();
-        String pkgName = pathName.substring(pathName
-                .lastIndexOf(File.separator) + 1, pathName.lastIndexOf("."));
-        packages.add(pkgName);
-        HashMap<String, ArrayList<String>> selectedResult =
-                       new HashMap<String, ArrayList<String>>();
-        selectedResult.put(pkgName, null);
-        TestSessionBuilder.getInstance().serialize(TEMP_PLAN_NAME, packages, selectedResult);
-
-        // step 3: start the plan
-        TestSession ts = startSession(TEMP_PLAN_NAME, getFirstAvailableDevice().getSerialNumber(),
-                null);
-
-        // step 4: copy the resulting zip file
-        String resultName = pathName.substring(0, pathName.lastIndexOf("."))
-                + ".zip";
-        TestSessionLog log = ts.getSessionLog();
-        copyFile(log.getResultPath() + ".zip", resultName);
-
-        // step 5: clear the temporary working environment
-        removePlans(TEMP_PLAN_NAME);
-        //give the system some time to avoid asserting
-        Thread.sleep(1000);
-
-        removePackages(pkgName);
-        //give the system some time to avoid asserting
-        Thread.sleep(1000);
-    }
-
-    /**
-     * Copy the source file to the destination file.
-     *
-     * @param srcFileName The name of the source file.
-     * @param dstFileName The name of the destination file.
-     */
-    private void copyFile(final String srcFileName, final String dstFileName) throws IOException {
-        FileReader input = new FileReader(new File(srcFileName));
-        BufferedWriter output = new BufferedWriter(new FileWriter(dstFileName));
-
-        int c;
-        while ((c = input.read()) != -1) {
-            output.write(c);
-        }
-
-        input.close();
-        output.flush();
-        output.close();
-    }
-
-    /**
-     * Add a package by the path and package name.
-     *
-     * @param pathName The path name.
-     * @return If succeed in adding package, return true; else, return false.
-     */
-    public boolean addPackage(final String pathName) throws FileNotFoundException,
-            IOException, NoSuchAlgorithmException {
-
-        CaseRepository caseRepo = sConfig.getCaseRepository();
-        if (!HostUtils.isFileExist(pathName)) {
-            Log.e("Package error: package file " + pathName + " doesn't exist.", null);
-            return false;
-        }
-
-        if (!caseRepo.isValidPackageName(pathName)) {
-            return false;
-        }
-
-        caseRepo.addPackage(pathName);
-        return true;
-    }
-
-    /**
-     * Remove plans from the plan repository according to the specific plan name.
-     *
-     * @param name The plan name.
-     */
-    public void removePlans(final String name) {
-        if ((name == null) || (name.length() == 0)) {
-            CUIOutputStream.println("Please add plan name or all as parameter.");
-            return;
-        }
-
-        PlanRepository planRepo = sConfig.getPlanRepository();
-        if (name.equals(HostConfig.ALL)) {
-            ArrayList<String> plans = planRepo.getAllPlanNames();
-            for (String plan : plans) {
-                removePlan(plan, planRepo);
-            }
-        } else {
-            if (!planRepo.getAllPlanNames().contains(name)) {
-                Log.e("No plan named " + name + " in repository!", null);
-                return;
-            }
-            removePlan(name, planRepo);
-        }
-    }
-
-    /**
-     * Remove a specified plan from the plan repository.
-     *
-     * @param planName The plan name.
-     * @param planRepo The plan repository.
-     */
-    private void removePlan(final String planName, final PlanRepository planRepo) {
-        File planFile = new File(planRepo.getPlanPath(planName));
-        if (!planFile.isFile() || !planFile.exists()) {
-            Log.e("Can't locate the file of the plan, please check your repository!", null);
-            return;
-        }
-
-        if (!planFile.canWrite()) {
-            Log.e("Can't delete this plan, permission denied!", null);
-            return;
-        }
-
-        if (!planFile.delete()) {
-            Log.e(planName + " plan file delete failed", null);
-        }
-    }
-
-    /**
-     * Remove packages from the case repository..
-     *
-     * @param packageName The java package name to be removed from the case repository.
-     */
-    public void removePackages(final String packageName)
-            throws IndexOutOfBoundsException {
-        CaseRepository caseRepo = sConfig.getCaseRepository();
-
-        if ((packageName == null) || (packageName.length() == 0)) {
-            CUIOutputStream.println("Please add package name or all as parameter.");
-            return;
-        }
-
-        caseRepo.removePackages(packageName);
-    }
-
-    /**
-     * Initialize TestHost with the arguments passed in.
-     *
-     * @param mainArgs The arguments.
-     * @return CommandParser which contains the command and options.
-     */
-    static CommandParser init(final ConsoleUi cui, final String[] mainArgs) {
-        CommandParser cp = null;
-        String cfgPath= null;
-
-        if (mainArgs.length == 0) {
-            sMode = MODE.CONSOLE;
-            cfgPath = System.getProperty("HOST_CONFIG");
-            if ((cfgPath == null) || (cfgPath.length() == 0)) {
-                Log.e("Please make sure environment variable CTS_HOST_CFG is "
-                       + "set as {cts install path}[/host_config.xml].", null);
-                exit();
-            }
-        } else if (mainArgs.length == 1) {
-            sMode = MODE.CONSOLE;
-            cfgPath = mainArgs[0];
-        } else {
-            String cmdLine = "";
-            for (int i = 0; i < mainArgs.length; i ++) {
-                cmdLine += mainArgs[i] + " ";
-            }
-
-            try {
-                cp = CommandParser.parse(cmdLine);
-                if (!cui.validateCommandParams(cp)) {
-                    Log.e("Please type in arguments correctly to activate CTS.", null);
-                    exit();
-                }
-            } catch (UnknownCommandException e1) {
-                Log.e("Please type in arguments correctly to activate CTS.", null);
-                exit();
-            } catch (CommandNotFoundException e1) {
-                Log.e("Please type in arguments correctly to activate CTS.", null);
-                exit();
-            }
-
-            sMode = getMode(cp);
-            if (sMode == MODE.RUN) {
-                if (cp.containsKey(CTSCommand.OPTION_CFG)) {
-                    cfgPath = cp.getValue(CTSCommand.OPTION_CFG);
-                } else {
-                    cfgPath = System.getProperty("HOST_CONFIG");
-                    if ((cfgPath == null) || (cfgPath.length() == 0)) {
-                        Log.e("Please make sure environment variable CTS_HOST_CFG "
-                               + "is set as {cts install path}[/host_config.xml].", null);
-                        exit();
-                    }
-                }
-            }
-
-            if (cp.containsKey(CTSCommand.OPTION_QUICK)) {
-                sQuick = true;
-            }
-        }
-
-        if ((cfgPath == null) || (cfgPath.length() == 0)) {
-            Log.e("Please type in arguments correctly to activate CTS.", null);
-            exit();
-        }
-
-        String filePath = getConfigFilePath(cfgPath);
-        try {
-            if (loadConfig(filePath) == false) {
-                exit();
-            }
-            if (sQuick) {
-                HostConfig.Ints.valueOf("postInstallWaitMs").setValue(1);
-            }
-
-            Log.initLog(sConfig.getLogRoot());
-            sConfig.loadRepositories(sQuick);
-        } catch (Exception e) {
-            Log.e("Error while parsing cts config file", e);
-            exit();
-        }
-        return cp;
-    }
-
-    /**
-     * Singleton generator.
-     *
-     * @return The TestHost.
-     */
-    public static TestHost getInstance() {
-        if (sInstance == null) {
-            sInstance = new TestHost();
-        }
-
-        return sInstance;
-    }
-
-    /**
-     * Get configuration file from the arguments given.
-     *
-     * @param filePath The file path.
-     * @return The the path of the configuration file.
-     */
-    static private String getConfigFilePath(final String filePath) {
-        if (filePath != null) {
-            if (!HostUtils.isFileExist(filePath)) {
-                Log.e("Configuration file \"" + filePath + "\" doesn't exist.", null);
-                exit();
-            }
-        } else {
-            Log.e("Configuration file doesn't exist.", null);
-            exit();
-        }
-
-        return filePath;
-    }
-
-    /**
-     * Load configuration from the given file.
-     *
-     * @param configPath The configuration path.
-     * @return If succeed, return true; else, return false.
-     */
-    static boolean loadConfig(final String configPath) throws SAXException,
-            IOException, ParserConfigurationException {
-        sConfig = HostConfig.getInstance();
-
-        return sConfig.load(configPath);
-    }
-
-    /**
-     * Get case repository.
-     *
-     * @return The case repository.
-     */
-    public HostConfig.CaseRepository getCaseRepository() {
-        return sConfig.getCaseRepository();
-    }
-
-    /**
-     * Get plan repository.
-     *
-     * @return The plan repository.
-     */
-    public HostConfig.PlanRepository getPlanRepository() {
-        return sConfig.getPlanRepository();
-    }
-
-    /**
-     * Run the specified {@link TestSession} on the specified {@link TestDevice}(s)
-     *
-     * @param ts the specified {@link TestSession}
-     * @param deviceId the ID of the specified {@link TestDevice}
-     * @param testFullName The full name of the test to be run.
-     * @param javaPkgName The specific java package name to be run.
-     * @param type The action type to activate the test session.
-     */
-    static private void runTest(final TestSession ts, final String deviceId,
-            final String testFullName, final String javaPkgName, ActionType type)
-            throws DeviceNotAvailableException, TestNotFoundException, IllegalTestNameException,
-            DeviceDisconnectedException, InvalidNameSpaceException,
-            InvalidApkPathException {
-
-        if (ts == null) {
-            return;
-        }
-
-        ts.setObserver(getInstance());
-        TestDevice device = sDeviceManager.allocateFreeDeviceById(deviceId);
-        TestSessionLog sessionLog = ts.getSessionLog();
-        ts.setTestDevice(device);
-        ts.getDevice().installDeviceSetupApp();
-        if (!sQuick) {
-            sessionLog.setDeviceInfo(ts.getDevice().getDeviceInfo());
-        }
-
-        boolean finish = false;
-        while (!finish) {
-            ts.getDevice().disableKeyguard();
-            try {
-                switch (type) {
-                case RUN_SINGLE_TEST:
-                    ts.start(testFullName);
-                    break;
-
-                case RUN_SINGLE_JAVA_PACKAGE:
-                    ts.start(javaPkgName);
-                    break;
-
-                case START_NEW_SESSION:
-                    ts.start();
-                    break;
-
-                case RESUME_SESSION:
-                    ts.resume();
-                    break;
-                }
-
-                finish = true;
-            } catch (ADBServerNeedRestartException e) {
-                Log.d(e.getMessage());
-                Log.i("Max ADB operations reached. Restarting ADB...");
-
-                TestSession.setADBServerRestartedMode();
-                sDeviceManager.restartADBServer(ts);
-
-                type = ActionType.RESUME_SESSION;
-            }
-        }
-
-        TestSession.resetADBServerRestartedMode();
-        if (HostConfig.getMaxTestCount() > 0) {
-            sDeviceManager.resetTestDevice(ts.getDevice());
-        }
-
-        ts.getDevice().uninstallDeviceSetupApp();
-    }
-
-    /**
-     * Create {@link TestSession} according to the specified test plan.
-     *
-     * @param testPlanName the name of the specified test plan
-     * @return a {@link TestSession}
-     */
-    static public TestSession createSession(final String testPlanName)
-            throws IOException, TestNotFoundException, SAXException,
-            ParserConfigurationException, TestPlanNotFoundException, NoSuchAlgorithmException {
-
-        String testPlanPath = sConfig.getPlanRepository().getPlanPath(testPlanName);
-        TestSession ts = TestSessionBuilder.getInstance().build(testPlanPath);
-        sSessions.add(ts);
-
-        return ts;
-    }
-
-    /** {@inheritDoc} */
-    public void notifyFinished(final TestSession ts) {
-        // As test run on a session, so just keep session info in debug level
-        Log.d("Session " + ts.getId() + " finished.");
-
-        synchronized (sTestSessionSync) {
-            sTestSessionSync.notify();
-        }
-        ts.getSessionLog().sessionComplete();
-    }
-
-    /**
-     * Tear down ADB connection.
-     */
-    public void tearDown() {
-        AndroidDebugBridge.disconnectBridge();
-        AndroidDebugBridge.terminate();
-    }
-
-    /**
-     * Get the sessions connected with devices.
-     *
-     * @return The sessions.
-     */
-    public Collection<TestSession> getSessions() {
-        return sSessions;
-    }
-
-    /**
-     * Get session by session ID.
-     *
-     * @param sessionId The session ID.
-     * @return The session.
-     */
-    public TestSession getSession(final int sessionId) {
-        for (TestSession session : sSessions) {
-            if (session.getId() == sessionId) {
-                return session;
-            }
-        }
-        return null;
-    }
-
-    /**
-     * Get session by test plan name.
-     *
-     * @param testPlanName Test plan name.
-     * @return The session corresponding to the test plan name.
-     */
-    public ArrayList<TestSession> getSessionList(final String testPlanName) {
-        ArrayList<TestSession> list = new ArrayList<TestSession>();
-        for (TestSession session : sSessions) {
-            if (testPlanName.equals(session.getSessionLog().getTestPlanName())) {
-                list.add(session);
-            }
-        }
-        return list;
-    }
-
-    /**
-     * List the ID, name and status of all {@link TestDevice} which connected to
-     * the {@link TestHost}.
-     *
-     * @return a string list of {@link TestDevice}'s id, name and status.
-     */
-    public String[] listDevices() {
-        ArrayList<String> deviceList = new ArrayList<String>();
-        TestDevice[] devices = sDeviceManager.getDeviceList();
-
-        for (TestDevice device : devices) {
-            deviceList.add(device.getSerialNumber() + "\t" + device.getStatusAsString());
-        }
-        return deviceList.toArray(new String[deviceList.size()]);
-    }
-
-    /**
-     * Get device list connected with the host.
-     *
-     * @return The device list connected with the host.
-     */
-    public TestDevice[] getDeviceList() {
-        return sDeviceManager.getDeviceList();
-    }
-
-    /**
-     * Get the first available device.
-     *
-     * @return the first available device or null if none are available.
-     */
-    public TestDevice getFirstAvailableDevice() {
-        for (TestDevice td : sDeviceManager.getDeviceList()) {
-            if (td.getStatus() == TestDevice.STATUS_IDLE) {
-                return td;
-            }
-        }
-        return null;
-    }
-
-    /**
-     * Get session logs.
-     *
-     * @return Session logs.
-     */
-    public Collection<TestSessionLog> getSessionLogs() {
-        ArrayList<TestSessionLog> sessionLogs = new ArrayList<TestSessionLog>();
-        for (TestSession session : sSessions) {
-            sessionLogs.add(session.getSessionLog());
-        }
-        return sessionLogs;
-    }
-    /**
-     * Start a test session.
-     *
-     * @param testPlanName TestPlan config file name
-     * @param deviceId Target device ID
-     * @param profile The profile of the device being tested.
-     * @param javaPkgName The specific java package name to be run.
-     */
-    public TestSession startSession(final String testPlanName,
-            String deviceId, final String javaPkgName)
-            throws IOException, DeviceNotAvailableException,
-            TestNotFoundException, SAXException, ParserConfigurationException,
-            TestPlanNotFoundException, IllegalTestNameException,
-            DeviceDisconnectedException, NoSuchAlgorithmException,
-            InvalidNameSpaceException, InvalidApkPathException {
-
-        TestSession ts = createSession(testPlanName);
-        if ((javaPkgName != null) && (javaPkgName.length() != 0)) {
-            runTest(ts, deviceId, null, javaPkgName, ActionType.RUN_SINGLE_JAVA_PACKAGE);
-        } else {
-            runTest(ts, deviceId, null, javaPkgName, ActionType.START_NEW_SESSION);
-        }
-
-        ts.getSessionLog().sessionComplete();
-        return ts;
-    }
-
-    /**
-     * Start a test session.
-     *
-     * @param ts The test session.
-     * @param deviceId Target device ID.
-     * @param testFullName Specific test full name.
-     * @param javaPkgName The specific java package name to be run.
-     * @param type The action type to activate the test session.
-     */
-    public TestSession startSession(final TestSession ts, String deviceId,
-            final String testFullName, final String javaPkgName, ActionType type)
-            throws DeviceNotAvailableException,
-            TestNotFoundException, IllegalTestNameException,
-            DeviceDisconnectedException, InvalidNameSpaceException,
-            InvalidApkPathException {
-
-        runTest(ts, deviceId, testFullName, javaPkgName, type);
-        ts.getSessionLog().sessionComplete();
-        return ts;
-    }
-
-    /**
-     * Get plan name from what is typed in by the user.
-     *
-     * @param rawPlanName The raw plan name.
-     * @return The plan name.
-     */
-    public String getPlanName(final String rawPlanName) {
-        if (rawPlanName.indexOf("\\") != -1) {
-            return rawPlanName.replaceAll("\\\\", "");
-        }
-        if (rawPlanName.indexOf("\"") != -1) {
-            return rawPlanName.replaceAll("\"", "");
-        }
-        return rawPlanName;
-    }
-
-    /**
-     * Add test session.
-     *
-     * @param ts The test session.
-     */
-    public void addSession(TestSession ts) {
-        sSessions.add(ts);
-    }
-}
diff --git a/tools/host/src/com/android/cts/TestNotFoundException.java b/tools/host/src/com/android/cts/TestNotFoundException.java
deleted file mode 100644
index 1990743..0000000
--- a/tools/host/src/com/android/cts/TestNotFoundException.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (C) 2008 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.cts;
-
-/**
- * Exception on test not found.
- *
- */
-public class TestNotFoundException extends Exception {
-
-    private static final long serialVersionUID = 167003945777574277L;
-
-    public TestNotFoundException() {
-        super();
-    }
-
-    public TestNotFoundException(final String msg) {
-        super(msg);
-    }
-}
diff --git a/tools/host/src/com/android/cts/TestPackage.java b/tools/host/src/com/android/cts/TestPackage.java
deleted file mode 100644
index a332297..0000000
--- a/tools/host/src/com/android/cts/TestPackage.java
+++ /dev/null
@@ -1,1154 +0,0 @@
-/*
- * Copyright (C) 2008 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.cts;
-
-import com.android.cts.TestSession.TestSessionThread;
-
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.TimerTask;
-
-/**
- * Correspond to an APK, provide functions on
- * representing and executing an APK from CTS test harness.
- */
-public class TestPackage implements DeviceObserver {
-    protected static final String PKG_LOG_SEPARATOR =
-              "==============================================================";
-
-    /**
-     * For batch mode, there is just one command sent to the device
-     * for the whole package, and the device will feed back the result
-     * test by test. To guard the command, a timeout timer is started
-     * to prevent it from running forever. And to make the timeout time
-     * not too long, it's better choice to restart the timer each time
-     * received the feedback from device. The following two variables
-     * are used to restart/stop the timer, START for restarting and
-     * FINISH for stopping.
-     */
-    public static final String FINISH = "finish";
-    public static final String START = "start";
-
-    private final String mName;
-    private final String mVersion;
-    private final String mAndroidVersion;
-    private final String mTargetNameSpace;
-    private final String mTargetBinaryName;
-    private final String mInstrumentationRunner;
-    private final Collection<TestSuite> mSuites;
-    private String mDigest;
-    private final String mJarPath;
-    private final String mAppNameSpace;
-    private final String mAppPackageName;
-    private final String mJavaPackageFilter;
-
-    protected TestSuite mCurrentTestSuite;
-
-    protected TestDevice mDevice;
-
-    protected boolean mTestStop;
-    private TestSessionThread mTestThread;
-
-    private HostTimer mTimeOutTimer;
-    private ProgressObserver mProgressObserver;
-    private boolean mIsInBatchMode;
-    private Test mCurrentTest;
-
-    /**
-     * Construct a test package with given necessary information.
-     *
-     * @param instrumentationRunner The instrumentation runner.
-     * @param testPkgBinaryName The binary name of the TestPackage.
-     * @param targetNameSpace The target name space of the dependent package, if available.
-     * @param version The version of the CTS Host allowed.
-     * @param androidVersion The version of the Anroid platform allowed.
-     * @param jarPath The host controller's jar path and file.
-     * @param appNameSpace The package name space.
-     * @param appPackageName The package name of the test package.
-     * @param javaPackageFilter The prefix used to select which Java packages to run
-     */
-    public TestPackage(final String instrumentationRunner,
-            final String testPkgBinaryName, final String targetNameSpace,
-            final String targetBinaryName, final String version,
-            final String androidVersion, final String jarPath, final String appNameSpace,
-            final String appPackageName, final String javaPackageFilter) {
-        mInstrumentationRunner = instrumentationRunner;
-        mName = testPkgBinaryName;
-        mTargetNameSpace = targetNameSpace;
-        mTargetBinaryName = targetBinaryName;
-        mVersion = version;
-        mAndroidVersion = androidVersion;
-        mSuites = new ArrayList<TestSuite>();
-        mJarPath = jarPath;
-        mAppNameSpace = appNameSpace;
-        mAppPackageName = appPackageName;
-        mJavaPackageFilter = javaPackageFilter;
-
-        mDevice = null;
-        mTestStop = false;
-        mTestThread = null;
-        mIsInBatchMode = false;
-        mCurrentTest = null;
-    }
-
-    /**
-     * Get the app package name space.
-     *
-     * @return The app package name space.
-     */
-    public String getAppNameSpace() {
-        return mAppNameSpace;
-    }
-
-    /**
-     * Get the app package name.
-     *
-     * @return The app package name.
-     */
-    public String getAppPackageName() {
-        return mAppPackageName;
-    }
-
-    /**
-     * Returns whether this is a host side test package.
-     */
-    public boolean isHostSideOnly() {
-        return false;
-    }
-
-    /**
-     * Add a TestSuite.
-     *
-     * @param suite The TestSuite to be added.
-     */
-    public void addTestSuite(final TestSuite suite) {
-        mSuites.add(suite);
-    }
-
-    /**
-     * Get test suites under this package.
-     *
-     * @return The test suites under this package.
-     */
-    public Collection<TestSuite> getTestSuites() {
-        return mSuites;
-    }
-
-    /**
-     * Get the specific test suite by the full suite name.
-     *
-     * @param suiteFullName The full suite name.
-     * @return The test suite.
-     */
-    public TestSuite getTestSuiteByName(final String suiteFullName) {
-        for (TestSuite suite : getAllTestSuites()) {
-            if (suite.getFullName().equals(suiteFullName)) {
-                return suite;
-            }
-        }
-        return null;
-    }
-
-    /**
-     * Get the specific test case by the full test case name.
-     *
-     * @param testCaseFullName The full test case name.
-     * @return The test case.
-     */
-    public TestCase getTestCaseByName(final String testCaseFullName) {
-        for (TestCase testCase : getAllTestCases()) {
-            if (testCase.getFullName().equals(testCaseFullName)) {
-                return testCase;
-            }
-        }
-        return null;
-    }
-
-    /**
-     * Get all of test suites under this package.
-     *
-     * @return All of the test suites under this package.
-     */
-    public Collection<TestSuite> getAllTestSuites() {
-        Collection<TestSuite> suites = new ArrayList<TestSuite>();
-        for (TestSuite suite : mSuites) {
-            suites.addAll(suite.getAllSuites());
-        }
-        return suites;
-    }
-
-    /**
-     * Get suite/case names contained in this test package, searched against the expected name.
-     *
-     * @param expectName The expected name.
-     * @param suiteNameList The suite names list.
-     * @param caseNameList The case names list.
-     */
-    public void getTestSuiteNames(final String expectName,
-            List<String> suiteNameList, List<String> caseNameList) {
-
-        for (TestCase testCase : getAllTestCases()) {
-            String testCaseName = testCase.getFullName();
-            if (testCaseName.startsWith(expectName)) {
-                String suiteName = testCaseName.substring(0, testCaseName.lastIndexOf("."));
-                if (suiteName.equals(expectName)) {
-                    if (!caseNameList.contains(testCaseName)) {
-                        caseNameList.add(testCaseName);
-                    }
-                } else {
-                    if (!suiteNameList.contains(suiteName)) {
-                        suiteNameList.add(suiteName);
-                    }
-                }
-            }
-        }
-    }
-
-    /**
-     * Get all test suite names contained in this test package.
-     *
-     * @return The test suite name list.
-     */
-    public List<String> getAllTestSuiteNames() {
-        List<String> suiteNameList = new ArrayList<String>();
-        for (TestCase testCase : getAllTestCases()) {
-            String testCaseName = testCase.getFullName();
-            String suiteName = testCaseName.substring(0, testCaseName.lastIndexOf("."));
-            if (!suiteNameList.contains(suiteName)) {
-                suiteNameList.add(suiteName);
-            }
-        }
-        return suiteNameList;
-    }
-
-    /**
-     * Get all test case names contained in the suite in this test package.
-     *
-     * @param suiteFullName The full suite name.
-     * @return All test case names.
-     */
-    public List<String> getAllTestCaseNames(final String suiteFullName) {
-        List<String> caseNameList = new ArrayList<String>();
-        TestSuite suite = getTestSuiteByName(suiteFullName);
-        if (suite != null) {
-            caseNameList.addAll(suite.getAllTestCaseNames());
-        }
-        return caseNameList;
-    }
-
-    /**
-     * Get all test names contained in the test case in this test package.
-     *
-     * @param testCaseFullName The full test case name.
-     * @return All test names.
-     */
-    public List<String> getAllTestNames(final String testCaseFullName) {
-        List<String> testNameList = new ArrayList<String>();
-        TestCase testCase = getTestCaseByName(testCaseFullName);
-        if (testCase != null) {
-            testNameList.addAll(testCase.getAllTestNames());
-        }
-        return testNameList;
-    }
-
-    /**
-     * Get test case names list.
-     *
-     * @param expectPackage The expected package name.
-     * @param caseList The searched test case result.
-     * @param testList The searched test result.
-     */
-    public void getTestCaseNames(final String expectPackage, List<String> caseList,
-            List<String> testList) {
-
-        for (TestCase testCase : getAllTestCases()) {
-            String testCaseName = testCase.getFullName();
-            if (testCaseName.equals(expectPackage)) {
-                for (Test test : testCase.getTests()) {
-                    testList.add(test.getFullName());
-                }
-                return;
-            } else if (testCaseName.startsWith(expectPackage)) {
-                caseList.add(testCaseName);
-            }
-        }
-    }
-
-    /**
-     * Get test names list.
-     *
-     * @param expectPackage The expected package name.
-     * @param testList The searched test result.
-     */
-    public void getTestNames(final String expectPackage, List<String> testList) {
-
-        for (Test test : getTests()) {
-            String testName = test.getFullName();
-            if (testName.startsWith(expectPackage)) {
-                testList.add(testName);
-            }
-        }
-    }
-
-    /**
-     * Get the binary name of this package.
-     *
-     * @return The binary name of this package.
-     */
-    public String getAppBinaryName() {
-        return mName;
-    }
-
-    /**
-     * Get the version string of this package.
-     *
-     * @return The version string of this package.
-     */
-    public String getVersion() {
-        return mVersion;
-    }
-
-    /**
-     * Get the version information of Android.
-     *
-     * @return The version information of Android.
-     */
-    public String getAndroidVersion() {
-        return mAndroidVersion;
-    }
-
-    /**
-     * Get the target name space of this package.
-     *
-     * @return The target name space of the package.
-     */
-    public String getTargetNameSpace() {
-        return mTargetNameSpace;
-    }
-
-    /**
-     * Get the target binary name.
-     *
-     * @return The target binary name.
-     */
-    public String getTargetBinaryName() {
-        return mTargetBinaryName;
-    }
-
-    /**
-     * Get the instrumentation runner.
-     *
-     * @return The instrumentation runner.
-     */
-    public String getInstrumentationRunner() {
-        return mInstrumentationRunner;
-    }
-
-    /**
-     * Search a specific Test within this package.
-     *
-     * @param testName The test name to be searched against.
-     * @return The Test matches the given name.
-     */
-    public Test searchTest(final String testName) {
-        Test test = null;
-        for (TestSuite suite : mSuites) {
-            test = suite.searchTest(testName);
-            if (test != null) {
-                break;
-            }
-        }
-
-        return test;
-    }
-
-    /**
-     * Get all tests of this test package.
-     *
-     * @return The tests of this test package.
-     */
-    public Collection<Test> getTests() {
-        List<Test> tests = new ArrayList<Test>();
-        for (TestSuite s : mSuites) {
-            tests.addAll(s.getTests());
-        }
-
-        return tests;
-    }
-
-    /**
-     * Get all test cases of this test package.
-     *
-     * @return The test cases of this test package.
-     */
-    public Collection<TestCase> getAllTestCases() {
-        List<TestCase> testCases = new ArrayList<TestCase>();
-        for (TestSuite s : mSuites) {
-            testCases.addAll(s.getAllTestCases());
-        }
-
-        return testCases;
-    }
-
-    /**
-     * Set the message digest of the test package.
-     *
-     * @param digest the string of the package's message digest.
-     */
-    private void setMessageDigest(final String digest) {
-        mDigest = digest;
-    }
-
-    /**
-     * Get the string of package's message digest.
-     *
-     * @return message digest string.
-     */
-    public String getMessageDigest() {
-        return mDigest;
-    }
-
-    /**
-     * Get the the path of the controller jar file.
-     *
-     * @return message digest string.
-     */
-    public String getJarPath() {
-        return mJarPath;
-    }
-
-    /**
-     * Get the excluded list according to the execution status of each test.
-     *
-     * @param resultType The result type to filter the tests.
-     * @return All excluded list. There are three scenarios to interpret the return value:
-     *      <ul>
-     *          <li> null: nothing should be added to plan;
-     *          <li> list size equals 0: the whole package should be added to plan;
-     *          <li> list size greater than 0: the given excluded list should be added to plan.
-     *      </ul>
-     */
-    public ArrayList<String> getExcludedList(final String resultType) {
-        ArrayList<String> excludedList = new ArrayList<String>();
-        ArrayList<String> fullNameList = new ArrayList<String>();
-        for (TestSuite suite : getTestSuites()) {
-            fullNameList.add(suite.getFullName());
-            ArrayList<String> list = suite.getExcludedList(resultType);
-            if ((list != null) && (list.size() > 0)) {
-                excludedList.addAll(list);
-            }
-        }
-
-        int count = 0;
-        for (String fullName : fullNameList) {
-            if (excludedList.contains(fullName)) {
-                count ++;
-            }
-        }
-        if (count == fullNameList.size()) {
-            //all suites contained have been excluded,
-            //return null to tell the caller nothing to add to the plan
-            return null;
-        }
-        return excludedList;
-    }
-
-    /**
-     * Print the message by appending the new line mark.
-     *
-     * @param msg The message to be print.
-     */
-    protected void println(final String msg) {
-        if (!mTestStop) {
-            CUIOutputStream.println(msg);
-        }
-    }
-
-    /**
-     * Print the message without appending the new line mark.
-     *
-     * @param msg The message to be print.
-     */
-    protected void print(final String msg) {
-        if (!mTestStop) {
-            CUIOutputStream.print(msg);
-        }
-    }
-
-    /**
-     * Notify that the batch mode finished.
-     */
-    public void notifyBatchModeFinish() {
-        Log.d("TestPackage.notifyBatchModeFinish() is called, mTestStop=" + mTestStop);
-        if (mTestStop) {
-            return;
-        }
-
-        if (mIsInBatchMode) {
-            if (mCurrentTest != null) {
-                handleMissingFinishEvent();
-            }
-            synchronized (mTimeOutTimer) {
-                mTimeOutTimer.sendNotify();
-            }
-        }
-    }
-
-    /**
-     * Handle the missing FINISH event.
-     */
-    private void handleMissingFinishEvent() {
-        mProgressObserver.stop();
-        synchronized (mTimeOutTimer) {
-            mTimeOutTimer.cancel(false);
-        }
-        // The currently running test did not report a result. Mark it as not executed, so that it
-        // will be run again in individual mode.
-        mCurrentTest.setResult(new CtsTestResult(CtsTestResult.CODE_NOT_EXECUTED, null, null));
-        mCurrentTest = null;
-    }
-
-    /**
-     * Update Test running status when running in batch mode.
-     *
-     * @param test The Test to update. May be null if a status gets reported on a test that is not
-     * in the test plan.
-     * @param status The status to be updated.
-     */
-    public void notifyTestStatus(final Test test, final String status) {
-        if (mTestStop) {
-            return;
-        }
-
-        if (mIsInBatchMode) {
-            if (status.equals(START)) {
-                if ((mCurrentTest != null) && (mCurrentTest.getResult().isNotExecuted())) {
-                    Log.d("Err: Missing FINISH msg for test " + mCurrentTest.getFullName());
-                    handleMissingFinishEvent();
-                }
-                mCurrentTest = test;
-                if (test != null) {
-                    print(mCurrentTest.getFullName() + "...");
-                    mProgressObserver.start();
-                }
-            } else {
-                mProgressObserver.stop();
-                mCurrentTest = null;
-            }
-            // restart the timer even for unexpected tests
-            mTimeOutTimer.restart(new TimeOutTask(this),
-                    HostConfig.Ints.testStatusTimeoutMs.value());
-        }
-    }
-
-    /** {@inheritDoc} */
-    public void notifyInstallingComplete(final int resultCode) {
-        Log.d("notifyInstallingComplete() is called with resultCode=" + resultCode);
-        sendNotify();
-
-        if (resultCode == FAIL) {
-            Log.d("install failed");
-        }
-    }
-
-    /** {@inheritDoc} */
-    public void notifyUninstallingComplete(final int resultCode) {
-        Log.d("notifyUninstallingComplete() is called with resultCode=" + resultCode);
-        sendNotify();
-
-        if (resultCode == FAIL) {
-            Log.d("uninstall failed");
-        }
-    }
-
-    /**
-     * Send notify to wake up the thread waiting on the object.
-     */
-    private void sendNotify() {
-        synchronized (this) {
-            notify();
-        }
-    }
-
-    /** {@inheritDoc} */
-    public void notifyInstallingTimeout(final TestDevice testDevice) {
-        Log.d("TestPackage.notifyInstallingTimeout() is called");
-        mTestStop = true;
-        synchronized (this) {
-            notify();
-        }
-
-        genPackageActionTimeoutCause(testDevice, "Installing");
-    }
-
-    /** {@inheritDoc} */
-    public void notifyUninstallingTimeout(final TestDevice testDevice) {
-        Log.d("TestPackage.notifyUninstallingTimeout() is called");
-        mTestStop = true;
-        synchronized (this) {
-            notify();
-        }
-
-        genPackageActionTimeoutCause(testDevice, "Uninstalling");
-    }
-
-    /**
-     * Generate the cause of package action timeout.
-     *
-     * @param testDevice The {@link TestDevice} which got timeout.
-     * @param type Install or Uninstall.
-     */
-    private void genPackageActionTimeoutCause(final TestDevice testDevice, String type) {
-        String cause;
-        if (testDevice.getStatus() == TestDevice.STATUS_OFFLINE) {
-            cause = testDevice.getSerialNumber() + " is offline.";
-        } else {
-            cause = "Unknown reason.";
-        }
-
-        if (type == null) {
-            type = "Unknown timer";
-        }
-        Log.e(type + " met timeout due to " + cause, null);
-    }
-
-    /** {@inheritDoc} */
-    public void notifyTestingDeviceDisconnected() {
-        Log.d("busyDeviceDisconnected invoked");
-        mTestStop = true;
-        synchronized (this) {
-            notify();
-        }
-
-        cleanUp();
-
-        try {
-            CUIOutputStream.println("Test stopped.");
-            mTestThread.join();
-        } catch (InterruptedException e) {
-            Log.d("test thread interrupted");
-        }
-    }
-
-    /**
-     * Set the {@link TestDevice} which will run the test.
-     *
-     * @param device The {@link TestDevice} will run the test.
-     */
-    public void setTestDevice(final TestDevice device) {
-        mDevice = device;
-        device.setRuntimeListener(this);
-        device.setStatus(TestDevice.STATUS_BUSY);
-    }
-
-    /**
-     * Get the full path information.
-     *
-     * @param binaryFileName The binary file name.
-     * @return The full path information.
-     */
-    private String getFullPath(String binaryFileName) {
-        String packagePath = null;
-        if ((binaryFileName != null) && (binaryFileName.length() != 0)) {
-            packagePath = HostConfig.getInstance().getCaseRepository()
-                .getApkPath(binaryFileName);
-        }
-        return packagePath;
-    }
-    /**
-     * Load(install) test package and target package(if it exists).
-     *
-     * @return If succeed in installing, return true; else, return false.
-     */
-    private boolean install() throws DeviceDisconnectedException, InvalidApkPathException {
-        String packageBinaryName = getAppBinaryName();
-        String targetBinaryName = getTargetBinaryName();
-        String packagePath = getFullPath(packageBinaryName);
-        String targetApkPath = getFullPath(targetBinaryName);
-
-        boolean success = true;
-        if (packagePath != null) {
-            installAPK(packagePath);
-            if ((!mTestStop) && (targetApkPath != null)) {
-                installAPK(targetApkPath);
-            }
-        } else {
-            success = false;
-            Log.e("The package binary name contains nothing!", null);
-        }
-
-        if (mTestStop) {
-            success = false;
-            println("Install package " + packageBinaryName + "failed");
-        }
-
-        return success;
-    }
-
-    /**
-     * Uninstall test package and target package(if it exists)
-     */
-    private void uninstall() throws DeviceDisconnectedException, InvalidNameSpaceException {
-
-        String testPkgBinaryName = getAppBinaryName();
-        String appNameSpace = getAppNameSpace();
-        String targetNameSpace = getTargetNameSpace();
-        String packagePath = getFullPath(testPkgBinaryName);
-        String targetApkPath = getFullPath(targetNameSpace);
-
-        if ((packagePath != null) && HostUtils.isFileExist(packagePath)) {
-            uninstallAPK(appNameSpace);
-            if ((!mTestStop) && (targetNameSpace != null)
-                    && ((targetApkPath != null) && (HostUtils.isFileExist(targetApkPath)))) {
-                uninstallAPK(targetNameSpace);
-            }
-        }
-    }
-
-    /**
-     * Uninstall the specified package(.apk)
-     */
-    private void uninstallAPK(final String packageName) throws DeviceDisconnectedException,
-                InvalidNameSpaceException {
-        Log.d("Uninstall: " + packageName);
-        mDevice.uninstallAPK(packageName);
-        waitPackageActionComplete();
-    }
-
-    /**
-     * Install the test package on the devices attached to this session.
-     *
-     * @param apkPath The test package to be installed.
-     */
-    private void installAPK(final String apkPath) throws DeviceDisconnectedException,
-            InvalidApkPathException {
-        Log.d("installAPK " + apkPath + " ...");
-        mDevice.installAPK(apkPath);
-        waitPackageActionComplete();
-        Log.d("installAPK " + apkPath + " finish");
-    }
-
-    /**
-     * Wait for package action to complete.
-     */
-    private void waitPackageActionComplete() {
-        Log.d("Enter waitPackageActionComplete()");
-        synchronized (this) {
-            if (!mTestStop) {
-                try {
-                    wait();
-                } catch (InterruptedException e) {
-                    Log.d("interrupted while waiting for package action complete");
-                }
-            }
-        }
-        try {
-            Thread.sleep(HostConfig.Ints.postInstallWaitMs.value());
-        } catch (InterruptedException e) {
-            Log.d("sleeping after package action complete interrupted");
-        }
-        Log.d("Leave waitPackageActionComplete()");
-    }
-
-    /**
-     * Generate the message digest of the specified package
-     *
-     * @param packagePath path to the package.
-     * @return message digest string(base64 encoded).
-     */
-    private String genMessageDigest(final String packagePath) throws IOException {
-        final String algorithm = "SHA-1";
-        FileInputStream fin = new FileInputStream(packagePath);
-        try {
-            MessageDigest md = MessageDigest.getInstance(algorithm);
-            byte[] buffer = new byte[1024];
-            int len;
-            while ((len = fin.read(buffer)) != -1) {
-                md.update(buffer, 0, len);
-            }
-            fin.close();
-            return HostUtils.toHexString(md.digest());
-        } catch (NoSuchAlgorithmException e) {
-            return algorithm + " not found";
-        }
-    }
-
-    /**
-     * Set the test session thread.
-     *
-     * @param thread
-     */
-    public void setSessionThread(TestSessionThread thread) {
-        mTestThread = thread;
-    }
-
-    /**
-     * Check if it's valid to use batch mode.
-     *
-     * @return If each test under this package doesn't depend on any host controller, return true;
-     *         else, return false;
-     */
-    private boolean supportsBatchMode() {
-        Collection<Test> tests = getTests();
-
-        // check whether the package is small enough for batch mode
-        if (tests.size() > HostConfig.Ints.maxTestsInBatchMode.value()) {
-            return false;
-        }
-
-        for (Test test : tests) {
-            if (!test.getResult().isNotExecuted()) {
-                // if any test has been run, use individual mode
-                return false;
-            }
-
-            if ((test.getTestController() != null)
-                && (test.getTestController().getFullName() != null)) {
-                return false;
-            }
-        }
-
-        return true;
-    }
-
-    /**
-     * Get the first segment list of all of the test packages.
-     *
-     * @return the first segment list of all of the test packages contained in this test package;
-     */
-     List<String> getPackageNames() {
-        List<String> pkgNames = new ArrayList<String>();
-        List<String> suiteNames = getAllTestSuiteNames();
-        for (String suiteName : suiteNames) {
-            String pkgSeg = suiteName;
-            if (suiteName.contains(".")) {
-                pkgSeg = suiteName.split("\\.")[0];
-            }
-            if (!pkgNames.contains(pkgSeg)) {
-                pkgNames.add(pkgSeg);
-            }
-        }
-
-        return pkgNames;
-    }
-
-    /**
-     * Run this package or the java package contained in this package in batch mode.
-     *
-     * @param javaPkgName The java package name. If null, run the whole package;
-     *              else, run the specified java package contained in this package
-     */
-    private void runInBatchMode(final String javaPkgName)
-            throws DeviceDisconnectedException {
-        mTimeOutTimer = new HostTimer(new TimeOutTask(this),
-                HostConfig.Ints.batchStartTimeoutMs.value());
-        mTimeOutTimer.start();
-        mProgressObserver = new ProgressObserver();
-
-        if ((javaPkgName != null) && !javaPkgName.isEmpty()) {
-            runInBatchModeImpl(javaPkgName);
-        } else {
-            for (String pkgName : getPackageNames()) {
-                runInBatchModeImpl(pkgName);
-            }
-        }
-    }
-
-    /**
-     * Implementation of running in batch mode.
-     *
-     * @param javaPkgName The java package name.
-     */
-    private void runInBatchModeImpl(String javaPkgName)
-            throws DeviceDisconnectedException {
-        mDevice.runInBatchMode(this, javaPkgName);
-
-        synchronized (mTimeOutTimer) {
-            if (!mTestStop) {
-                try {
-                    mTimeOutTimer.waitOn();
-                } catch (InterruptedException e) {
-                    Log.d("time out object interrupted");
-                }
-            }
-
-            mProgressObserver.stop();
-            if (mTimeOutTimer.isTimeOut()) {
-                return;
-            } else {
-                // not caused by watch dog timer timing out,
-                // need to cancel timer
-                mTimeOutTimer.cancel(false);
-            }
-        }
-    }
-
-    /**
-     * Run this package in individual mode.
-     *
-     * @param javaPkgName The java package name.
-     * @param profile The profile of the device being tested.
-     */
-    protected void runInIndividualMode(final String javaPkgName) throws IOException,
-                    DeviceDisconnectedException, ADBServerNeedRestartException {
-        Iterator<TestSuite> suites = getTestSuites().iterator();
-        while (suites.hasNext() && (!mTestStop)) {
-            mCurrentTestSuite = suites.next();
-            mCurrentTestSuite.run(mDevice, javaPkgName);
-        }
-    }
-
-    /**
-     * The timer task which aids in guarding the running package with the
-     * guarding timer. If the executing of the package is not finished, and the
-     * guarding timer is expired, this task will be executed to force the finish
-     * of the running package.
-     */
-    class TimeOutTask extends TimerTask {
-        private TestPackage mTestPackage;
-
-        public TimeOutTask(final TestPackage testPackage) {
-            mTestPackage = testPackage;
-        }
-
-        @Override
-        public void run() {
-            mProgressObserver.stop();
-            synchronized (mTimeOutTimer) {
-                mTimeOutTimer.cancel(true);
-                mTimeOutTimer.sendNotify();
-            }
-
-            if ((mIsInBatchMode) && (mCurrentTest != null)) {
-                mCurrentTest.setResult(
-                        new CtsTestResult(CtsTestResult.CODE_TIMEOUT, null, null));
-                mCurrentTest = null;
-            }
-
-            Log.d("mTimeOutTimer timed out");
-            killDeviceProcess(mTestPackage.getAppPackageName());
-        }
-    }
-
-    /**
-     * Kill the device process.
-     *
-     * @param packageName
-     */
-    private void killDeviceProcess(final String packageName) {
-        mDevice.killProcess(packageName);
-    }
-
-    /**
-     * Check if all of the tests contained in this package have been run.
-     *
-     * @return If all tests have been run, return true; else, return false.
-     */
-    protected boolean isAllTestsRun(){
-        for (Test test : getTests()) {
-            if (test.getResult().isNotExecuted()) {
-                return false;
-            }
-        }
-        return true;
-    }
-
-    /**
-     * Check if any of the tests contained in this package have been executed.
-     *
-     * @return If no tests have been executed, return true, otherwise return false.
-     */
-    protected boolean noTestsExecuted() {
-        for (Test test : getTests()) {
-            if (!test.getResult().isNotExecuted()) {
-                return false;
-            }
-        }
-        return true;
-    }
-
-    /**
-     * Run the java package contained within this package over device.
-     *
-     * @param device The device to run this package.getName
-     * @param sessionLog the TestSession log for this TestSession.
-     */
-    public void run(final TestDevice device, final String javaPkgName,
-                    TestSessionLog sessionLog)
-            throws IOException, DeviceDisconnectedException,
-            ADBServerNeedRestartException, InvalidApkPathException,
-            InvalidNameSpaceException {
-        if (isAllTestsRun()) {
-            return;
-        }
-
-        String javaPackage = (javaPkgName != null) ? javaPkgName : mJavaPackageFilter;
-        setup(device, javaPackage);
-        runImpl(javaPackage);
-    }
-
-    /**
-     * Implementation of running the test package.
-     *
-     * @param javaPkgName The Java package name.
-     * @param profile The profile of the device being tested.
-     */
-    protected void runImpl(final String javaPkgName) throws IOException,
-            DeviceDisconnectedException, ADBServerNeedRestartException, InvalidApkPathException,
-            InvalidNameSpaceException {
-        try {
-            if (!install()) {
-                return;
-            }
-
-            if (!mTestStop) {
-                Log.d("install " + getAppBinaryName() + " succeed!");
-
-                setMessageDigest(genMessageDigest(HostConfig.getInstance()
-                        .getCaseRepository().getApkPath(getAppBinaryName())));
-
-                if (supportsBatchMode()) {
-                    mIsInBatchMode = true;
-                    Log.d("run in batch mode...");
-                    runInBatchMode(javaPkgName);
-                    if (!isAllTestsRun()) {
-                        mIsInBatchMode = false;
-                        Log.d("run in individual mode");
-                        runInIndividualMode(javaPkgName);
-                    }
-                } else {
-                    Log.d("run in individual mode...");
-                    runInIndividualMode(javaPkgName);
-                }
-            }
-
-            if (!mTestStop) {
-                uninstall();
-                if (!TestSession.isADBServerRestartedMode()) {
-                    println(PKG_LOG_SEPARATOR);
-                }
-            }
-        } catch (DeviceDisconnectedException e) {
-            cleanUp();
-            throw e;
-        }
-    }
-
-    /**
-     * Set up before running.
-     *
-     * @param device The device to run this package.getName
-     * @param javaPkgName The Java package name.
-     */
-    protected void setup(final TestDevice device, final String javaPkgName) {
-        if (!TestSession.isADBServerRestartedMode() || noTestsExecuted()) {
-            println(PKG_LOG_SEPARATOR);
-            if ((javaPkgName == null) || (javaPkgName.length() == 0)) {
-                println("Test package: " + getAppPackageName());
-            } else {
-                println("Test java package contained in test package "
-                        + getAppPackageName() + ": " + javaPkgName);
-            }
-        }
-
-        mTestStop = false;
-        mIsInBatchMode = false;
-        mCurrentTest = null;
-        mCurrentTestSuite = null;
-
-        setTestDevice(device);
-    }
-
-    /**
-     * Clean up.
-     */
-    public void cleanUp() {
-        if (mCurrentTestSuite != null) {
-            mCurrentTestSuite.setTestStopped(mTestStop);
-            mCurrentTestSuite.notifyTestingDeviceDisconnected();
-        }
-
-        if (mProgressObserver != null) {
-            mProgressObserver.stop();
-        }
-
-        if (mTimeOutTimer != null) {
-            mTimeOutTimer.cancel(false);
-        }
-    }
-
-    /**
-     * Run the specific test contained in the package over device.
-     *
-     * @param device The device to run the specific test.
-     * @param test The specific test to be run.
-     * @param profile The profile of the device being tested.
-     */
-    public void runTest(final TestDevice device, final Test test)
-            throws DeviceDisconnectedException, ADBServerNeedRestartException,
-            InvalidApkPathException, InvalidNameSpaceException {
-
-        if (test == null) {
-            return;
-        }
-
-        mTestStop = false;
-        mIsInBatchMode = false;
-
-        println(PKG_LOG_SEPARATOR);
-        println("Test package: " + getAppPackageName());
-        setTestDevice(device);
-
-        runTestImpl(test);
-    }
-
-    /**
-     * Implementation of running test.
-     *
-     * @param test The test to be run.
-     * @param profile The profile of the device being tested.
-     */
-    protected void runTestImpl(final Test test) throws DeviceDisconnectedException,
-            ADBServerNeedRestartException, InvalidApkPathException,
-            InvalidNameSpaceException {
-        try {
-            if (!install()) {
-                return;
-            }
-
-            if (!mTestStop) {
-                Log.d("install " + getAppPackageName() + " succeed!");
-                mCurrentTestSuite = test.getTestSuite();
-                mCurrentTestSuite.run(mDevice, test);
-            }
-
-            if (!mTestStop) {
-                uninstall();
-                println(PKG_LOG_SEPARATOR);
-            }
-        } catch (DeviceDisconnectedException e) {
-            cleanUp();
-            throw e;
-        }
-    }
-}
diff --git a/tools/host/src/com/android/cts/TestPlan.java b/tools/host/src/com/android/cts/TestPlan.java
deleted file mode 100644
index 9eb4d5b..0000000
--- a/tools/host/src/com/android/cts/TestPlan.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Copyright (C) 2008 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.cts;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collection;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.xml.sax.SAXException;
-
-/**
- * Define TestPlan tags and attributes.
- */
-public class TestPlan extends XMLResourceHandler{
-    public static final String EXCLUDE_SEPARATOR = ";";
-
-    public interface Tag {
-        public static final String TEST_SUITE = "TestSuite";
-        public static final String ENTRY = "Entry";
-        public static final String TEST_PLAN = "TestPlan";
-        public static final String PLAN_SETTING = "PlanSettings";
-        public static final String REQUIRED_DEVICE = "RequiredDevice";
-        public static final String TEST_CASE = "TestCase";
-    }
-
-    public interface Attribute {
-        public static final String NAME = "name";
-        public static final String URI = "uri";
-        public static final String EXCLUDE = "exclude";
-        public static final String AMOUNT = "amount";
-    }
-
-    /**
-     * Get test package names via test plan file path.
-     *
-     * @param planPath TestPlan configuration file path
-     * @param removedPkgList The removed package list.
-     * @return The package names.
-     */
-    public static Collection<String> getEntries(String planPath,
-            ArrayList<String> removedPkgList)
-            throws SAXException, IOException, ParserConfigurationException {
-        ArrayList<String> entries = new ArrayList<String>();
-
-        DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
-        File planFile = new File(planPath);
-        Document doc = builder.parse(planFile);
-
-        NodeList pkgEntries = doc.getElementsByTagName(TestPlan.Tag.ENTRY);
-        for (int i = 0; i < pkgEntries.getLength(); i++) {
-            Node pkgEntry = pkgEntries.item(i);
-            String uri = getStringAttributeValue(pkgEntry, TestPlan.Attribute.URI);
-
-            String packageBinaryName = HostConfig.getInstance().getPackageBinaryName(uri);
-            if (packageBinaryName != null) {
-                entries.add(getStringAttributeValue(pkgEntry, TestPlan.Attribute.URI));
-            } else {
-                removedPkgList.add(uri);
-            }
-        }
-
-        return entries;
-    }
-
-    /**
-     * Check if the given package name is valid in the case repository.
-     *
-     * @param pkgName
-     * @return if both the apk file and xml file exist, return true;
-     *         else, return false.
-     */
-    public static boolean isValidPackageName(String pkgName) {
-        String xmlPath = HostConfig.getInstance().getCaseRepository().getXmlPath(pkgName);
-        String apkPath = HostConfig.getInstance().getCaseRepository().getApkPath(pkgName);
-        File xmlFile = new File(xmlPath);
-        File apkFile = new File(apkPath);
-
-        if (xmlFile.exists() && apkFile.exists()) {
-            return true;
-        } else {
-            return false;
-        }
-    }
-}
diff --git a/tools/host/src/com/android/cts/TestPlanNotFoundException.java b/tools/host/src/com/android/cts/TestPlanNotFoundException.java
deleted file mode 100644
index bbe1132..0000000
--- a/tools/host/src/com/android/cts/TestPlanNotFoundException.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (C) 2008 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.cts;
-
-/**
- * Exception if input a nonexistent test plan.
- */
-public class TestPlanNotFoundException extends Exception {
-
-    private static final long serialVersionUID = -2311532206911427651L;
-
-    public TestPlanNotFoundException() {
-        super();
-    }
-
-    public TestPlanNotFoundException(String message) {
-        super(message);
-    }
-}
diff --git a/tools/host/src/com/android/cts/TestSession.java b/tools/host/src/com/android/cts/TestSession.java
deleted file mode 100644
index e3693d8..0000000
--- a/tools/host/src/com/android/cts/TestSession.java
+++ /dev/null
@@ -1,617 +0,0 @@
-/*
- * Copyright (C) 2008 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.cts;
-
-import java.io.IOException;
-import java.util.Collection;
-
-/**
- * Represents a runtime session for a test plan, takes charge in running a
- * plan and the setup&tear-downs.
- */
-public class TestSession {
-    private SessionObserver mSessionObserver;
-    private TestSessionLog mSessionLog;
-    private TestDevice mDevice;
-
-    private int mId;
-    private STATUS mStatus;
-
-    private static int sIdCounter = 0;
-
-    enum STATUS {
-        INIT, STARTED, INSTALLING, RUNNING, PAUSED, RESUMED, STOPPED, FINISHED
-    }
-
-    private int mRequiredDeviceNumber;
-    private boolean mTestStop;
-    private TestSessionThread mTestThread;
-    private boolean mNeedRestartAdbServer;
-    private static boolean mADBServerRestartedMode;
-
-    /** Running count of tests executed since last reboot. */
-    private static long mTestCount;
-
-    public TestSession(final TestSessionLog sessionLog,
-            final int requiredDeviceNum) {
-        mStatus = STATUS.INIT;
-
-        mNeedRestartAdbServer = false;
-        mADBServerRestartedMode = false;
-        mTestCount = 0;
-        mSessionLog = sessionLog;
-        mDevice = null;
-        mRequiredDeviceNumber = requiredDeviceNum;
-        mTestStop = false;
-        mId = sIdCounter++;
-    }
-
-    /**
-     * Get the last session ID.
-     *
-     * @return The last session ID.
-     */
-    public static int getLastSessionId() {
-        return sIdCounter-1;
-    }
-
-    /**
-     * Set ADB server restarted mode.
-     */
-    public static void setADBServerRestartedMode() {
-        mADBServerRestartedMode = true;
-    }
-
-    /**
-     * Reset ADB server restarted mode.
-     */
-    public static void resetADBServerRestartedMode() {
-        mADBServerRestartedMode = false;
-    }
-
-    /**
-     * Check if it's in ADB server restarted mode.
-     *
-     * @return If in ADB server restarted mode, return true; else, return false.
-     */
-    public static boolean isADBServerRestartedMode() {
-        return mADBServerRestartedMode;
-    }
-
-    /**
-     * Increase the test count.
-     */
-    public static void incTestCount() {
-        mTestCount++;
-    }
-
-    /**
-     * Reset the test count.
-     */
-    public static void resetTestCount() {
-        mTestCount = 0;
-    }
-
-    /**
-     * Get the test count recently has been run.
-     *
-     * @return The test count recently has been run.
-     */
-    public static long getTestCount() {
-        return mTestCount;
-    }
-
-    /**
-     * Check if the test count exceeds the max test count. If the max test count is disabled
-     * (HostConfig.getMaxTestCount() <= 0), this method always returns false.
-     *
-     * @return true, if the max count is enabled and exceeded.
-     */
-    public static boolean exceedsMaxCount() {
-        final long maxTestCount = HostConfig.getMaxTestCount();
-        return (maxTestCount > 0) && (mTestCount >= maxTestCount);
-    }
-
-    /**
-     * Get status.
-     *
-     * @return The status.
-     */
-    public STATUS getStatus() {
-        return mStatus;
-    }
-
-    /**
-     * Get device ID.
-     *
-     * @return device ID.
-     */
-    public String getDeviceId() {
-        if (mDevice == null) {
-            return null;
-        }
-        return mDevice.getSerialNumber();
-    }
-
-    /**
-     * Get the test device.
-     *
-     * @return the test device.
-     */
-    public TestDevice getDevice() {
-        return mDevice;
-    }
-
-    /**
-     * Get the number of required devices.
-     *
-     * @return The number of required devices.
-     */
-    public int getNumOfRequiredDevices() {
-        return mRequiredDeviceNumber;
-    }
-
-    /**
-     * Get ID.
-     *
-     * @return ID.
-     */
-    public int getId() {
-        return mId;
-    }
-
-    /**
-     * Start the single test with full name.
-     *
-     * @param testFullName The test full name.
-     */
-    public void start(final String testFullName) throws TestNotFoundException,
-            IllegalTestNameException, ADBServerNeedRestartException {
-
-        if ((testFullName == null) || (testFullName.length() == 0)) {
-            throw new IllegalArgumentException();
-        }
-
-        // The test full name follows the following rule:
-        //     java_package_name.class_name#method_name.
-        // Other forms will be treated as illegal.
-        if (!testFullName.matches("(\\w+.)+\\w+")) {
-            throw new IllegalTestNameException(testFullName);
-        }
-
-        Test test = null;
-        TestPackage pkg = null;
-        if (-1 != testFullName.indexOf(Test.METHOD_SEPARATOR)) {
-            test = searchTest(testFullName);
-            if (test == null) {
-                throw new TestNotFoundException(
-                        "The specific test does not exist: " + testFullName);
-            }
-
-            mTestThread = new TestSessionThread(this, test);
-            CUIOutputStream.println("start test " + testFullName);
-        } else {
-            pkg = searchTestPackage(testFullName);
-            if (pkg == null) {
-                throw new TestNotFoundException(
-                        "The specific test package does not exist: " + testFullName);
-            }
-
-            mTestThread = new TestSessionThread(this, pkg, testFullName);
-            CUIOutputStream.println("start java package " + testFullName);
-        }
-
-        mStatus = STATUS.STARTED;
-        startImpl();
-    }
-
-    /**
-     * Implement starting/resuming session.
-     */
-    private void startImpl() throws ADBServerNeedRestartException {
-        String resultPath = mSessionLog.getResultPath();
-        if ((resultPath == null) || (resultPath.length() == 0)) {
-            mSessionLog.setStartTime(System.currentTimeMillis());
-        }
-        resetTestCount();
-        mTestThread.start();
-        try {
-            mTestThread.join();
-        } catch (InterruptedException e) {
-            e.printStackTrace();
-        }
-        if (mNeedRestartAdbServer && HostConfig.getMaxTestCount() > 0) {
-            throw new ADBServerNeedRestartException("Need restart ADB server");
-        }
-    }
-
-    /**
-     * Resume the test session.
-     */
-    public void resume() throws ADBServerNeedRestartException {
-        mStatus = STATUS.RESUMED;
-        mTestThread = new TestSessionThread(this);
-        if (!isADBServerRestartedMode()) {
-            CUIOutputStream.println("resume test plan " + getSessionLog().getTestPlanName()
-                + " (session id = " + mId + ")");
-        }
-        startImpl();
-    }
-
-    /**
-     * Search the test with the test full name given among the test
-     * packages contained within this session.
-     *
-     * @param testFullName The full name of the test.
-     * @return The test with the full name given.
-     */
-    private Test searchTest(final String testFullName) {
-        Test test = null;
-        for (TestPackage pkg : mSessionLog.getTestPackages()) {
-            test = pkg.searchTest(testFullName);
-            if (test != null) {
-                break;
-            }
-        }
-
-        return test;
-    }
-
-    /**
-     * Search the test package with the specified java package name.
-     *
-     * @param javaPkgName The java package name.
-     * @return The test package with the specified java package name.
-     */
-    private TestPackage searchTestPackage(String javaPkgName) {
-        for (TestPackage pkg : mSessionLog.getTestPackages()) {
-            Collection<Test> tests = pkg.getTests();
-            for (Test test : tests) {
-                String testFullName = test.getFullName();
-                if (testFullName.startsWith(javaPkgName)) {
-                    //adjust the java package name to make it equal to some java package name
-                    if (testFullName.charAt(javaPkgName.length()) != '.') {
-                        javaPkgName = javaPkgName.substring(0, javaPkgName.lastIndexOf("."));
-                    }
-                    return pkg;
-                }
-            }
-        }
-
-        return null;
-    }
-    /**
-     * Start a new test session thread to execute the specific test plan.
-     */
-    public void start() throws ADBServerNeedRestartException {
-        mStatus = STATUS.STARTED;
-        mSessionLog.setStartTime(System.currentTimeMillis());
-        mTestThread = new TestSessionThread(this);
-
-        CUIOutputStream.println("start test plan " + getSessionLog().getTestPlanName());
-        startImpl();
-    }
-
-    /**
-     * Set observer.
-     *
-     * @param so Session observer.
-     */
-    public void setObserver(final SessionObserver so) {
-        mSessionObserver = so;
-    }
-
-    /**
-     * Print the message by appending the new line mark.
-     *
-     * @param msg The message to be print.
-     */
-    private void println(final String msg) {
-        if (!mTestStop) {
-            CUIOutputStream.println(msg);
-        }
-    }
-
-    /**
-     * Set the {@link TestDevice} which will run the test.
-     *
-     * @param device The {@link TestDevice} will run the test.
-     */
-    public void setTestDevice(final TestDevice device) {
-        mDevice = device;
-    }
-
-    /**
-     * Get the session log of this session.
-     *
-     * @return The session log of this session.
-     */
-    public TestSessionLog getSessionLog() {
-        return mSessionLog;
-    }
-
-    /**
-     * Get the test packages contained within this session.
-     *
-     * @return The test packages contained within this session.
-     */
-    public Collection<TestPackage> getTestPackages() {
-        return mSessionLog.getTestPackages();
-    }
-
-    /**
-     * The Thread to be run the {@link TestSession}
-     */
-    class TestSessionThread extends Thread {
-        private final int MSEC_PER_SECOND = 1000;
-
-        private TestSession mTestSession;
-        private Test mTest;
-        private TestPackage mTestPackage;
-        private String mJavaPackageName;
-        private ResultObserver mResultObserver;
-
-        public TestSessionThread(final TestSession ts) {
-            mTestSession = ts;
-            mResultObserver = ResultObserver.getInstance();
-        }
-
-        public TestSessionThread(final TestSession ts, final Test test) {
-            mTestSession = ts;
-            mResultObserver = ResultObserver.getInstance();
-            mTest = test;
-        }
-
-        public TestSessionThread(final TestSession ts,
-                final TestPackage pkg, final String javaPkgName) {
-            mTestSession = ts;
-            mResultObserver = ResultObserver.getInstance();
-            mTestPackage = pkg;
-            mJavaPackageName = javaPkgName;
-        }
-
-        /** {@inheritDoc} */
-        @Override
-        public void run() {
-            Log.d("Start a test session.");
-            mNeedRestartAdbServer = false;
-            mResultObserver.setTestSessionLog(getSessionLog());
-            mResultObserver.start();
-
-            try {
-                if (mTest != null) {
-                    TestPackage pkg = mTest.getTestPackage();
-                    pkg.setSessionThread(this);
-                    pkg.runTest(mDevice, mTest);
-                } else if (mTestPackage != null) {
-                    mTestPackage.setSessionThread(this);
-                    mTestPackage.run(mDevice, mJavaPackageName, mSessionLog);
-                } else {
-                    for (TestPackage pkg : mSessionLog.getTestPackages()) {
-                        if (!pkg.isAllTestsRun()) {
-                            pkg.setSessionThread(this);
-                            pkg.run(mDevice, null, mSessionLog);
-                            if (!isAllTestsRun()) {
-                                if (HostConfig.getMaxTestCount() > 0) {
-                                    // ADB server restart enabled
-                                    markNeedRestartADBServer();
-                                    return;
-                                }
-                            } else {
-                                Log.d("All tests have been run.");
-                                break;
-                            }
-                        }
-                    }
-                    mNeedRestartAdbServer = false;
-                    displayTestResultSummary();
-                }
-            } catch (IOException e) {
-                Log.e("Got exception when running the package", e);
-            } catch (DeviceDisconnectedException e) {
-                Log.e("Device " + e.getMessage() + " disconnected ", null);
-            } catch (ADBServerNeedRestartException e) {
-                Log.d(e.getMessage());
-                if (mTest == null) {
-                    markNeedRestartADBServer();
-                    return;
-                }
-            } catch (InvalidApkPathException e) {
-                Log.e(e.getMessage(), null);
-            } catch (InvalidNameSpaceException e) {
-                Log.e(e.getMessage(), null);
-            }
-
-            long startTime = getSessionLog().getStartTime().getTime();
-            displayTimeInfo(startTime, System.currentTimeMillis());
-
-            mStatus = STATUS.FINISHED;
-            mTestSession.getSessionLog().setEndTime(System.currentTimeMillis());
-            mSessionObserver.notifyFinished(mTestSession);
-            notifyResultObserver();
-        }
-
-        /**
-         * Mark need restarting ADB server.
-         */
-        private void markNeedRestartADBServer() {
-            Log.d("mark mNeedRestartAdbServer to true");
-            mNeedRestartAdbServer = true;
-            mStatus = STATUS.FINISHED;
-            notifyResultObserver();
-            return;
-        }
-
-        /**
-         * Notify result observer.
-         */
-        private void notifyResultObserver() {
-            mResultObserver.notifyUpdate();
-            mResultObserver.finish();
-        }
-
-        /**
-         * Check if all tests contained in all of the test packages has been run.
-         *
-         * @return If all tests have been run, return true; else, return false.
-         */
-        private boolean isAllTestsRun() {
-            Collection<TestPackage> pkgs = getTestPackages();
-            for (TestPackage pkg : pkgs) {
-                if (!pkg.isAllTestsRun()) {
-                    return false;
-                }
-            }
-            return true;
-        }
-
-        /**
-         * Display the summary of test result.
-         */
-        private void displayTestResultSummary() {
-            int passNum = mSessionLog.getTestList(CtsTestResult.CODE_PASS).size();
-            int failNum = mSessionLog.getTestList(CtsTestResult.CODE_FAIL).size();
-            int notExecutedNum = mSessionLog.getTestList(CtsTestResult.CODE_NOT_EXECUTED).size();
-            int timeOutNum = mSessionLog.getTestList(CtsTestResult.CODE_TIMEOUT).size();
-            int total = passNum + failNum + notExecutedNum + timeOutNum;
-
-            println("Test summary:   pass=" + passNum
-                    + "   fail=" + failNum
-                    + "   timeOut=" + timeOutNum
-                    + "   notExecuted=" + notExecutedNum
-                    + "   Total=" + total);
-        }
-
-        /**
-         * Display the time information of running a test plan.
-         *
-         * @param startTime start time in milliseconds.
-         * @param endTime end time in milliseconds.
-         */
-        private void displayTimeInfo(final long startTime, final long endTime) {
-            long diff = endTime - startTime;
-            long seconds = diff / MSEC_PER_SECOND;
-            long millisec = diff % MSEC_PER_SECOND;
-            println("Time: " + seconds + "." + millisec + "s\n");
-        }
-    }
-
-    /**
-     * Update test result after executing each test.
-     * During running test, the process may be interrupted. To avoid
-     * test result losing, it's needed to update the test result into
-     * xml file after executing each test, which is done by this observer.
-     * The possible reasons causing interruption to the process include:
-     * <ul>
-     *    <li> Device disconnected
-     *    <li> Run time exception
-     *    <li> System crash
-     *    <li> User action to cause the system exit
-     * </ul>
-     *
-     */
-   static class ResultObserver {
-        static private boolean mFinished = false;
-        static private boolean mNotified = false; //used for avoiding race condition
-        static private boolean mNeedUpdate = true;
-        static private TestSessionLog mSessionLog;
-        static final ResultObserver sInstance = new ResultObserver();
-
-        private Observer mObserver;
-        /**
-         * Get the static instance.
-         *
-         * @return The static instance.
-         */
-        public static final ResultObserver getInstance() {
-            return sInstance;
-        }
-
-        /**
-         * Set TestSessionLog.
-         *
-         * @param log The TestSessionLog.
-         */
-        public void setTestSessionLog(TestSessionLog log) {
-            mSessionLog = log;
-        }
-
-        /**
-         * Notify this updating thread to update the test result to xml file.
-         */
-        public void notifyUpdate() {
-            if (mObserver != null) {
-                synchronized (mObserver) {
-                    mNotified = true;
-                    mObserver.notify();
-                }
-            }
-        }
-
-        /**
-         * Start the observer.
-         */
-        public void start() {
-            mFinished = false;
-            mNeedUpdate = true;
-            mObserver = new Observer();
-            mObserver.start();
-        }
-
-        /**
-         * Finish updating.
-         */
-        public void finish() {
-            mFinished = true;
-            mNeedUpdate = false;
-            notifyUpdate();
-            try {
-                mObserver.join();
-                mObserver = null;
-            } catch (InterruptedException e) {
-            }
-        }
-
-        /**
-         * Observer which updates the test result to result XML file.
-         *
-         */
-        class Observer extends Thread {
-
-            /** {@inheritDoc} */
-            @Override
-            public void run() {
-                while (!mFinished) {
-                    try {
-                        synchronized (this) {
-                            if ((!mNotified) && (!mFinished)) {
-                                wait();
-                            }
-
-                            mNotified = false;
-                        }
-
-                        if (mNeedUpdate && (mSessionLog != null)) {
-                            mSessionLog.sessionComplete();
-                        }
-                    } catch (InterruptedException e) {
-                    }
-                }
-            }
-        }
-    }
-}
diff --git a/tools/host/src/com/android/cts/TestSessionBuilder.java b/tools/host/src/com/android/cts/TestSessionBuilder.java
deleted file mode 100644
index fd520a7..0000000
--- a/tools/host/src/com/android/cts/TestSessionBuilder.java
+++ /dev/null
@@ -1,589 +0,0 @@
-/*
- * Copyright (C) 2008 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.cts;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.xml.sax.SAXException;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.security.NoSuchAlgorithmException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactoryConfigurationError;
-
-/**
- * Builder of test plan and also provides serialization for a test plan.
- */
-public class TestSessionBuilder extends XMLResourceHandler {
-    // defined for external document, which is from the configuration files
-    // this should keep synchronized with the format of the configuration files
-
-    private static final String TAG_TEST_SUITE = "TestSuite";
-    private static final String TAG_TEST_CASE = "TestCase";
-    public static final String TAG_TEST = "Test";
-
-    // attribute name define
-    public static final String ATTRIBUTE_SIGNATURE_CHECK = "signatureCheck";
-    public static final String ATTRIBUTE_REFERENCE_APP_TEST = "referenceAppTest";
-    public static final String ATTRIBUTE_PRIORITY = "priority";
-
-    private static final String ATTRIBUTE_NAME = "name";
-    private static final String ATTRIBUTE_RUNNER = "runner";
-    private static final String ATTRIBUTE_JAR_PATH = "jarPath";
-    private static final String ATTRIBUTE_APP_NAME_SPACE = "appNameSpace";
-    public static final String ATTRIBUTE_APP_PACKAGE_NAME = "appPackageName";
-    private static final String ATTRIBUTE_TARGET_NAME_SPACE = "targetNameSpace";
-    private static final String ATTRIBUTE_TARGET_BINARY_NAME = "targetBinaryName";
-    private static final String ATTRIBUTE_TYPE = "type";
-    private static final String ATTRIBUTE_CONTROLLER = "HostController";
-    private static final String ATTRIBUTE_KNOWN_FAILURE = "KnownFailure";
-    private static final String ATTRIBUTE_HOST_SIDE_ONLY = "hostSideOnly";
-    private static final String ATTRIBUTE_VERSION = "version";
-    private static final String ATTRIBUTE_FRAMEWORK_VERSION = "AndroidFramework";
-    private static final String ATTRIBUTE_APK_TO_TEST_NAME = "apkToTestName";
-    private static final String ATTRIBUTE_PACKAGE_TO_TEST = "packageToTest";
-    private static final String ATTRIBUTE_JAVA_PACKAGE_FILTER = "javaPackageFilter";
-    private static TestSessionBuilder sInstance;
-
-    private DocumentBuilder mDocBuilder;
-
-    public static TestSessionBuilder getInstance()
-            throws ParserConfigurationException {
-        if (sInstance == null) {
-            sInstance = new TestSessionBuilder();
-        }
-
-        return sInstance;
-    }
-
-    private TestSessionBuilder() throws ParserConfigurationException {
-        mDocBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
-    }
-
-    /**
-     * Create TestSession via TestSessionLog.
-     *
-     * @param log The test session log.
-     * @return The test session.
-     */
-    public TestSession build(TestSessionLog log) {
-        if (log == null) {
-            return null;
-        }
-        return new TestSession(log, 1);
-    }
-
-    /**
-     * Create TestSession via TestPlan XML configuration file.
-     *
-     * @param config TestPlan XML configuration file.
-     * @return TestSession.
-     */
-    public TestSession build(final String config) throws SAXException, IOException,
-            TestPlanNotFoundException, TestNotFoundException, NoSuchAlgorithmException {
-        File file = new File(config);
-        if (!file.exists()) {
-            throw new TestPlanNotFoundException();
-        }
-        Document doc = mDocBuilder.parse(file);
-
-        // parse device configuration
-        int numOfRequiredDevices = 1; // default is 1
-        try {
-            Node deviceConfigNode = doc.getElementsByTagName(
-                    TestPlan.Tag.REQUIRED_DEVICE).item(0);
-            numOfRequiredDevices = getAttributeValue(deviceConfigNode,
-                    TestPlan.Attribute.AMOUNT);
-        } catch (Exception e) {
-        }
-
-        Collection<TestPackage> packages = loadPackages(doc);
-        if (packages.size() == 0) {
-            throw new TestNotFoundException("No valid package in test plan.");
-        }
-
-        String planFileName = file.getName();
-        int index = planFileName.indexOf(".");
-        String planName;
-        if (index != -1) {
-            planName = planFileName.substring(0, planFileName.indexOf("."));
-        } else{
-            planName = planFileName;
-        }
-
-        TestSessionLog sessionLog = new TestSessionLog(packages, planName);
-        TestSession ts = new TestSession(sessionLog, numOfRequiredDevices);
-        return ts;
-    }
-
-    /**
-     * Load TestPackages from a TestPlan DOM doc.
-     *
-     * @param doc TestPlan DOM Document
-     * @return loaded test package from TestPlan DOM Document
-     */
-    private Collection<TestPackage> loadPackages(Document doc)
-                throws SAXException, IOException, NoSuchAlgorithmException {
-
-        ArrayList<TestPackage> packages = new ArrayList<TestPackage>();
-        NodeList packageList = doc.getElementsByTagName(TestPlan.Tag.ENTRY);
-        ArrayList<String> removedPkgList = new ArrayList<String>();
-        for (int i = 0; i < packageList.getLength(); i++) {
-            Node pNode = packageList.item(i);
-            String uri = getStringAttributeValue(pNode, TestPlan.Attribute.URI);
-            String list = getStringAttributeValue(pNode, TestPlan.Attribute.EXCLUDE);
-            ArrayList<String> excludedList = null;
-            if ((list != null) && (list.length() != 0)) {
-                excludedList = getStrArrayList(list);
-            }
-
-            String packageBinaryName = HostConfig.getInstance().getPackageBinaryName(uri);
-            if (packageBinaryName != null) {
-                String xmlConfigFilePath =
-                       HostConfig.getInstance().getCaseRepository().getXmlPath(packageBinaryName);
-                File xmlFile = new File(xmlConfigFilePath);
-                TestPackage pkg = loadPackage(xmlFile, excludedList);
-                if (pkg instanceof SignatureCheckPackage) {
-                    // insert the signature check package
-                    // to the head of the list
-                    packages.add(0, pkg);
-                } else {
-                    packages.add(pkg);
-                }
-            } else{
-                removedPkgList.add(uri);
-            }
-        }
-        if (removedPkgList.size() != 0) {
-            CUIOutputStream.println("The following package(s) doesn't exist:");
-            for (String pkgName : removedPkgList) {
-                CUIOutputStream.println("    " + pkgName);
-            }
-        }
-        return packages;
-    }
-
-    /**
-     * Load TestPackage via Package XML configuration file.
-     *
-     * @param packageConfigFile test package XML file
-     * @param excludedList The list containing the excluded suites and sub types.
-     * @return loaded TestPackage from test package XML configuration file
-     */
-    public TestPackage loadPackage(final File packageConfigFile, ArrayList<String> excludedList)
-                                throws SAXException, IOException, NoSuchAlgorithmException {
-        Node pNode = mDocBuilder.parse(packageConfigFile).getDocumentElement();
-        return loadPackage(pNode, excludedList);
-    }
-
-    /**
-     * Load TestPackage via Package XML configuration file.
-     *
-     * @param pkgNode the test package node in the XML file
-     * @param excludedList The list containing the excluded suites and sub types.
-     * @return loaded TestPackage from test package XML configuration file
-     */
-    public TestPackage loadPackage(final Node pkgNode, ArrayList<String> excludedList)
-                                throws NoSuchAlgorithmException {
-
-        NodeList suiteList = pkgNode.getChildNodes();
-
-        String appBinaryName = getStringAttributeValue(pkgNode, ATTRIBUTE_NAME);
-        String targetNameSpace = getStringAttributeValue(pkgNode, ATTRIBUTE_TARGET_NAME_SPACE);
-        String targetBinaryName = getStringAttributeValue(pkgNode, ATTRIBUTE_TARGET_BINARY_NAME);
-        String version = getStringAttributeValue(pkgNode, ATTRIBUTE_VERSION);
-        String frameworkVersion = getStringAttributeValue(pkgNode, ATTRIBUTE_FRAMEWORK_VERSION);
-        String runner = getStringAttributeValue(pkgNode, ATTRIBUTE_RUNNER);
-        String jarPath = getStringAttributeValue(pkgNode, ATTRIBUTE_JAR_PATH);
-        String appNameSpace = getStringAttributeValue(pkgNode, ATTRIBUTE_APP_NAME_SPACE);
-        String appPackageName = getStringAttributeValue(pkgNode, ATTRIBUTE_APP_PACKAGE_NAME);
-        String hostSideOnly = getStringAttributeValue(pkgNode, ATTRIBUTE_HOST_SIDE_ONLY);
-        String signature = getStringAttributeValue(pkgNode, ATTRIBUTE_SIGNATURE_CHECK);
-        String referenceAppTest = getStringAttributeValue(pkgNode, ATTRIBUTE_REFERENCE_APP_TEST);
-        String javaPackageFilter = getStringAttributeValue(pkgNode, ATTRIBUTE_JAVA_PACKAGE_FILTER);
-        TestPackage pkg = null;
-
-        if ("true".equals(referenceAppTest)) {
-            String apkToTestName = getStringAttributeValue(pkgNode, ATTRIBUTE_APK_TO_TEST_NAME);
-            String packageUnderTest = getStringAttributeValue(pkgNode, ATTRIBUTE_PACKAGE_TO_TEST);
-            pkg = new ReferenceAppTestPackage(runner, appBinaryName, targetNameSpace,
-                    targetBinaryName, version, frameworkVersion, jarPath,
-                    appNameSpace, appPackageName,
-                    apkToTestName, packageUnderTest);
-        } else if ("true".equals(signature)) {
-            pkg = new SignatureCheckPackage(runner, appBinaryName, targetNameSpace,
-                    targetBinaryName, version, frameworkVersion, jarPath,
-                    appNameSpace, appPackageName);
-        } else if ("true".equals(hostSideOnly)) {
-            pkg = new HostSideOnlyPackage(appBinaryName, version, frameworkVersion,
-                    jarPath, appPackageName);
-        } else {
-            pkg = new TestPackage(runner, appBinaryName, targetNameSpace, targetBinaryName, version,
-                    frameworkVersion, jarPath, appNameSpace, appPackageName, javaPackageFilter);
-        }
-
-        for (int i = 0; i < suiteList.getLength(); i++) {
-            Node sNode = suiteList.item(i);
-            if (sNode.getNodeType() == Document.ELEMENT_NODE
-                    && TAG_TEST_SUITE.equals(sNode.getNodeName())) {
-                String fullSuiteName = getFullSuiteName(sNode);
-                if (checkFullMatch(excludedList, fullSuiteName) == false) {
-                    ArrayList<String> excludedCaseList =
-                                          getExcludedList(excludedList, fullSuiteName);
-                    TestSuite suite = loadSuite(pkg, sNode, excludedCaseList);
-                    if ((suite.getTestCases().size() != 0) || (suite.getSubSuites().size() != 0)) {
-                        pkg.addTestSuite(suite);
-                    }
-                } else {
-                    Log.d("suite=" + fullSuiteName + " is fully excluded");
-                }
-            }
-        }
-
-        return pkg;
-    }
-
-    /**
-     * Get string ArrayList from string.
-     *
-     * @param str The given string.
-     * @return The list.
-     */
-    private ArrayList<String> getStrArrayList(String str) {
-        if ((str == null) || (str.length() == 0)) {
-            return null;
-        }
-
-        String[] list = str.split(TestPlan.EXCLUDE_SEPARATOR);
-        if ((list == null) || (list.length == 0)) {
-            return null;
-        }
-
-        ArrayList<String> result = new ArrayList<String>();
-        for (String s : list) {
-            result.add(s);
-        }
-
-        return result;
-    }
-
-    /**
-     * Get excluded list from a list by offered expectation.
-     *
-     * @param excludedList The list containing excluded items.
-     * @param expectation The expectations.
-     * @return The excluded list.
-     */
-    private ArrayList<String> getExcludedList(ArrayList<String> excludedList, String expectation) {
-        if ((excludedList == null) || (excludedList.size() == 0)) {
-            return null;
-        }
-
-        ArrayList<String> list = new ArrayList<String>();
-        for (String str : excludedList) {
-            if (str.startsWith(expectation)) {
-                list.add(str);
-            }
-        }
-
-        if (list.size() == 0) {
-            return null;
-        } else {
-            return list;
-        }
-    }
-
-    /**
-     * Check if the expectation is fully matched among a list.
-     *
-     * @param list The array list.
-     * @param expectation The expectation.
-     * @return If there is full match of expectation among the list, return true;
-     *         else, return false.
-     */
-    private boolean checkFullMatch(ArrayList<String> list, String expectation) {
-        if ((list == null) || (list.size() == 0)) {
-            return false;
-        }
-
-        for (String str : list) {
-            if (str.equals(expectation)) {
-                return true;
-            }
-        }
-
-        return false;
-    }
-
-    /**
-     * Load TestSuite via suite node. Package Name is used to output test result.
-     *
-     * @param pkg TestPackage
-     * @param sNode suite node
-     * @param excludedCaseList The list containing the excluded cases and sub types.
-     * @return TestSuite
-     */
-    private TestSuite loadSuite(final TestPackage pkg, Node sNode,
-                                ArrayList<String> excludedCaseList) {
-        NodeList cNodes = sNode.getChildNodes();
-        String fullSuiteName = getFullSuiteName(sNode);
-        String suiteName = getStringAttributeValue(sNode, TestPlan.Attribute.NAME);
-        TestSuite suite = new TestSuite(pkg, suiteName, fullSuiteName);
-
-        for (int i = 0; i < cNodes.getLength(); i++) {
-            Node cNode = cNodes.item(i);
-            if (cNode.getNodeType() == Document.ELEMENT_NODE) {
-                if (cNode.getNodeName().equals(TAG_TEST_SUITE)) {
-                    String subSuiteName = getFullSuiteName(cNode);
-                    if (checkFullMatch(excludedCaseList, subSuiteName) == false) {
-                        ArrayList<String> excludedList = getExcludedList(excludedCaseList,
-                                                             subSuiteName);
-                        TestSuite subSuite = loadSuite(pkg, cNode, excludedList);
-                        if ((subSuite.getTestCases().size() != 0)
-                            || (subSuite.getSubSuites().size() != 0)) {
-                            suite.addSubSuite(subSuite);
-                        }
-                    } else {
-                        Log.d("suite=" + subSuiteName + " is fully excluded");
-                    }
-                } else if (cNode.getNodeName().equals(TAG_TEST_CASE)) {
-                    String cName = getStringAttributeValue(cNode, ATTRIBUTE_NAME);
-                    String priority = getStringAttributeValue(cNode, ATTRIBUTE_PRIORITY);
-
-                    TestCase testCase = new TestCase(suite, cName, priority);
-                    String fullCaseName = fullSuiteName + "." + testCase.getName();
-                    if (checkFullMatch(excludedCaseList, fullCaseName) == false) {
-                        NodeList mNodes = cNode.getChildNodes();
-                        for (int t = 0; t < mNodes.getLength(); t ++) {
-                            Node testNode = mNodes.item(t);
-                            if ((testNode.getNodeType() == Document.ELEMENT_NODE)
-                                    && (testNode.getNodeName().equals(TAG_TEST))) {
-                                Test test = loadTest(pkg, testCase, testNode);
-                                if (!checkFullMatch(excludedCaseList, test.getFullName())) {
-                                    testCase.addTest(test);
-                                } else {
-                                    Log.d("Test=" + test.getFullName() + " is excluded");
-                                }
-                            }
-                        }
-                        if (testCase.getTests().size() != 0) {
-                            suite.addTestCase(testCase);
-                        }
-                    } else {
-                        Log.d("case=" + fullCaseName + " is fully excluded");
-                    }
-                }
-            }
-        }
-
-        return suite;
-    }
-
-    /**
-     * Load test via test node.
-     *
-     * @param pkg The test package.
-     * @param testCase The test case.
-     * @param testNode The test node.
-     * @return The test loaded.
-     */
-    private Test loadTest(final TestPackage pkg, TestCase testCase,
-            Node testNode) {
-        String cType = getStringAttributeValue(testNode, ATTRIBUTE_TYPE);
-        String name = getStringAttributeValue(testNode, ATTRIBUTE_NAME);
-        String description = getStringAttributeValue(testNode,
-                ATTRIBUTE_CONTROLLER);
-        String knownFailure = getStringAttributeValue(testNode,
-                ATTRIBUTE_KNOWN_FAILURE);
-        String fullJarPath =
-            HostConfig.getInstance().getCaseRepository().getRoot()
-            + File.separator + pkg.getJarPath();
-        CtsTestResult testResult = loadTestResult(testNode);
-        Test test = null;
-        if (pkg.isHostSideOnly()) {
-            test = new HostSideOnlyTest(testCase, name, cType,
-                    knownFailure,
-                    CtsTestResult.CODE_NOT_EXECUTED);
-            description = test.getFullName();
-        } else {
-            test = new Test(testCase, name, cType,
-                    knownFailure,
-                    CtsTestResult.CODE_NOT_EXECUTED);
-        }
-
-        TestController controller =
-            genTestControler(fullJarPath, description);
-        test.setTestController(controller);
-        if (testResult != null) {
-            test.addResult(testResult);
-        }
-        return test;
-    }
-
-    /**
-     * Load the CTS test result from the test node.
-     *
-     * @param testNode The test node.
-     * @return The CTS test result.
-     */
-    private CtsTestResult loadTestResult(Node testNode) {
-        String result = getStringAttributeValue(testNode,
-                TestSessionLog.ATTRIBUTE_RESULT);
-
-        String failedMessage = null;
-        String stackTrace = null;
-        NodeList nodes = testNode.getChildNodes();
-        for (int i = 0; i < nodes.getLength(); i ++) {
-            Node rNode = nodes.item(i);
-            if ((rNode.getNodeType() == Document.ELEMENT_NODE)
-                    && (rNode.getNodeName().equals(TestSessionLog.TAG_FAILED_SCENE))) {
-                failedMessage = getStringAttributeValue(rNode, TestSessionLog.TAG_FAILED_MESSAGE);
-                stackTrace = getStringAttributeValue(rNode, TestSessionLog.TAG_STACK_TRACE);
-                if (stackTrace == null) {
-                    NodeList sNodeList = rNode.getChildNodes();
-                    for (int j = 0; j < sNodeList.getLength(); j ++) {
-                        Node sNode = sNodeList.item(i);
-                        if ((sNode.getNodeType() == Document.ELEMENT_NODE)
-                                && (sNode.getNodeName().equals(TestSessionLog.TAG_STACK_TRACE))) {
-                            stackTrace = sNode.getTextContent();
-                        }
-                    }
-                }
-                break;
-            }
-        }
-
-        CtsTestResult testResult = null;
-        if (result != null) {
-            try {
-                testResult = new CtsTestResult(result, failedMessage, stackTrace);
-            } catch (InvalidTestResultStringException e) {
-            }
-        }
-
-        return testResult;
-    }
-
-    /**
-     * Generate controller according to the description string.
-     *
-     * @return The test controller.
-     */
-    public TestController genTestControler(String jarPath, String description) {
-        if ((jarPath == null) || (jarPath.length() == 0)
-                || (description == null) || (description.length() == 0)) {
-            return null;
-        }
-
-        String packageName = description.substring(0, description.lastIndexOf("."));
-        String className   = description.substring(packageName.length() + 1,
-                             description.lastIndexOf(Test.METHOD_SEPARATOR));
-        String methodName  = description.substring(
-                             description.lastIndexOf(Test.METHOD_SEPARATOR) + 1,
-                             description.length());
-
-        return new TestController(jarPath, packageName, className, methodName);
-    }
-
-    /**
-     * Get the full suite name of the specified suite node. Since the test
-     * suite can be nested, so the full name of a tests suite is combined
-     * with his name and his ancestor suite's names.
-     *
-     * @param node The specified suite node.
-     * @return The full name of the given suite node.
-     */
-    private String getFullSuiteName(Node node) {
-        StringBuilder buf = new StringBuilder();
-        buf.append(getStringAttributeValue(node, TestPlan.Attribute.NAME));
-
-        Node parent = node.getParentNode();
-        while (parent != null) {
-            if (parent.getNodeType() == Document.ELEMENT_NODE
-                    && parent.getNodeName() == TAG_TEST_SUITE) {
-                buf.insert(0, ".");
-                buf.insert(0, getStringAttributeValue(parent, TestPlan.Attribute.NAME));
-            }
-
-            parent = parent.getParentNode();
-        }
-
-        return buf.toString();
-    }
-
-    /**
-     * Create TestPlan which contain a series TestPackages.
-     *
-     * @param planName test plan name
-     * @param packageNames Package names to be added
-     * @param selectedResult The selected result mapping selected
-     *                       package with selected removal result.
-     */
-    public void serialize(String planName,
-            ArrayList<String> packageNames, HashMap<String, ArrayList<String>> selectedResult)
-            throws ParserConfigurationException, FileNotFoundException, IOException,
-            TransformerFactoryConfigurationError, TransformerException {
-        File plan = new File(HostConfig.getInstance().getPlanRepository()
-                .getPlanPath(planName));
-        if (plan.exists()) {
-            Log.e("Plan " + planName + " already exist, please use another name!",
-                    null);
-            return;
-        }
-
-        Document doc = DocumentBuilderFactory.newInstance()
-                .newDocumentBuilder().newDocument();
-        Node root = doc.createElement(TestPlan.Tag.TEST_PLAN);
-        setAttribute(doc, root, ATTRIBUTE_VERSION, "1.0");
-        doc.appendChild(root);
-
-        // append device configure node
-        Node deviceConfigNode = doc.createElement(TestPlan.Tag.PLAN_SETTING);
-
-        root.appendChild(deviceConfigNode);
-
-        // append test packages
-        for (String pName : packageNames) {
-            if (selectedResult.containsKey(pName)) {
-                Node entryNode = doc.createElement(TestPlan.Tag.ENTRY);
-
-                setAttribute(doc, entryNode, TestPlan.Attribute.URI, pName);
-                ArrayList<String> excluded = selectedResult.get(pName);
-                if ((excluded != null) && (excluded.size() != 0)) {
-                    String excludedList = "";
-                    for (String str : excluded) {
-                        excludedList += str + TestPlan.EXCLUDE_SEPARATOR;
-                    }
-                    setAttribute(doc, entryNode, TestPlan.Attribute.EXCLUDE, excludedList);
-                }
-                root.appendChild(entryNode);
-            }
-        }
-
-        writeToFile(plan, doc);
-    }
-
-}
diff --git a/tools/host/src/com/android/cts/TestSessionLog.java b/tools/host/src/com/android/cts/TestSessionLog.java
deleted file mode 100644
index 7eb9ffd..0000000
--- a/tools/host/src/com/android/cts/TestSessionLog.java
+++ /dev/null
@@ -1,613 +0,0 @@
-/*
- * Copyright (C) 2008 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.cts;
-
-import com.android.cts.TestDevice.DeviceParameterCollector;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-import org.w3c.dom.ProcessingInstruction;
-
-import java.io.File;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Date;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import javax.xml.parsers.DocumentBuilderFactory;
-
-/**
- * Store the information of a test plan.
- */
-public class TestSessionLog extends XMLResourceHandler {
-    private static final String EXPR_TEST_FAILED = ".+\\((\\S+):(\\d+)\\)";
-    private static Pattern mTestFailedPattern = Pattern.compile(EXPR_TEST_FAILED);
-    private static final String ATTRIBUTE_NAME = "name";
-    static final String ATTRIBUTE_RESULT = "result";
-    private static final String ATTRIBUTE_VERSION = "version";
-    private static final String ATTRIBUTE_DIGEST = "digest";
-    private static final String ATTRIBUTE_KNOWN_FAILURE = "KnownFailure";
-
-    public static final String CTS_RESULT_FILE_NAME = "testResult.xml";
-    private static final String CTS_RESULT_FILE_VERSION = "1.11";
-
-    static final String ATTRIBUTE_STARTTIME = "starttime";
-    static final String ATTRIBUTE_ENDTIME = "endtime";
-    static final String ATTRIBUTE_TESTPLAN = "testPlan";
-    static final String ATTRIBUTE_RESOLUTION = "resolution";
-    static final String ATTRIBUTE_SUBSCRIBER_ID = "subscriberId";
-    static final String ATTRIBUTE_DEVICE_ID = "deviceID";
-    static final String ATTRIBUTE_BUILD_ID = "buildID";
-    static final String ATTRIBUTE_BUILD_VERSION = "buildVersion";
-    static final String ATTRIBUTE_ANDROID_PLATFORM_VERSION = "androidPlatformVersion";
-    static final String ATTRIBUTE_LOCALES = "locales";
-    static final String ATTRIBUTE_XDPI = "Xdpi";
-    static final String ATTRIBUTE_YDPI = "Ydpi";
-    static final String ATTRIBUTE_TOUCH = "touch";
-    static final String ATTRIBUTE_NAVIGATION = "navigation";
-    static final String ATTRIBUTE_KEYPAD = "keypad";
-    static final String ATTRIBUTE_NETWORK = "network";
-    static final String ATTRIBUTE_IMEI = "imei";
-    static final String ATTRIBUTE_IMSI = "imsi";
-    static final String ATTRIBUTE_BUILD_NAME = "buildName";
-    static final String ATTRIBUTE_ARCH = "arch";
-    static final String ATTRIBUTE_VALUE = "value";
-    static final String ATTRIBUTE_AVAILABLE = "available";
-    static final String ATTRIBUTE_TYPE = "type";
-    static final String ATTRIBUTE_UID = "uid";
-    static final String ATTRIBUTE_OPEN_GL_ES_VERSION = "openGlEsVersion";
-    static final String ATTRIBUTE_PARTITIONS = "partitions";
-
-    static final String ATTRIBUTE_PASS = "pass";
-    static final String ATTRIBUTE_FAILED = "failed";
-    static final String ATTRIBUTE_TIMEOUT = "timeout";
-    static final String ATTRIBUTE_NOT_EXECUTED = "notExecuted";
-
-    static final String TAG_DEVICEINFO = "DeviceInfo";
-    static final String TAG_HOSTINFO = "HostInfo";
-    static final String TAG_OSINFO = "Os";
-    static final String TAG_JAVA = "Java";
-    static final String TAG_CTS = "Cts";
-    static final String TAG_INTVALUE = "IntValue";
-    static final String TAG_SUMMARY = "Summary";
-    static final String TAG_SCREEN = "Screen";
-    static final String TAG_BUILD_INFO = "BuildInfo";
-    static final String TAG_FEATURE_INFO = "FeatureInfo";
-    static final String TAG_FEATURE = "Feature";
-    static final String TAG_PROCESS_INFO = "ProcessInfo";
-    static final String TAG_PROCESS = "Process";
-    static final String TAG_PHONE_SUB_INFO = "PhoneSubInfo";
-    static final String TAG_TEST_RESULT = "TestResult";
-    static final String TAG_TESTPACKAGE = "TestPackage";
-    static final String TAG_TESTSUITE = "TestSuite";
-    static final String TAG_TESTCASE = "TestCase";
-    static final String TAG_FAILED_SCENE = "FailedScene";
-    static final String TAG_STACK_TRACE = "StackTrace";
-    static final String TAG_FAILED_MESSAGE = "message";
-
-    private Collection<TestPackage> mTestPackages;
-    private Date mSessionStartTime;
-    private Date mSessionEndTime;
-    private String mResultPath;
-    private String mResultDir;
-    private String mTestPlanName;
-
-    private ArrayList<DeviceParameterCollector> mDeviceParameterBase;
-
-    public TestSessionLog(final Collection<TestPackage> packages, final String testPlanName) {
-        mTestPackages = packages;
-
-        mDeviceParameterBase = new ArrayList<TestDevice.DeviceParameterCollector>();
-        mTestPlanName = testPlanName;
-
-        mSessionStartTime = new Date();
-        mSessionEndTime = new Date();
-    }
-
-    /**
-     * Get the test plan name.
-     *
-     * @return The test plan name.
-     */
-    public String getTestPlanName() {
-        return mTestPlanName;
-    }
-
-    /**
-     * Get all result of this session.
-     *
-     * @return All the tests with a result code of this session.
-     */
-    public Collection<Test> getAllResults() {
-        if (mTestPackages == null || mTestPackages.size() == 0) {
-            return null;
-        }
-
-        ArrayList<Test> results = new ArrayList<Test>();
-        for (TestPackage p : mTestPackages) {
-            results.addAll(p.getTests());
-        }
-
-        return results;
-    }
-
-    /**
-     * Get test list according to the result type code.
-     *
-     * @param resCode The result code.
-     * @return The list of {@link Test}.
-     */
-    public Collection<Test> getTestList(int resCode) {
-        if ((resCode < CtsTestResult.CODE_FIRST)
-                || (resCode > CtsTestResult.CODE_LAST)) {
-            return null;
-        }
-
-        ArrayList<Test> tests = new ArrayList<Test>();
-        for (Test test : getAllResults()) {
-            if (resCode == test.getResult().getResultCode()) {
-                tests.add(test);
-            }
-        }
-
-        return tests;
-    }
-
-    /**
-     * Get TestSession start time
-     *
-     * @return The start time.
-     */
-    public Date getStartTime() {
-        return mSessionStartTime;
-    }
-
-    /**
-     * Get TestSession end time
-     *
-     * @return The end time.
-     */
-    public Date getEndTime() {
-        return mSessionEndTime;
-    }
-
-    /**
-     * Get test packages.
-     *
-     * @return The test packages.
-     */
-    public Collection<TestPackage> getTestPackages() {
-        return mTestPackages;
-    }
-
-    /**
-     * Get the path to the XML result file.
-     *
-     * @return The result path.
-     */
-    public String getResultPath() {
-        return mResultPath;
-    }
-
-    /**
-     * Get the result directory.  This is the directory that all result files
-     * should go into.
-     */
-    public String getResultDir() {
-        return mResultDir;
-    }
-
-    /**
-     * set TestSession start time
-     *
-     * @param time The start time.
-     */
-    public void setStartTime(final long time) {
-        mSessionStartTime.setTime(time);
-
-        String startTimeStr = HostUtils.getFormattedTimeString(time, "_", ".", ".");
-        mResultDir = HostConfig.getInstance().getResultRepository().getRoot()
-            + File.separator + startTimeStr;
-        mResultPath =  mResultDir + File.separator + CTS_RESULT_FILE_NAME;
-        // Make sure the result directory exists
-        new File(mResultDir).mkdirs();
-    }
-
-    /**
-     * set TestSession end time
-     *
-     * @param time The end time.
-     */
-    public void setEndTime(final long time) {
-        mSessionEndTime.setTime(time);
-    }
-
-    /**
-     * Calling this functions indicates that the TestSession is complete.  This
-     * indicates to the TestSessionLog that it is time to store the results
-     * to the filesystem.
-     */
-    public void sessionComplete() {
-        try {
-            writeToFile(new File(mResultPath), createResultDoc());
-            // Now zip up the results directory so we have something nice
-            // that people can upload.
-            HostUtils.zipUpDirectory(mResultDir,
-                    mResultDir + ".zip",
-                    new HostUtils.ZipFilenameTransformer() {
-                        public String transform(String filename) {
-                            if (filename.startsWith(mResultDir)) {
-                                return filename.substring(mResultDir.length() + 1);
-                            }
-                            return filename;
-                        }
-            });
-        } catch (Exception e) {
-            Log.e("Got exception when trying to write to result file", e);
-        }
-        HostConfig.getInstance().extractResultResources(mResultDir);
-    }
-
-    /**
-     * Create result Doc in XML format.
-     *
-     * @return Result document.
-     */
-    protected Document createResultDoc() {
-        try {
-
-            Document doc = DocumentBuilderFactory.newInstance()
-                    .newDocumentBuilder().newDocument();
-            ProcessingInstruction pr = doc.createProcessingInstruction(
-                    "xml-stylesheet", "type=\"text/xsl\"  href=\"cts_result.xsl\"");
-            doc.appendChild(pr);
-            Node root = doc.createElement(TAG_TEST_RESULT);
-            doc.appendChild(root);
-
-            setAttribute(doc, root, ATTRIBUTE_VERSION, CTS_RESULT_FILE_VERSION);
-            setAttribute(doc, root, ATTRIBUTE_STARTTIME, HostUtils.dateToString(mSessionStartTime));
-            setAttribute(doc, root, ATTRIBUTE_ENDTIME, HostUtils.dateToString(mSessionEndTime));
-            setAttribute(doc, root, ATTRIBUTE_TESTPLAN, mTestPlanName);
-
-            // set device information
-            for (int i = 0; i < mDeviceParameterBase.size(); i ++) {
-                DeviceParameterCollector bldInfo = mDeviceParameterBase.get(i);
-                // set device setting
-                Node deviceSettingNode = doc.createElement(TAG_DEVICEINFO);
-
-                Node screenNode = doc.createElement(TAG_SCREEN);
-                setAttribute(doc, screenNode, ATTRIBUTE_RESOLUTION, bldInfo.getScreenResolution());
-
-                setAttribute(doc, screenNode, DeviceParameterCollector.SCREEN_SIZE,
-                        bldInfo.getScreenSize());
-                setAttribute(doc, screenNode, DeviceParameterCollector.SCREEN_DENSITY,
-                        bldInfo.getScreenDensity());
-                setAttribute(doc, screenNode, DeviceParameterCollector.SCREEN_DENSITY_BUCKET,
-                        bldInfo.getScreenDensityBucket());
-
-                deviceSettingNode.appendChild(screenNode);
-                Node simCardNode = doc.createElement(TAG_PHONE_SUB_INFO);
-                setAttribute(doc, simCardNode, ATTRIBUTE_SUBSCRIBER_ID, bldInfo.getPhoneNumber());
-                deviceSettingNode.appendChild(simCardNode);
-                root.appendChild(deviceSettingNode);
-
-                Node devInfoNode = doc.createElement(TAG_BUILD_INFO);
-                setAttribute(doc, devInfoNode, ATTRIBUTE_DEVICE_ID, bldInfo.getSerialNumber());
-                setAttribute(doc, devInfoNode, ATTRIBUTE_BUILD_ID, bldInfo.getBuildId());
-                setAttribute(doc, devInfoNode, ATTRIBUTE_BUILD_NAME, bldInfo.getProductName());
-                setAttribute(doc, devInfoNode, ATTRIBUTE_BUILD_VERSION,
-                             bldInfo.getBuildVersion());
-                setAttribute(doc, devInfoNode, ATTRIBUTE_ANDROID_PLATFORM_VERSION,
-                             bldInfo.getAndroidPlatformVersion());
-                setAttribute(doc, devInfoNode, ATTRIBUTE_LOCALES, bldInfo.getLocales());
-                setAttribute(doc, devInfoNode, ATTRIBUTE_XDPI, bldInfo.getXdpi());
-                setAttribute(doc, devInfoNode, ATTRIBUTE_YDPI, bldInfo.getYdpi());
-                setAttribute(doc, devInfoNode, ATTRIBUTE_TOUCH, bldInfo.getTouchInfo());
-                setAttribute(doc, devInfoNode, ATTRIBUTE_NAVIGATION, bldInfo.getNavigation());
-                setAttribute(doc, devInfoNode, ATTRIBUTE_KEYPAD, bldInfo.getKeypad());
-                setAttribute(doc, devInfoNode, ATTRIBUTE_NETWORK, bldInfo.getNetwork());
-                setAttribute(doc, devInfoNode, ATTRIBUTE_IMEI, bldInfo.getIMEI());
-                setAttribute(doc, devInfoNode, ATTRIBUTE_IMSI, bldInfo.getIMSI());
-                setAttribute(doc, devInfoNode, ATTRIBUTE_OPEN_GL_ES_VERSION,
-                        bldInfo.getOpenGlEsVersion());
-                setAttribute(doc, devInfoNode, ATTRIBUTE_PARTITIONS,
-                        bldInfo.getPartitions());
-
-                setAttribute(doc, devInfoNode,
-                        DeviceParameterCollector.BUILD_FINGERPRINT, bldInfo.getBuildFingerPrint());
-                setAttribute(doc, devInfoNode,
-                        DeviceParameterCollector.BUILD_TYPE, bldInfo.getBuildType());
-                setAttribute(doc, devInfoNode,
-                        DeviceParameterCollector.BUILD_MODEL, bldInfo.getBuildModel());
-                setAttribute(doc, devInfoNode,
-                        DeviceParameterCollector.BUILD_MANUFACTURER,
-                                bldInfo.getBuildManufacturer());
-                setAttribute(doc, devInfoNode,
-                        DeviceParameterCollector.BUILD_BRAND, bldInfo.getBuildBrand());
-                setAttribute(doc, devInfoNode,
-                        DeviceParameterCollector.BUILD_BOARD, bldInfo.getBuildBoard());
-                setAttribute(doc, devInfoNode,
-                        DeviceParameterCollector.BUILD_DEVICE, bldInfo.getBuildDevice());
-                setAttribute(doc, devInfoNode,
-                        DeviceParameterCollector.BUILD_ABI, bldInfo.getBuildAbi());
-                setAttribute(doc, devInfoNode,
-                        DeviceParameterCollector.BUILD_ABI2, bldInfo.getBuildAbi2());
-
-                deviceSettingNode.appendChild(devInfoNode);
-
-                addFeatureInfo(doc, deviceSettingNode, bldInfo);
-                addProcessInfo(doc, deviceSettingNode, bldInfo);
-            }
-
-            Node hostInfo = doc.createElement(TAG_HOSTINFO);
-            root.appendChild(hostInfo);
-            String hostName = "";
-            try {
-                hostName = InetAddress.getLocalHost().getHostName();
-            } catch (UnknownHostException ignored) {}
-            setAttribute(doc, hostInfo, ATTRIBUTE_NAME, hostName);
-            Node osInfo = doc.createElement(TAG_OSINFO);
-            hostInfo.appendChild(osInfo);
-            setAttribute(doc, osInfo, ATTRIBUTE_NAME, System.getProperty("os.name"));
-            setAttribute(doc, osInfo, ATTRIBUTE_VERSION, System.getProperty("os.version"));
-            setAttribute(doc, osInfo, ATTRIBUTE_ARCH, System.getProperty("os.arch"));
-            Node javaInfo = doc.createElement(TAG_JAVA);
-            hostInfo.appendChild(javaInfo);
-            setAttribute(doc, javaInfo, ATTRIBUTE_NAME, System.getProperty("java.vendor"));
-            setAttribute(doc, javaInfo, ATTRIBUTE_VERSION, System.getProperty("java.version"));
-            Node ctsInfo = doc.createElement(TAG_CTS);
-            hostInfo.appendChild(ctsInfo);
-            setAttribute(doc, ctsInfo, ATTRIBUTE_VERSION, Version.asString());
-            for (HostConfig.Ints i : HostConfig.Ints.values()) {
-                Node intValue = doc.createElement(TAG_INTVALUE);
-                ctsInfo.appendChild(intValue);
-                setAttribute(doc, intValue, ATTRIBUTE_NAME, i.name());
-                setAttribute(doc, intValue, ATTRIBUTE_VALUE, i.value());
-            }
-
-            int passNum = getTestList(CtsTestResult.CODE_PASS).size();
-            int failNum = getTestList(CtsTestResult.CODE_FAIL).size();
-            int notExecutedNum = getTestList(CtsTestResult.CODE_NOT_EXECUTED).size();
-            int timeOutNum = getTestList(CtsTestResult.CODE_TIMEOUT).size();
-            Node summaryNode = doc.createElement(TAG_SUMMARY);
-            root.appendChild(summaryNode);
-            setAttribute(doc, summaryNode, ATTRIBUTE_PASS, passNum);
-            setAttribute(doc, summaryNode, ATTRIBUTE_FAILED, failNum);
-            setAttribute(doc, summaryNode, ATTRIBUTE_NOT_EXECUTED, notExecutedNum);
-            setAttribute(doc, summaryNode, ATTRIBUTE_TIMEOUT, timeOutNum);
-
-            for (TestPackage testPackage : mTestPackages) {
-                Node testPackageNode = doc.createElement(TAG_TESTPACKAGE);
-                setAttribute(doc, testPackageNode, ATTRIBUTE_NAME, testPackage.getAppBinaryName());
-                setAttribute(doc, testPackageNode, TestSessionBuilder.ATTRIBUTE_APP_PACKAGE_NAME,
-                        testPackage.getAppPackageName());
-                setAttribute(doc, testPackageNode, ATTRIBUTE_DIGEST,
-                             testPackage.getMessageDigest());
-
-                if (testPackage instanceof SignatureCheckPackage) {
-                    setAttribute(doc, testPackageNode,
-                              TestSessionBuilder.ATTRIBUTE_SIGNATURE_CHECK, "true");
-                }
-
-                for (TestSuite testSuite : testPackage.getTestSuites()) {
-                    outputTestSuite(doc, testPackage, testPackageNode, testSuite);
-                }
-                root.appendChild(testPackageNode);
-            }
-
-            return doc;
-        } catch (Exception e) {
-            Log.e("create result doc failed", e);
-        }
-        return null;
-    }
-
-    /**
-     * Creates a {@link #TAG_FEATURE_INFO} tag with {@link #TAG_FEATURE} elements indicating
-     * what features are supported by the device. It parses a string from the deviceInfo argument
-     * that is in the form of "feature1:true;feature2:false;featuer3;true;" with a trailing
-     * semi-colon.
-     *
-     * <pre>
-     *  <FeatureInfo>
-     *     <Feature name="android.name.of.feature" available="true" />
-     *     ...
-     *   </FeatureInfo>
-     * </pre>
-     * @param document used to create elements
-     * @param parentNode to attach the FeatureInfo element to
-     * @param deviceInfo to get the feature data from
-     */
-    private void addFeatureInfo(Document document, Node parentNode,
-            DeviceParameterCollector deviceInfo) {
-        Node featureInfo = document.createElement(TAG_FEATURE_INFO);
-        parentNode.appendChild(featureInfo);
-
-        String features = deviceInfo.getFeatures();
-        if (features == null) {
-            features = "";
-        }
-
-        String[] featurePairs = features.split(";");
-        for (String featurePair : featurePairs) {
-            String[] nameTypeAvailability = featurePair.split(":");
-            if (nameTypeAvailability.length >= 3) {
-                Node feature = document.createElement(TAG_FEATURE);
-                featureInfo.appendChild(feature);
-
-                setAttribute(document, feature, ATTRIBUTE_NAME, nameTypeAvailability[0]);
-                setAttribute(document, feature, ATTRIBUTE_TYPE, nameTypeAvailability[1]);
-                setAttribute(document, feature, ATTRIBUTE_AVAILABLE, nameTypeAvailability[2]);
-            }
-        }
-    }
-
-    /**
-     * Creates a {@link #TAG_PROCESS_INFO} tag with {@link #TAG_PROCESS} elements indicating
-     * what particular processes of interest were running on the device. It parses a string from
-     * the deviceInfo argument that is in the form of "processName1;processName2;..." with a
-     * trailing semi-colon.
-     *
-     * <pre>
-     *   <ProcessInfo>
-     *     <Process name="long_cat_viewer" uid="0" />
-     *     ...
-     *   </ProcessInfo>
-     * </pre>
-     *
-     * @param document
-     * @param parentNode
-     * @param deviceInfo
-     */
-    private void addProcessInfo(Document document, Node parentNode,
-            DeviceParameterCollector deviceInfo) {
-        Node processInfo = document.createElement(TAG_PROCESS_INFO);
-        parentNode.appendChild(processInfo);
-
-        String rootProcesses = deviceInfo.getProcesses();
-        if (rootProcesses == null) {
-            rootProcesses = "";
-        }
-
-        String[] processNames = rootProcesses.split(";");
-        for (String processName : processNames) {
-            processName = processName.trim();
-            if (!processName.isEmpty()) {
-                Node process = document.createElement(TAG_PROCESS);
-                processInfo.appendChild(process);
-
-                setAttribute(document, process, ATTRIBUTE_NAME, processName);
-                setAttribute(document, process, ATTRIBUTE_UID, "0");
-            }
-        }
-    }
-
-    /**
-     * Output TestSuite and result to XML DOM Document.
-     *
-     * @param doc The document.
-     * @param parentNode The parent node.
-     * @param testSuite The test suite.
-     */
-    private void outputTestSuite(final Document doc,
-            final TestPackage testPackage, final Node parentNode,
-            TestSuite testSuite) {
-
-        Collection<TestSuite> subSuites = testSuite.getSubSuites();
-        Collection<TestCase> testCases = testSuite.getTestCases();
-
-        Node testSuiteNode = doc.createElement(TAG_TESTSUITE);
-        setAttribute(doc, testSuiteNode, ATTRIBUTE_NAME, testSuite.getName());
-
-        for (TestCase testCase : testCases) {
-            Node testCaseNode = doc.createElement(TAG_TESTCASE);
-            testSuiteNode.appendChild(testCaseNode);
-            setAttribute(doc, testCaseNode, ATTRIBUTE_NAME, testCase.getName());
-            setAttribute(doc, testCaseNode, TestSessionBuilder.ATTRIBUTE_PRIORITY,
-                    testCase.getPriority());
-
-            Collection<Test> tests = testCase.getTests();
-            for (Test test : tests) {
-                Node testNode = doc.createElement(TestSessionBuilder.TAG_TEST);
-                testCaseNode.appendChild(testNode);
-
-                if (test.isKnownFailure()) {
-                    setAttribute(doc, testNode, ATTRIBUTE_KNOWN_FAILURE, test.getKnownFailure());
-                }
-
-                CtsTestResult result = test.getResult();
-                setAttribute(doc, testNode, ATTRIBUTE_NAME, test.getName());
-                setAttribute(doc, testNode, ATTRIBUTE_RESULT, result.getResultString());
-                setAttribute(doc, testNode, ATTRIBUTE_STARTTIME,
-                             new Date(test.getStartTime()).toString());
-                setAttribute(doc, testNode, ATTRIBUTE_ENDTIME,
-                             new Date(test.getEndTime()).toString());
-
-                String failedMessage = result.getFailedMessage();
-
-                if (failedMessage != null) {
-                    // failure message may contain control characters < 0x20 that get translated
-                    // into illegal XML character entities. Replace them first.
-                    failedMessage = HostUtils.replaceControlChars(failedMessage);
-                    Node failedMessageNode = doc.createElement(TAG_FAILED_SCENE);
-                    testNode.appendChild(failedMessageNode);
-                    setAttribute(doc, failedMessageNode,TAG_FAILED_MESSAGE, failedMessage);
-
-                    String stackTrace = sanitizeStackTrace(result.getStackTrace());
-                    if (stackTrace != null) {
-                        Node stackTraceNode = doc.createElement(TAG_STACK_TRACE);
-                        failedMessageNode.appendChild(stackTraceNode);
-                        Node stackTraceTextNode = doc.createTextNode(stackTrace);
-                        stackTraceNode.appendChild(stackTraceTextNode);
-                    }
-                }
-            }
-        }
-
-        for (TestSuite subSuite : subSuites) {
-            outputTestSuite(doc, testPackage, testSuiteNode, subSuite);
-            parentNode.appendChild(testSuiteNode);
-        }
-        parentNode.appendChild(testSuiteNode);
-    }
-
-    /**
-     * Strip out any invalid XML characters that might cause the report to be unviewable.
-     * http://www.w3.org/TR/REC-xml/#dt-character
-     */
-    private static String sanitizeStackTrace(String trace) {
-        if (trace != null) {
-            return trace.replaceAll("[^\\u0009\\u000A\\u000D\\u0020-\\uD7FF\\uE000-\\uFFFD]", "");
-        } else {
-            return null;
-        }
-    }
-
-    /**
-     * Fetch failed file name and line number
-     *
-     * @param failedResult failed message
-     * @return failed file name and line number
-     */
-    public final static String[] getFailedLineNumber(final String failedResult) {
-        Matcher m = mTestFailedPattern.matcher(failedResult);
-        if (m.matches()) {
-            return new String[]{m.group(1), m.group(2)};
-        }
-        return null;
-    }
-
-    /**
-     * set the device information of a specific device
-     *
-     * @param dInfo The device information.
-     */
-    public void setDeviceInfo(final TestDevice.DeviceParameterCollector dInfo) {
-        for (DeviceParameterCollector collector : mDeviceParameterBase) {
-            if (collector.getSerialNumber().equals(dInfo.getSerialNumber())) {
-                //if there has information for the device with given serial number,
-                //replace it with the new information.
-                mDeviceParameterBase.remove(collector);
-                break;
-            }
-        }
-        mDeviceParameterBase.add(dInfo);
-    }
-}
diff --git a/tools/host/src/com/android/cts/TestSessionLogBuilder.java b/tools/host/src/com/android/cts/TestSessionLogBuilder.java
deleted file mode 100644
index 4f0be8d..0000000
--- a/tools/host/src/com/android/cts/TestSessionLogBuilder.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * Copyright (C) 2008 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.cts;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.xml.sax.SAXException;
-
-import java.io.File;
-import java.io.IOException;
-import java.security.NoSuchAlgorithmException;
-import java.text.ParseException;
-import java.util.ArrayList;
-import java.util.Collection;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-
-/**
- * Builder of test session from the test result XML file.
- */
-public class TestSessionLogBuilder extends XMLResourceHandler {
-    private static TestSessionLogBuilder sInstance;
-
-    private DocumentBuilder mDocBuilder;
-
-    public static TestSessionLogBuilder getInstance()
-            throws ParserConfigurationException {
-        if (sInstance == null) {
-            sInstance = new TestSessionLogBuilder();
-        }
-
-        return sInstance;
-    }
-
-    private TestSessionLogBuilder() throws ParserConfigurationException {
-        mDocBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
-    }
-
-    /**
-     * Create TestSessionLog from the result XML file.
-     *
-     * @param resultFilePath The result file path.
-     * @return TestSessionLog.
-     */
-    public TestSessionLog build(final String resultFilePath) throws SAXException, IOException,
-            TestPlanNotFoundException, TestNotFoundException,
-            NoSuchAlgorithmException, ParserConfigurationException {
-
-        File file = new File(resultFilePath);
-        if (!file.exists()) {
-            throw new TestPlanNotFoundException();
-        }
-
-        Document doc = mDocBuilder.parse(file);
-        return loadSessionLog(doc);
-    }
-
-    /**
-     * Load TestSessionLog from a Test result DOM doc.
-     *
-     * @param doc Test result DOM Document.
-     * @return loaded test session log from Test result DOM Document.
-     */
-    private TestSessionLog loadSessionLog(Document doc)
-                throws NoSuchAlgorithmException, ParserConfigurationException,
-                SAXException, IOException, TestPlanNotFoundException,
-                TestNotFoundException {
-
-        ArrayList<TestPackage> pkgsFromResult = new ArrayList<TestPackage>();
-        NodeList resultList = doc.getElementsByTagName(TestSessionLog.TAG_TEST_RESULT);
-
-        // currently, there should be just one test result tag in the result file
-        Node resultNode = resultList.item(0);
-        String planName = getStringAttributeValue(resultNode, TestSessionLog.ATTRIBUTE_TESTPLAN);
-        String start = getStringAttributeValue(resultNode, TestSessionLog.ATTRIBUTE_STARTTIME);
-        String end = getStringAttributeValue(resultNode, TestSessionLog.ATTRIBUTE_ENDTIME);
-        String planFilePath = HostConfig.getInstance().getPlanRepository().getPlanPath(planName);
-        TestSession sessionFromPlan = TestSessionBuilder.getInstance().build(planFilePath);
-
-        NodeList pkgList = resultNode.getChildNodes();
-        for (int i = 0; i < pkgList.getLength(); i++) {
-            Node pkgNode = pkgList.item(i);
-            if (pkgNode.getNodeType() == Document.ELEMENT_NODE
-                    && TestSessionLog.TAG_TESTPACKAGE.equals(pkgNode.getNodeName())) {
-                TestPackage pkg = TestSessionBuilder.getInstance().loadPackage(pkgNode, null);
-                if (pkg != null) {
-                    pkgsFromResult.add(pkg);
-                }
-            }
-        }
-
-        Collection<TestPackage> pkgsFromPlan = sessionFromPlan.getSessionLog().getTestPackages();
-        for (TestPackage pkgFromPlan : pkgsFromPlan) {
-            for (TestPackage pkgFromResult : pkgsFromResult) {
-                if (pkgFromPlan.getAppPackageName().equals(pkgFromResult.getAppPackageName())) {
-                    Collection<Test> testsFromPlan = pkgFromPlan.getTests();
-                    Collection<Test> testsFromResult = pkgFromResult.getTests();
-                    for (Test testFromPlan : testsFromPlan) {
-                        for (Test testFromResult : testsFromResult) {
-                            if (testFromPlan.getFullName().equals(testFromResult.getFullName())) {
-                                CtsTestResult result = testFromResult.getResult();
-                                testFromPlan.addResult(testFromResult.getResult());
-                                break;
-                            }
-                        }
-                    }
-                    break;
-                }
-            }
-        }
-
-        TestSessionLog log = new TestSessionLog(pkgsFromPlan, planName);
-        try {
-            log.setStartTime(HostUtils.dateFromString(start).getTime());
-            log.setEndTime(HostUtils.dateFromString(end).getTime());
-        } catch (NullPointerException ignored) {
-            // use default time
-        } catch (ParseException ignored) {
-            // use default time
-        }
-        return log;
-    }
-}
diff --git a/tools/host/src/com/android/cts/TestSuite.java b/tools/host/src/com/android/cts/TestSuite.java
deleted file mode 100644
index 136fc3f..0000000
--- a/tools/host/src/com/android/cts/TestSuite.java
+++ /dev/null
@@ -1,365 +0,0 @@
-/*
- * Copyright (C) 2008 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.cts;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-
-/**
- * Hold information for a suite of test case, provide functions
- * on storing and executing a test suite from CTS test harness.
- *
- */
-public class TestSuite implements DeviceObserver {
-    private TestPackage mParentPackage;
-    private Collection<TestCase> mTestCases;
-    private String mName;
-    private String mFullName;
-    private Collection<TestSuite> mSubSuites;
-
-    private TestCase mCurrentTestCase;
-    private TestSuite mCurrentSubSuite;
-    private boolean mTestStop;
-
-    /**
-     * Construct a test suite.
-     *
-     * @param pkg TestPakcage as the reference to the parent package.
-     * @param suiteName The current suite name, not the full name.
-     * @param fullName The full suite name along the nested suite path.
-     */
-    public TestSuite(final TestPackage pkg, final String suiteName, final String fullName) {
-        mParentPackage = pkg;
-        mName = suiteName;
-        mFullName = fullName;
-        mTestCases = new ArrayList<TestCase>();
-        mSubSuites = new ArrayList<TestSuite>();
-
-        mTestStop = false;
-        mCurrentTestCase = null;
-        mCurrentSubSuite = null;
-    }
-
-    /**
-     * Get parent package.
-     *
-     * @return Parent package.
-     */
-    public TestPackage getParent() {
-        return mParentPackage;
-    }
-
-    /**
-     * Add a specific test case.
-     *
-     * @param tc The test case to be added.
-     */
-    public void addTestCase(final TestCase tc) {
-        mTestCases.add(tc);
-    }
-
-    /**
-     * Add a specific test suite.
-     *
-     * @param suite The test suite to be added.
-     */
-    public void addSubSuite(final TestSuite suite) {
-        mSubSuites.add(suite);
-    }
-
-    /**
-     * Get TestCases.
-     *
-     * @return TestCases
-     */
-    public Collection<TestCase> getTestCases() {
-        return mTestCases;
-    }
-
-    /**
-     * Get the suite name of this TestSuite.
-     *
-     * @return The suite name of this TestCase.
-     */
-    public String getName() {
-        return mName;
-    }
-
-    /**
-     * Get the full suite name of this TestSuite.
-     *
-     * @return The full suite name of this TestCase.
-     */
-    public String getFullName() {
-        return mFullName;
-    }
-
-    /**
-     * Get the nested test suites of this test suite.
-     *
-     * @return The nested test suites.
-     */
-    public Collection<TestSuite> getSubSuites() {
-        return mSubSuites;
-    }
-
-    /**
-     * Get all of the test suites contained in this test suite.
-     *
-     * @return All of the test suites.
-     */
-    public Collection<TestSuite> getAllSuites() {
-        Collection<TestSuite> testSuites = new ArrayList<TestSuite>();
-        testSuites.add(this);
-        for (TestSuite suite : mSubSuites) {
-            testSuites.addAll(suite.getAllSuites());
-        }
-        return testSuites;
-    }
-
-    /**
-     * Search test in this test suite.
-     *
-     * @param testName The test name to be searched against.
-     * @return null if not found, or return founded test
-     */
-    public Test searchTest(final String testName) {
-        Test test = null;
-        for (TestCase testCase : mTestCases) {
-            test = testCase.searchTest(testName);
-            if (test != null) {
-                return test;
-            }
-        }
-
-        if (mSubSuites.size() != 0) {
-            for (TestSuite subSuite : mSubSuites) {
-                test = subSuite.searchTest(testName);
-                if (test != null) {
-                    return test;
-                }
-            }
-        }
-
-        return null;
-    }
-
-    /**
-     * Get the excluded list according to the execution status of each test.
-     *
-     * @param resultType The result type to filter the tests.
-     * @return All excluded list.
-     */
-    public ArrayList<String> getExcludedList(final String resultType) {
-        ArrayList<String> excludedList = new ArrayList<String>();
-        ArrayList<String> fullNameList = new ArrayList<String>();
-        for (TestSuite suite : mSubSuites) {
-            fullNameList.add(suite.getFullName());
-            ArrayList<String> list = suite.getExcludedList(resultType);
-            if ((list != null) && (list.size() > 0)) {
-                excludedList.addAll(list);
-            }
-        }
-
-        for (TestCase tc : mTestCases) {
-            fullNameList.add(tc.getFullName());
-            ArrayList<String> list = tc.getExcludedList(resultType);
-            if ((list != null) && (list.size() > 0)) {
-                excludedList.addAll(list);
-            }
-        }
-
-        int count = 0;
-        for (String fullName : fullNameList) {
-            if (excludedList.contains(fullName)) {
-                count ++;
-            }
-        }
-        if (count == fullNameList.size()) {
-            //the whole suite is excluded, just need to add the full suite name
-            excludedList.removeAll(excludedList);
-            excludedList.add(getFullName());
-        }
-        return excludedList;
-    }
-
-    /**
-     * Get all tests of this test suite.
-     *
-     * @return The tests of this suite.
-     */
-    public Collection<Test> getTests() {
-        ArrayList<Test> tests = new ArrayList<Test>();
-        for (TestSuite subSuite : mSubSuites) {
-            tests.addAll(subSuite.getTests());
-        }
-
-        for (TestCase testCase : mTestCases) {
-            tests.addAll(testCase.getTests());
-        }
-
-        return tests;
-    }
-
-    /**
-     * Get all test cases of this test suite.
-     *
-     * @return The test cases of this suite.
-     */
-    public Collection<TestCase> getAllTestCases() {
-        ArrayList<TestCase> testCases = new ArrayList<TestCase>();
-        testCases.addAll(mTestCases);
-        for (TestSuite subSuite : mSubSuites) {
-            testCases.addAll(subSuite.getAllTestCases());
-        }
-
-        return testCases;
-    }
-
-    /**
-     * Get all test case names contained in the suite.
-     *
-     * @return All test case names.
-     */
-    public ArrayList<String> getAllTestCaseNames() {
-        ArrayList<String> caseNameList = new ArrayList<String>();
-        for (TestCase testCase : getAllTestCases()) {
-            caseNameList.add(testCase.getFullName());
-        }
-        return caseNameList;
-    }
-
-    /**
-     * Set test stopped;
-     *
-     * @param testStopped If true, it's stopped. Else, still running.
-     */
-    public void setTestStopped(final boolean testStopped) {
-        mTestStop = testStopped;
-        if (mCurrentTestCase != null) {
-            mCurrentTestCase.setTestStopped(mTestStop);
-        }
-
-        if (mCurrentSubSuite != null) {
-            mCurrentSubSuite.setTestStopped(mTestStop);
-        }
-    }
-
-    /**
-     * Run the this test suite or the specific java package contained
-     * in the test suite over device given.
-     *
-     * @param device The device to run the test over.
-     * @param javaPkgName The java package name.
-     */
-    public void run(final TestDevice device, final String javaPkgName)
-            throws IOException, DeviceDisconnectedException, ADBServerNeedRestartException {
-        Iterator<TestSuite> subSuites = getSubSuites().iterator();
-        Iterator<TestCase> testCases = getTestCases().iterator();
-
-        mTestStop = false;
-        mCurrentTestCase = null;
-        mCurrentSubSuite = null;
-
-        while (subSuites.hasNext() && (!mTestStop)) {
-            mCurrentSubSuite = subSuites.next();
-            mCurrentSubSuite.run(device, javaPkgName);
-        }
-
-        while (testCases.hasNext() && (!mTestStop)) {
-            mCurrentTestCase = testCases.next();
-            String fullName = mFullName + "." + mCurrentTestCase.getName();
-            if ((javaPkgName == null) || (javaPkgName.length() == 0)
-                    || fullName.startsWith(javaPkgName)) {
-                mCurrentTestCase.run(device);
-            }
-        }
-    }
-
-    /**
-     * Run the specific test contained in the test suite over device given.
-     *
-     * @param device The device to run the test over.
-     * @param test The specific test to be run.
-     */
-    public void run(final TestDevice device, final Test test)
-            throws DeviceDisconnectedException, ADBServerNeedRestartException {
-        mTestStop = false;
-        mCurrentTestCase = null;
-        mCurrentSubSuite = null;
-
-        mCurrentTestCase = test.getTestCase();
-        mCurrentTestCase.run(device, test);
-    }
-
-    /** {@inheritDoc} */
-    public void notifyInstallingComplete(final int resultCode) {
-        if (mCurrentTestCase != null) {
-            mCurrentTestCase.notifyInstallingComplete(resultCode);
-        }
-
-        if (mCurrentSubSuite != null) {
-            mCurrentSubSuite.notifyInstallingComplete(resultCode);
-        }
-    }
-
-    /** {@inheritDoc} */
-    public void notifyUninstallingComplete(final int resultCode) {
-        if (mCurrentTestCase != null) {
-            mCurrentTestCase.notifyUninstallingComplete(resultCode);
-        }
-
-        if (mCurrentSubSuite != null) {
-            mCurrentSubSuite.notifyUninstallingComplete(resultCode);
-        }
-    }
-
-    /** {@inheritDoc} */
-    public void notifyInstallingTimeout(final TestDevice testDevice) {
-        if (mCurrentTestCase != null) {
-            mCurrentTestCase.notifyInstallingTimeout(testDevice);
-        }
-
-        if (mCurrentSubSuite != null) {
-            mCurrentSubSuite.notifyInstallingTimeout(testDevice);
-        }
-    }
-
-    /** {@inheritDoc} */
-    public void notifyUninstallingTimeout(final TestDevice testDevice) {
-        if (mCurrentTestCase != null) {
-            mCurrentTestCase.notifyUninstallingTimeout(testDevice);
-        }
-
-        if (mCurrentSubSuite != null) {
-            mCurrentSubSuite.notifyUninstallingTimeout(testDevice);
-        }
-    }
-
-    /** {@inheritDoc} */
-    public void notifyTestingDeviceDisconnected() {
-        if (mCurrentTestCase != null) {
-            mCurrentTestCase.notifyTestingDeviceDisconnected();
-        }
-
-        if (mCurrentSubSuite != null) {
-            mCurrentSubSuite.notifyTestingDeviceDisconnected();
-        }
-    }
-}
diff --git a/tools/host/src/com/android/cts/UnknownCommandException.java b/tools/host/src/com/android/cts/UnknownCommandException.java
deleted file mode 100644
index 585d532..0000000
--- a/tools/host/src/com/android/cts/UnknownCommandException.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (C) 2008 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.cts;
-
-/**
- * Exception threw out if CommandParser encounter unknown command.
- */
-public class UnknownCommandException extends Exception{
-
-    private static final long serialVersionUID = -23012571004369516L;
-
-    public UnknownCommandException() {
-        super();
-    }
-    public UnknownCommandException(String message) {
-        super(message);
-    }
-}
diff --git a/tools/host/src/com/android/cts/Version.java b/tools/host/src/com/android/cts/Version.java
deleted file mode 100644
index 92dc255..0000000
--- a/tools/host/src/com/android/cts/Version.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (C) 2009 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.cts;
-
-public class Version {
-    // The CTS version string
-    private static final String version = "1337";
-
-    private Version() {
-        // no instances allowed
-    }
-
-    public static String asString() {
-        return version;
-    }
-}
diff --git a/tools/host/src/com/android/cts/XMLResourceHandler.java b/tools/host/src/com/android/cts/XMLResourceHandler.java
deleted file mode 100644
index f44a574..0000000
--- a/tools/host/src/com/android/cts/XMLResourceHandler.java
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * Copyright (C) 2008 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.cts;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.TransformerFactoryConfigurationError;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-
-import org.w3c.dom.Attr;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-/**
- * An abstract class to deal with the XML information using DOM.
- */
-public abstract class XMLResourceHandler {
-
-    protected String getElementContent(Node elem) {
-        return elem.getChildNodes().item(0).getNodeValue().trim();
-    }
-
-    /**
-     * Get string from DOM node by attribute name.
-     *
-     * @param elem a node from DOM tree.
-     * @param attrName the attribute name.
-     * @return string value of the attribute name from the DOM node.
-     */
-    static public String getStringAttributeValue(Node elem, String attrName) {
-        Node node = elem.getAttributes().getNamedItem(attrName);
-        if (node == null) {
-            return null;
-        }
-        return node.getNodeValue().trim();
-    }
-
-    /**
-     * Get integer attribute value.
-     *
-     * @param elem The element node.
-     * @param attrName The attribute name.
-     * @return The attribute value in integer.
-     */
-    protected int getAttributeValue(Node elem, String attrName) {
-        return Integer.parseInt(getStringAttributeValue(elem, attrName));
-    }
-
-    /**
-     * Get child by attribute.
-     *
-     * @param parent The parent node.
-     * @param attrName The attribute name.
-     * @param attrValue The attribute value.
-     * @return The child node.
-     */
-    protected Node getChildByAttribute(Node parent, String attrName, String attrValue) {
-        if (parent == null || attrName == null || attrValue == null) {
-            return null;
-        }
-        NodeList children = parent.getChildNodes();
-        for (int i = 0; i < children.getLength(); i++) {
-            Node child = children.item(i);
-            if (child.getNodeType() == Node.ELEMENT_NODE) {
-                if (attrValue.equals(getStringAttributeValue(child, attrName))) {
-                    return child;
-                }
-            }
-        }
-
-        return null;
-    }
-
-    /**
-     * Set the attribute value.
-     *
-     * @param doc The document.
-     * @param elem The element node.
-     * @param name The attribute name.
-     * @param value The attribute value in integer.
-     */
-    protected void setAttribute(Document doc, Node elem, String name, int value) {
-        setAttribute(doc, elem, name, Integer.toString(value));
-    }
-
-    /**
-     * Set the attribute value.
-     *
-     * @param doc The document.
-     * @param elem The element node.
-     * @param name The attribute name.
-     * @param value The attribute value in string.
-     */
-    protected void setAttribute(Document doc, Node elem, String name, String value) {
-        Attr attrNode = doc.createAttribute(name);
-        attrNode.setNodeValue(value);
-
-        elem.getAttributes().setNamedItem(attrNode);
-    }
-
-    /**
-     * Write a DOM Document object into a file.
-     *
-     * @param file XML file to be written
-     * @param doc DOM Document
-     */
-    protected static void writeToFile(File file, Document doc) throws FileNotFoundException,
-            IOException, TransformerFactoryConfigurationError, TransformerException {
-        Transformer t = TransformerFactory.newInstance().newTransformer();
-        // enable indent in result file
-        t.setOutputProperty("indent", "yes");
-        FileOutputStream fos = new FileOutputStream(file);
-        try {
-            StreamResult sr = new StreamResult(fos);
-            t.transform(new DOMSource(doc), sr);
-        } finally {
-            fos.close();
-        }
-    }
-}
diff --git a/tools/host/test/com/android/cts/CommandParserTest.java b/tools/host/test/com/android/cts/CommandParserTest.java
deleted file mode 100644
index 95a0fc0..0000000
--- a/tools/host/test/com/android/cts/CommandParserTest.java
+++ /dev/null
@@ -1,282 +0,0 @@
-/*
- * Copyright (C) 2008 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.cts;
-
-import java.util.ArrayList;
-import java.util.Set;
-
-/**
- * Test the logic of parsing the command, option, and parameters.
- */
-public class CommandParserTest extends CtsTestBase {
-
-    /**
-     * Test parsing the simple normal command.
-     */
-    public void testParseSimpleCommand()
-                throws UnknownCommandException, CommandNotFoundException {
-        final String action = "start";
-        final String option = "--plan";
-        final String value = "test_plan";
-        CommandParser cp;
-        cp = CommandParser.parse(action + " " + option + " " + value);
-        assertEquals(1, cp.getOptionSize());
-        assertEquals(action, cp.getAction());
-        assertTrue(cp.containsKey(CTSCommand.OPTION_PLAN));
-        assertEquals(value, cp.getValue(CTSCommand.OPTION_PLAN));
-    }
-
-    /**
-     * Test parsing command with multiple options.
-     */
-    public void testParseMultiOptionsCommand()
-                throws UnknownCommandException, CommandNotFoundException {
-        final String action = "start";
-        final String option1 = "--plan";
-        final String value1 = "test_plan";
-        final String option2 = "-d";
-        final String value2 = "0";
-        final String unexistOption = "unexist";
-        CommandParser cp;
-        cp = CommandParser.parse(action + " " + option1 + " " + value1
-                + " " + option2 + " " + value2);
-        assertEquals(2, cp.getOptionSize());
-        assertEquals(action, cp.getAction());
-        assertTrue(cp.containsKey(CTSCommand.OPTION_PLAN));
-        assertEquals(value1, cp.getValue(CTSCommand.OPTION_PLAN));
-        assertTrue(cp.containsKey(CTSCommand.OPTION_DEVICE));
-        assertEquals(value2, cp.getValue(CTSCommand.OPTION_DEVICE));
-        assertFalse(cp.containsKey(unexistOption));
-    }
-
-    /**
-     * Test parsing command with multiple same options.
-     */
-    public void testParseSameOptionCommand() throws CommandNotFoundException{
-        final String action = "ls";
-        final String option1 = "-d";
-        final String value1 = "test_plan";
-        final String option2 = "-d";
-        final String value2 = "0";
-        try {
-            CommandParser.parse(action + " " + option1 + " "
-                    + value1 + " " + option2 + " " + value2);
-            fail("no exception");
-        } catch (UnknownCommandException e) {
-        }
-    }
-
-    /**
-     * Test parsing command with option without value.
-     */
-    public void testParseNoValueForOptionCommand()
-                throws UnknownCommandException, CommandNotFoundException {
-        final String action = "ls";
-        final String option1 = "-d";
-
-        CommandParser cp;
-        cp = CommandParser.parse(action + " " + option1);
-        assertEquals(1, cp.getOptionSize());
-        assertEquals(action, cp.getAction());
-        assertTrue(cp.containsKey(CTSCommand.OPTION_DEVICE));
-        assertEquals("", cp.getValue(CTSCommand.OPTION_DEVICE));
-    }
-
-    /**
-     * Test parsing command with single illegal option.
-     */
-    public void testParseIllOptionCommand()
-                throws UnknownCommandException, CommandNotFoundException {
-        final String action = "ls";
-        final String actionValue = "devices";
-        CommandParser cp = CommandParser.parse(action + " " + actionValue);
-        assertEquals(action, cp.getAction());
-        ArrayList<String> actionValues = cp.getActionValues();
-        assertEquals(1, actionValues.size());
-        assertTrue(actionValues.contains(actionValue));
-    }
-
-    /**
-     * Test parsing command with multiple illegal options.
-     */
-    public void testParseMultiIllOptionCommand() throws CommandNotFoundException {
-        final String action = "ls";
-        final String option1 = "-devices";
-        final String value1 = "v1";
-        final String option2 = "op2";
-        final String value2 = "v2";
-        try {
-            CommandParser.parse(action + " " + option1 + " " + value1 + " "
-                    + option2 + " " + value2);
-            fail("no exception");
-        } catch (UnknownCommandException e) {
-        }
-    }
-
-    /**
-     * Test parsing command and then get the options.
-     */
-    public void testGetOptions()
-                throws UnknownCommandException, CommandNotFoundException {
-        final String action = "ls";
-        final String option1 = "-d";
-        final String value1 = "v1";
-        final String option2 = "--plan";
-        final String value2 = "v2";
-        CommandParser cp;
-        cp = CommandParser.parse(action + " " + option1 + " " + value1
-                + " " + option2 + " " + value2);
-        assertEquals(2, cp.getOptionSize());
-        Set<String> set = cp.getOptionKeys();
-        assertEquals(2, set.size());
-        assertTrue(set.contains(CTSCommand.OPTION_DEVICE));
-        assertTrue(set.contains(CTSCommand.OPTION_PLAN));
-    }
-
-    /**
-     * Test parsing empty command.
-     */
-    public void testParseEmptyCommand() throws UnknownCommandException {
-        try {
-            CommandParser.parse("");
-            CommandParser.parse("             ");
-            fail("should throw out exception");
-        } catch (CommandNotFoundException e) {
-        }
-    }
-
-    /**
-     * Test parsing command without option.
-     */
-    public void testParseSingleCommand()
-                throws UnknownCommandException, CommandNotFoundException {
-        final String action = "exit";
-        CommandParser cp;
-        cp = CommandParser.parse(action);
-        assertEquals(action, cp.getAction());
-        assertEquals(0, cp.getOptionSize());
-        assertEquals(0, cp.getOptionKeys().size());
-    }
-
-    /**
-     * Test parsing command with number.
-     */
-    public void testParseNumberOption()
-                throws UnknownCommandException, CommandNotFoundException {
-        final String action = "h";
-        final String actionValue = "1234";
-        CommandParser cp;
-        cp = CommandParser.parse(action + " " + actionValue);
-        assertEquals(action, cp.getAction());
-        ArrayList<String> actionValues = cp.getActionValues();
-        assertEquals(1, actionValues.size());
-        assertTrue(actionValues.contains(actionValue));
-        assertEquals(0, cp.getOptionSize());
-        Set<String> set = cp.getOptionKeys();
-        assertEquals(0, set.size());
-    }
-
-    /**
-     * Test parsing command with negative number.
-     */
-    public void testParseValueNegative()
-                throws UnknownCommandException, CommandNotFoundException {
-        final String action = "ls";
-        final String resultOption = "-r";
-        final String resultValue = "-13";
-        CommandParser cp;
-        cp = CommandParser.parse(action + " " + resultOption + " "
-                + resultValue);
-        assertEquals(action, cp.getAction());
-        assertEquals(1, cp.getOptionSize());
-        assertTrue(cp.containsKey(CTSCommand.OPTION_RESULT));
-        assertEquals(resultValue, cp.getValue(CTSCommand.OPTION_RESULT));
-    }
-
-    /**
-     * Test parsing command with capital letter.
-     */
-    public void testParseCapitalLetter()
-                throws UnknownCommandException, CommandNotFoundException {
-        final String action = "LS";
-        final String resultOption = "-R";
-        final String resultValue = "-13";
-        CommandParser cp;
-        cp = CommandParser.parse(action + " " + resultOption + " "
-                + resultValue);
-        assertEquals(action.toLowerCase(), cp.getAction());
-        assertEquals(1, cp.getOptionSize());
-        assertTrue(cp.containsKey(CTSCommand.OPTION_RESULT));
-        assertEquals(resultValue, cp.getValue(CTSCommand.OPTION_RESULT));
-    }
-
-    /**
-     * Test parsing command with multiple action values.
-     */
-    public void testParseActionValue()
-                throws UnknownCommandException, CommandNotFoundException {
-        final String action = "h";
-        final String actionValue1 = "192";
-        final String actionValue2 = "e";
-        CommandParser cp = CommandParser.parse(action + " " + actionValue1 + " "
-                + actionValue2);
-        assertEquals(action, cp.getAction());
-        assertEquals(0, cp.getOptionKeys().size());
-        ArrayList<String> actionValues = cp.getActionValues();
-        assertEquals(2, actionValues.size());
-        assertTrue(actionValues.contains(actionValue1));
-        assertTrue(actionValues.contains(actionValue2));
-    }
-
-    /**
-     * Test parsing command of list result.
-     */
-    public void testParseListResultCmd() throws UnknownCommandException,
-            CommandNotFoundException {
-        final String action = "ls";
-        final String resultOpt = "-r";
-        final String resultValue = "pass";
-        final String sessionOpt = "-s";
-        final String sessionOptComplete = "--session";
-        final String sessionId = "1";
-        String cmdStr;
-        CommandParser cp;
-
-        cmdStr = action + " " + resultOpt + " " + sessionOpt + " " + sessionId;
-        cp = CommandParser.parse(cmdStr);
-        assertEquals(action, cp.getAction());
-        assertEquals(2, cp.getOptionSize());
-        assertEquals("", cp.getValue(CTSCommand.OPTION_RESULT));
-        assertEquals(sessionId, cp.getValue(CTSCommand.OPTION_SESSION));
-
-        cmdStr = action + " " + resultOpt + " " + sessionOptComplete + " "
-                + sessionId;
-        cp = CommandParser.parse(cmdStr);
-        assertEquals(action, cp.getAction());
-        assertEquals(2, cp.getOptionSize());
-        assertEquals("", cp.getValue(CTSCommand.OPTION_RESULT));
-        assertEquals(sessionId, cp.getValue(CTSCommand.OPTION_SESSION));
-
-        cmdStr = action + " " + resultOpt + " " + resultValue + " " + sessionOptComplete + " "
-                + sessionId;
-        cp = CommandParser.parse(cmdStr);
-        assertEquals(action, cp.getAction());
-        assertEquals(2, cp.getOptionSize());
-        assertEquals(resultValue, cp.getValue(CTSCommand.OPTION_RESULT));
-        assertEquals(sessionId, cp.getValue(CTSCommand.OPTION_SESSION));
-    }
-}
diff --git a/tools/host/test/com/android/cts/ConsoleTests.java b/tools/host/test/com/android/cts/ConsoleTests.java
deleted file mode 100644
index 81f4958..0000000
--- a/tools/host/test/com/android/cts/ConsoleTests.java
+++ /dev/null
@@ -1,523 +0,0 @@
-/*
- * Copyright (C) 2008 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.cts;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.security.NoSuchAlgorithmException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipOutputStream;
-
-import com.android.cts.HostConfig.CaseRepository;
-
-/**
- * Test the console commands.
- */
-public class ConsoleTests extends CtsTestBase {
-
-    private String mPath1;
-    private String mPath2;
-    private String mPath3;
-
-    /** {@inheritDoc} */
-    @Override
-    public void tearDown() {
-        HostConfig.getInstance().removeTestPacakges();
-        deleteTestPackage(mPath1);
-        deleteTestPackage(mPath2);
-        deleteTestPackage(mPath3);
-
-        super.tearDown();
-    }
-
-    /**
-     * Test adding package to test case repository and then getting the package names.
-     */
-    public void testAddPackage() throws Exception {
-        ConsoleUi cui = new ConsoleUi(TestHost.getInstance());
-
-        mPath1 = ROOT + File.separator + "com.google.android.cts.p1.zip";
-        mPath2 = ROOT + File.separator + "com.google.android.cts.p2.zip";
-        mPath3 = ROOT + File.separator + "net.sf.jlee.cts.p3.zip";
-
-        final String expPackageName1 = "com.google.android.cts.p1";
-        final String expPackageName2 = "com.google.android.cts.p2";
-        final String expPackageName3 = "net.sf.jlee.cts.p3";
-
-        HostConfig.getInstance().removeTestPacakges();
-
-        ArrayList<String> pNames = HostConfig.getInstance().getCaseRepository()
-                .getPackageBinaryNames();
-
-        assertEquals(0, pNames.size());
-        createTestPackageZip(mPath1, expPackageName1);
-        createTestPackageZip(mPath2, expPackageName2);
-        createTestPackageZip(mPath3, expPackageName3);
-
-        // add package 1
-        String cmdline = CTSCommand.ADD + " " + "-p" + " "
-                + mPath1;
-        cui.processCommand(CommandParser.parse(cmdline));
-
-        pNames = HostConfig.getInstance().getCaseRepository().getPackageBinaryNames();
-        assertEquals(1, pNames.size());
-        assertTrue(pNames.contains(expPackageName1));
-
-        // add package 2
-        cmdline = CTSCommand.ADD + " " + "-p" + " " + mPath2;
-        cui.processCommand(CommandParser.parse(cmdline));
-
-        pNames = HostConfig.getInstance().getCaseRepository().getPackageBinaryNames();
-        assertEquals(2, pNames.size());
-        assertTrue(pNames.contains(expPackageName1));
-        assertTrue(pNames.contains(expPackageName2));
-
-        // add package 2
-        cmdline = CTSCommand.ADD + " " + "-p" + " " + mPath3;
-        cui.processCommand(CommandParser.parse(cmdline));
-
-        pNames = HostConfig.getInstance().getCaseRepository().getPackageBinaryNames();
-        assertEquals(3, pNames.size());
-        assertTrue(pNames.contains(expPackageName1));
-        assertTrue(pNames.contains(expPackageName2));
-        assertTrue(pNames.contains(expPackageName3));
-
-        deleteTestPackage(expPackageName1);
-        deleteTestPackage(expPackageName2);
-        deleteTestPackage(expPackageName3);
-    }
-
-    /**
-     * Test removing package after adding the packages into the test case repository.
-     */
-    public void testRemovePackage() throws Exception {
-        ConsoleUi cui = new ConsoleUi(TestHost.getInstance());
-        mPath1 = ROOT + File.separator + "com.google.android.cts.p1.zip";
-        mPath2 = ROOT + File.separator + "com.google.android.cts.p2.zip";
-        mPath3 = ROOT + File.separator + "net.sf.jlee.cts.p3.zip";
-
-        final String expPackageName1 = "com.google.android.cts.p1";
-        final String expPackageName2 = "com.google.android.cts.p2";
-        final String expPackageName3 = "net.sf.jlee.cts.p3";
-
-        HostConfig.getInstance().removeTestPacakges();
-        createTestPackageZip(mPath1, expPackageName1);
-        createTestPackageZip(mPath2, expPackageName2);
-        createTestPackageZip(mPath3, expPackageName3);
-
-        // add package 1
-        String cmdLine = CTSCommand.ADD + " -p " + mPath1;
-        cui.processCommand(CommandParser.parse(cmdLine));
-        cmdLine = CTSCommand.ADD + " -p " + mPath2;
-        cui.processCommand(CommandParser.parse(cmdLine));
-        cmdLine = CTSCommand.ADD + " -p " + mPath3;
-        cui.processCommand(CommandParser.parse(cmdLine));
-
-        ArrayList<String> pNames = HostConfig.getInstance().getCaseRepository()
-                .getPackageBinaryNames();
-        assertEquals(3, pNames.size());
-        assertTrue(pNames.contains(expPackageName1));
-        assertTrue(pNames.contains(expPackageName2));
-        assertTrue(pNames.contains(expPackageName3));
-
-        cmdLine = CTSCommand.REMOVE + " " + "-p" + " "
-                + expPackageName1;
-        cui.processCommand(CommandParser.parse(cmdLine));
-        pNames = HostConfig.getInstance().getCaseRepository().getPackageBinaryNames();
-        assertEquals(2, pNames.size());
-        assertTrue(pNames.contains(expPackageName2));
-        assertTrue(pNames.contains(expPackageName3));
-
-        cmdLine = CTSCommand.REMOVE + " " + "-p" + " "
-                + expPackageName2;
-        cui.processCommand(CommandParser.parse(cmdLine));
-        pNames = HostConfig.getInstance().getCaseRepository().getPackageBinaryNames();
-        assertEquals(1, pNames.size());
-        assertTrue(pNames.contains(expPackageName3));
-
-        cmdLine = CTSCommand.REMOVE + " " + "-p" + " "
-                + expPackageName3;
-        cui.processCommand(CommandParser.parse(cmdLine));
-        pNames = HostConfig.getInstance().getCaseRepository().getPackageBinaryNames();
-        assertEquals(0, pNames.size());
-
-        deleteTestPackage(expPackageName1);
-        deleteTestPackage(expPackageName2);
-        deleteTestPackage(expPackageName3);
-    }
-
-    /**
-     * Test validating partial zipped package when adding package..
-     */
-    public void testValidatePartialZipPackageName() throws Exception {
-        final String pkgName1 = "com.google.android.cts.apkPartial.zip";
-        final String pkgName2 = "com.google.android.cts.xmlPartial.zip";
-        mPath1 = ROOT + File.separator + pkgName1;
-        mPath2 = ROOT + File.separator + pkgName2;
-
-        HostConfig config = HostConfig.getInstance();
-        HostConfig.CaseRepository caseRepos = config.getCaseRepository();
-
-        createPartialTestPackageZip(mPath1, HostConfig.FILE_SUFFIX_APK);
-        assertFalse(caseRepos.addPackage(mPath1));
-
-        createPartialTestPackageZip(mPath2, HostConfig.FILE_SUFFIX_XML);
-        assertFalse(caseRepos.addPackage(mPath2));
-    }
-
-    /**
-     * Test validating package file suffix when adding package.
-     */
-    public void testValidatePackageSuffix() throws Exception {
-        final String content = "test test test";
-        final String pkgName1 = "com.google.android.cts.invalidSuffix.txt";
-        mPath1 = ROOT + File.separator + pkgName1;
-
-        createFile(content, mPath1);
-
-        HostConfig config = HostConfig.getInstance();
-        HostConfig.CaseRepository caseRepos = config.getCaseRepository();
-
-        assertFalse(caseRepos.isValidPackageName(mPath1));
-    }
-
-    /**
-     * Test validate duplicate package name by adding the same package twice.
-     */
-    public void testValidateDuplicatePackageName() throws Exception {
-        final String name = "com.google.android.cts.mypackage";
-        mPath1 = ROOT + File.separator + name + HostConfig.FILE_SUFFIX_ZIP;
-
-        HostConfig config = HostConfig.getInstance();
-        HostConfig.CaseRepository caseRepos = config.getCaseRepository();
-        createTestPackageZip(mPath1, name);
-
-        caseRepos.removePackages(name);
-        assertTrue(caseRepos.addPackage(mPath1));
-        assertFalse(caseRepos.isValidPackageName(mPath1));
-        caseRepos.removePackages(name);
-
-        deleteTestPackage(name);
-    }
-
-    /**
-     * Create zipped test package.
-     *
-     * @param zipFilePath The file name with path.
-     * @param packageName The package name.
-     */
-    private void createTestPackageZip(String zipFilePath, final String packageName)
-            throws IOException {
-        final String descriptionConfigStr = "<TestPackage name=\""
-            + packageName + "\" " + "appPackageName=\"" + packageName
-            + "\""
-            + " version=\"1.0\" AndroidFramework=\"Android 1.0\""
-            + " runner=\"android.test.InstrumentationTestRunner\" jarPath=\"\">\n"
-            + "  <Description>something extracted from java doc</Description>\n"
-            + "  <TestSuite name=\"com.google\">\n"
-            + "     <TestCase name=\"TestCaseName\" priority=\"mandatory\">\n"
-            + "         <Description>" + "something extracted from java doc"
-            + "         </Description>\n"
-            + "         <!-- Test Methods -->\n"
-            + "         <Test method=\"testName1\" type=\"automatic\"/>\n"
-            + "     </TestCase>\n"
-            + "  </TestSuite>\n" + "</TestPackage>\n";
-
-        createTestPackage(descriptionConfigStr, packageName);
-        String apkFile = ROOT + File.separator + packageName + HostConfig.FILE_SUFFIX_APK;
-        String xmlFile = ROOT + File.separator + packageName + HostConfig.FILE_SUFFIX_XML;
-        String zipFile = ROOT + File.separator + packageName + ".zip";
-        ZipOutputStream out = new ZipOutputStream(new FileOutputStream(zipFile));
-        addEntry(out, apkFile);
-        addEntry(out, xmlFile);
-        out.close();
-
-        deleteTestPackage(packageName);
-    }
-
-    /**
-     * Add entry into the zip ouput stream.
-     *
-     * @param out The zip output stream.
-     * @param filePath The entry to be added into the zip output stream.
-     */
-    private void addEntry(ZipOutputStream out, String filePath) throws IOException {
-        byte[] buf = new byte[1024];
-        FileInputStream in = new FileInputStream(filePath);
-        out.putNextEntry(new ZipEntry(filePath));
-        int len;
-        while ((len = in.read(buf)) > 0) {
-            out.write(buf, 0, len);
-        }
-        out.closeEntry();
-        in.close();
-    }
-
-    /**
-     * Create test package with the package name and the xml message as the content.
-     *
-     * @param xmlMsg The message as the content of the package.
-     * @param packageName The package name.
-     */
-    @Override
-    protected void createTestPackage(String xmlMsg, String packageName) throws IOException {
-        String caseRoot = ROOT;
-
-        String apkPath = caseRoot + File.separator + packageName + APK_SUFFIX;
-        String xmlPath = caseRoot + File.separator + packageName + DESCRITION_SUFFIX;
-
-        createFile(null, apkPath);
-        createFile(xmlMsg, xmlPath);
-    }
-    /**
-     * Create partial test package.
-     *
-     * @param zipFilePath The file name with path.
-     * @param suffix The file suffix.
-     */
-    private void createPartialTestPackageZip(String zipFilePath, String suffix)
-                 throws IOException {
-        ZipOutputStream out = new ZipOutputStream(new FileOutputStream(
-                zipFilePath));
-
-        String packageName = zipFilePath.substring(zipFilePath
-                .lastIndexOf(File.separator), zipFilePath.lastIndexOf("."));
-        String file = packageName + suffix;
-
-        addFileToZip(file, out);
-
-        out.close();
-    }
-
-    /**
-     * Add file to zip output stream.
-     *
-     * @param filename The file to be added to the zip output stream.
-     * @param out The zip output stream.
-     */
-    private void addFileToZip(String filename, ZipOutputStream out)
-            throws IOException {
-        out.putNextEntry(new ZipEntry(filename));
-
-        out.closeEntry();
-    }
-
-    /**
-     * Test listing package contents with different levels of expectation.
-     */
-    public void testListPackage() throws IOException, NoSuchAlgorithmException {
-
-        List<ArrayList<String>> list = null;
-        ArrayList<String> packageList = null;
-        ArrayList<String> suiteList = null;
-        ArrayList<String> caseList = null;
-        ArrayList<String> testList = null;
-
-        final String packageName = "com.google";
-        final String suiteName   = "com.google.cts";
-        final String caseName    = "CtsTest";
-        final String testName    = "testHello";
-
-        final String expect1 = "com";
-        final String expect2 = "com.google";
-        final String expect3 = "com.google.cts";
-        final String expect4 = "com.google.cts.CtsTest";
-        final String expect5 = "com.google.cts.CtsTest#testHello";
-        final String expect6 = "com.google.cts.CtsTest#test";
-        final CaseRepository caseRepository = HostConfig.getInstance()
-                .getCaseRepository();
-
-        final String descriptionConfigStr = "<TestPackage name=\""
-                + packageName + "\" appPackageName=\"" + packageName
-                + "\""
-                + " version=\"1.0\" AndroidFramework=\"Android 1.0\""
-                + " runner=\"android.test.InstrumentationTestRunner\">\n"
-                + "  <Description>something extracted from java doc</Description>\n"
-                + "      <TestSuite name=\"" + suiteName + "\">\n"
-                + "         <TestCase name=\"" + caseName + "\" priority=\"mandatory\">\n"
-                + "             <Description>" + "something extracted from java doc"
-                + "             </Description>\n"
-                + "             <!-- Test Cases -->\n"
-                + "             <Test name=\"" + testName + "\"" + " type=\"automatic\"" + ">\n"
-                + "                 <Description>Simple deadloop test</Description>"
-                + "             </Test>"
-                + "        </TestCase>"
-                + "     </TestSuite>\n"
-                + "</TestPackage>\n";
-
-        final String caseDescPath = caseRepository.getXmlPath(packageName);
-        final String caseAPK = caseRepository.getApkPath(packageName);
-
-        try {
-            createFile(descriptionConfigStr, caseDescPath);
-            createFile("", caseAPK);
-
-            HostConfig.getInstance().loadTestPackages();
-
-            list = caseRepository.listAvailablePackage(expect1);
-            packageList = list.get(0);
-            suiteList = list.get(1);
-            caseList = list.get(2);
-            testList = list.get(3);
-            assertEquals(1, packageList.size());
-            assertEquals(expect2, packageList.get(0));
-            assertEquals(0, suiteList.size());
-            assertEquals(0, caseList.size());
-            assertEquals(0, testList.size());
-
-            list = caseRepository.listAvailablePackage(expect2);
-            packageList = list.get(0);
-            suiteList = list.get(1);
-            caseList = list.get(2);
-            testList = list.get(3);
-            assertEquals(0, packageList.size());
-            assertEquals(1, suiteList.size());
-            assertEquals(expect3, suiteList.get(0));
-            assertEquals(0, caseList.size());
-            assertEquals(0, testList.size());
-
-            list = caseRepository.listAvailablePackage(expect3);
-            packageList = list.get(0);
-            suiteList = list.get(1);
-            caseList = list.get(2);
-            testList = list.get(3);
-            assertEquals(0, packageList.size());
-            assertEquals(0, suiteList.size());
-            assertEquals(1, caseList.size());
-            assertEquals(expect4, caseList.get(0));
-            assertEquals(0, testList.size());
-
-            list = caseRepository.listAvailablePackage(expect4);
-            packageList = list.get(0);
-            suiteList = list.get(1);
-            caseList = list.get(2);
-            testList = list.get(3);
-            assertEquals(0, packageList.size());
-            assertEquals(0, suiteList.size());
-            assertEquals(0, caseList.size());
-            assertEquals(1, testList.size());
-            assertEquals(expect5, testList.get(0));
-
-            list = caseRepository.listAvailablePackage(expect6);
-            packageList = list.get(0);
-            suiteList = list.get(1);
-            caseList = list.get(2);
-            testList = list.get(3);
-            assertEquals(0, packageList.size());
-            assertEquals(0, suiteList.size());
-            assertEquals(0, caseList.size());
-            assertEquals(1, testList.size());
-            assertEquals(expect5, testList.get(0));
-        } finally {
-            deleteFile(caseDescPath);
-            deleteFile(caseAPK);
-        }
-    }
-
-    /**
-     * Test starting console UI.
-     */
-    public void testStartUi() throws Exception {
-        String cmdLine = CONFIG_PATH;
-        ConsoleUi cui = new ConsoleUi(TestHost.getInstance());
-        CommandParser cp = TestHost.init(cui, cmdLine.split(" "));
-        assertEquals(null, cp);
-        assertEquals(TestHost.MODE.CONSOLE, TestHost.sMode);
-
-        cmdLine = ROOT;
-        cp = TestHost.init(cui, cmdLine.split(" "));
-        assertEquals(null, cp);
-        assertEquals(TestHost.MODE.CONSOLE, TestHost.sMode);
-    }
-
-    /**
-     * Test starting test plan directly when activating CTS from console.
-     */
-    public void testStartPlanDirectly() throws Exception {
-        String cmdLine = "start --plan demo --config " + CONFIG_PATH;
-        ConsoleUi cui = new ConsoleUi(TestHost.getInstance());
-        CommandParser cp = TestHost.init(cui, cmdLine.split(" "));
-        assertEquals(CTSCommand.START, cp.getAction());
-        assertTrue(cp.containsKey(CTSCommand.OPTION_CFG));
-        assertTrue(cp.getValue(CTSCommand.OPTION_CFG) != null);
-        assertTrue(cp.containsKey(CTSCommand.OPTION_PLAN));
-        assertTrue(cp.getValue(CTSCommand.OPTION_PLAN) != null);
-        cp.removeKey(CTSCommand.OPTION_CFG);
-        assertFalse(cp.containsKey(CTSCommand.OPTION_CFG));
-        assertEquals(null, cp.getValue(CTSCommand.OPTION_CFG));
-
-        cmdLine = "start --plan demo --config " + ROOT;
-        cp = TestHost.init(cui, cmdLine.split(" "));
-        assertTrue(cp.containsKey(CTSCommand.OPTION_CFG));
-        assertTrue(cp.getValue(CTSCommand.OPTION_CFG) != null);
-        assertTrue(cp.containsKey(CTSCommand.OPTION_PLAN));
-        assertTrue(cp.getValue(CTSCommand.OPTION_PLAN) != null);
-        cp.removeKey(CTSCommand.OPTION_CFG);
-        assertFalse(cp.containsKey(CTSCommand.OPTION_CFG));
-        assertEquals(null, cp.getValue(CTSCommand.OPTION_CFG));
-    }
-
-    /**
-     * Test starting package directly when activating CTS from console.
-     */
-    public void testStartPackageDirectly() throws Exception {
-        String cmdLine = "start -p demo.zip --config " + CONFIG_PATH;
-        ConsoleUi cui = new ConsoleUi(TestHost.getInstance());
-        CommandParser cp = TestHost.init(cui, cmdLine.split(" "));
-        assertEquals(CTSCommand.START, cp.getAction());
-        assertTrue(cp.containsKey(CTSCommand.OPTION_CFG));
-        assertTrue(cp.getValue(CTSCommand.OPTION_CFG) != null);
-        assertTrue(cp.containsKey(
-                CTSCommand.OPTION_PACKAGE) || cp.containsKey(CTSCommand.OPTION_P));
-        assertEquals("demo.zip", cp.getValue(CTSCommand.OPTION_PACKAGE));
-        cp.removeKey(CTSCommand.OPTION_CFG);
-        assertFalse(cp.containsKey(CTSCommand.OPTION_CFG));
-        assertEquals(null, cp.getValue(CTSCommand.OPTION_CFG));
-
-        cmdLine = "start --package demo.zip --config " + ROOT;
-        cp = TestHost.init(cui, cmdLine.split(" "));
-        assertTrue(cp.containsKey(CTSCommand.OPTION_CFG));
-        assertTrue(cp.getValue(CTSCommand.OPTION_CFG) != null);
-        assertTrue(cp.containsKey(
-                CTSCommand.OPTION_PACKAGE) || cp.containsKey(CTSCommand.OPTION_P));
-        assertEquals("demo.zip", cp.getValue(CTSCommand.OPTION_PACKAGE));
-        cp.removeKey(CTSCommand.OPTION_CFG);
-        assertFalse(cp.containsKey(CTSCommand.OPTION_CFG));
-        assertEquals(null, cp.getValue(CTSCommand.OPTION_CFG));
-    }
-
-    /**
-     * Test getting device ID from the device ID string list.
-     */
-    public void testGetDeviceId() {
-        ConsoleUi cui = new ConsoleUi(TestHost.getInstance());
-        ArrayList<TestDevice> devList = new ArrayList<TestDevice>();
-        devList.add(new TestDevice("dev-100"));
-        devList.add(new TestDevice("dev-101"));
-        TestDevice[] devices = devList.toArray(new TestDevice[4]);
-
-        int deviceId = cui.getDeviceId(devices, "dev-100");
-        assertEquals(0, deviceId);
-
-        deviceId = cui.getDeviceId(devices, "dev-101");
-        assertEquals(1, deviceId);
-    }
-}
diff --git a/tools/host/test/com/android/cts/CtsTestBase.java b/tools/host/test/com/android/cts/CtsTestBase.java
deleted file mode 100644
index 1df40a7..0000000
--- a/tools/host/test/com/android/cts/CtsTestBase.java
+++ /dev/null
@@ -1,182 +0,0 @@
-/*
- * Copyright (C) 2008 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.cts;
-
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-
-import junit.framework.TestCase;
-
-/**
- * Set up the test environment and offer the utility APIs.
- */
-public abstract class CtsTestBase extends TestCase {
-    public static final String APK_SUFFIX = ".apk";
-    public static final String DESCRITION_SUFFIX = ".xml";
-
-    protected static final String ROOT = "tmp";
-    protected static final String CONFIG_PATH = ROOT + File.separator + "host_config.xml";
-
-    private static final String CASE_REPOSITORY = "case_rep_demo";
-    private static final String RESULT_REPOSITORY = "result_rep_demo";
-    private static final String PLAN_REPOSITORY = "plan_rep_demo";
-
-    /** {@inheritDoc} */
-    @Override
-    public void setUp() {
-        // create root direcoty for the test
-        new File(ROOT).mkdirs();
-
-        initConfig();
-        Log.initLog(ROOT);
-    }
-
-    /** {@inheritDoc} */
-    @Override
-    public void tearDown() {
-        Log.closeLog();
-        clearDirectory(ROOT);
-    }
-
-    /**
-     * Initialize the configuration for tests.
-     */
-    private void initConfig() {
-        StringBuilder buf = new StringBuilder();
-
-        buf.append("<HostConfiguration>");
-        buf.append("\t<Repository root=\"" + ROOT + "\" >");
-        buf.append("\t\t<TestPlan path=\"" + PLAN_REPOSITORY + "\" />");
-        buf.append("\t\t<TestCase path=\"" + CASE_REPOSITORY + "\" />");
-        buf.append("\t\t<TestResult path=\"" + RESULT_REPOSITORY + "\" />");
-        buf.append("\t</Repository>");
-        buf.append("</HostConfiguration>");
-        try {
-            new File(ROOT + File.separator + PLAN_REPOSITORY).mkdirs();
-            new File(ROOT + File.separator + CASE_REPOSITORY).mkdirs();
-            new File(ROOT + File.separator + RESULT_REPOSITORY).mkdirs();
-            createFile(buf.toString(), CONFIG_PATH);
-
-        } catch (IOException e1) {
-            fail("Can't create config file");
-        }
-
-        try {
-            TestHost.loadConfig(CONFIG_PATH);
-        } catch (Exception e) {
-            e.printStackTrace();
-            fail("Can't initiate config");
-        }
-    }
-
-    /**
-     * Create test package with the package name and the xml message as the content.
-     * 
-     * @param xmlMsg The message as the content of the package.
-     * @param packageName The package name.
-     */
-    protected void createTestPackage(String xmlMsg, String packageName) throws IOException {
-        String caseRoot = HostConfig.getInstance().getCaseRepository()
-                .getRoot();
-
-        String apkPath = caseRoot + File.separator + packageName + APK_SUFFIX;
-        String xmlPath = caseRoot + File.separator + packageName
-                + DESCRITION_SUFFIX;
-
-        createFile(null, apkPath);
-        createFile(xmlMsg, xmlPath);
-    }
-
-    /**
-     * Delete the test package.
-     */
-    protected void deleteTestPackage(String path) {
-        String apkPath = path + File.separator + APK_SUFFIX;
-        String desPath = path + File.separator + DESCRITION_SUFFIX;
-
-        deleteFile(apkPath);
-        deleteFile(desPath);
-    }
-
-    /**
-     * Create the specified file with the specified content.
-     * 
-     * @param content The content written into the file.
-     * @param filePath The file to be created.
-     */
-    protected void createFile(String content, String filePath)
-            throws IOException {
-        BufferedWriter out = new BufferedWriter(new FileWriter(filePath));
-        if (content != null) {
-            out.write(content);
-        }
-
-        out.close();
-    }
-
-    /**
-     * Delete the specified file.
-     * 
-     * @param path The file to be deleted.
-     */
-    protected void deleteFile(String path) {
-        File f = new File(path);
-
-        if (f.exists() && f.canWrite()) {
-            f.delete();
-        }
-    }
-
-    /**
-     * Clear the directory by deleting the files and directories under it.
-     * 
-     * @param path The directory to be cleared.
-     */
-    private void clearDirectory(String path) {
-        File root = new File(path);
-        for (File f : root.listFiles()) {
-            if (f.isFile()) {
-                f.delete();
-            } else {
-                deleteDirectory(f);
-            }
-        }
-
-        root.delete();
-    }
-
-    /**
-     * Deleted the directory, including the files and sub-directories under it.
-     * 
-     * @param path The directory to be deleted.
-     */
-    private void deleteDirectory(File path) {
-        if (path.exists()) {
-            File[] files = path.listFiles();
-            for (int i = 0; i < files.length; i++) {
-                if (files[i].isDirectory()) {
-                    deleteDirectory(files[i]);
-                } else {
-                    files[i].delete();
-                }
-            }
-
-            path.delete();
-        }
-    }
-}
diff --git a/tools/host/test/com/android/cts/DeviceManagerTests.java b/tools/host/test/com/android/cts/DeviceManagerTests.java
deleted file mode 100644
index 6fed9ec..0000000
--- a/tools/host/test/com/android/cts/DeviceManagerTests.java
+++ /dev/null
@@ -1,175 +0,0 @@
-/*
- * Copyright (C) 2008 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.cts;
-
-/**
- * Test the device manager.
- */
-public class DeviceManagerTests extends CtsTestBase {
-
-    private TestDevice d1, d2, d3;
-    private static String d1SerialNumber = "mock_device1";
-    private static String d2SerialNumber = "mock_device2";
-    private static String d3SerialNumber = "mock_device3";
-
-    /** {@inheritDoc} */
-    @Override
-    public void setUp() {
-        d1 = new TestDevice(d1SerialNumber);
-        d2 = new TestDevice(d2SerialNumber);
-        d3 = new TestDevice(d3SerialNumber);
-    }
-
-    /** {@inheritDoc} */
-    @Override
-    public void tearDown() {
-        d1 = d2 = d3 = null;
-    }
-
-    /**
-     * Test allocating devices.
-     */
-    public void testAllocateDevices() throws DeviceNotAvailableException {
-        DeviceManager dm = new DeviceManager();
-        TestDevice[] devices;
-
-        try {
-            devices = dm.allocateDevices(1);
-            fail();
-        } catch (DeviceNotAvailableException e) {
-            // pass
-        }
-        dm.mDevices.add(d1);
-        dm.mDevices.add(d2);
-        dm.mDevices.add(d3);
-
-        try {
-            devices = dm.allocateDevices(-1);
-            fail();
-        } catch (IllegalArgumentException e) {
-            // pass
-        }
-
-        devices = dm.allocateDevices(0);
-        assertEquals(0, devices.length);
-
-        try {
-            devices = dm.allocateDevices(4);
-            fail();
-        } catch (DeviceNotAvailableException e) {
-            // pass
-        }
-
-        devices = dm.allocateDevices(2);
-        assertEquals(2, devices.length);
-        assertEquals(d1SerialNumber, devices[0].getSerialNumber());
-        assertEquals(d2SerialNumber, devices[1].getSerialNumber());
-
-        d1.setStatus(TestDevice.STATUS_BUSY);
-        d3.setStatus(TestDevice.STATUS_OFFLINE);
-        try {
-            devices = dm.allocateDevices(2);
-            fail();
-        } catch (DeviceNotAvailableException e) {
-            // pass
-        }
-        devices = dm.allocateDevices(1);
-        assertEquals(1, devices.length);
-        assertEquals(d2SerialNumber, devices[0].getSerialNumber());
-    }
-
-    /**
-     * Test getting device list.
-     */
-    public void testGetDeviceList() {
-        DeviceManager dm = new DeviceManager();
-        TestDevice[] devices;
-
-        dm.mDevices.add(d1);
-        dm.mDevices.add(d2);
-        dm.mDevices.add(d3);
-        devices = dm.getDeviceList();
-        assertEquals(3, devices.length);
-        assertEquals(d1SerialNumber, devices[0].getSerialNumber());
-        assertEquals(d2SerialNumber, devices[1].getSerialNumber());
-        assertEquals(d3SerialNumber, devices[2].getSerialNumber());
-    }
-
-    /**
-     * Test getting the number of all available devices.
-     */
-    public void testGetNumOfAllAvailableDevices() {
-        DeviceManager dm = new DeviceManager();
-        assertEquals(0, dm.getCountOfFreeDevices());
-
-        d1.setStatus(TestDevice.STATUS_BUSY);
-        d2.setStatus(TestDevice.STATUS_OFFLINE);
-        dm.mDevices.add(d1);
-        dm.mDevices.add(d2);
-        dm.mDevices.add(d3);
-        assertEquals(1, dm.getCountOfFreeDevices());
-    }
-
-    /**
-     * Test the default status of test device.
-     */
-    public void testDeviceDefaultStatus() {
-        assertEquals(TestDevice.STATUS_IDLE, d1.getStatus());
-        assertEquals(TestDevice.STATUS_IDLE, d2.getStatus());
-        assertEquals(TestDevice.STATUS_IDLE, d3.getStatus());
-    }
-
-    /**
-     * Test allocating device by the specified ID.
-     */
-    public void testAllocateDeviceById() throws DeviceNotAvailableException {
-        DeviceManager dm = new DeviceManager();
-        TestDevice device;
-
-        d1.setStatus(TestDevice.STATUS_BUSY);
-        d2.setStatus(TestDevice.STATUS_OFFLINE);
-        dm.mDevices.add(d1);
-        dm.mDevices.add(d2);
-        dm.mDevices.add(d3);
-
-        try {
-            device = dm.allocateFreeDeviceById("fake device");
-            fail();
-        } catch (DeviceNotAvailableException e) {
-            // pass
-        }
-
-        device = dm.allocateFreeDeviceById(d3SerialNumber);
-        assertEquals(d3SerialNumber, device.getSerialNumber());
-    }
-
-    /**
-     * Test resetting test devices.
-     */
-    public void testResetTestDevices() {
-        DeviceManager dm = new DeviceManager();
-
-        d1.setStatus(TestDevice.STATUS_BUSY);
-        d2.setStatus(TestDevice.STATUS_OFFLINE);
-        dm.resetTestDevice(d1);
-        dm.resetTestDevice(d2);
-        dm.resetTestDevice(d3);
-        assertEquals(d1.getStatus(), TestDevice.STATUS_IDLE);
-        assertEquals(d2.getStatus(), TestDevice.STATUS_OFFLINE);
-        assertEquals(d3.getStatus(), TestDevice.STATUS_IDLE);
-    }
-}
diff --git a/tools/host/test/com/android/cts/TestPlanBuilderTests.java b/tools/host/test/com/android/cts/TestPlanBuilderTests.java
deleted file mode 100644
index 7f2f74e..0000000
--- a/tools/host/test/com/android/cts/TestPlanBuilderTests.java
+++ /dev/null
@@ -1,300 +0,0 @@
-/*
- * Copyright (C) 2008 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.cts;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.security.NoSuchAlgorithmException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactoryConfigurationError;
-
-/**
- * Test the test plan builder.
- *
- */
-public class TestPlanBuilderTests extends CtsTestBase {
-    public static boolean DEBUG = false;
-
-    private String mTestPackageBinaryName = "CtsTestPackage";
-
-    /** {@inheritDoc} */
-    @Override
-    public void tearDown() {
-        HostConfig.getInstance().removeTestPacakges();
-        deleteTestPackage(mTestPackageBinaryName);
-
-        super.tearDown();
-    }
-
-    /**
-     * Test getting test suite name list contained within a test package.
-     */
-    public void testGetTestSuiteNames() throws IOException, NoSuchAlgorithmException {
-        final String appPackageName = "com.google.android.cts";
-        final String fullName = mTestPackageBinaryName + ".CtsTest";
-        final String caseName = "CtsTestHello";
-        final String testName = "testHello";
-
-        final String descriptionConfigStr = "<TestPackage name=\"" + mTestPackageBinaryName + "\""
-                + " appPackageName=\"" + appPackageName + "\""
-                + " version=\"1.0\" AndroidFramework=\"Android 1.0\""
-                + " runner=\"android.test.InstrumentationTestRunner\" >\n"
-                + "  <Description>something extracted from java doc</Description>\n"
-                + "  <TestSuite name=\"com.google\">\n"
-                + "     <TestCase name=\"CtsTestHello\" priority=\"mandatory\">\n"
-                + "         <Description>" + "something extracted from java doc"
-                + "         </Description>\n"
-                + "         <!-- Test Methods -->\n"
-                + "         <Test name=\"testHello\"" + " type=\"automatic\"" + "/>\n"
-                + "     </TestCase>\n"
-                + "     <TestSuite name=\"TestSuiteName\">\n"
-                + "         <TestCase name=\"TestCaseName\" priority=\"mandatory\">\n"
-                + "             <Description>" + "something extracted from java doc"
-                + "             </Description>\n"
-                + "             <!-- Test Methods -->\n"
-                + "             <Test name=\"testName1\"" + " type=\"automatic\"" + "/>\n"
-                + "         </TestCase>\n"
-                + "     </TestSuite>\n"
-                + "  </TestSuite>\n"
-                + "</TestPackage>\n";
-
-        HostConfig.getInstance().removeTestPacakges();
-        createTestPackage(descriptionConfigStr, mTestPackageBinaryName);
-
-        HostConfig.getInstance().loadTestPackages();
-        Collection<TestPackage> testPackages = HostConfig.getInstance().getTestPackages();
-        assertEquals(1, testPackages.size());
-        TestPackage testPackage = testPackages.iterator().next();
-
-        String suiteFullName = "com.google";
-        TestSuite suite = testPackage.getTestSuiteByName(suiteFullName);
-        assertEquals(suiteFullName, suite.getFullName());
-
-        String caseFullName = "com.google.CtsTestHello";
-        TestCase cazz = testPackage.getTestCaseByName(caseFullName);
-        assertEquals(caseFullName, cazz.getFullName());
-
-        List<String> testNames = testPackage.getAllTestNames(caseFullName);
-        String testFullName = "com.google.CtsTestHello#testHello";
-        assertEquals(1, testNames.size());
-        assertEquals(testFullName, testNames.get(0));
-
-        suiteFullName = "com.google.TestSuiteName";
-        suite = testPackage.getTestSuiteByName(suiteFullName);
-        assertEquals(suiteFullName, suite.getFullName());
-
-        caseFullName = "com.google.TestSuiteName.TestCaseName";
-        cazz = testPackage.getTestCaseByName(caseFullName);
-        assertEquals(caseFullName, cazz.getFullName());
-
-        testNames = testPackage.getAllTestNames(caseFullName);
-        testFullName = "com.google.TestSuiteName.TestCaseName#testName1";
-        assertEquals(1, testNames.size());
-        assertEquals(testFullName, testNames.get(0));
-    }
-
-    /**
-     * Test building test plan.
-     */
-    public void testPlanBuilder() throws IOException,
-            ParserConfigurationException,
-            TransformerFactoryConfigurationError, TransformerException, NoSuchAlgorithmException {
-
-        if (DEBUG) {
-            final String appPackageName = "com.google";
-            final String suiteName1 = "com.google.SuiteName1";
-            final String caseName1 = "CtsTestHello";
-            final String testName1 = "testHello";
-
-            final String cName2 = "CtsTestHello2";
-            final String testName2 = "testHello2";
-            final String testName3 = "testHello3";
-            final String testName4 = "testHello4";
-            final String testName5 = "testHello5";
-            final String nestedSuiteName1 = "com.google";
-            final String nestedSuiteName2 = "CtsTest.SuiteName2";
-
-            final String descriptionConfigStr =
-                    "<TestPackage name=\"" + mTestPackageBinaryName + "\""
-                    + " appPackageName=\"" + appPackageName + "\""
-                    + " version=\"1.0\" AndroidFramework=\"Android 1.0\""
-                    + " runner=\"android.test.InstrumentationTestRunner\" >\n"
-                    + " <Description>something extracted from java doc</Description>\n"
-                    + " <TestSuite name=\"" + suiteName1 + "\"" + ">\n"
-                    + "     <TestCase name=\"" + caseName1 + "\"" + " category=\"mandatory\">\n"
-                    + "         <Description>" + "something extracted from java doc"
-                    + "         </Description>\n"
-                    + "         <!-- Test Methods -->\n"
-                    + "         <Test name=\"" + testName1 + "\" type=\"automatic\"" + "/>\n"
-                    + "     </TestCase>\n"
-                    + " </TestSuite>\n"
-                    + " <TestSuite name=\"" + nestedSuiteName1+ "\"" + ">\n"
-                    + "     <TestSuite name=\"" + nestedSuiteName2+ "\"" + ">\n"
-                    + "         <TestCase name=\"" + cName2 + "\"" + " priority=\"mandatory\">\n"
-                    + "             <Test name=\"" + testName2 +"\" type=\"automatic\" />\n"
-                    + "             <Test name=\"" + testName3 +"\" type=\"automatic\" />\n"
-                    + "             <Test name=\"" + testName4 +"\" type=\"automatic\" />\n"
-                    + "             <Test name=\"" + testName5 +"\" type=\"automatic\" />\n"
-                    + "         </TestCase>\n"
-                    + "     </TestSuite>\n"
-                    + " </TestSuite>\n"
-                    + "</TestPackage>\n";
-
-            createTestPackage(descriptionConfigStr, mTestPackageBinaryName);
-            HostConfig.getInstance().loadTestPackages();
-            ArrayList<String> packageNames = new ArrayList<String>();
-            packageNames.add(appPackageName);
-            PlanBuilder planBuilder = new PlanBuilder(packageNames);
-            BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
-            planBuilder.setInputStream(in);
-            HashMap<String, ArrayList<String>> results = planBuilder.doSelect();
-            String planName = "plan_test";
-            if (results != null) {
-                Log.i("result=" + results.toString());
-                ArrayList<String> excludedList = results.get(appPackageName);
-                if (excludedList != null) {
-                    for(String str : excludedList) {
-                        Log.i(str);
-                    }
-                } else {
-                    Log.i("Nothing is excluded at all!");
-                }
-
-                String planPath =
-                              HostConfig.getInstance().getPlanRepository().getPlanPath(planName);
-                TestSessionBuilder.getInstance().serialize(planName, packageNames, results);
-                Log.i("planPath=" + planPath);
-            } else {
-                Log.i("Selected nothing for the plan of "
-                        + planName + ". The plan is not created!");
-            }
-        }
-    }
-
-    /**
-     * Test get excluded list.
-     */
-    public void testGetExcludedList() throws IOException,
-            TransformerFactoryConfigurationError, NoSuchAlgorithmException {
-
-        final String appPackageName = "com.google";
-        final String suiteName1 = "com.google.SuiteName1";
-        final String caseName1 = "CtsTestHello";
-        final String testName1 = "testHello";
-
-        final String cName2 = "CtsTestHello2";
-        final String testName2 = "testHello2";
-        final String testName3 = "testHello3";
-        final String testName4 = "testHello4";
-        final String testName5 = "testHello5";
-        final String nestedSuiteName1 = "com.google";
-        final String nestedSuiteName2 = "CtsTest.SuiteName2";
-
-        final String descriptionConfigStr =
-                    "<TestPackage name=\"" + mTestPackageBinaryName + "\""
-                    + " appPackageName=\"" + appPackageName + "\""
-                    + " version=\"1.0\" AndroidFramework=\"Android 1.0\""
-                    + " runner=\"android.test.InstrumentationTestRunner\" >\n"
-                    + " <Description>something extracted from java doc</Description>\n"
-                    + " <TestSuite name=\"" + suiteName1 + "\"" + ">\n"
-                    + "     <TestCase name=\"" + caseName1 + "\"" + " category=\"mandatory\">\n"
-                    + "         <Description>" + "something extracted from java doc"
-                    + "         </Description>\n"
-                    + "         <!-- Test Methods -->\n"
-                    + "         <Test name=\"" + testName1 + "\" type=\"automatic\"" + "/>\n"
-                    + "     </TestCase>\n"
-                    + " </TestSuite>\n"
-                    + " <TestSuite name=\"" + nestedSuiteName1+ "\"" + ">\n"
-                    + "     <TestSuite name=\"" + nestedSuiteName2+ "\"" + ">\n"
-                    + "         <TestCase name=\"" + cName2 + "\"" + " priority=\"mandatory\">\n"
-                    + "             <Test name=\"" + testName2 +"\" type=\"automatic\" />\n"
-                    + "             <Test name=\"" + testName3 +"\" type=\"automatic\" />\n"
-                    + "         </TestCase>\n"
-                    + "     </TestSuite>\n"
-                    + "     <TestCase name=\"" + caseName1 + "\"" + " category=\"mandatory\">\n"
-                    + "         <Description>" + "something extracted from java doc"
-                    + "         </Description>\n"
-                    + "         <!-- Test Methods -->\n"
-                    + "         <Test name=\"" + testName1 + "\" type=\"automatic\"" + "/>\n"
-                    + "     </TestCase>\n"
-                    + " </TestSuite>\n"
-                    + "</TestPackage>\n";
-
-        createTestPackage(descriptionConfigStr, mTestPackageBinaryName);
-        HostConfig hf = HostConfig.getInstance();
-        hf.loadTestPackages();
-        TestPackage pkg = hf.getTestPackage(appPackageName);
-        assertNotNull(pkg);
-        String caseOneName = suiteName1 + "." + caseName1;
-        String caseTwoName = nestedSuiteName1 + "." + nestedSuiteName2 + "." + cName2;
-        Collection<Test> tests = pkg.getTests();
-        assertEquals(4, tests.size());
-        Iterator<Test> iterator = tests.iterator();
-        Test test1 = iterator.next();
-        Test test2 = iterator.next();
-        Test test3 = iterator.next();
-        Test test4 = iterator.next();
-        ArrayList<String> excludedList = null;
-
-        //scenario 1: all tests are not executed and get excluded list with notExecuted
-        excludedList = pkg.getExcludedList(CtsTestResult.STR_NOT_EXECUTED);
-        assertNotNull(excludedList);
-        assertEquals(0, excludedList.size());
-
-        //scenario 2: all tests are not executed and get excluded list with timeout
-        excludedList = pkg.getExcludedList(CtsTestResult.STR_TIMEOUT);
-        assertNull(excludedList);
-
-        //scenario 3: all tests are not executed and get excluded list with nothing
-        excludedList = pkg.getExcludedList(null);
-        assertNotNull(excludedList);
-        assertEquals(0, excludedList.size());
-
-        //scenario 4: not all all tests are executed and get excluded list with notExecuted
-        test2.setResult(new CtsTestResult(CtsTestResult.CODE_PASS, null, null));
-        excludedList = pkg.getExcludedList(CtsTestResult.STR_NOT_EXECUTED);
-        assertNotNull(excludedList);
-        assertEquals(1, excludedList.size());
-        assertEquals(test2.getFullName(), excludedList.get(0));
-        test2.setResult(new CtsTestResult(CtsTestResult.CODE_NOT_EXECUTED, null, null));
-
-        //scenario 5: excluded a whole suite
-        test1.setResult(new CtsTestResult(CtsTestResult.CODE_PASS, null, null));
-        excludedList = pkg.getExcludedList(CtsTestResult.STR_NOT_EXECUTED);
-        assertNotNull(excludedList);
-        assertEquals(1, excludedList.size());
-        assertEquals(suiteName1, excludedList.get(0));
-        test1.setResult(new CtsTestResult(CtsTestResult.CODE_NOT_EXECUTED, null, null));
-
-        //scenario 6: excluded the test case directly under the embedded test suite
-        String caseName = nestedSuiteName1 + "." + caseName1;
-        test4.setResult(new CtsTestResult(CtsTestResult.CODE_PASS, null, null));
-        excludedList = pkg.getExcludedList(CtsTestResult.STR_NOT_EXECUTED);
-        assertNotNull(excludedList);
-        assertEquals(1, excludedList.size());
-        assertEquals(caseName, excludedList.get(0));
-        test4.setResult(new CtsTestResult(CtsTestResult.CODE_NOT_EXECUTED, null, null));
-    }
-}
diff --git a/tools/host/test/com/android/cts/TestSessionBuilderTests.java b/tools/host/test/com/android/cts/TestSessionBuilderTests.java
deleted file mode 100644
index d0f5230..0000000
--- a/tools/host/test/com/android/cts/TestSessionBuilderTests.java
+++ /dev/null
@@ -1,1445 +0,0 @@
-/*
- * Copyright (C) 2008 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.cts;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileReader;
-import java.io.IOException;
-import java.security.NoSuchAlgorithmException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactoryConfigurationError;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-import org.xml.sax.SAXException;
-
-import android.annotation.cts.Profile;
-
-import com.android.cts.TestDevice.DeviceParameterCollector;
-
-/**
- * Test the session builder.
- */
-public class TestSessionBuilderTests extends CtsTestBase {
-    private static final String mTmpPlanFileName = "plan";
-
-    private static final String ATTRIBUTE_DEVICE_ID = "deviceID";
-    private static final String ATTRIBUTE_BUILD_ID = "buildID";
-    private static final String ATTRIBUTE_BUILD_VERSION = "buildVersion";
-    private static final String ATTRIBUTE_BUILD_NAME = "buildName";
-
-    private String mTestPackageBinaryName = "CtsTestPackage";
-
-    /** {@inheritDoc} */
-    @Override
-    public void tearDown() {
-        HostConfig.getInstance().removeTestPacakges();
-        deleteTestPackage(mTestPackageBinaryName);
-
-        super.tearDown();
-    }
-
-    /**
-     * Test building simple test session.
-     */
-    public void testBuildSimpleSession() throws IOException,
-            ParserConfigurationException, SAXException, TestPlanNotFoundException,
-            TestNotFoundException, NoSuchAlgorithmException {
-        final String appPackageName = "com.google.android.cts" + ".CtsTest";
-        final String suiteName = appPackageName;
-        final String caseName = "CtsTestHello";
-        final String runner = "android.test.InstrumentationTestRunner";
-
-        final String serialNum = "serialNum";
-        final String buildID = "buildid";
-        final String buildName = "buildname";
-        final String buildVersion = "buildVersion";
-        final String testPlanConfigStr = "<TestPlan version=\"1.0\">\n"
-                + "\t<Description>Demo test plan</Description>\n"
-                + "\t\t<PlanSettings>\n"
-                + "\t\t\t<RequiredDevice amount=\"" + 1 + "\"" + "/>\n"
-                + "\t\t</PlanSettings>\n"
-                + "\t<Entry uri=\""
-                + appPackageName
-                + "\"/>\n"
-                + "</TestPlan>";
-
-        final String descriptionConfigStr = "<TestPackage name=\""
-                + mTestPackageBinaryName+ "\" "
-                + "appPackageName=\"" + appPackageName
-                + "\" version=\"1.0\" AndroidFramework=\"Android 1.0\""
-                + " runner=\"" + runner + "\">\n"
-                + " <Description>something extracted from java doc</Description>\n"
-                + " <TestSuite name=\"" + suiteName + "\"" + ">\n"
-                + "     <TestCase name=\"" + caseName + "\"" + " priority=\"mandatory\">\n"
-                + "         <Description>" + "something extracted from java doc"
-                + "         </Description>\n"
-                + "         <!-- Test Methods -->\n"
-                + "         <Test name=\"testHello\"" + " type=\"automatic\"" + "/>\n"
-                + "     </TestCase>\n"
-                + " </TestSuite>\n"
-                + "</TestPackage>\n";
-
-        HostConfig.getInstance().removeTestPacakges();
-        String planPath =
-            HostConfig.getInstance().getPlanRepository().getPlanPath(mTmpPlanFileName);
-        createFile(testPlanConfigStr, planPath);
-
-        createTestPackage(descriptionConfigStr, mTestPackageBinaryName);
-        HostConfig.getInstance().loadTestPackages();
-
-        TestSession ts = TestSessionBuilder.getInstance().build(planPath, Profile.ALL);
-        assertEquals(1, ts.getNumOfRequiredDevices());
-
-        TestSessionLog tsl = ts.getSessionLog();
-        assertEquals(1, tsl.getTestPackages().size());
-
-        TestPackage testPackage = tsl.getTestPackages().iterator().next();
-        assertEquals(1, testPackage.getTestSuites().size());
-        assertEquals(mTestPackageBinaryName, testPackage.getAppBinaryName());
-        assertEquals(appPackageName, testPackage.getAppPackageName());
-        assertEquals("1.0", testPackage.getVersion());
-        assertEquals("Android 1.0", testPackage.getAndroidVersion());
-        assertEquals(runner, testPackage.getInstrumentationRunner());
-
-        TestSuite testSuite = testPackage.getTestSuites().iterator().next();
-        assertEquals(1, testSuite.getTestCases().size());
-        assertEquals(suiteName, testSuite.getFullName());
-
-        TestCase testCase = testSuite.getTestCases().iterator().next();
-        assertEquals(caseName, testCase.getName());
-        assertEquals("mandatory", testCase.getPriority());
-
-        Test test = testCase.getTests().iterator().next();
-        assertEquals("automatic", test.getType());
-        assertEquals(CtsTestResult.CODE_NOT_EXECUTED, test.getResult().getResultCode());
-        assertEquals(runner, test.getInstrumentationRunner());
-
-        // test build information
-        DeviceParameterCollector deviceParam = new DeviceParameterCollector();
-        deviceParam.setSerialNumber(serialNum);
-        deviceParam.setBuildId(buildID);
-        deviceParam.setBuildVersion(buildVersion);
-        deviceParam.setProductName(buildName);
-        tsl.setDeviceInfo(deviceParam);
-        Document doc = tsl.createResultDoc();
-
-        Node buildInfoNode = doc.getElementsByTagName("BuildInfo").item(0);
-        assertEquals(serialNum, buildInfoNode.getAttributes().getNamedItem(
-                ATTRIBUTE_DEVICE_ID).getNodeValue().trim());
-        assertEquals(buildID, buildInfoNode.getAttributes().getNamedItem(
-                ATTRIBUTE_BUILD_ID).getNodeValue().trim());
-        assertEquals(buildVersion, buildInfoNode.getAttributes().getNamedItem(
-                ATTRIBUTE_BUILD_VERSION).getNodeValue().trim());
-        assertEquals(buildName, buildInfoNode.getAttributes().getNamedItem(
-                ATTRIBUTE_BUILD_NAME).getNodeValue().trim());
-
-        deleteTestPackage(mTestPackageBinaryName);
-    }
-
-    /**
-     * Test getting and removing entries from plan file.
-     */
-    public void testGetAndRemoveEntriesFromPlanFile() throws UnknownCommandException,
-                    CommandNotFoundException, Exception {
-
-        final String appPackageName = "com.google.android.cts";
-        final String suiteName = appPackageName;
-        final String caseName = "CtsTestHello";
-        final String runner = "android.test.InstrumentationTestRunner";
-
-        final String testPlanConfigStr = "<TestPlan version=\"1.0\">\n"
-                + "\t<Description>Demo test plan</Description>\n"
-                + "\t\t<PlanSettings>\n"
-                + "\t\t\t<RequiredDevice amount=\"" + 1 + "\"" + "/>\n"
-                + "\t\t</PlanSettings>\n"
-                + "\t<Entry uri=\""
-                + appPackageName
-                + "\"/>\n"
-                + "</TestPlan>";
-
-        final String descriptionConfigStr = "<TestPackage name=\""
-                + mTestPackageBinaryName+ "\" "
-                + "appPackageName=\"" + appPackageName
-                + "\" version=\"1.0\" AndroidFramework=\"Android 1.0\""
-                + " runner=\"" + runner + "\">\n"
-                + " <Description>something extracted from java doc</Description>\n"
-                + " <TestSuite name=\"" + suiteName + "\"" + ">\n"
-                + "     <TestCase name=\"" + caseName + "\"" + " priority=\"mandatory\">\n"
-                + "         <Description>" + "something extracted from java doc"
-                + "         </Description>\n"
-                + "         <!-- Test Methods -->\n"
-                + "         <Test name=\"testHello\"" + " type=\"automatic\"" + "/>\n"
-                + "     </TestCase>\n"
-                + " </TestSuite>\n"
-                + "</TestPackage>\n";
-
-        HostConfig.getInstance().removeTestPacakges();
-        createTestPackage(descriptionConfigStr, mTestPackageBinaryName);
-        HostConfig.getInstance().loadTestPackages();
-
-        String planPath = HostConfig.getInstance().getPlanRepository()
-                .getPlanPath(mTmpPlanFileName);
-        createFile(testPlanConfigStr, planPath);
-
-        ArrayList<String> removedPkgList = new ArrayList<String>();
-        Collection<String> entries = TestPlan.getEntries(planPath, removedPkgList);
-        Iterator<String> it = entries.iterator();
-
-        assertEquals(1, entries.size());
-        assertEquals(appPackageName, it.next());
-        ConsoleUi cui = new ConsoleUi(TestHost.getInstance());
-        String cmdLine = CTSCommand.REMOVE + " " + "-p" + " "
-                + appPackageName;
-        cui.processCommand(CommandParser.parse(cmdLine));
-        entries = TestPlan.getEntries(planPath, removedPkgList);
-        assertEquals(1, removedPkgList.size());
-
-        deleteTestPackage(mTestPackageBinaryName);
-    }
-
-    /**
-     * Test validating package name.
-     */
-    public void testValidatePackageName() throws IOException {
-        final String packageName = "com.google.android.testname";
-        String testPackageXmlFilePath =
-            HostConfig.getInstance().getCaseRepository().getXmlPath(packageName);
-        String testpackageAPKFilePath =
-            HostConfig.getInstance().getCaseRepository().getApkPath(packageName);
-
-        HostConfig.getInstance().removeTestPacakges();
-        createTestPackage("", packageName);
-
-        assertEquals(true, TestPlan.isValidPackageName(packageName));
-
-        deleteFile(testPackageXmlFilePath);
-        assertEquals(false, TestPlan.isValidPackageName(packageName));
-
-        deleteFile(testpackageAPKFilePath);
-        assertEquals(false, TestPlan.isValidPackageName(packageName));
-    }
-
-    /**
-     * Test building test session with dependency.
-     */
-    public void testBuildSessionWithDependency() throws IOException,
-            ParserConfigurationException, SAXException, TestPlanNotFoundException,
-            TestNotFoundException, NoSuchAlgorithmException {
-
-        final String targetNameSpace = "i don't want to be the target!";
-        final String appPackageName = "com.google.android.cts";
-        final String suiteName = appPackageName + ".CtsTest";
-        final String caseName = "CtsTestHello";
-        final String runner = "android.test.InstrumentationTestRunner";
-
-        final String testPlanConfigStr = "<TestPlan version=\"1.0\">\n"
-                + "\t<Description>Demo test plan</Description>\n"
-                + "\t\t<PlanSettings>\n"
-                + "\t\t\t<RequiredDevice amount=\"" + 1 + "\"" + "/>\n"
-                + "\t\t</PlanSettings>\n"
-                + "\t<Entry uri=\""
-                + appPackageName
-                + "\"/>\n"
-                + "</TestPlan>";
-
-        final String descriptionConfigStr = "<TestPackage name=\""
-                + mTestPackageBinaryName + "\" "
-                + "appPackageName=\"" + appPackageName
-                + "\" targetNameSpace=\"" + targetNameSpace
-                + "\" version=\"1.0\" AndroidFramework=\"Android 1.0\""
-                + " runner=\"" +runner + "\">\n"
-                + " <Description>something extracted from java doc</Description>\n"
-                + " <TestSuite name=\"" + suiteName + "\"" + ">\n"
-                + "     <TestCase name=\"" + caseName + "\"" + " priority=\"mandatory\">\n"
-                + "         <Description>" + "something extracted from java doc"
-                + "         </Description>\n"
-                + "         <!-- Test Methods -->\n"
-                + "         <Test name=\"testHello\"" + " type=\"automatic\"" + "/>\n"
-                + "     </TestCase>\n"
-                + " </TestSuite>\n"
-                + "</TestPackage>\n";
-
-        HostConfig.getInstance().removeTestPacakges();
-
-        String planPath =
-            HostConfig.getInstance().getPlanRepository().getPlanPath(mTmpPlanFileName);
-        createFile(testPlanConfigStr, planPath);
-
-        createTestPackage(descriptionConfigStr, mTestPackageBinaryName);
-        HostConfig.getInstance().loadTestPackages();
-
-        TestSession ts = TestSessionBuilder.getInstance().build(planPath, Profile.ALL);
-        assertEquals(1, ts.getNumOfRequiredDevices());
-
-        TestSessionLog tsl = ts.getSessionLog();
-        assertEquals(1, tsl.getTestPackages().size());
-
-        TestPackage testPackage = tsl.getTestPackages().iterator().next();
-        assertEquals(1, testPackage.getTestSuites().size());
-        assertEquals(mTestPackageBinaryName, testPackage.getAppBinaryName());
-        assertEquals(targetNameSpace, testPackage.getTargetNameSpace());
-        assertEquals("1.0", testPackage.getVersion());
-        assertEquals("Android 1.0", testPackage.getAndroidVersion());
-        assertEquals(runner, testPackage.getInstrumentationRunner());
-
-        TestSuite testSuite = testPackage.getTestSuites().iterator().next();
-        assertEquals(1, testSuite.getTestCases().size());
-        assertEquals(suiteName, testSuite.getFullName());
-
-        TestCase testCase = testSuite.getTestCases().iterator().next();
-        assertEquals(caseName, testCase.getName());
-        assertEquals("mandatory", testCase.getPriority());
-
-        Test test = testCase.getTests().iterator().next();
-        assertEquals("automatic", test.getType());
-        assertEquals(CtsTestResult.CODE_NOT_EXECUTED, test.getResult().getResultCode());
-        assertEquals(runner, test.getInstrumentationRunner());
-
-        deleteTestPackage(mTestPackageBinaryName);
-    }
-
-    /**
-     * Test building test session from embedded suites.
-     */
-    public void testBuildSessionFromEmbeddedSuites() throws IOException,
-            ParserConfigurationException, SAXException, TestPlanNotFoundException,
-            TestNotFoundException, NoSuchAlgorithmException {
-
-        final String appPackageName = "com.google.android.cts";
-        final String caseName = "CtsTestHello";
-        final String testName = "testHello";
-
-        final String testPlanConfigStr = "<TestPlan version=\"1.0\">\n"
-                + "<Description>Demo test plan</Description>\n"
-                + "<PlanSettings>\n"
-                + "    <RequiredDevice amount=\"" + 1 + "\"" + "/>\n"
-                + "</PlanSettings>\n"
-                + "<Entry uri=\"" + appPackageName + "\"/>\n"
-                + "</TestPlan>";
-
-        final String descriptionConfigStr = "<TestPackage name=\"" + mTestPackageBinaryName + "\""
-                + " appPackageName=\"" + appPackageName + "\""
-                + " version=\"1.0\" AndroidFramework=\"Android 1.0\""
-                + " runner=\"android.test.InstrumentationTestRunner\" >\n"
-                + "  <Description>something extracted from java doc</Description>\n"
-                + "  <TestSuite name=\"com.google\">\n"
-                + "     <TestCase name=\"CtsTestHello\" priority=\"mandatory\">\n"
-                + "         <Description>" + "something extracted from java doc"
-                + "         </Description>\n"
-                + "         <!-- Test Methods -->\n"
-                + "         <Test name=\"testHello\"" + " type=\"automatic\"" + "/>\n"
-                + "     </TestCase>\n"
-                + "     <TestSuite name=\"TestSuiteName\">\n"
-                + "         <TestCase name=\"TestCaseName\" priority=\"mandatory\">\n"
-                + "             <Description>" + "something extracted from java doc"
-                + "             </Description>\n"
-                + "             <!-- Test Methods -->\n"
-                + "             <Test name=\"testName\"" + " type=\"automatic\"" + "/>\n"
-                + "         </TestCase>\n"
-                + "     </TestSuite>\n"
-                + "  </TestSuite>\n"
-                + "</TestPackage>\n";
-
-        HostConfig.getInstance().removeTestPacakges();
-
-        String planPath =
-            HostConfig.getInstance().getPlanRepository().getPlanPath(mTmpPlanFileName);
-        createFile(testPlanConfigStr, planPath);
-
-        createTestPackage(descriptionConfigStr, mTestPackageBinaryName);
-        HostConfig.getInstance().loadTestPackages();
-
-        TestSession ts = TestSessionBuilder.getInstance().build(planPath, Profile.ALL);
-        assertEquals(1, ts.getNumOfRequiredDevices());
-
-        TestSessionLog tsl = ts.getSessionLog();
-        assertEquals(1, tsl.getTestPackages().size());
-
-        TestPackage testPackage = tsl.getTestPackages().iterator().next();
-        assertEquals(1, testPackage.getTestSuites().size());
-        assertEquals(mTestPackageBinaryName, testPackage.getAppBinaryName());
-        assertEquals("1.0", testPackage.getVersion());
-        assertEquals("Android 1.0", testPackage.getAndroidVersion());
-
-        TestSuite testSuite;
-        testSuite = testPackage.getTestSuites().iterator().next();
-        assertEquals(1, testSuite.getSubSuites().size());
-        assertEquals(1, testSuite.getTestCases().size());
-        assertEquals("com.google", testSuite.getFullName());
-        assertEquals("com.google", testSuite.getName());
-
-        TestCase testCase = testSuite.getTestCases().iterator().next();
-        assertEquals(caseName, testCase.getName());
-        assertEquals("mandatory", testCase.getPriority());
-
-        Test test = testCase.getTests().iterator().next();
-        assertEquals("com.google.CtsTestHello#testHello", test.getFullName());
-        assertEquals("automatic", test.getType());
-        assertEquals(testName, test.getName());
-        assertEquals(CtsTestResult.CODE_NOT_EXECUTED, test.getResult().getResultCode());
-
-        testSuite = testSuite.getSubSuites().iterator().next();
-        assertEquals(0, testSuite.getSubSuites().size());
-        assertEquals(1, testSuite.getTestCases().size());
-        assertEquals("com.google.TestSuiteName", testSuite.getFullName());
-        assertEquals("TestSuiteName", testSuite.getName());
-
-        testCase = testSuite.getTestCases().iterator().next();
-        assertEquals("TestCaseName", testCase.getName());
-        assertEquals("mandatory", testCase.getPriority());
-
-        test = testCase.getTests().iterator().next();
-        assertEquals("com.google.TestSuiteName.TestCaseName#testName", test.getFullName());
-        assertEquals("automatic", test.getType());
-        assertEquals("testName", test.getName());
-        assertEquals(CtsTestResult.CODE_NOT_EXECUTED, test.getResult().getResultCode());
-
-        deleteTestPackage(mTestPackageBinaryName);
-    }
-
-    /**
-     * Test loading plan with excluded list from the xml file.
-     */
-    public void testExcludingFromXmlFile() throws IOException,
-                ParserConfigurationException,
-                SAXException,
-                TestPlanNotFoundException,
-                TestNotFoundException, NoSuchAlgorithmException {
-
-        final String appPackageName = "com.google.android.cts";
-        final String caseName = "CtsTestHello";
-        final String testName = "testHello";
-        final String excludedList = "com.google.TestSuiteName";
-
-        final String testPlanConfigStr = "<TestPlan version=\"1.0\">\n"
-                + "<Description>Demo test plan</Description>\n"
-                + "<PlanSettings>\n"
-                + "    <RequiredDevice amount=\"" + 1 + "\"" + "/>\n"
-                + "</PlanSettings>\n"
-                + "     <Entry uri=\"" + appPackageName
-                + "\" " + "exclude=\"" + excludedList + "\"/>\n"
-                + "</TestPlan>";
-
-        final String descriptionConfigStr = "<TestPackage name=\"" + mTestPackageBinaryName + "\""
-                + " appPackageName=\"" + appPackageName + "\""
-                + " version=\"1.0\" AndroidFramework=\"Android 1.0\""
-                + " runner=\"android.test.InstrumentationTestRunner\" >\n"
-                + "  <Description>something extracted from java doc</Description>\n"
-                + "  <TestSuite name=\"com.google\">\n"
-                + "     <TestCase name=\"CtsTestHello\" priority=\"mandatory\">\n"
-                + "         <Description>" + "something extracted from java doc"
-                + "         </Description>\n"
-                + "         <!-- Test Methods -->\n"
-                + "         <Test name=\"testHello\"" + " type=\"automatic\"" + "/>\n"
-                + "         <Test name=\"testHello2\"" + " type=\"automatic\"" + "/>\n"
-                + "     </TestCase>\n"
-                + "     <TestSuite name=\"TestSuiteName\">\n"
-                + "         <TestCase name=\"TestCaseName\" priority=\"mandatory\">\n"
-                + "             <Description>" + "something extracted from java doc"
-                + "             </Description>\n"
-                + "             <!-- Test Methods -->\n"
-                + "             <Test name=\"testName1\"" + " type=\"automatic\"" + "/>\n"
-                + "             <Test name=\"testName2\"" + " type=\"automatic\"" + "/>\n"
-                + "         </TestCase>\n"
-                + "     </TestSuite>\n"
-                + "  </TestSuite>\n"
-                + "</TestPackage>\n";
-
-        HostConfig.getInstance().removeTestPacakges();
-
-        String planPath =
-            HostConfig.getInstance().getPlanRepository().getPlanPath(mTmpPlanFileName);
-        createFile(testPlanConfigStr, planPath);
-
-        createTestPackage(descriptionConfigStr, mTestPackageBinaryName);
-        HostConfig.getInstance().loadTestPackages();
-
-        TestSession ts = TestSessionBuilder.getInstance().build(planPath, Profile.ALL);
-        assertEquals(1, ts.getNumOfRequiredDevices());
-
-        TestSessionLog tsl = ts.getSessionLog();
-        assertEquals(1, tsl.getTestPackages().size());
-
-        TestPackage testPackage = tsl.getTestPackages().iterator().next();
-        assertEquals(1, testPackage.getTestSuites().size());
-        assertEquals(mTestPackageBinaryName, testPackage.getAppBinaryName());
-        assertEquals("1.0", testPackage.getVersion());
-        assertEquals("Android 1.0", testPackage.getAndroidVersion());
-
-        TestSuite testSuite;
-        testSuite = testPackage.getTestSuites().iterator().next();
-        assertEquals(0, testSuite.getSubSuites().size());
-        assertEquals(1, testSuite.getTestCases().size());
-        assertEquals("com.google", testSuite.getFullName());
-
-        TestCase testCase = testSuite.getTestCases().iterator().next();
-        assertEquals(caseName, testCase.getName());
-        assertEquals("mandatory", testCase.getPriority());
-
-        Test test = testCase.getTests().iterator().next();
-        assertEquals("com.google.CtsTestHello#testHello", test.getFullName());
-        assertEquals("automatic", test.getType());
-        assertEquals(testName, test.getName());
-        assertEquals(CtsTestResult.CODE_NOT_EXECUTED, test.getResult().getResultCode());
-
-        deleteTestPackage(mTestPackageBinaryName);
-    }
-
-    /**
-     * Test building and loading plan with excluding list of embedded suite.
-     */
-    public void testExcludingEmbeddedSuite() throws IOException,
-            ParserConfigurationException, SAXException, TestPlanNotFoundException,
-            TestNotFoundException,
-            TransformerFactoryConfigurationError, TransformerException, NoSuchAlgorithmException {
-
-        final String appPackageName = "com.google.android.cts";
-        final String caseName = "CtsTestHello";
-        final String testName = "testHello";
-        final String excludedList = "com.google.TestSuiteName";
-
-        final String descriptionConfigStr = "<TestPackage name=\"" + mTestPackageBinaryName + "\""
-                + " appPackageName=\"" + appPackageName + "\""
-                + " version=\"1.0\" AndroidFramework=\"Android 1.0\""
-                + " runner=\"android.test.InstrumentationTestRunner\" >\n"
-                + "  <Description>something extracted from java doc</Description>\n"
-                + "  <TestSuite name=\"com.google\">\n"
-                + "     <TestCase name=\"CtsTestHello\" priority=\"mandatory\">\n"
-                + "         <Description>" + "something extracted from java doc"
-                + "         </Description>\n"
-                + "         <!-- Test Methods -->\n"
-                + "         <Test name=\"testHello\"" + " type=\"automatic\"" + "/>\n"
-                + "         <Test name=\"testHello2\"" + " type=\"automatic\"" + "/>\n"
-                + "     </TestCase>\n"
-                + "     <TestSuite name=\"TestSuiteName\">\n"
-                + "         <TestCase name=\"TestCaseName\" priority=\"mandatory\">\n"
-                + "             <Description>" + "something extracted from java doc"
-                + "             </Description>\n"
-                + "             <!-- Test Methods -->\n"
-                + "             <Test name=\"testName1\"" + " type=\"automatic\"" + "/>\n"
-                + "             <Test name=\"testName2\"" + " type=\"automatic\"" + "/>\n"
-                + "         </TestCase>\n"
-                + "     </TestSuite>\n"
-                + "  </TestSuite>\n"
-                + "</TestPackage>\n";
-
-        HostConfig.getInstance().removeTestPacakges();
-        createTestPackage(descriptionConfigStr, mTestPackageBinaryName);
-        HostConfig.getInstance().loadTestPackages();
-
-        ArrayList<String> packageNames = new ArrayList<String>();
-        packageNames.add(appPackageName);
-
-        HashMap<String, ArrayList<String>> results = new HashMap<String, ArrayList<String>>();
-        ArrayList<String> list = new ArrayList<String>();
-        list.add(excludedList);
-        results.put(appPackageName, list);
-        String planName = "plan_test_excluding";
-        String planPath = HostConfig.getInstance().getPlanRepository().getPlanPath(planName);
-        TestSessionBuilder.getInstance().serialize(planName, packageNames, results);
-
-        TestSession ts = TestSessionBuilder.getInstance().build(planPath, Profile.ALL);
-        assertEquals(1, ts.getNumOfRequiredDevices());
-
-        TestSessionLog tsl = ts.getSessionLog();
-        assertEquals(1, tsl.getTestPackages().size());
-
-        TestPackage testPackage = tsl.getTestPackages().iterator().next();
-        assertEquals(1, testPackage.getTestSuites().size());
-        assertEquals(mTestPackageBinaryName, testPackage.getAppBinaryName());
-        assertEquals("1.0", testPackage.getVersion());
-        assertEquals("Android 1.0", testPackage.getAndroidVersion());
-
-        TestSuite testSuite;
-        testSuite = testPackage.getTestSuites().iterator().next();
-        assertEquals(0, testSuite.getSubSuites().size());
-        assertEquals(1, testSuite.getTestCases().size());
-        assertEquals("com.google", testSuite.getFullName());
-
-        TestCase testCase = testSuite.getTestCases().iterator().next();
-        assertEquals(caseName, testCase.getName());
-        assertEquals("mandatory", testCase.getPriority());
-
-        Test test = testCase.getTests().iterator().next();
-        assertEquals("com.google.CtsTestHello#testHello", test.getFullName());
-        assertEquals("automatic", test.getType());
-        assertEquals(testName, test.getName());
-        assertEquals(CtsTestResult.CODE_NOT_EXECUTED, test.getResult().getResultCode());
-
-        deleteTestPackage(mTestPackageBinaryName);
-    }
-
-    /**
-     * Test building and loading plan with excluding list of the top suite.
-     */
-    public void testExcludingTopSuite() throws IOException,
-            ParserConfigurationException, SAXException, TestPlanNotFoundException,
-            TestNotFoundException,
-            TransformerFactoryConfigurationError, TransformerException, NoSuchAlgorithmException {
-
-        final String appPackageName = "com.google.android.cts";
-        final String excludedList = "com.google";
-
-        final String descriptionConfigStr = "<TestPackage name=\"" + mTestPackageBinaryName + "\""
-                + " appPackageName=\"" + appPackageName + "\""
-                + " version=\"1.0\" AndroidFramework=\"Android 1.0\""
-                + " runner=\"android.test.InstrumentationTestRunner\" >\n"
-                + "  <Description>something extracted from java doc</Description>\n"
-                + "  <TestSuite name=\"com.google\">\n"
-                + "     <TestCase name=\"CtsTestHello\" priority=\"mandatory\">\n"
-                + "         <Description>" + "something extracted from java doc"
-                + "         </Description>\n"
-                + "         <!-- Test Methods -->\n"
-                + "         <Test name=\"testHello\"" + " type=\"automatic\"" + "/>\n"
-                + "         <Test name=\"testHello2\"" + " type=\"automatic\"" + "/>\n"
-                + "     </TestCase>\n"
-                + "     <TestSuite name=\"TestSuiteName\">\n"
-                + "         <TestCase name=\"TestCaseName\" priority=\"mandatory\">\n"
-                + "             <Description>" + "something extracted from java doc"
-                + "             </Description>\n"
-                + "             <!-- Test Methods -->\n"
-                + "             <Test name=\"testName1\"" + " type=\"automatic\"" + "/>\n"
-                + "             <Test name=\"testName2\"" + " type=\"automatic\"" + "/>\n"
-                + "         </TestCase>\n"
-                + "     </TestSuite>\n"
-                + "  </TestSuite>\n"
-                + "</TestPackage>\n";
-
-        HostConfig.getInstance().removeTestPacakges();
-        createTestPackage(descriptionConfigStr, mTestPackageBinaryName);
-        HostConfig.getInstance().loadTestPackages();
-
-        ArrayList<String> packageNames = new ArrayList<String>();
-        packageNames.add(appPackageName);
-
-        HashMap<String, ArrayList<String>> results = new HashMap<String, ArrayList<String>>();
-        ArrayList<String> list = new ArrayList<String>();
-        list.add(excludedList);
-        results.put(appPackageName, list);
-        String planName = "plan_test_excluding";
-        String planPath = HostConfig.getInstance().getPlanRepository().getPlanPath(planName);
-        TestSessionBuilder.getInstance().serialize(planName, packageNames, results);
-
-        TestSession ts = TestSessionBuilder.getInstance().build(planPath, Profile.ALL);
-        assertEquals(1, ts.getNumOfRequiredDevices());
-
-        TestSessionLog tsl = ts.getSessionLog();
-        assertEquals(1, tsl.getTestPackages().size());
-
-        TestPackage testPackage = tsl.getTestPackages().iterator().next();
-        assertEquals(0, testPackage.getTestSuites().size());
-        assertEquals(mTestPackageBinaryName, testPackage.getAppBinaryName());
-        assertEquals("1.0", testPackage.getVersion());
-        assertEquals("Android 1.0", testPackage.getAndroidVersion());
-
-        deleteTestPackage(mTestPackageBinaryName);
-    }
-
-    /**
-     * Test building and loading plan with excluded list of test case.
-     */
-    public void testExcludingTestCase() throws IOException,
-            ParserConfigurationException, SAXException, TestPlanNotFoundException,
-            TestNotFoundException,
-            TransformerFactoryConfigurationError, TransformerException, NoSuchAlgorithmException {
-
-        final String appPackageName = "com.google.android.cts";
-        final String caseName = "CtsTestHello";
-        final String testName = "testHello";
-        final String excludedList = "com.google.TestCaseName";
-
-        final String descriptionConfigStr = "<TestPackage name=\"" + mTestPackageBinaryName + "\""
-                + " appPackageName=\"" + appPackageName + "\""
-                + " version=\"1.0\" AndroidFramework=\"Android 1.0\""
-                + " runner=\"android.test.InstrumentationTestRunner\" >\n"
-                + "  <Description>something extracted from java doc</Description>\n"
-                + "  <TestSuite name=\"com.google\">\n"
-                + "     <TestCase name=\"CtsTestHello\" priority=\"mandatory\">\n"
-                + "         <Description>" + "something extracted from java doc"
-                + "         </Description>\n"
-                + "         <!-- Test Methods -->\n"
-                + "         <Test name=\"testHello\"" + " type=\"automatic\"" + "/>\n"
-                + "         <Test name=\"testHello2\"" + " type=\"automatic\"" + "/>\n"
-                + "     </TestCase>\n"
-                + "     <TestCase name=\"TestCaseName\" priority=\"mandatory\">\n"
-                + "         <Description>" + "something extracted from java doc"
-                + "         </Description>\n"
-                + "         <!-- Test Methods -->\n"
-                + "         <Test name=\"testName1\"" + " type=\"automatic\"" + "/>\n"
-                + "         <Test name=\"testName2\"" + " type=\"automatic\"" + "/>\n"
-                + "     </TestCase>\n"
-                + "  </TestSuite>\n"
-                + "</TestPackage>\n";
-
-        HostConfig.getInstance().removeTestPacakges();
-        createTestPackage(descriptionConfigStr, mTestPackageBinaryName);
-        HostConfig.getInstance().loadTestPackages();
-
-        ArrayList<String> packageNames = new ArrayList<String>();
-        packageNames.add(appPackageName);
-
-        HashMap<String, ArrayList<String>> results = new HashMap<String, ArrayList<String>>();
-        ArrayList<String> list = new ArrayList<String>();
-        list.add(excludedList);
-        results.put(appPackageName, list);
-        String planName = "plan_test_excluding";
-        String planPath = HostConfig.getInstance().getPlanRepository().getPlanPath(planName);
-        TestSessionBuilder.getInstance().serialize(planName, packageNames, results);
-
-        TestSession ts = TestSessionBuilder.getInstance().build(planPath, Profile.ALL);
-        assertEquals(1, ts.getNumOfRequiredDevices());
-
-        TestSessionLog tsl = ts.getSessionLog();
-        assertEquals(1, tsl.getTestPackages().size());
-
-        TestPackage testPackage = tsl.getTestPackages().iterator().next();
-        assertEquals(1, testPackage.getTestSuites().size());
-        assertEquals(mTestPackageBinaryName, testPackage.getAppBinaryName());
-        assertEquals("1.0", testPackage.getVersion());
-        assertEquals("Android 1.0", testPackage.getAndroidVersion());
-
-        TestSuite testSuite;
-        testSuite = testPackage.getTestSuites().iterator().next();
-        assertEquals(1, testSuite.getTestCases().size());
-        assertEquals("com.google", testSuite.getFullName());
-
-        assertEquals(1, testSuite.getTestCases().size());
-
-        TestCase testCase = testSuite.getTestCases().iterator().next();
-        assertEquals(caseName, testCase.getName());
-        assertEquals("mandatory", testCase.getPriority());
-
-        Test test = testCase.getTests().iterator().next();
-        assertEquals("com.google.CtsTestHello#testHello", test.getFullName());
-        assertEquals("automatic", test.getType());
-        assertEquals(testName, test.getName());
-        assertEquals(CtsTestResult.CODE_NOT_EXECUTED, test.getResult().getResultCode());
-
-        deleteTestPackage(mTestPackageBinaryName);
-    }
-
-    /**
-     * Test building and loading plan with excluded list of all of the test cases.
-     */
-    public void testExcludingAllTestCases() throws IOException,
-            ParserConfigurationException, SAXException, TestPlanNotFoundException,
-            TestNotFoundException,
-            TransformerFactoryConfigurationError, TransformerException, NoSuchAlgorithmException {
-
-        final String appPackageName = "com.google.android.cts";
-        final String excludedList = "com.google.TestCaseName;com.google.CtsTestHello";
-
-        final String descriptionConfigStr = "<TestPackage name=\"" + mTestPackageBinaryName + "\""
-                + " appPackageName=\"" + appPackageName + "\""
-                + " version=\"1.0\" AndroidFramework=\"Android 1.0\""
-                + " runner=\"android.test.InstrumentationTestRunner\" >\n"
-                + "  <Description>something extracted from java doc</Description>\n"
-                + "  <TestSuite name=\"com.google\">\n"
-                + "     <TestCase name=\"CtsTestHello\" priority=\"mandatory\">\n"
-                + "         <Description>" + "something extracted from java doc"
-                + "         </Description>\n"
-                + "         <!-- Test Methods -->\n"
-                + "         <Test name=\"testHello\"" + " type=\"automatic\"" + "/>\n"
-                + "         <Test name=\"testHello2\"" + " type=\"automatic\"" + "/>\n"
-                + "     </TestCase>\n"
-                + "     <TestCase name=\"TestCaseName\" priority=\"mandatory\">\n"
-                + "         <Description>" + "something extracted from java doc"
-                + "         </Description>\n"
-                + "         <!-- Test Methods -->\n"
-                + "         <Test name=\"testName1\"" + " type=\"automatic\"" + "/>\n"
-                + "         <Test name=\"testName2\"" + " type=\"automatic\"" + "/>\n"
-                + "     </TestCase>\n"
-                + "  </TestSuite>\n"
-                + "</TestPackage>\n";
-
-        HostConfig.getInstance().removeTestPacakges();
-        createTestPackage(descriptionConfigStr, mTestPackageBinaryName);
-        HostConfig.getInstance().loadTestPackages();
-
-        ArrayList<String> packageNames = new ArrayList<String>();
-        packageNames.add(appPackageName);
-
-        HashMap<String, ArrayList<String>> results = new HashMap<String, ArrayList<String>>();
-        ArrayList<String> list = new ArrayList<String>();
-        list.add(excludedList);
-        results.put(appPackageName, list);
-        String planName = "plan_test_excluding";
-        String planPath = HostConfig.getInstance().getPlanRepository().getPlanPath(planName);
-        TestSessionBuilder.getInstance().serialize(planName, packageNames, results);
-
-        TestSession ts = TestSessionBuilder.getInstance().build(planPath, Profile.ALL);
-        assertEquals(1, ts.getNumOfRequiredDevices());
-
-        TestSessionLog tsl = ts.getSessionLog();
-        assertEquals(1, tsl.getTestPackages().size());
-
-        TestPackage testPackage = tsl.getTestPackages().iterator().next();
-        assertEquals(0, testPackage.getTestSuites().size());
-        assertEquals(mTestPackageBinaryName, testPackage.getAppBinaryName());
-        assertEquals("1.0", testPackage.getVersion());
-        assertEquals("Android 1.0", testPackage.getAndroidVersion());
-
-        assertEquals(0, testPackage.getTestSuites().size());
-
-        deleteTestPackage(mTestPackageBinaryName);
-    }
-
-    /**
-     * Test building and loading plan with excluded list of test.
-     */
-    public void testExcludingTest() throws IOException,
-            ParserConfigurationException, SAXException, TestPlanNotFoundException,
-            TestNotFoundException,
-            TransformerFactoryConfigurationError, TransformerException, NoSuchAlgorithmException {
-
-        final String appPackageName = "com.google.android.cts";
-        final String caseName = "CtsTestHello";
-        final String testName = "testHello";
-        final String excludedList = "com.google.CtsTestHello#testHello2";
-
-        final String descriptionConfigStr = "<TestPackage name=\"" + mTestPackageBinaryName + "\""
-                + " appPackageName=\"" + appPackageName + "\""
-                + " version=\"1.0\" AndroidFramework=\"Android 1.0\""
-                + " runner=\"android.test.InstrumentationTestRunner\" >\n"
-                + "  <Description>something extracted from java doc</Description>\n"
-                + "  <TestSuite name=\"com.google\">\n"
-                + "     <TestCase name=\"CtsTestHello\" priority=\"mandatory\">\n"
-                + "         <Description>" + "something extracted from java doc"
-                + "         </Description>\n"
-                + "         <!-- Test Methods -->\n"
-                + "         <Test name=\"testHello\"" + " type=\"automatic\"" + "/>\n"
-                + "         <Test name=\"testHello2\"" + " type=\"automatic\"" + "/>\n"
-                + "     </TestCase>\n"
-                + "  </TestSuite>\n"
-                + "</TestPackage>\n";
-
-        HostConfig.getInstance().removeTestPacakges();
-        createTestPackage(descriptionConfigStr, mTestPackageBinaryName);
-        HostConfig.getInstance().loadTestPackages();
-
-        ArrayList<String> packageNames = new ArrayList<String>();
-        packageNames.add(appPackageName);
-
-        HashMap<String, ArrayList<String>> results = new HashMap<String, ArrayList<String>>();
-        ArrayList<String> list = new ArrayList<String>();
-        list.add(excludedList);
-        results.put(appPackageName, list);
-        String planName = "plan_test_excluding";
-        String planPath = HostConfig.getInstance().getPlanRepository().getPlanPath(planName);
-        TestSessionBuilder.getInstance().serialize(planName, packageNames, results);
-
-        TestSession ts = TestSessionBuilder.getInstance().build(planPath, Profile.ALL);
-        assertEquals(1, ts.getNumOfRequiredDevices());
-
-        TestSessionLog tsl = ts.getSessionLog();
-        assertEquals(1, tsl.getTestPackages().size());
-
-        TestPackage testPackage = tsl.getTestPackages().iterator().next();
-        assertEquals(1, testPackage.getTestSuites().size());
-        assertEquals(mTestPackageBinaryName, testPackage.getAppBinaryName());
-        assertEquals("1.0", testPackage.getVersion());
-        assertEquals("Android 1.0", testPackage.getAndroidVersion());
-
-        TestSuite testSuite;
-        testSuite = testPackage.getTestSuites().iterator().next();
-        assertEquals(1, testSuite.getTestCases().size());
-        assertEquals("com.google", testSuite.getFullName());
-
-        assertEquals(1, testSuite.getTestCases().size());
-
-        TestCase testCase = testSuite.getTestCases().iterator().next();
-        assertEquals(caseName, testCase.getName());
-        assertEquals("mandatory", testCase.getPriority());
-
-        Test test = testCase.getTests().iterator().next();
-        assertEquals("com.google.CtsTestHello#testHello", test.getFullName());
-        assertEquals("automatic", test.getType());
-        assertEquals(testName, test.getName());
-        assertEquals(CtsTestResult.CODE_NOT_EXECUTED, test.getResult().getResultCode());
-
-        deleteTestPackage(mTestPackageBinaryName);
-    }
-
-    /**
-     * Test building and loading plan with excluded list of all of the tests.
-     */
-    public void testExcludingAllTests() throws IOException,
-            ParserConfigurationException, SAXException, TestPlanNotFoundException,
-            TestNotFoundException,
-            TransformerFactoryConfigurationError, TransformerException, NoSuchAlgorithmException {
-
-        final String appPackageName = "com.google.android.cts";
-        final String excludedList =
-            "com.google.CtsTestHello#testHello;com.google.CtsTestHello#testHello2;";
-
-        final String descriptionConfigStr = "<TestPackage name=\"" + mTestPackageBinaryName + "\""
-                + " appPackageName=\"" + appPackageName + "\""
-                + " version=\"1.0\" AndroidFramework=\"Android 1.0\""
-                + " runner=\"android.test.InstrumentationTestRunner\" >\n"
-                + "  <Description>something extracted from java doc</Description>\n"
-                + "  <TestSuite name=\"com.google\">\n"
-                + "     <TestCase name=\"CtsTestHello\" priority=\"mandatory\">\n"
-                + "         <Description>" + "something extracted from java doc"
-                + "         </Description>\n"
-                + "         <!-- Test Methods -->\n"
-                + "         <Test name=\"testHello\"" + " type=\"automatic\"" + "/>\n"
-                + "         <Test name=\"testHello2\"" + " type=\"automatic\"" + "/>\n"
-                + "     </TestCase>\n"
-                + "  </TestSuite>\n"
-                + "</TestPackage>\n";
-
-        HostConfig.getInstance().removeTestPacakges();
-        createTestPackage(descriptionConfigStr, mTestPackageBinaryName);
-        HostConfig.getInstance().loadTestPackages();
-
-        ArrayList<String> packageNames = new ArrayList<String>();
-        packageNames.add(appPackageName);
-
-        HashMap<String, ArrayList<String>> results = new HashMap<String, ArrayList<String>>();
-        ArrayList<String> list = new ArrayList<String>();
-        list.add(excludedList);
-        results.put(appPackageName, list);
-        String planName = "plan_test_excluding";
-        String planPath = HostConfig.getInstance().getPlanRepository().getPlanPath(planName);
-        TestSessionBuilder.getInstance().serialize(planName, packageNames, results);
-
-        TestSession ts = TestSessionBuilder.getInstance().build(planPath, Profile.ALL);
-        assertEquals(1, ts.getNumOfRequiredDevices());
-
-        TestSessionLog tsl = ts.getSessionLog();
-        assertEquals(1, tsl.getTestPackages().size());
-
-        TestPackage testPackage = tsl.getTestPackages().iterator().next();
-        assertEquals(0, testPackage.getTestSuites().size());
-        assertEquals(mTestPackageBinaryName, testPackage.getAppBinaryName());
-        assertEquals("1.0", testPackage.getVersion());
-        assertEquals("Android 1.0", testPackage.getAndroidVersion());
-
-        deleteTestPackage(mTestPackageBinaryName);
-    }
-
-    /**
-     * Test creating plan with excluded list.
-     */
-    public void testCreatePlanWithExcludedList() throws IOException,
-          ParserConfigurationException, SAXException,
-          TestPlanNotFoundException, TestNotFoundException,
-          TransformerFactoryConfigurationError, TransformerException, NoSuchAlgorithmException{
-
-        final String appPackageName = "com.google.android.cts";
-        final String suiteName1 = appPackageName + "." + "SuiteName1";
-        final String caseName1 = "CtsTestHello";
-        final String testName1 = "testHello";
-
-        final String caseName2 = "CtsTestHello2";
-        final String testName2 = "testHello2";
-        final String testName3 = "testHello3";
-        final String suiteName2 = "com.google.android.cts.CtsTest.SuiteName2";
-
-        final String descriptionConfigStr = "<TestPackage name=\""
-              + mTestPackageBinaryName + "\""
-              + " appPackageName=\"" + appPackageName + "\""
-              + " version=\"1.0\" AndroidFramework=\"Android 1.0\""
-              + " runner=\"android.test.InstrumentationTestRunner\" >\n"
-              + " <Description>something extracted from java doc</Description>\n"
-              + " <TestSuite name=\"" + suiteName1 + "\"" + ">\n"
-              + "     <TestCase name=\"" + caseName1 + "\"" + " category=\"mandatory\">\n"
-              + "         <Description>" + "something extracted from java doc"
-              + "         </Description>\n"
-              + "         <!-- Test Methods -->\n"
-              + "         <Test name=\"" + testName1 + "\" type=\"automatic\"" + "/>\n"
-              + "     </TestCase>\n"
-              + " </TestSuite>\n"
-              + " <TestSuite name=\"" + suiteName2 + "\"" + ">\n"
-              + "     <TestCase name=\"" + caseName2 + "\"" + " priority=\"mandatory\">\n"
-              + "         <Test name=\"" + testName2 +"\" type=\"automatic\" />\n"
-              + "         <Test name=\"" + testName3 +"\" type=\"automatic\" />\n"
-              + "     </TestCase>\n"
-              + " </TestSuite>\n"
-              + "</TestPackage>\n";
-
-        HostConfig.getInstance().removeTestPacakges();
-        createTestPackage(descriptionConfigStr, mTestPackageBinaryName);
-        HostConfig.getInstance().loadTestPackages();
-
-        ArrayList<String> packageNames = new ArrayList<String>();
-        packageNames.add(appPackageName);
-
-        HashMap<String, ArrayList<String>> results = new HashMap<String, ArrayList<String>>();
-        ArrayList<String> list = new ArrayList<String>();
-        String excludedList = suiteName1 + "." + caseName1 + TestPlan.EXCLUDE_SEPARATOR;
-        excludedList += suiteName2 + "." + caseName2 + Test.METHOD_SEPARATOR + testName2;
-        list.add(excludedList);
-        results.put(appPackageName, list);
-
-        String planName = "plan_test_excluding";
-        String planPath = HostConfig.getInstance().getPlanRepository().getPlanPath(planName);
-        TestSessionBuilder.getInstance().serialize(planName, packageNames, results);
-
-        TestSession ts = TestSessionBuilder.getInstance().build(planPath, Profile.ALL);
-        assertEquals(1, ts.getNumOfRequiredDevices());
-
-        TestSessionLog tsl = ts.getSessionLog();
-        assertEquals(1, tsl.getTestPackages().size());
-
-        TestPackage testPackage = tsl.getTestPackages().iterator().next();
-        assertEquals(1, testPackage.getTestSuites().size());
-        assertEquals(mTestPackageBinaryName, testPackage.getAppBinaryName());
-        assertEquals("1.0", testPackage.getVersion());
-        assertEquals("Android 1.0", testPackage.getAndroidVersion());
-
-        TestSuite testSuite;
-        testSuite = testPackage.getTestSuites().iterator().next();
-        assertEquals(1, testSuite.getTestCases().size());
-        assertEquals(suiteName2, testSuite.getFullName());
-
-        assertEquals(1, testSuite.getTestCases().size());
-
-        TestCase testCase = testSuite.getTestCases().iterator().next();
-        assertEquals(caseName2, testCase.getName());
-        assertEquals("mandatory", testCase.getPriority());
-        assertEquals(1, testCase.getTests().size());
-
-        Test test = testCase.getTests().iterator().next();
-        String testName = suiteName2 + "." + caseName2 + Test.METHOD_SEPARATOR + testName3;
-        assertEquals(testName, test.getFullName());
-        assertEquals("automatic", test.getType());
-        assertEquals(CtsTestResult.CODE_NOT_EXECUTED, test.getResult().getResultCode());
-
-        deleteTestPackage(mTestPackageBinaryName);
-    }
-
-    /**
-     * Test creating plan with excluded list of nested suites.
-     */
-    public void testCreatePlanWithExcludedListForNestedSuite() throws IOException,
-          ParserConfigurationException, SAXException,
-          TestPlanNotFoundException, TestNotFoundException,
-          TransformerFactoryConfigurationError, TransformerException, NoSuchAlgorithmException{
-
-        final String appPackageName = "com.google.android.cts";
-        final String fullName = mTestPackageBinaryName + ".CtsTest";
-        final String suiteName1 = fullName + "." + "SuiteName1";
-        final String caseName1 = "CtsTestHello";
-        final String testName1 = "testHello";
-
-        final String caseName2 = "CtsTestHello2";
-        final String testName2 = "testHello2";
-        final String testName3 = "testHello3";
-        final String nestedSuiteName1 = "com.google";
-        final String nestedSuiteName2 = "android.cts.CtsTest.SuiteName2";
-
-        final String descriptionConfigStr = "<TestPackage name=\""
-            + mTestPackageBinaryName + "\""
-            + " appPackageName=\"" + appPackageName + "\""
-            + " version=\"1.0\" AndroidFramework=\"Android 1.0\""
-              + " runner=\"android.test.InstrumentationTestRunner\" >\n"
-              + " <Description>something extracted from java doc</Description>\n"
-              + " <TestSuite name=\"" + suiteName1 + "\"" + ">\n"
-              + "     <TestCase name=\"" + caseName1 + "\"" + " category=\"mandatory\">\n"
-              + "         <Description>" + "something extracted from java doc" + "</Description>\n"
-              + "         <!-- Test Methods -->\n"
-              + "         <Test name=\"" + testName1 + "\" type=\"automatic\"" + "/>\n"
-              + "     </TestCase>\n"
-              + " </TestSuite>\n"
-              + " <TestSuite name=\"" + nestedSuiteName1 + "\"" + ">\n"
-              + "     <TestSuite name=\"" + nestedSuiteName2 + "\"" + ">\n"
-              + "         <TestCase name=\"" + caseName2 + "\"" + " priority=\"mandatory\">\n"
-              + "             <Test name=\"" + testName2 +"\" type=\"automatic\" />\n"
-              + "             <Test name=\"" + testName3 +"\" type=\"automatic\" />\n"
-              + "         </TestCase>\n"
-              + "     </TestSuite>\n"
-              + " </TestSuite>\n"
-              + "</TestPackage>\n";
-
-        HostConfig.getInstance().removeTestPacakges();
-        createTestPackage(descriptionConfigStr, mTestPackageBinaryName);
-        HostConfig.getInstance().loadTestPackages();
-
-        ArrayList<String> packageNames = new ArrayList<String>();
-        packageNames.add(appPackageName);
-
-        HashMap<String, ArrayList<String>> results = new HashMap<String, ArrayList<String>>();
-        ArrayList<String> list = new ArrayList<String>();
-        String excludedList = suiteName1 + "." + caseName1 + TestPlan.EXCLUDE_SEPARATOR;
-        excludedList += nestedSuiteName1 + "." + nestedSuiteName2
-                        + "." + caseName2 + Test.METHOD_SEPARATOR + testName2;
-        list.add(excludedList);
-        results.put(appPackageName, list);
-
-        String planName = "plan_test_excluding";
-        String planPath = HostConfig.getInstance().getPlanRepository().getPlanPath(planName);
-        TestSessionBuilder.getInstance().serialize(planName, packageNames, results);
-
-        TestSession ts = TestSessionBuilder.getInstance().build(planPath, Profile.ALL);
-        assertEquals(1, ts.getNumOfRequiredDevices());
-
-        TestSessionLog tsl = ts.getSessionLog();
-        assertEquals(1, tsl.getTestPackages().size());
-
-        TestPackage testPackage = tsl.getTestPackages().iterator().next();
-        assertEquals(1, testPackage.getTestSuites().size());
-        assertEquals(mTestPackageBinaryName, testPackage.getAppBinaryName());
-        assertEquals("1.0", testPackage.getVersion());
-        assertEquals("Android 1.0", testPackage.getAndroidVersion());
-
-        TestSuite testSuite;
-        testSuite = testPackage.getTestSuites().iterator().next();
-        assertEquals(0, testSuite.getTestCases().size());
-        assertEquals(nestedSuiteName1, testSuite.getFullName());
-
-        assertEquals(1, testSuite.getSubSuites().size());
-        TestSuite testSubSuite = testSuite.getSubSuites().iterator().next();
-        assertEquals(1, testSubSuite.getTestCases().size());
-        String suiteName = nestedSuiteName1 + "." + nestedSuiteName2;
-        assertEquals(suiteName, testSubSuite.getFullName());
-
-        assertEquals(1, testSubSuite.getTestCases().size());
-
-        TestCase testCase = testSubSuite.getTestCases().iterator().next();
-        assertEquals(caseName2, testCase.getName());
-        assertEquals("mandatory", testCase.getPriority());
-        assertEquals(1, testCase.getTests().size());
-
-        Test test = testCase.getTests().iterator().next();
-        String testName = nestedSuiteName1 + "." + nestedSuiteName2 + "." +caseName2
-                          + Test.METHOD_SEPARATOR + testName3;
-        assertEquals(testName, test.getFullName());
-        assertEquals("automatic", test.getType());
-        assertEquals(CtsTestResult.CODE_NOT_EXECUTED, test.getResult().getResultCode());
-
-        deleteTestPackage(mTestPackageBinaryName);
-    }
-
-    /**
-     * Test building plan of protocol type.
-     */
-    public void testBuildProtocolPlan() throws IOException,
-            ParserConfigurationException, SAXException, TestPlanNotFoundException,
-            TestNotFoundException, NoSuchAlgorithmException {
-
-        final String appPackageName = "com.google.android.cts";
-
-        final String testPlanConfigStr = "<TestPlan version=\"1.0\">\n"
-                + "\t<Description>Demo test plan</Description>\n"
-                + "\t\t<PlanSettings>\n"
-                + "\t\t\t<RequiredDevice amount=\"" + 2 + "\"" + "/>\n"
-                + "\t\t</PlanSettings>\n"
-                + "\t<Entry uri=\""
-                + appPackageName
-                + "\"/>\n"
-                + "</TestPlan>";
-
-        final String descriptionConfigStr = "<TestPackage name=\"" + mTestPackageBinaryName +"\" "
-                + " appPackageName=\"" + appPackageName + "\""
-                + " version=\"1.0\" AndroidFramework=\"Android 1.0\""
-                + " runner=\"android.test.InstrumentationTestRunner\" >\n"
-                + " <Description>something extracted from java doc</Description>\n"
-                + " <TestSuite name=\"com.google.android.cts\"" + ">\n"
-                + "     <TestCase name=\"CtsTestHello\"" + " priority=\"mandatory\">\n"
-                + "         <Description>" + "something extracted from java doc"
-                + "         </Description>\n"
-                + "         <Test name=\"testHello\"" + " type=\"automatic\"" + "/>\n"
-                + "     </TestCase>\n"
-                + " </TestSuite>\n"
-                + "</TestPackage>\n";
-
-        HostConfig.getInstance().removeTestPacakges();
-        String planPath = HostConfig.getInstance().getPlanRepository()
-                .getPlanPath(mTmpPlanFileName);
-        createFile(testPlanConfigStr, planPath);
-
-        createTestPackage(descriptionConfigStr, mTestPackageBinaryName);
-        HostConfig.getInstance().loadTestPackages();
-
-        TestSession ts = TestSessionBuilder.getInstance().build(planPath, Profile.ALL);
-        assertEquals(2, ts.getNumOfRequiredDevices());
-
-        TestSessionLog tsl = ts.getSessionLog();
-        assertEquals(1, tsl.getTestPackages().size());
-
-        TestPackage testPackage = tsl.getTestPackages().iterator().next();
-        assertEquals(1, testPackage.getTestSuites().size());
-        assertEquals(mTestPackageBinaryName, testPackage.getAppBinaryName());
-        assertEquals("1.0", testPackage.getVersion());
-        assertEquals("Android 1.0", testPackage.getAndroidVersion());
-
-        TestSuite testSuite = testPackage.getTestSuites().iterator().next();
-        assertEquals(1, testSuite.getTestCases().size());
-        assertEquals("com.google.android.cts", testSuite.getFullName());
-
-        TestCase testCase = testSuite.getTestCases().iterator().next();
-        Test test = testCase.getTests().iterator().next();
-        assertEquals("testHello", test.getName());
-        assertEquals("automatic", test.getType());
-        assertEquals(CtsTestResult.CODE_NOT_EXECUTED, test.getResult().getResultCode());
-
-        deleteTestPackage(mTestPackageBinaryName);
-    }
-
-    /**
-     * Test serializing the test plan.
-     */
-    public void testSerialize() throws Exception {
-        final String srcStr = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n"
-            + "<TestPlan version=\"1.0\">\n"
-            + "<PlanSettings/>\n"
-            + "<Entry uri=\"com.google.android.cts.CtsTest\"/>\n"
-            + "</TestPlan>";
-
-        final String package1 = "com.google.android.cts.CtsTest";
-        ArrayList<String> packageNames = new ArrayList<String>();
-        packageNames.add(package1);
-        HashMap<String, ArrayList<String>> selectedResult =
-                      new HashMap<String, ArrayList<String>>();
-        selectedResult.put(package1, null);
-
-        HostConfig.getInstance().removeTestPacakges();
-        String planName = "plan_test";
-        String planPath = HostConfig.getInstance().getPlanRepository().getPlanPath(planName);
-        TestSessionBuilder.getInstance().serialize(planName, packageNames, selectedResult);
-
-        File file = new File(planPath);
-        assertTrue(file.exists());
-        assertTrue(file.isFile());
-
-        FileReader dstInput = new FileReader(file);
-        BufferedReader dstBufReader = new BufferedReader(dstInput);
-
-        char[] resChars = new char[1024];
-        dstBufReader.read(resChars);
-        assertEquals(srcStr, new String(resChars).trim());
-
-        dstBufReader.close();
-        deleteFile(planPath);
-
-    }
-
-    /**
-     * Test loading plan with sub suites.
-     */
-    public void testLoadPlanWithSubSuite() throws IOException,
-            ParserConfigurationException, SAXException, TestPlanNotFoundException,
-            TestNotFoundException,
-            TransformerFactoryConfigurationError, TransformerException, NoSuchAlgorithmException {
-
-        final String appPackageName = "com.google.android.cts";
-        final String fullName = mTestPackageBinaryName + ".CtsTest";
-        final String caseName = "CtsTestHello";
-        final String testName = "testHello";
-
-        final String descriptionConfigStr = "<TestPackage name=\"" + mTestPackageBinaryName + "\""
-                + " appPackageName=\"" + appPackageName + "\""
-                + " version=\"1.0\" AndroidFramework=\"Android 1.0\""
-                + " runner=\"android.test.InstrumentationTestRunner\" >\n"
-                + "  <Description>something extracted from java doc</Description>\n"
-                + "  <TestSuite name=\"com.google\">\n"
-                + "     <TestCase name=\"CtsTestHello\" priority=\"mandatory\">\n"
-                + "         <Description>" + "something extracted from java doc"
-                + "         </Description>\n"
-                + "         <!-- Test Methods -->\n"
-                + "         <Test name=\"testHello\"" + " type=\"automatic\"" + "/>\n"
-                + "     </TestCase>\n"
-                + "     <TestSuite name=\"TestSuiteName\">\n"
-                + "         <TestCase name=\"TestCaseName\" priority=\"mandatory\">\n"
-                + "             <Description>" + "something extracted from java doc"
-                + "             </Description>\n"
-                + "             <!-- Test Methods -->\n"
-                + "             <Test name=\"testName1\"" + " type=\"automatic\"" + "/>\n"
-                + "         </TestCase>\n"
-                + "     </TestSuite>\n"
-                + "  </TestSuite>\n"
-                + "</TestPackage>\n";
-
-        HostConfig.getInstance().removeTestPacakges();
-        createTestPackage(descriptionConfigStr, mTestPackageBinaryName);
-        HostConfig.getInstance().loadTestPackages();
-
-        ArrayList<String> packageNames = new ArrayList<String>();
-        packageNames.add(appPackageName);
-
-        HashMap<String, ArrayList<String>> results = new HashMap<String, ArrayList<String>>();
-        results.put(appPackageName, null);
-        String planName = "plan_test_excluding";
-        String planPath = HostConfig.getInstance().getPlanRepository().getPlanPath(planName);
-        TestSessionBuilder.getInstance().serialize(planName, packageNames, results);
-
-        TestSession ts = TestSessionBuilder.getInstance().build(planPath, Profile.ALL);
-        assertEquals(1, ts.getNumOfRequiredDevices());
-
-        ts.getSessionLog().setStartTime(System.currentTimeMillis());
-        TestSessionLog tsl = ts.getSessionLog();
-        tsl.createResultDoc();
-        assertEquals(1, tsl.getTestPackages().size());
-
-        TestPackage testPackage = tsl.getTestPackages().iterator().next();
-        assertEquals(1, testPackage.getTestSuites().size());
-        assertEquals(mTestPackageBinaryName, testPackage.getAppBinaryName());
-        assertEquals("1.0", testPackage.getVersion());
-        assertEquals("Android 1.0", testPackage.getAndroidVersion());
-
-        TestSuite testSuite;
-        testSuite = testPackage.getTestSuites().iterator().next();
-        assertEquals(1, testSuite.getSubSuites().size());
-        assertEquals(1, testSuite.getTestCases().size());
-        assertEquals("com.google", testSuite.getFullName());
-
-        TestCase testCase = testSuite.getTestCases().iterator().next();
-        assertEquals(caseName, testCase.getName());
-        assertEquals("mandatory", testCase.getPriority());
-
-        Test test = testCase.getTests().iterator().next();
-        assertEquals("com.google.CtsTestHello#testHello", test.getFullName());
-        assertEquals("automatic", test.getType());
-        assertEquals(testName, test.getName());
-        assertEquals(CtsTestResult.CODE_NOT_EXECUTED, test.getResult().getResultCode());
-
-        TestSuite subTestSuite;
-        subTestSuite = testSuite.getSubSuites().iterator().next();
-        assertEquals(1, subTestSuite.getTestCases().size());
-        assertEquals("com.google.TestSuiteName", subTestSuite.getFullName());
-        assertEquals("TestSuiteName", subTestSuite.getName());
-
-        testCase = subTestSuite.getTestCases().iterator().next();
-        assertEquals("TestCaseName", testCase.getName());
-        assertEquals("mandatory", testCase.getPriority());
-
-        test = testCase.getTests().iterator().next();
-        assertEquals("com.google.TestSuiteName.TestCaseName#testName1", test.getFullName());
-        assertEquals("automatic", test.getType());
-        assertEquals("testName1", test.getName());
-        assertEquals(CtsTestResult.CODE_NOT_EXECUTED, test.getResult().getResultCode());
-
-        deleteTestPackage(mTestPackageBinaryName);
-    }
-
-    /**
-     * Test validating test controller.
-     */
-    public void testValidateTestController() {
-        String jarPath = "test.jar";
-        String packageName = "com.android.tests";
-        String className = "ConsoleTests";
-        String methodName = "testMethod";
-
-        TestController controller = new TestController(null, null, null, null);
-        assertFalse(controller.isValid());
-
-        controller = new TestController(jarPath, null, null, null);
-        assertFalse(controller.isValid());
-
-        controller = new TestController(null, packageName, null, null);
-        assertFalse(controller.isValid());
-
-        controller = new TestController(null, null, className, null);
-        assertFalse(controller.isValid());
-
-        controller = new TestController(null, null, null, methodName);
-        assertFalse(controller.isValid());
-
-        controller = new TestController("", "", "", "");
-        assertFalse(controller.isValid());
-
-        controller = new TestController("", packageName, className, methodName);
-        assertFalse(controller.isValid());
-
-        controller = new TestController(jarPath, "", className, methodName);
-        assertFalse(controller.isValid());
-
-        controller = new TestController(jarPath, packageName, "", methodName);
-        assertFalse(controller.isValid());
-
-        controller = new TestController(jarPath, packageName, className, "");
-        assertFalse(controller.isValid());
-
-        controller = new TestController(jarPath, packageName, className, methodName);
-        assertTrue(controller.isValid());
-    }
-
-    /**
-     * Test loading plan with test controller.
-     */
-    public void testLoadPlanWithTestController() throws IOException,
-            ParserConfigurationException, SAXException,
-            TestPlanNotFoundException, TestNotFoundException,
-            TransformerFactoryConfigurationError,
-            TransformerException, NoSuchAlgorithmException {
-
-        final String appPackageName = "com.google.android.cts";
-        final String jarPath = "test.jar";
-        final String controllerPackageName = "com.android.tests";
-        final String className = "ConsoleTests";
-        final String methodName = "testMethod";
-        final String description = controllerPackageName + "." + className
-                + Test.METHOD_SEPARATOR + methodName;
-
-        final String descriptionConfigStr = "<TestPackage name=\""
-                + mTestPackageBinaryName + "\" "
-                + " appPackageName=\"" + appPackageName + "\""
-                + " version=\"1.0\" AndroidFramework=\"Android 1.0\""
-                + " runner=\"android.test.InstrumentationTestRunner\" jarPath=\"" + jarPath
-                + "\">\n"
-                + "  <Description>something extracted from java doc</Description>\n"
-                + "  <TestSuite name=\"com.google\">\n"
-                + "     <TestCase name=\"TestCaseName\" priority=\"mandatory\">\n"
-                + "         <Description>"
-                + "something extracted from java doc" + "</Description>\n"
-                + "         <!-- Test Methods -->\n"
-                + "         <Test name=\"testName1\""
-                + " type=\"automatic\"" + " HostController=\""
-                + description + "\"" + "/>\n" + "     </TestCase>\n"
-                + "  </TestSuite>\n" + "</TestPackage>\n";
-
-        createTestPackage(descriptionConfigStr, mTestPackageBinaryName);
-        HostConfig.getInstance().loadTestPackages();
-
-        ArrayList<String> packageNames = new ArrayList<String>();
-        packageNames.add(appPackageName);
-
-        HashMap<String, ArrayList<String>> results = new HashMap<String, ArrayList<String>>();
-        results.put(appPackageName, null);
-
-        String planName = "plan_test";
-        String planPath = HostConfig.getInstance().getPlanRepository().getPlanPath(planName);
-        TestSessionBuilder.getInstance().serialize(planName, packageNames, results);
-
-        TestSession ts = TestSessionBuilder.getInstance().build(planPath, Profile.ALL);
-        ts.getSessionLog().setStartTime(System.currentTimeMillis());
-        TestSessionLog tsl = ts.getSessionLog();
-        TestPackage testPackage = tsl.getTestPackages().iterator().next();
-
-        assertEquals(jarPath, testPackage.getJarPath());
-
-        TestSuite testSuite;
-        testSuite = testPackage.getTestSuites().iterator().next();
-        TestCase testCase = testSuite.getTestCases().iterator().next();
-        Test test = testCase.getTests().iterator().next();
-        assertEquals(controllerPackageName, test.getTestController().getPackageName());
-        assertEquals(className, test.getTestController().getClassName());
-        assertEquals(methodName, test.getTestController().getMethodName());
-
-        deleteTestPackage(mTestPackageBinaryName);
-    }
-}
diff --git a/tools/host/test/com/android/cts/TestSessionLogBuilderTests.java b/tools/host/test/com/android/cts/TestSessionLogBuilderTests.java
deleted file mode 100644
index a2b5274..0000000
--- a/tools/host/test/com/android/cts/TestSessionLogBuilderTests.java
+++ /dev/null
@@ -1,173 +0,0 @@
-/*
- * Copyright (C) 2009 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.cts;
-
-import org.xml.sax.SAXException;
-
-import java.io.IOException;
-import java.security.NoSuchAlgorithmException;
-import java.util.Collection;
-import java.util.Iterator;
-
-import javax.xml.parsers.ParserConfigurationException;
-
-/**
- * Test the logic of TestSessionLogBuilder.
- *
- */
-public class TestSessionLogBuilderTests extends CtsTestBase {
-
-    public void testLoadTestSessionLogBuilder() throws IOException, NoSuchAlgorithmException,
-            SAXException, TestPlanNotFoundException, TestNotFoundException,
-            ParserConfigurationException {
-
-        final String resultFile =
-            "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
-            "<?xml-stylesheet type=\"text/xsl\"  href=\"cts_result.xsl\"?>\n" +
-            "\n" +
-            "<TestResult endtime=\"Wed Apr 29 10:36:47 CST 2009\" " +
-            "starttime=\"Wed Apr 29 10:36:30 CST 2009\" testPlan=\"location\" version=\"1.0\" profile=\"ALL\">\n" +
-            "  <DeviceInfo>\n" +
-            "    <Screen resolution=\"480x320\"/>\n" +
-            "    <PhoneSubInfo subscriberId=\"15555218135\"/>\n" +
-            "    <BuildInfo Xdpi=\"164.75456\" Ydpi=\"165.87724\" androidPlatformVersion=\"3\" " +
-            "    buildID=\"CUPCAKE\" buildName=\"generic\" buildVersion=\"1.5\" " +
-            "    build_board=\"unknown\" build_brand=\"generic\" build_device=\"generic\" " +
-            "    build_fingerprint=\"test-keys\" build_model=\"generic\" build_type=\"eng\" " +
-            "    deviceID=\"emulator-5554\" imei=\"000000000000000\" imsi=\"310260000000000\" " +
-            "    keypad=\"qwty\" locales=\"en_US;\" navigation=\"trkball\" network=\"Android\" " +
-            "    touch=\"finger\"/>\n" +
-            "  </DeviceInfo>\n" +
-            "  <Summary failed=\"22\" notExecuted=\"0\" pass=\"22\" timeout=\"0\"/>\n" +
-            "  <TestPackage digest=\"7GDPKCxBGKuVyEkH1PGWJc=&#10;\" name=\"android.location\" " +
-            "  appPackageName=\"android.location\">\n" +
-            "    <TestSuite name=\"android\">\n" +
-            "      <TestSuite name=\"location\">\n" +
-            "        <TestSuite name=\"cts\">\n" +
-            "          <TestCase name=\"LocationManagerTest\" priority=\"\">\n" +
-            "           <Test endtime=\"Wed Apr 29 10:36:44 CST 2009\" name=\"testOne\"" +
-            "            result=\"fail\" starttime=\"Thu Jan 01 07:00:00 CST 1970\">\n" +
-            "             <FailedScene message=\"java.SecurityException: (Parcel.java:1234)\">\n" +
-            "               <StackTrace>at android.os.Parcel.readException(Parcel.java:1234)\n" +
-            "                  at android.os.Parcel.readException(Parcel.java:1222)\n" +
-            "                  at android.location.addTestProvider(ILocationManager.java:821)\n" +
-            "                  at android.location.addTestProvider(LocationManager.java:987)\n" +
-            "               </StackTrace>\n" +
-            "             </FailedScene>\n" +
-            "           </Test>\n" +
-            "           <Test endtime=\"Wed Apr 29 10:36:44 CST 2009\" name=\"testTwo\"" +
-            "             result=\"fail\" starttime=\"Thu Jan 01 07:00:00 CST 1970\">\n" +
-            "             <FailedScene message=\"java.SecurityException: (Parcel.java:1234)\">\n" +
-            "               <StackTrace>at android.os.Parcel.readException(Parcel.java:1234)\n" +
-            "                  at android.os.Parcel.readException(Parcel.java:1222)\n" +
-            "                  at android.location.(ILocationManager.java:821)\n" +
-            "               </StackTrace>\n" +
-            "             </FailedScene>\n" +
-            "           </Test>\n" +
-            "          </TestCase>\n" +
-            "          <TestCase name=\"AddressTest\" priority=\"\">\n" +
-            "           <Test endtime=\"Wed Apr 29 10:36:43 CST 2009\" name=\"testThree\" " +
-            "            result=\"pass\" starttime=\"Thu Jan 01 07:00:00 CST 1970\"/>\n" +
-            "           <Test endtime=\"Wed Apr 29 10:36:43 CST 2009\" name=\"testFour\" " +
-            "            result=\"pass\" starttime=\"Thu Jan 01 07:00:00 CST 1970\"/>\n" +
-            "          </TestCase>\n" +
-            "        </TestSuite>\n" +
-            "      </TestSuite>\n" +
-            "    </TestSuite>\n" +
-            "  </TestPackage>\n" +
-            "</TestResult>";
-
-        final String pkgDescription =
-            "<TestPackage name=\"android.location\" " +
-            "appPackageName=\"android.location\" targetNameSpace=\"targetNameSpace\" " +
-            " version=\"1.0\" AndroidFramework=\"Android 1.0\"" +
-            " runner=\"runner\">\n" +
-            "    <Description>something extracted from java doc</Description>\n" +
-            "    <TestSuite name=\"android\">\n" +
-            "      <TestSuite name=\"location\">\n" +
-            "        <TestSuite name=\"cts\">\n" +
-            "          <TestCase name=\"LocationManagerTest\" priority=\"\">\n" +
-            "           <Test name=\"testOne\" />\n" +
-            "           <Test name=\"testTwo\" />\n" +
-            "          </TestCase>\n" +
-            "          <TestCase name=\"AddressTest\" priority=\"\">\n" +
-            "           <Test name=\"testThree\" />\n" +
-            "           <Test name=\"testFour\" />\n" +
-            "          </TestCase>\n" +
-            "        </TestSuite>\n" +
-            "      </TestSuite>\n" +
-            "    </TestSuite>\n" +
-            "</TestPackage>\n";
-
-        final String testPlanConfigStr = "<TestPlan version=\"1.0\">\n" +
-            "\t<Description>Demo test plan</Description>\n" +
-            "\t\t<PlanSettings>\n" +
-            "\t\t\t<RequiredDevice amount=\"" + 1 + "\"" + "/>\n" +
-            "\t\t</PlanSettings>\n" +
-            "\t<Entry uri=\"android.location\"/>\n" +
-            "</TestPlan>";
-
-        final String resultFileName = "testResult.xml";
-        final String descriptionFileName = "CtsLocation.xml";
-
-        HostConfig.getInstance().removeTestPacakges();
-
-        String planPath =
-            HostConfig.getInstance().getPlanRepository().getPlanPath("location");
-        createFile(testPlanConfigStr, planPath);
-
-        String resultPath =
-            HostConfig.getInstance().getResultRepository().getRoot() + resultFileName;
-        createFile(resultFile, resultPath);
-
-        createTestPackage(pkgDescription, "android.location");
-        HostConfig.getInstance().loadTestPackages();
-        TestSession ts = TestSessionBuilder.getInstance().build(
-                TestSessionLogBuilder.getInstance().build(resultPath));
-        assertNotNull(ts);
-        TestSessionLog log = ts.getSessionLog();
-        assertNotNull(log);
-        assertEquals("location", log.getTestPlanName());
-
-        Collection<TestPackage> packages = log.getTestPackages();
-        assertEquals(1, packages.size());
-        TestPackage pkg = packages.iterator().next();
-
-        Collection<Test> tests = pkg.getTests();
-        assertNotNull(tests);
-        assertEquals(4, tests.size());
-        Iterator<Test> iterator = tests.iterator();
-        Test test1 = iterator.next();
-        assertEquals("android.location.cts.LocationManagerTest#testOne", test1.getFullName());
-
-        CtsTestResult result = test1.getResult();
-        assertNotNull(result);
-        assertEquals("fail", result.getResultString());
-        assertNotNull(result.getFailedMessage());
-        assertNotNull(result.getStackTrace());
-
-        Test test2 = iterator.next();
-        Test test3 = iterator.next();
-        assertEquals("android.location.cts.AddressTest#testThree", test3.getFullName());
-
-        result = test3.getResult();
-        assertNotNull(result);
-        assertEquals("pass", result.getResultString());
-        assertNull(result.getFailedMessage());
-        assertNull(result.getStackTrace());
-    }
-}
diff --git a/tools/tradefed-host/Android.mk b/tools/tradefed-host/Android.mk
index 86fba8d..7af7993 100644
--- a/tools/tradefed-host/Android.mk
+++ b/tools/tradefed-host/Android.mk
@@ -18,7 +18,7 @@
 
 # Only compile source java files in this lib.
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
-LOCAL_JAVA_RESOURCE_DIRS := res ../host/src/res
+LOCAL_JAVA_RESOURCE_DIRS := res
 
 LOCAL_MODULE := cts-tradefed
 LOCAL_MODULE_TAGS := optional
@@ -29,4 +29,3 @@
 
 # Build all sub-directories
 include $(call all-makefiles-under,$(LOCAL_PATH))
-
diff --git a/tools/host/src/res/cts_result.css b/tools/tradefed-host/res/report/cts_result.css
similarity index 100%
rename from tools/host/src/res/cts_result.css
rename to tools/tradefed-host/res/report/cts_result.css
diff --git a/tools/host/src/res/cts_result.xsd b/tools/tradefed-host/res/report/cts_result.xsd
similarity index 100%
rename from tools/host/src/res/cts_result.xsd
rename to tools/tradefed-host/res/report/cts_result.xsd
diff --git a/tools/host/src/res/cts_result.xsl b/tools/tradefed-host/res/report/cts_result.xsl
similarity index 100%
rename from tools/host/src/res/cts_result.xsl
rename to tools/tradefed-host/res/report/cts_result.xsl
diff --git a/tools/host/src/res/logo.gif b/tools/tradefed-host/res/report/logo.gif
similarity index 100%
rename from tools/host/src/res/logo.gif
rename to tools/tradefed-host/res/report/logo.gif
Binary files differ
diff --git a/tools/host/src/res/newrule-green.png b/tools/tradefed-host/res/report/newrule-green.png
similarity index 100%
rename from tools/host/src/res/newrule-green.png
rename to tools/tradefed-host/res/report/newrule-green.png
Binary files differ
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 11b4b1c..190227a 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
@@ -334,7 +334,7 @@
      */
     private void copyFormattingFiles(File resultsDir) {
         for (String resultFileName : CTS_RESULT_RESOURCES) {
-            InputStream configStream = getClass().getResourceAsStream(String.format("/%s",
+            InputStream configStream = getClass().getResourceAsStream(String.format("/report/%s",
                     resultFileName));
             if (configStream != null) {
                 File resultFile = new File(resultsDir, resultFileName);