Dont run tests if the APK wasn't installed

Change-Id: I213568c70d14cfc0ff671daa8c3970001a20c1a3
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/CtsInstrumentationApkTest.java b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/CtsInstrumentationApkTest.java
index 6765305..66d1135 100644
--- a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/CtsInstrumentationApkTest.java
+++ b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/CtsInstrumentationApkTest.java
@@ -77,9 +77,9 @@
     @Override
     public void run(final ITestInvocationListener listener)
             throws DeviceNotAvailableException {
-        ITestDevice mTestDevice = getDevice();
+        ITestDevice testDevice = getDevice();
 
-        if (mTestDevice == null) {
+        if (testDevice == null) {
             Log.e(LOG_TAG, "Missing device.");
             return;
         }
@@ -87,28 +87,32 @@
             Log.e(LOG_TAG, "Missing build");
             return;
         }
-
+        boolean success = true;
         for (String apkFileName : mInstallFileNames) {
             Log.d(LOG_TAG, String.format("Installing %s on %s", apkFileName,
-                    mTestDevice.getSerialNumber()));
+                    testDevice.getSerialNumber()));
             try {
                 File apkFile = mCtsBuild.getTestApp(apkFileName);
                 String errorCode = null;
                 String[] options = {AbiUtils.createAbiFlag(mAbi.getName())};
-                errorCode = mTestDevice.installPackage(apkFile, true, options);
+                errorCode = testDevice.installPackage(apkFile, true, options);
                 if (errorCode != null) {
                     Log.e(LOG_TAG, String.format("Failed to install %s on %s. Reason: %s",
-                          apkFileName, mTestDevice.getSerialNumber(), errorCode));
+                          apkFileName, testDevice.getSerialNumber(), errorCode));
+                    success = false;
                 }
             } catch (FileNotFoundException e) {
                 Log.e(LOG_TAG, String.format("Could not find file %s", apkFileName));
+                success = false;
             }
         }
-        super.run(listener);
+        if (success) {
+            super.run(listener);
+        }
         for (String packageName : mUninstallPackages) {
             Log.d(LOG_TAG, String.format("Uninstalling %s on %s", packageName,
-                    mTestDevice.getSerialNumber()));
-            mTestDevice.uninstallPackage(packageName);
+                    testDevice.getSerialNumber()));
+            testDevice.uninstallPackage(packageName);
         }
     }
 }