Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 672f2fc2 authored by vadimt's avatar vadimt
Browse files

Generate bugreports for ANRs and other anomalies

Bug: 211907395
Test: a similar approach was implemented for SysUI tests
Change-Id: I04770e73e6adf6bda63a8362976ec550434df6f3
parent 27981bac
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -220,7 +220,7 @@ public class NavigationModeSwitchRule implements TestRule {
        if (!condition) {
            final AssertionError assertionError = new AssertionError(message);
            if (description != null) {
                FailureWatcher.onError(launcher.getDevice(), description, assertionError);
                FailureWatcher.onError(launcher, description, assertionError);
            }
            throw assertionError;
        }
+9 −2
Original line number Diff line number Diff line
@@ -84,7 +84,7 @@ public class FailureWatcher extends TestWatcher {

    @Override
    protected void failed(Throwable e, Description description) {
        onError(mDevice, description, e);
        onError(mLauncher, description, e);
    }

    static File diagFile(Description description, String prefix, String ext) {
@@ -93,7 +93,9 @@ public class FailureWatcher extends TestWatcher {
                        + description.getMethodName() + "." + ext);
    }

    public static void onError(UiDevice device, Description description, Throwable e) {
    public static void onError(LauncherInstrumentation launcher, Description description,
            Throwable e) {
        final UiDevice device = launcher.getDevice();
        Log.d("b/196820244", "onError 1");
        if (device == null) return;
        Log.d("b/196820244", "onError 2");
@@ -128,6 +130,11 @@ public class FailureWatcher extends TestWatcher {
        }

        dumpCommand("logcat -d -s TestRunner", diagFile(description, "FilteredLogcat", "txt"));

        // Dump bugreport
        if (launcher.getSystemAnomalyMessage(false, false) != null) {
            dumpCommand("bugreportz -s", diagFile(description, "Bugreport", "zip"));
        }
    }

    private static void dumpStringCommand(String cmd, OutputStream out) throws IOException {
+1 −1
Original line number Diff line number Diff line
@@ -426,7 +426,7 @@ public final class LauncherInstrumentation {
        }
    }

    private String getSystemAnomalyMessage(
    public String getSystemAnomalyMessage(
            boolean ignoreNavmodeChangeStates, boolean ignoreOnlySystemUiViews) {
        try {
            {