From 8520e569980c8b2bbca0872c906d057165121012 Mon Sep 17 00:00:00 2001 From: Michael Wachenschwanz Date: Thu, 24 May 2018 15:28:24 +0000 Subject: [PATCH] Revert "Write UsageEvents Parcel data as a Blob" This reverts commit f5bae21c5efcd51c0b3fb29942c02c00b896fccf. Reason for revert: Bug: 79860717 Fixes: 80215357 Change-Id: I0768e5ce0a95afe7ff091c0035335437bb33c46c --- core/java/android/app/usage/UsageEvents.java | 38 +++++++++++----------------- 1 file changed, 15 insertions(+), 23 deletions(-) diff --git a/core/java/android/app/usage/UsageEvents.java b/core/java/android/app/usage/UsageEvents.java index 3e90af356da0..503ca6c3712d 100644 --- a/core/java/android/app/usage/UsageEvents.java +++ b/core/java/android/app/usage/UsageEvents.java @@ -399,20 +399,16 @@ public final class UsageEvents implements Parcelable { * {@hide} */ public UsageEvents(Parcel in) { - byte[] bytes = in.readBlob(); - Parcel data = Parcel.obtain(); - data.unmarshall(bytes, 0, bytes.length); - data.setDataPosition(0); - mEventCount = data.readInt(); - mIndex = data.readInt(); + mEventCount = in.readInt(); + mIndex = in.readInt(); if (mEventCount > 0) { - mStringPool = data.createStringArray(); + mStringPool = in.createStringArray(); - final int listByteLength = data.readInt(); - final int positionInParcel = data.readInt(); + final int listByteLength = in.readInt(); + final int positionInParcel = in.readInt(); mParcel = Parcel.obtain(); mParcel.setDataPosition(0); - mParcel.appendFrom(data, data.dataPosition(), listByteLength); + mParcel.appendFrom(in, in.dataPosition(), listByteLength); mParcel.setDataSize(mParcel.dataPosition()); mParcel.setDataPosition(positionInParcel); } @@ -590,11 +586,10 @@ public final class UsageEvents implements Parcelable { @Override public void writeToParcel(Parcel dest, int flags) { - Parcel data = Parcel.obtain(); - data.writeInt(mEventCount); - data.writeInt(mIndex); + dest.writeInt(mEventCount); + dest.writeInt(mIndex); if (mEventCount > 0) { - data.writeStringArray(mStringPool); + dest.writeStringArray(mStringPool); if (mEventsToWrite != null) { // Write out the events @@ -609,34 +604,31 @@ public final class UsageEvents implements Parcelable { final int listByteLength = p.dataPosition(); // Write the total length of the data. - data.writeInt(listByteLength); + dest.writeInt(listByteLength); // Write our current position into the data. - data.writeInt(0); + dest.writeInt(0); // Write the data. - data.appendFrom(p, 0, listByteLength); + dest.appendFrom(p, 0, listByteLength); } finally { p.recycle(); } } else if (mParcel != null) { // Write the total length of the data. - data.writeInt(mParcel.dataSize()); + dest.writeInt(mParcel.dataSize()); // Write out current position into the data. - data.writeInt(mParcel.dataPosition()); + dest.writeInt(mParcel.dataPosition()); // Write the data. - data.appendFrom(mParcel, 0, mParcel.dataSize()); + dest.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 CREATOR = new Creator() { -- 2.11.0