* commit 'dfdeabf9ba40ea7f082acf7eba6fe086d2e643fb': EventLog: event log translation errors
This commit is contained in:
@@ -56,16 +56,18 @@ public class EventLog {
|
||||
public static final class Event {
|
||||
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 HEADER_SIZE_OFFSET = 2;
|
||||
private static final int PROCESS_OFFSET = 4;
|
||||
private static final int THREAD_OFFSET = 8;
|
||||
private static final int SECONDS_OFFSET = 12;
|
||||
private static final int NANOSECONDS_OFFSET = 16;
|
||||
|
||||
private static final int PAYLOAD_START = 20;
|
||||
private static final int TAG_OFFSET = 20;
|
||||
private static final int DATA_START = 24;
|
||||
// Layout for event log v1 format, v2 and v3 use HEADER_SIZE_OFFSET
|
||||
private static final int V1_PAYLOAD_START = 20;
|
||||
private static final int DATA_OFFSET = 4;
|
||||
|
||||
// Value types
|
||||
private static final byte INT_TYPE = 0;
|
||||
@@ -97,14 +99,22 @@ public class EventLog {
|
||||
|
||||
/** @return the type tag code of the entry */
|
||||
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. */
|
||||
public synchronized Object getData() {
|
||||
try {
|
||||
mBuffer.limit(PAYLOAD_START + mBuffer.getShort(LENGTH_OFFSET));
|
||||
mBuffer.position(DATA_START); // Just after the tag.
|
||||
int offset = mBuffer.getShort(HEADER_SIZE_OFFSET);
|
||||
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();
|
||||
} catch (IllegalArgumentException e) {
|
||||
Log.wtf(TAG, "Illegal entry payload: tag=" + getTag(), e);
|
||||
|
||||
Reference in New Issue
Block a user