diff options
| author | Michael Wachenschwanz <mwachens@google.com> | 2018-05-24 20:45:34 +0000 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2018-05-24 20:45:34 +0000 |
| commit | 14c61286c42eeadc9dd3bc033dca985ffa91e19d (patch) | |
| tree | e891d17b4aa1ef852c9c92b0506d53860507b374 /core/java | |
| parent | 473b8b09b063799411b5233ab034a154f86a5f64 (diff) | |
| parent | 76d03fcd7e7f70287a49107e3f9b6420b99c6865 (diff) | |
Merge "Revert "Revert "Write UsageEvents Parcel data as a Blob""" into pi-dev
Diffstat (limited to 'core/java')
| -rw-r--r-- | core/java/android/app/usage/UsageEvents.java | 38 |
1 files changed, 23 insertions, 15 deletions
diff --git a/core/java/android/app/usage/UsageEvents.java b/core/java/android/app/usage/UsageEvents.java index 503ca6c3712d..3e90af356da0 100644 --- a/core/java/android/app/usage/UsageEvents.java +++ b/core/java/android/app/usage/UsageEvents.java @@ -399,16 +399,20 @@ public final class UsageEvents implements Parcelable { * {@hide} */ public UsageEvents(Parcel in) { - mEventCount = in.readInt(); - mIndex = in.readInt(); + byte[] bytes = in.readBlob(); + Parcel data = Parcel.obtain(); + data.unmarshall(bytes, 0, bytes.length); + data.setDataPosition(0); + mEventCount = data.readInt(); + mIndex = data.readInt(); if (mEventCount > 0) { - mStringPool = in.createStringArray(); + mStringPool = data.createStringArray(); - final int listByteLength = in.readInt(); - final int positionInParcel = in.readInt(); + final int listByteLength = data.readInt(); + final int positionInParcel = data.readInt(); mParcel = Parcel.obtain(); mParcel.setDataPosition(0); - mParcel.appendFrom(in, in.dataPosition(), listByteLength); + mParcel.appendFrom(data, data.dataPosition(), listByteLength); mParcel.setDataSize(mParcel.dataPosition()); mParcel.setDataPosition(positionInParcel); } @@ -586,10 +590,11 @@ public final class UsageEvents implements Parcelable { @Override public void writeToParcel(Parcel dest, int flags) { - dest.writeInt(mEventCount); - dest.writeInt(mIndex); + Parcel data = Parcel.obtain(); + data.writeInt(mEventCount); + data.writeInt(mIndex); if (mEventCount > 0) { - dest.writeStringArray(mStringPool); + data.writeStringArray(mStringPool); if (mEventsToWrite != null) { // Write out the events @@ -604,31 +609,34 @@ public final class UsageEvents implements Parcelable { final int listByteLength = p.dataPosition(); // Write the total length of the data. - dest.writeInt(listByteLength); + data.writeInt(listByteLength); // Write our current position into the data. - dest.writeInt(0); + data.writeInt(0); // Write the data. - dest.appendFrom(p, 0, listByteLength); + data.appendFrom(p, 0, listByteLength); } finally { p.recycle(); } } else if (mParcel != null) { // Write the total length of the data. - dest.writeInt(mParcel.dataSize()); + data.writeInt(mParcel.dataSize()); // Write out current position into the data. - dest.writeInt(mParcel.dataPosition()); + data.writeInt(mParcel.dataPosition()); // Write the data. - dest.appendFrom(mParcel, 0, mParcel.dataSize()); + data.appendFrom(mParcel, 0, mParcel.dataSize()); } else { throw new IllegalStateException( "Either mParcel or mEventsToWrite must not be null"); } } + // Data can be too large for a transact. Write the data as a Blob, which will be written to + // ashmem if too large. + dest.writeBlob(data.marshall()); } public static final Creator<UsageEvents> CREATOR = new Creator<UsageEvents>() { |
