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

Commit 922084e5 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Generate bugreports for ANRs and other anomalies"

parents 1af0e4d2 672f2fc2
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 {
            {