Java Code Examples for android.util.EventLog#Event

The following examples show how to use android.util.EventLog#Event . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MetricsReader.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
Event(EventLog.Event nativeEvent) {
    mTimeMillis = TimeUnit.MILLISECONDS.convert(
            nativeEvent.getTimeNanos(), TimeUnit.NANOSECONDS);
    mPid = nativeEvent.getProcessId();
    mUid = nativeEvent.getUid();
    mData = nativeEvent.getData();
}
 
Example 2
Source File: MetricsReader.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
public void readEvents(int[] tags, long horizonMs, Collection<Event> events)
        throws IOException {
    // Testing in Android: the Static Final Class Strikes Back!
    ArrayList<EventLog.Event> nativeEvents = new ArrayList<>();
    long horizonNs = TimeUnit.NANOSECONDS.convert(horizonMs, TimeUnit.MILLISECONDS);
    EventLog.readEventsOnWrapping(tags, horizonNs, nativeEvents);
    for (EventLog.Event nativeEvent : nativeEvents) {
        Event event = new Event(nativeEvent);
        events.add(event);
    }
}
 
Example 3
Source File: CondomMiscTest.java    From condom with Apache License 2.0 5 votes vote down vote up
private static List<EventLog.Event> readNewEvents(final CondomCore.CondomEvent type) throws IOException {
	final List<EventLog.Event> events = new ArrayList<>();
	EventLog.readEvents(new int[] { EVENT_TAG_MARK, "Condom".hashCode() + type.ordinal() }, events);
	if (events.isEmpty()) return Collections.emptyList();
	for (int i = events.size() - 1; i >= 0; i --) {
		final EventLog.Event event = events.get(i);
		if (event.getTag() == EVENT_TAG_MARK) {
			EventLog.writeEvent(EVENT_TAG_MARK);
			return events.subList(i + 1, events.size());
		}
	}
	EventLog.writeEvent(EVENT_TAG_MARK);
	return events;
}
 
Example 4
Source File: CondomMiscTest.java    From MiPushFramework with GNU General Public License v3.0 5 votes vote down vote up
private static List<EventLog.Event> readNewEvents(final CondomCore.CondomEvent type) throws IOException {
	final List<EventLog.Event> events = new ArrayList<>();
	EventLog.readEvents(new int[] { EVENT_TAG_MARK, "Condom".hashCode() + type.ordinal() }, events);
	if (events.isEmpty()) return Collections.emptyList();
	for (int i = events.size() - 1; i >= 0; i --) {
		final EventLog.Event event = events.get(i);
		if (event.getTag() == EVENT_TAG_MARK) {
			EventLog.writeEvent(EVENT_TAG_MARK);
			return events.subList(i + 1, events.size());
		}
	}
	EventLog.writeEvent(EVENT_TAG_MARK);
	return events;
}
 
Example 5
Source File: CondomMiscTest.java    From condom with Apache License 2.0 4 votes vote down vote up
private static Object[] readLastEvent(final CondomCore.CondomEvent type) throws IOException {
	final List<EventLog.Event> events = readNewEvents(type);
	assertEquals(1, events.size());
	return (Object[]) events.get(0).getData();
}
 
Example 6
Source File: CondomMiscTest.java    From MiPushFramework with GNU General Public License v3.0 4 votes vote down vote up
private static Object[] readLastEvent(final CondomCore.CondomEvent type) throws IOException {
	final List<EventLog.Event> events = readNewEvents(type);
	assertEquals(1, events.size());
	return (Object[]) events.get(0).getData();
}