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

Commit 01528824 authored by Kweku Adams's avatar Kweku Adams
Browse files

Removing the settings-based IncidentReportArgs method.

Bug: 72378645
Test: Flashed device
Change-Id: Ia12afffed169e1d0201e99887e74398de40c6cf6
parent e588d614
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -3770,7 +3770,6 @@ package android.os {

  public class IncidentManager {
    method public void reportIncident(android.os.IncidentReportArgs);
    method public void reportIncident(java.lang.String, byte[]);
  }

  public final class IncidentReportArgs implements android.os.Parcelable {
@@ -3781,7 +3780,6 @@ package android.os {
    method public boolean containsSection(int);
    method public int describeContents();
    method public boolean isAll();
    method public static android.os.IncidentReportArgs parseSetting(java.lang.String) throws java.lang.IllegalArgumentException;
    method public void readFromParcel(android.os.Parcel);
    method public int sectionCount();
    method public void setAll(boolean);
+0 −2
Original line number Diff line number Diff line
@@ -473,7 +473,6 @@ package android.os {

  public class IncidentManager {
    method public void reportIncident(android.os.IncidentReportArgs);
    method public void reportIncident(java.lang.String, byte[]);
  }

  public final class IncidentReportArgs implements android.os.Parcelable {
@@ -484,7 +483,6 @@ package android.os {
    method public boolean containsSection(int);
    method public int describeContents();
    method public boolean isAll();
    method public static android.os.IncidentReportArgs parseSetting(java.lang.String) throws java.lang.IllegalArgumentException;
    method public void readFromParcel(android.os.Parcel);
    method public int sectionCount();
    method public void setAll(boolean);
+0 −42
Original line number Diff line number Diff line
@@ -21,7 +21,6 @@ import android.annotation.SystemApi;
import android.annotation.SystemService;
import android.annotation.TestApi;
import android.content.Context;
import android.provider.Settings;
import android.util.Slog;

/**
@@ -57,47 +56,6 @@ public class IncidentManager {
        reportIncidentInternal(args);
    }

    /**
     * Convenience method to trigger an incident report and put it in dropbox.
     * <p>
     * The fields that are reported will be looked up in the system setting named by
     * the settingName parameter.  The setting must match one of these patterns:
     *      The string "disabled": The report will not be taken.
     *      The string "all": The report will taken with all sections.
     *      The string "none": The report will taken with no sections, but with the header.
     *      A comma separated list of field numbers: The report will have these fields.
     * <p>
     * The header parameter will be added as a header for the incident report.  Fill in a
     * {@link android.util.proto.ProtoOutputStream ProtoOutputStream}, and then call the
     * {@link android.util.proto.ProtoOutputStream#bytes bytes()} method to retrieve
     * the encoded data for the header.
     */
    @RequiresPermission(allOf = {
            android.Manifest.permission.DUMP,
            android.Manifest.permission.PACKAGE_USAGE_STATS
    })
    public void reportIncident(String settingName, byte[] headerProto) {
        // Sections
        String setting = Settings.Global.getString(mContext.getContentResolver(), settingName);
        IncidentReportArgs args;
        try {
            args = IncidentReportArgs.parseSetting(setting);
        } catch (IllegalArgumentException ex) {
            Slog.w(TAG, "Bad value for incident report setting '" + settingName + "'", ex);
            return;
        }
        if (args == null) {
            Slog.i(TAG, String.format("Incident report requested but disabled with "
                    + "settings [name: %s, value: %s]", settingName, setting));
            return;
        }

        args.addHeader(headerProto);

        Slog.i(TAG, "Taking incident report: " + settingName);
        reportIncidentInternal(args);
    }

    private class IncidentdDeathRecipient implements IBinder.DeathRecipient {
        @Override
        public void binderDied() {
+0 −48
Original line number Diff line number Diff line
@@ -188,53 +188,5 @@ public final class IncidentReportArgs implements Parcelable {
    public void addHeader(byte[] header) {
        mHeaders.add(header);
    }

    /**
     * Parses an incident report config as described in the system setting.
     *
     * @see IncidentManager#reportIncident
     */
    public static IncidentReportArgs parseSetting(String setting)
            throws IllegalArgumentException {
        if (setting == null || setting.length() == 0) {
            return null;
        }
        setting = setting.trim();
        if (setting.length() == 0 || "disabled".equals(setting)) {
            return null;
        }

        final IncidentReportArgs args = new IncidentReportArgs();

        if ("all".equals(setting)) {
            args.setAll(true);
            return args;
        } else if ("none".equals(setting)) {
            return args;
        }

        final String[] splits = setting.split(",");
        final int N = splits.length;
        for (int i=0; i<N; i++) {
            final String str = splits[i].trim();
            if (str.length() == 0) {
                continue;
            }
            int section;
            try {
                section = Integer.parseInt(str);
            } catch (NumberFormatException ex) {
                throw new IllegalArgumentException("Malformed setting. Bad integer at section"
                        + " index " + i + ": section='" + str + "' setting='" + setting + "'");
            }
            if (section < 1) {
                throw new IllegalArgumentException("Malformed setting. Illegal section at"
                        + " index " + i + ": section='" + str + "' setting='" + setting + "'");
            }
            args.addSection(section);
        }

        return args;
    }
}