Loading core/java/android/util/EventLog.java +26 −0 Original line number Diff line number Diff line Loading @@ -56,6 +56,7 @@ public class EventLog { /** A previously logged event read from the logs. Instances are thread safe. */ public static final class Event { private final ByteBuffer mBuffer; private Exception mLastWtf; // Layout of event log entry received from Android logger. // see system/core/include/log/logger.h Loading Loading @@ -116,13 +117,19 @@ public class EventLog { offset = V1_PAYLOAD_START; } mBuffer.limit(offset + mBuffer.getShort(LENGTH_OFFSET)); if ((offset + DATA_OFFSET) >= mBuffer.limit()) { // no payload return null; } mBuffer.position(offset + DATA_OFFSET); // Just after the tag. return decodeObject(); } catch (IllegalArgumentException e) { Log.wtf(TAG, "Illegal entry payload: tag=" + getTag(), e); mLastWtf = e; return null; } catch (BufferUnderflowException e) { Log.wtf(TAG, "Truncated entry payload: tag=" + getTag(), e); mLastWtf = e; return null; } } Loading @@ -148,6 +155,7 @@ public class EventLog { return new String(mBuffer.array(), start, length, "UTF-8"); } catch (UnsupportedEncodingException e) { Log.wtf(TAG, "UTF-8 is not supported", e); mLastWtf = e; return null; } Loading @@ -173,6 +181,24 @@ public class EventLog { byte[] bytes = mBuffer.array(); return Arrays.copyOf(bytes, bytes.length); } /** * Retreive the last WTF error generated by this object. * @hide */ //VisibleForTesting public Exception getLastError() { return mLastWtf; } /** * Clear the error state for this object. * @hide */ //VisibleForTesting public void clearError() { mLastWtf = null; } } // We assume that the native methods deal with any concurrency issues. Loading Loading
core/java/android/util/EventLog.java +26 −0 Original line number Diff line number Diff line Loading @@ -56,6 +56,7 @@ public class EventLog { /** A previously logged event read from the logs. Instances are thread safe. */ public static final class Event { private final ByteBuffer mBuffer; private Exception mLastWtf; // Layout of event log entry received from Android logger. // see system/core/include/log/logger.h Loading Loading @@ -116,13 +117,19 @@ public class EventLog { offset = V1_PAYLOAD_START; } mBuffer.limit(offset + mBuffer.getShort(LENGTH_OFFSET)); if ((offset + DATA_OFFSET) >= mBuffer.limit()) { // no payload return null; } mBuffer.position(offset + DATA_OFFSET); // Just after the tag. return decodeObject(); } catch (IllegalArgumentException e) { Log.wtf(TAG, "Illegal entry payload: tag=" + getTag(), e); mLastWtf = e; return null; } catch (BufferUnderflowException e) { Log.wtf(TAG, "Truncated entry payload: tag=" + getTag(), e); mLastWtf = e; return null; } } Loading @@ -148,6 +155,7 @@ public class EventLog { return new String(mBuffer.array(), start, length, "UTF-8"); } catch (UnsupportedEncodingException e) { Log.wtf(TAG, "UTF-8 is not supported", e); mLastWtf = e; return null; } Loading @@ -173,6 +181,24 @@ public class EventLog { byte[] bytes = mBuffer.array(); return Arrays.copyOf(bytes, bytes.length); } /** * Retreive the last WTF error generated by this object. * @hide */ //VisibleForTesting public Exception getLastError() { return mLastWtf; } /** * Clear the error state for this object. * @hide */ //VisibleForTesting public void clearError() { mLastWtf = null; } } // We assume that the native methods deal with any concurrency issues. Loading