Make sure to report interruption cause

Test: unit tests
Bug: 153374987
Change-Id: Ib2d210e4f276442d1c61bd73260b2983023de171
diff --git a/src/com/android/tradefed/device/NativeDeviceStateMonitor.java b/src/com/android/tradefed/device/NativeDeviceStateMonitor.java
index 5d55bb7..ebe4526 100644
--- a/src/com/android/tradefed/device/NativeDeviceStateMonitor.java
+++ b/src/com/android/tradefed/device/NativeDeviceStateMonitor.java
@@ -23,6 +23,7 @@
 import com.android.tradefed.device.IDeviceManager.IFastbootListener;
 import com.android.tradefed.log.LogUtil.CLog;
 import com.android.tradefed.util.IRunUtil;
+import com.android.tradefed.util.RunInterruptedException;
 import com.android.tradefed.util.RunUtil;
 
 import java.io.IOException;
@@ -432,7 +433,7 @@
             } catch (InterruptedException e) {
                 CLog.w("wait for device bootloader state update interrupted");
                 CLog.w(e);
-                throw new RuntimeException(e);
+                throw new RunInterruptedException(e);
             } finally {
                 mMgr.removeFastbootListener(listener);
             }
@@ -455,7 +456,7 @@
             } catch (InterruptedException e) {
                 CLog.w("wait for device state interrupted");
                 CLog.w(e);
-                throw new RuntimeException(e);
+                throw new RunInterruptedException(e);
             } finally {
                 removeDeviceStateListener(listener);
             }
diff --git a/src/com/android/tradefed/invoker/TestInvocation.java b/src/com/android/tradefed/invoker/TestInvocation.java
index 0c32e14..6ec3e30 100644
--- a/src/com/android/tradefed/invoker/TestInvocation.java
+++ b/src/com/android/tradefed/invoker/TestInvocation.java
@@ -275,7 +275,11 @@
         } catch (RunInterruptedException e) {
             exception = e;
             CLog.w("Invocation interrupted");
-            reportFailure(createFailureFromException(e, FailureStatus.UNSET), listener);
+            // if a stop cause was set, the interruption is most likely due to the invocation being
+            // cancelled
+            if (mStopCause == null) {
+                reportFailure(createFailureFromException(e, FailureStatus.UNSET), listener);
+            }
         } catch (AssertionError e) {
             exception = e;
             CLog.e("Caught AssertionError while running invocation: %s", e.toString());