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

Commit ac732708 authored by Mark Salyzyn's avatar Mark Salyzyn Committed by Gerrit Code Review
Browse files

Merge "EventLog: event log translation errors"

parents adcf38c9 747802f8
Loading
Loading
Loading
Loading
+17 −7
Original line number Original line Diff line number Diff line
@@ -56,16 +56,18 @@ public class EventLog {
    public static final class Event {
    public static final class Event {
        private final ByteBuffer mBuffer;
        private final ByteBuffer mBuffer;


        // Layout of event log entry received from kernel.
        // Layout of event log entry received from Android logger.
        //  see system/core/include/log/logger.h
        private static final int LENGTH_OFFSET = 0;
        private static final int LENGTH_OFFSET = 0;
        private static final int HEADER_SIZE_OFFSET = 2;
        private static final int PROCESS_OFFSET = 4;
        private static final int PROCESS_OFFSET = 4;
        private static final int THREAD_OFFSET = 8;
        private static final int THREAD_OFFSET = 8;
        private static final int SECONDS_OFFSET = 12;
        private static final int SECONDS_OFFSET = 12;
        private static final int NANOSECONDS_OFFSET = 16;
        private static final int NANOSECONDS_OFFSET = 16;


        private static final int PAYLOAD_START = 20;
        // Layout for event log v1 format, v2 and v3 use HEADER_SIZE_OFFSET
        private static final int TAG_OFFSET = 20;
        private static final int V1_PAYLOAD_START = 20;
        private static final int DATA_START = 24;
        private static final int DATA_OFFSET = 4;


        // Value types
        // Value types
        private static final byte INT_TYPE    = 0;
        private static final byte INT_TYPE    = 0;
@@ -97,14 +99,22 @@ public class EventLog {


        /** @return the type tag code of the entry */
        /** @return the type tag code of the entry */
        public int getTag() {
        public int getTag() {
            return mBuffer.getInt(TAG_OFFSET);
            int offset = mBuffer.getShort(HEADER_SIZE_OFFSET);
            if (offset == 0) {
                offset = V1_PAYLOAD_START;
            }
            return mBuffer.getInt(offset);
        }
        }


        /** @return one of Integer, Long, String, null, or Object[] of same. */
        /** @return one of Integer, Long, String, null, or Object[] of same. */
        public synchronized Object getData() {
        public synchronized Object getData() {
            try {
            try {
                mBuffer.limit(PAYLOAD_START + mBuffer.getShort(LENGTH_OFFSET));
                int offset = mBuffer.getShort(HEADER_SIZE_OFFSET);
                mBuffer.position(DATA_START);  // Just after the tag.
                if (offset == 0) {
                    offset = V1_PAYLOAD_START;
                }
                mBuffer.limit(offset + mBuffer.getShort(LENGTH_OFFSET));
                mBuffer.position(offset + DATA_OFFSET); // Just after the tag.
                return decodeObject();
                return decodeObject();
            } catch (IllegalArgumentException e) {
            } catch (IllegalArgumentException e) {
                Log.wtf(TAG, "Illegal entry payload: tag=" + getTag(), e);
                Log.wtf(TAG, "Illegal entry payload: tag=" + getTag(), e);