Methods Summary |
---|
public int | describeContents()
return 0;
|
protected void | finalize()
super.finalize();
if (mParcel != null) {
mParcel.recycle();
mParcel = null;
}
|
private int | findStringIndex(java.lang.String str)
final int index = Arrays.binarySearch(mStringPool, str);
if (index < 0) {
throw new IllegalStateException("String '" + str + "' is not in the string pool");
}
return index;
|
public boolean | getNextEvent(android.app.usage.UsageEvents$Event eventOut)Retrieve the next {@link android.app.usage.UsageEvents.Event} from the collection and put the
resulting data into {@code eventOut}.
if (mIndex >= mEventCount) {
return false;
}
readEventFromParcel(mParcel, eventOut);
mIndex++;
if (mIndex >= mEventCount) {
mParcel.recycle();
mParcel = null;
}
return true;
|
public boolean | hasNextEvent()Returns whether or not there are more events to read using
{@link #getNextEvent(android.app.usage.UsageEvents.Event)}.
return mIndex < mEventCount;
|
private void | readEventFromParcel(android.os.Parcel p, android.app.usage.UsageEvents$Event eventOut)Reads a single event from the parcel. Modify this when updating {@link Event}.
final int packageIndex = p.readInt();
if (packageIndex >= 0) {
eventOut.mPackage = mStringPool[packageIndex];
} else {
eventOut.mPackage = null;
}
final int classIndex = p.readInt();
if (classIndex >= 0) {
eventOut.mClass = mStringPool[classIndex];
} else {
eventOut.mClass = null;
}
eventOut.mEventType = p.readInt();
eventOut.mTimeStamp = p.readLong();
// Extract the configuration for configuration change events.
if (eventOut.mEventType == Event.CONFIGURATION_CHANGE) {
eventOut.mConfiguration = Configuration.CREATOR.createFromParcel(p);
} else {
eventOut.mConfiguration = null;
}
|
public void | resetToStart()Resets the collection so that it can be iterated over from the beginning.
mIndex = 0;
if (mParcel != null) {
mParcel.setDataPosition(0);
}
|
private void | writeEventToParcel(android.app.usage.UsageEvents$Event event, android.os.Parcel p, int flags)Writes a single event to the parcel. Modify this when updating {@link Event}.
final int packageIndex;
if (event.mPackage != null) {
packageIndex = findStringIndex(event.mPackage);
} else {
packageIndex = -1;
}
final int classIndex;
if (event.mClass != null) {
classIndex = findStringIndex(event.mClass);
} else {
classIndex = -1;
}
p.writeInt(packageIndex);
p.writeInt(classIndex);
p.writeInt(event.mEventType);
p.writeLong(event.mTimeStamp);
if (event.mEventType == Event.CONFIGURATION_CHANGE) {
event.mConfiguration.writeToParcel(p, flags);
}
|
public void | writeToParcel(android.os.Parcel dest, int flags)
dest.writeInt(mEventCount);
dest.writeInt(mIndex);
if (mEventCount > 0) {
dest.writeStringArray(mStringPool);
if (mEventsToWrite != null) {
// Write out the events
Parcel p = Parcel.obtain();
try {
p.setDataPosition(0);
for (int i = 0; i < mEventCount; i++) {
final Event event = mEventsToWrite.get(i);
writeEventToParcel(event, p, flags);
}
final int listByteLength = p.dataPosition();
// Write the total length of the data.
dest.writeInt(listByteLength);
// Write our current position into the data.
dest.writeInt(0);
// Write the data.
dest.appendFrom(p, 0, listByteLength);
} finally {
p.recycle();
}
} else if (mParcel != null) {
// Write the total length of the data.
dest.writeInt(mParcel.dataSize());
// Write out current position into the data.
dest.writeInt(mParcel.dataPosition());
// Write the data.
dest.appendFrom(mParcel, 0, mParcel.dataSize());
} else {
throw new IllegalStateException(
"Either mParcel or mEventsToWrite must not be null");
}
}
|