diff --git a/tests/src/com/android/launcher3/util/rule/ScreenRecordRule.java b/tests/src/com/android/launcher3/util/rule/ScreenRecordRule.java index 00b1cdd35e..7a5cf2c2cd 100644 --- a/tests/src/com/android/launcher3/util/rule/ScreenRecordRule.java +++ b/tests/src/com/android/launcher3/util/rule/ScreenRecordRule.java @@ -62,12 +62,17 @@ public class ScreenRecordRule implements TestRule { ParcelFileDescriptor output = automation.executeShellCommand("screenrecord " + outputFile); String screenRecordPid = device.executeShellCommand("pidof screenrecord"); + boolean success = false; try { base.evaluate(); + success = true; } finally { device.executeShellCommand("kill -INT " + screenRecordPid); Log.e(TAG, "Screenrecord captured at: " + outputFile); output.close(); + if (success) { + automation.executeShellCommand("rm " + outputFile); + } } } }; @@ -78,5 +83,6 @@ public class ScreenRecordRule implements TestRule { */ @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD) - public @interface ScreenRecord { } + public @interface ScreenRecord { + } }