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

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

Merge "add process ID to LogMaker"

parents f7683a6f 67b3eb95
Loading
Loading
Loading
Loading
+1 −6
Original line number Diff line number Diff line
@@ -26957,7 +26957,6 @@ package android.metrics {
    method public android.metrics.LogMaker clearPackageName();
    method public android.metrics.LogMaker clearSubtype();
    method public android.metrics.LogMaker clearTaggedData(int);
    method public android.metrics.LogMaker clearTimestamp();
    method public android.metrics.LogMaker clearType();
    method public void deserialize(java.lang.Object[]);
    method public int getCategory();
@@ -26965,6 +26964,7 @@ package android.metrics {
    method public java.lang.String getCounterName();
    method public int getCounterValue();
    method public java.lang.String getPackageName();
    method public int getProcessId();
    method public int getSubtype();
    method public java.lang.Object getTaggedData(int);
    method public long getTimestamp();
@@ -26974,13 +26974,8 @@ package android.metrics {
    method public boolean isValidValue(java.lang.Object);
    method public java.lang.Object[] serialize();
    method public android.metrics.LogMaker setCategory(int);
    method public android.metrics.LogMaker setCounterBucket(int);
    method public android.metrics.LogMaker setCounterBucket(long);
    method public android.metrics.LogMaker setCounterName(java.lang.String);
    method public android.metrics.LogMaker setCounterValue(int);
    method public android.metrics.LogMaker setPackageName(java.lang.String);
    method public android.metrics.LogMaker setSubtype(int);
    method public android.metrics.LogMaker setTimestamp(long);
    method public android.metrics.LogMaker setType(int);
  }
+85 −3
Original line number Diff line number Diff line
@@ -46,8 +46,9 @@ public class LogMaker {

    private SparseArray<Object> entries = new SparseArray();

    public LogMaker(int mainCategory) {
        setCategory(mainCategory);
    /** @param category for the new LogMaker. */
    public LogMaker(int category) {
        setCategory(category);
    }

    /* Deserialize from the eventlog */
@@ -55,71 +56,133 @@ public class LogMaker {
      deserialize(items);
    }

    /** @param category to replace the existing setting. */
    public LogMaker setCategory(int category) {
        entries.put(MetricsEvent.RESERVED_FOR_LOGBUILDER_CATEGORY, category);
        return this;
    }

    /** Set the category to unknown. */
    public LogMaker clearCategory() {
        entries.remove(MetricsEvent.RESERVED_FOR_LOGBUILDER_CATEGORY);
        return this;
    }

    /** @param type to replace the existing setting. */
    public LogMaker setType(int type) {
        entries.put(MetricsEvent.RESERVED_FOR_LOGBUILDER_TYPE, type);
        return this;
    }

    /** Set the type to unknown. */
    public LogMaker clearType() {
        entries.remove(MetricsEvent.RESERVED_FOR_LOGBUILDER_TYPE);
        return this;
    }

    /** @param subtype to replace the existing setting. */
    public LogMaker setSubtype(int subtype) {
        entries.put(MetricsEvent.RESERVED_FOR_LOGBUILDER_SUBTYPE, subtype);
        return this;
    }

    /** Set the subtype to 0. */
    public LogMaker clearSubtype() {
        entries.remove(MetricsEvent.RESERVED_FOR_LOGBUILDER_SUBTYPE);
        return this;
    }

    /**
     * This will be set by the system when the log is persisted.
     * Client-supplied values will be ignored.
     *
     * @param timestamp to replace the existing settings.
     * @hide
     */
    public LogMaker setTimestamp(long timestamp) {
        entries.put(MetricsEvent.RESERVED_FOR_LOGBUILDER_TIMESTAMP, timestamp);
        return this;
    }

    /** Remove the timestamp property.
     * @hide
     */
    public LogMaker clearTimestamp() {
        entries.remove(MetricsEvent.RESERVED_FOR_LOGBUILDER_TIMESTAMP);
        return this;
    }

    /** @param packageName to replace the existing setting. */
    public LogMaker setPackageName(String packageName) {
        entries.put(MetricsEvent.RESERVED_FOR_LOGBUILDER_PACKAGENAME, packageName);
        return this;
    }

    /** Remove the package name property. */
    public LogMaker clearPackageName() {
        entries.remove(MetricsEvent.RESERVED_FOR_LOGBUILDER_PACKAGENAME);
        return this;
    }

    /**
     * This will be set by the system when the log is persisted.
     * Client-supplied values will be ignored.
     *
     * @param pid to replace the existing setting.
     * @hide
     */
    public LogMaker setProcessId(int pid) {
        entries.put(MetricsEvent.RESERVED_FOR_LOGBUILDER_PID, pid);
        return this;
    }

    /** Remove the process ID property.
     * @hide
     */
    public LogMaker clearProcessId() {
        entries.remove(MetricsEvent.RESERVED_FOR_LOGBUILDER_PID);
        return this;
    }

    /**
     * The name of the counter or histogram.
     * Only useful for counter or histogram category objects.
     * @param name to replace the existing setting.
     * @hide
     */
    public LogMaker setCounterName(String name) {
        entries.put(MetricsEvent.RESERVED_FOR_LOGBUILDER_NAME, name);
        return this;
    }

    /**
     * The bucket label, expressed as an integer.
     * Only useful for histogram category objects.
     * @param bucket to replace the existing setting.
     * @hide
     */
    public LogMaker setCounterBucket(int bucket) {
        entries.put(MetricsEvent.RESERVED_FOR_LOGBUILDER_BUCKET, bucket);
        return this;
    }

    /**
     * The bucket label, expressed as a long integer.
     * Only useful for histogram category objects.
     * @param bucket to replace the existing setting.
     * @hide
     */
    public LogMaker setCounterBucket(long bucket) {
        entries.put(MetricsEvent.RESERVED_FOR_LOGBUILDER_BUCKET, bucket);
        return this;
    }

    /**
     * The value to increment the counter or bucket by.
     * Only useful for counter and histogram category objects.
     * @param value to replace the existing setting.
     * @hide
     */
    public LogMaker setCounterValue(int value) {
        entries.put(MetricsEvent.RESERVED_FOR_LOGBUILDER_VALUE, value);
        return this;
@@ -171,6 +234,7 @@ public class LogMaker {
        return entries.get(tag);
    }

    /** @return the category of the log, or unknown. */
    public int getCategory() {
        Object obj = entries.get(MetricsEvent.RESERVED_FOR_LOGBUILDER_CATEGORY);
        if (obj instanceof Integer) {
@@ -180,6 +244,7 @@ public class LogMaker {
        }
    }

    /** @return the type of the log, or unknwon. */
    public int getType() {
        Object obj = entries.get(MetricsEvent.RESERVED_FOR_LOGBUILDER_TYPE);
        if (obj instanceof Integer) {
@@ -189,6 +254,7 @@ public class LogMaker {
        }
    }

    /** @return the subtype of the log, or 0. */
    public int getSubtype() {
        Object obj = entries.get(MetricsEvent.RESERVED_FOR_LOGBUILDER_SUBTYPE);
        if (obj instanceof Integer) {
@@ -198,6 +264,7 @@ public class LogMaker {
        }
    }

    /** @return the timestamp of the log.or 0 */
    public long getTimestamp() {
        Object obj = entries.get(MetricsEvent.RESERVED_FOR_LOGBUILDER_TIMESTAMP);
        if (obj instanceof Long) {
@@ -207,6 +274,7 @@ public class LogMaker {
        }
    }

    /** @return the package name of the log, or null. */
    public String getPackageName() {
        Object obj = entries.get(MetricsEvent.RESERVED_FOR_LOGBUILDER_PACKAGENAME);
        if (obj instanceof String) {
@@ -216,6 +284,17 @@ public class LogMaker {
        }
    }

    /** @return the process ID of the log, or -1. */
    public int getProcessId() {
        Object obj = entries.get(MetricsEvent.RESERVED_FOR_LOGBUILDER_PID);
        if (obj instanceof Integer) {
            return (Integer) obj;
        } else {
            return -1;
        }
    }

    /** @return the name of the counter, or null. */
    public String getCounterName() {
        Object obj = entries.get(MetricsEvent.RESERVED_FOR_LOGBUILDER_NAME);
        if (obj instanceof String) {
@@ -225,6 +304,7 @@ public class LogMaker {
        }
    }

    /** @return the bucket label of the histogram\, or 0. */
    public long getCounterBucket() {
        Object obj = entries.get(MetricsEvent.RESERVED_FOR_LOGBUILDER_BUCKET);
        if (obj instanceof Number) {
@@ -234,11 +314,13 @@ public class LogMaker {
        }
    }

    /** @return true if the bucket label was specified as a long integer. */
    public boolean isLongCounterBucket() {
        Object obj = entries.get(MetricsEvent.RESERVED_FOR_LOGBUILDER_BUCKET);
        return obj instanceof Long;
    }

    /** @return the increment value of the counter, or 0. */
    public int getCounterValue() {
        Object obj = entries.get(MetricsEvent.RESERVED_FOR_LOGBUILDER_VALUE);
        if (obj instanceof Integer) {
@@ -249,7 +331,7 @@ public class LogMaker {
    }

    /**
     * Assemble logs into structure suitable for EventLog.
     * @return a representation of the log suitable for EventLog.
     */
    public Object[] serialize() {
        Object[] out = new Object[entries.size() * 2];
+2 −1
Original line number Diff line number Diff line
@@ -77,7 +77,8 @@ public class MetricsReader {
                    objects[0] = data;
                }
                mEventQueue.add(new LogMaker(objects)
                        .setTimestamp(eventTimestampMs));
                        .setTimestamp(eventTimestampMs)
                        .setProcessId(event.getProcessId()));
                mLastEventMs = eventTimestampMs;
            }
        }
+8 −0
Original line number Diff line number Diff line
@@ -171,6 +171,14 @@ public class LogMakerTest extends TestCase {
        assertEquals(null, builder.getPackageName());
    }

    public void testSetAndClearPid() {
        LogMaker builder = new LogMaker(0);
        builder.setProcessId(1);
        assertEquals(1, builder.getProcessId());
        builder.clearProcessId();
        assertEquals(-1, builder.getProcessId());
    }

    public void testGiantLogOmitted() {
        LogMaker badBuilder = new LogMaker(0);
        StringBuilder b = new StringBuilder();
+7 −3
Original line number Diff line number Diff line
@@ -3175,7 +3175,7 @@ message MetricsEvent {
    DIALOG_SUPPORT_SYSTEM_INFORMATION = 756;

    // These values should never appear in log outputs - they are reserved for
    // internal Tron use.
    // internal platform metrics use.
    RESERVED_FOR_LOGBUILDER_CATEGORY = 757;
    RESERVED_FOR_LOGBUILDER_TYPE = 758;
    RESERVED_FOR_LOGBUILDER_SUBTYPE = 759;
@@ -3282,7 +3282,7 @@ message MetricsEvent {
    DEFAULT_AUTOFILL_PICKER = 792;

    // These values should never appear in log outputs - they are reserved for
    // internal Tron use.
    // internal platform metrics use.
    NOTIFICATION_SINCE_CREATE_MILLIS = 793;
    NOTIFICATION_SINCE_VISIBLE_MILLIS = 794;
    NOTIFICATION_SINCE_UPDATE_MILLIS = 795;
@@ -3297,7 +3297,7 @@ message MetricsEvent {
    QS_NFC = 800;

    // These values should never appear in log outputs - they are reserved for
    // internal Tron use.
    // internal platform metrics use.
    RESERVED_FOR_LOGBUILDER_BUCKET = 801;
    RESERVED_FOR_LOGBUILDER_VALUE = 802;
    RESERVED_FOR_LOGBUILDER_COUNTER = 803;
@@ -3540,6 +3540,10 @@ message MetricsEvent {
    // OS: N
    ACTION_GET_CONTACT = 864;

    // This values should never appear in log outputs - it is reserved for
    // internal platform metrics use.
    RESERVED_FOR_LOGBUILDER_PID = 865;

    // ---- End O Constants, all O constants go above this line ----

    // Add new aosp constants above this line.