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

Commit 35a9e99c authored by Anton Hansson's avatar Anton Hansson
Browse files

Upload tombstone with the system_server_native_crash tag.

This allows monitoring system server native crashes separately from
all the other native crashes.

Note that this now double-reports native crashes in system server,
once with SYSTEM_TOMBSTONE tag and once with the
system_server_native_crash tag. This can likely be cleaned up to
only report the latter, once it's been verified to work.

Test: "ls /data/system/dropbox" after triggering a native SS crash.
Bug: 63172851
Change-Id: Ib09275b53627c0219e2f74ea2ab102575f9b33c0
parent c8b76fe1
Loading
Loading
Loading
Loading
+15 −3
Original line number Diff line number Diff line
@@ -72,6 +72,7 @@ public class BootReceiver extends BroadcastReceiver {
        SystemProperties.getInt("ro.debuggable", 0) == 1 ? 98304 : 65536;

    private static final File TOMBSTONE_DIR = new File("/data/tombstones");
    private static final String TAG_TOMBSTONE = "SYSTEM_TOMBSTONE";

    // The pre-froyo package and class of the system updater, which
    // ran in the system process.  We need to remove its packages here
@@ -265,7 +266,7 @@ public class BootReceiver extends BroadcastReceiver {
                    File file = new File(TOMBSTONE_DIR, path);
                    if (file.isFile()) {
                        addFileToDropBox(db, timestamps, headers, file.getPath(), LOG_SIZE,
                                "SYSTEM_TOMBSTONE");
                                TAG_TOMBSTONE);
                    }
                } catch (IOException e) {
                    Slog.e(TAG, "Can't log tombstone", e);
@@ -299,9 +300,20 @@ public class BootReceiver extends BroadcastReceiver {

        timestamps.put(filename, fileTime);


        String fileContents = FileUtils.readTextFile(file, maxSize, "[[TRUNCATED]]\n");
        String text = headers + fileContents + footers;
        // Create an additional report for system server native crashes, with a special tag.
        if (tag.equals(TAG_TOMBSTONE) && fileContents.contains(">>> system_server <<<")) {
            addTextToDropBox(db, "system_server_native_crash", text, filename, maxSize);
        }
        addTextToDropBox(db, tag, text, filename, maxSize);
    }

    private static void addTextToDropBox(DropBoxManager db, String tag, String text,
            String filename, int maxSize) {
        Slog.i(TAG, "Copying " + filename + " to DropBox (" + tag + ")");
        db.addText(tag, headers + FileUtils.readTextFile(file, maxSize, "[[TRUNCATED]]\n") +
                footers);
        db.addText(tag, text);
        EventLog.writeEvent(DropboxLogTags.DROPBOX_FILE_COPY, filename, maxSize, tag);
    }