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

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

Merge "Fix parsing enum types in incident report tool as well as adding some additional loggings"

parents 9b739de4 f32af480
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -54,9 +54,7 @@ LOCAL_SHARED_LIBRARIES := \
        libservices \
        libutils

ifeq (BUILD_WITH_INCIDENTD_RC,true)
LOCAL_INIT_RC := incidentd.rc
endif

include $(BUILD_EXECUTABLE)

+6 −3
Original line number Diff line number Diff line
@@ -225,9 +225,8 @@ Reporter::runReport()
    // and report to those that care that we're doing it.
    for (const Section** section=SECTION_LIST; *section; section++) {
        const int id = (*section)->id;
        ALOGD("Taking incident report section %d '%s'", id, (*section)->name.string());

        if (this->batch.containsSection(id)) {
            ALOGD("Taking incident report section %d '%s'", id, (*section)->name.string());
            // Notify listener of starting
            for (ReportRequestSet::iterator it=batch.begin(); it!=batch.end(); it++) {
                if ((*it)->listener != NULL && (*it)->args.containsSection(id)) {
@@ -251,6 +250,7 @@ Reporter::runReport()
                            IIncidentReportStatusListener::STATUS_FINISHED);
                }
            }
            ALOGD("Finish incident report section %d '%s'", id, (*section)->name.string());
        }
    }

@@ -324,6 +324,7 @@ Reporter::upload_backlog()
    struct stat st;
    status_t err;

    ALOGD("Start uploading backlogs in %s", INCIDENT_DIRECTORY);
    if ((err = create_directory(INCIDENT_DIRECTORY)) != NO_ERROR) {
        ALOGE("directory doesn't exist: %s", strerror(-err));
        return REPORT_FINISHED;
@@ -337,6 +338,7 @@ Reporter::upload_backlog()
    sp<DropBoxManager> dropbox = new DropBoxManager();

    // Enumerate, count and add up size
    int count = 0;
    while ((entry = readdir(dir)) != NULL) {
        if (entry->d_name[0] == '.') {
            continue;
@@ -360,8 +362,9 @@ Reporter::upload_backlog()
        // boot or the next checkin. If the directory gets too big older files will
        // be rotated out.
        unlink(filename.string());
        count++;
    }

    ALOGD("Successfully uploaded %d files to Dropbox.", count);
    closedir(dir);

    return REPORT_FINISHED;
+11 −22
Original line number Diff line number Diff line
@@ -21,8 +21,6 @@ import android.annotation.SystemApi;
import android.annotation.SystemService;
import android.annotation.TestApi;
import android.content.Context;
import android.os.IIncidentManager;
import android.os.ServiceManager;
import android.provider.Settings;
import android.util.Slog;

@@ -37,7 +35,7 @@ import android.util.Slog;
public class IncidentManager {
    private static final String TAG = "incident";

    private Context mContext;
    private final Context mContext;

    /**
     * @hide
@@ -54,18 +52,7 @@ public class IncidentManager {
            android.Manifest.permission.PACKAGE_USAGE_STATS
    })
    public void reportIncident(IncidentReportArgs args) {
        final IIncidentManager service = IIncidentManager.Stub.asInterface(
                ServiceManager.getService("incident"));
        if (service == null) {
            Slog.e(TAG, "reportIncident can't find incident binder service");
            return;
        }

        try {
            service.reportIncident(args);
        } catch (RemoteException ex) {
            Slog.e(TAG, "reportIncident failed", ex);
        }
        reportIncidentInternal(args);
    }

    /**
@@ -89,7 +76,7 @@ public class IncidentManager {
    })
    public void reportIncident(String settingName, byte[] headerProto) {
        // Sections
        String setting = Settings.System.getString(mContext.getContentResolver(), settingName);
        String setting = Settings.Global.getString(mContext.getContentResolver(), settingName);
        IncidentReportArgs args;
        try {
            args = IncidentReportArgs.parseSetting(setting);
@@ -98,23 +85,25 @@ public class IncidentManager {
            return;
        }
        if (args == null) {
            Slog.i(TAG, "Incident report requested but disabled: " + settingName);
            Slog.i(TAG, String.format("Incident report requested but disabled with "
                    + "settings [name: %s, value: %s]", settingName, setting));
            return;
        }

        // Header
        args.addHeader(headerProto);

        // Look up the service
        Slog.i(TAG, "Taking incident report: " + settingName);
        reportIncidentInternal(args);
    }

    private void reportIncidentInternal(IncidentReportArgs args) {
        final IIncidentManager service = IIncidentManager.Stub.asInterface(
                ServiceManager.getService("incident"));
                ServiceManager.getService(Context.INCIDENT_SERVICE));
        if (service == null) {
            Slog.e(TAG, "reportIncident can't find incident binder service");
            return;
        }

        // Call the service
        Slog.i(TAG, "Taking incident report: " + settingName);
        try {
            service.reportIncident(args);
        } catch (RemoteException ex) {
+6 −3
Original line number Diff line number Diff line
@@ -18,7 +18,6 @@ package android.os;

import android.annotation.SystemApi;
import android.annotation.TestApi;
import android.content.Intent;
import android.os.Parcel;
import android.os.Parcelable;
import android.util.IntArray;
@@ -50,10 +49,12 @@ public final class IncidentReportArgs implements Parcelable {
        readFromParcel(in);
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel out, int flags) {
        out.writeInt(mAll ? 1 : 0);

@@ -100,6 +101,7 @@ public final class IncidentReportArgs implements Parcelable {
    /**
     * Print this report as a string.
     */
    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder("Incident(");
        if (mAll) {
@@ -131,10 +133,11 @@ public final class IncidentReportArgs implements Parcelable {
    }

    /**
     * Add this section to the incident report.
     * Add this section to the incident report. Skip if the input is smaller than 2 since section
     * id are only valid for positive integer as Protobuf field id. Here 1 is reserved for Header.
     */
    public void addSection(int section) {
        if (!mAll) {
        if (!mAll && section > 1) {
            mSections.add(section);
        }
    }
+1 −1
Original line number Diff line number Diff line
@@ -1842,7 +1842,7 @@ public final class SystemServer {
                // TODO: Switch from checkService to getService once it's always
                // in the build and should reliably be there.
                final IIncidentManager incident = IIncidentManager.Stub.asInterface(
                        ServiceManager.checkService("incident"));
                        ServiceManager.getService(Context.INCIDENT_SERVICE));
                if (incident != null) incident.systemRunning();
            } catch (Throwable e) {
                reportWtf("Notifying incident daemon running", e);
Loading