Merge "Fix issue #22653116: Google App crashing on NYT app" into mnc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
5507bb41b0
@@ -4,6 +4,7 @@ import android.app.Activity;
|
|||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.graphics.Matrix;
|
import android.graphics.Matrix;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
|
import android.os.BadParcelableException;
|
||||||
import android.os.Binder;
|
import android.os.Binder;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
@@ -31,8 +32,12 @@ public class AssistStructure implements Parcelable {
|
|||||||
static final String TAG = "AssistStructure";
|
static final String TAG = "AssistStructure";
|
||||||
|
|
||||||
static final boolean DEBUG_PARCEL = false;
|
static final boolean DEBUG_PARCEL = false;
|
||||||
|
static final boolean DEBUG_PARCEL_CHILDREN = false;
|
||||||
static final boolean DEBUG_PARCEL_TREE = false;
|
static final boolean DEBUG_PARCEL_TREE = false;
|
||||||
|
|
||||||
|
static final int VALIDATE_WINDOW_TOKEN = 0x11111111;
|
||||||
|
static final int VALIDATE_VIEW_TOKEN = 0x22222222;
|
||||||
|
|
||||||
boolean mHaveData;
|
boolean mHaveData;
|
||||||
|
|
||||||
ComponentName mActivityComponent;
|
ComponentName mActivityComponent;
|
||||||
@@ -173,6 +178,26 @@ public class AssistStructure implements Parcelable {
|
|||||||
mCurViewStackEntry = entry;
|
mCurViewStackEntry = entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void writeView(ViewNode child, Parcel out, PooledStringWriter pwriter, int levelAdj) {
|
||||||
|
if (DEBUG_PARCEL) Log.d(TAG, "write view: at " + out.dataPosition()
|
||||||
|
+ ", windows=" + mNumWrittenWindows
|
||||||
|
+ ", views=" + mNumWrittenViews
|
||||||
|
+ ", level=" + (mCurViewStackPos+levelAdj));
|
||||||
|
out.writeInt(VALIDATE_VIEW_TOKEN);
|
||||||
|
int flags = child.writeSelfToParcel(out, pwriter, mTmpMatrix);
|
||||||
|
mNumWrittenViews++;
|
||||||
|
// If the child has children, push it on the stack to write them next.
|
||||||
|
if ((flags&ViewNode.FLAGS_HAS_CHILDREN) != 0) {
|
||||||
|
if (DEBUG_PARCEL_TREE || DEBUG_PARCEL_CHILDREN) Log.d(TAG,
|
||||||
|
"Preparing to write " + child.mChildren.length
|
||||||
|
+ " children: @ #" + mNumWrittenViews
|
||||||
|
+ ", level " + (mCurViewStackPos+levelAdj));
|
||||||
|
out.writeInt(child.mChildren.length);
|
||||||
|
int pos = ++mCurViewStackPos;
|
||||||
|
pushViewStackEntry(child, pos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
boolean writeNextEntryToParcel(AssistStructure as, Parcel out, PooledStringWriter pwriter) {
|
boolean writeNextEntryToParcel(AssistStructure as, Parcel out, PooledStringWriter pwriter) {
|
||||||
// Write next view node if appropriate.
|
// Write next view node if appropriate.
|
||||||
if (mCurViewStackEntry != null) {
|
if (mCurViewStackEntry != null) {
|
||||||
@@ -182,20 +207,7 @@ public class AssistStructure implements Parcelable {
|
|||||||
+ mCurViewStackEntry.curChild + " in " + mCurViewStackEntry.node);
|
+ mCurViewStackEntry.curChild + " in " + mCurViewStackEntry.node);
|
||||||
ViewNode child = mCurViewStackEntry.node.mChildren[mCurViewStackEntry.curChild];
|
ViewNode child = mCurViewStackEntry.node.mChildren[mCurViewStackEntry.curChild];
|
||||||
mCurViewStackEntry.curChild++;
|
mCurViewStackEntry.curChild++;
|
||||||
if (DEBUG_PARCEL) Log.d(TAG, "write view: at " + out.dataPosition()
|
writeView(child, out, pwriter, 1);
|
||||||
+ ", windows=" + mNumWrittenWindows
|
|
||||||
+ ", views=" + mNumWrittenViews);
|
|
||||||
out.writeInt(1);
|
|
||||||
int flags = child.writeSelfToParcel(out, pwriter, mTmpMatrix);
|
|
||||||
mNumWrittenViews++;
|
|
||||||
// If the child has children, push it on the stack to write them next.
|
|
||||||
if ((flags&ViewNode.FLAGS_HAS_CHILDREN) != 0) {
|
|
||||||
if (DEBUG_PARCEL_TREE) Log.d(TAG, "Preparing to write "
|
|
||||||
+ child.mChildren.length + " children under " + child);
|
|
||||||
out.writeInt(child.mChildren.length);
|
|
||||||
int pos = ++mCurViewStackPos;
|
|
||||||
pushViewStackEntry(child, pos);
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -223,13 +235,13 @@ public class AssistStructure implements Parcelable {
|
|||||||
if (DEBUG_PARCEL) Log.d(TAG, "write window #" + pos + ": at " + out.dataPosition()
|
if (DEBUG_PARCEL) Log.d(TAG, "write window #" + pos + ": at " + out.dataPosition()
|
||||||
+ ", windows=" + mNumWrittenWindows
|
+ ", windows=" + mNumWrittenWindows
|
||||||
+ ", views=" + mNumWrittenViews);
|
+ ", views=" + mNumWrittenViews);
|
||||||
out.writeInt(1);
|
out.writeInt(VALIDATE_WINDOW_TOKEN);
|
||||||
win.writeSelfToParcel(out, pwriter, mTmpMatrix);
|
win.writeSelfToParcel(out, pwriter, mTmpMatrix);
|
||||||
mNumWrittenWindows++;
|
mNumWrittenWindows++;
|
||||||
ViewNode root = win.mRoot;
|
ViewNode root = win.mRoot;
|
||||||
mCurViewStackPos = 0;
|
mCurViewStackPos = 0;
|
||||||
if (DEBUG_PARCEL_TREE) Log.d(TAG, "Pushing initial root view " + root);
|
if (DEBUG_PARCEL_TREE) Log.d(TAG, "Writing initial root view " + root);
|
||||||
pushViewStackEntry(root, 0);
|
writeView(root, out, pwriter, 0);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -271,11 +283,16 @@ public class AssistStructure implements Parcelable {
|
|||||||
+ ", views=" + mNumReadViews);
|
+ ", views=" + mNumReadViews);
|
||||||
}
|
}
|
||||||
|
|
||||||
Parcel readParcel() {
|
Parcel readParcel(int validateToken, int level) {
|
||||||
if (DEBUG_PARCEL) Log.d(TAG, "readParcel: at " + mCurParcel.dataPosition()
|
if (DEBUG_PARCEL) Log.d(TAG, "readParcel: at " + mCurParcel.dataPosition()
|
||||||
+ ", avail=" + mCurParcel.dataAvail() + ", windows=" + mNumReadWindows
|
+ ", avail=" + mCurParcel.dataAvail() + ", windows=" + mNumReadWindows
|
||||||
+ ", views=" + mNumReadViews);
|
+ ", views=" + mNumReadViews + ", level=" + level);
|
||||||
if (mCurParcel.readInt() != 0) {
|
int token = mCurParcel.readInt();
|
||||||
|
if (token != 0) {
|
||||||
|
if (token != validateToken) {
|
||||||
|
throw new BadParcelableException("Got token " + Integer.toHexString(token)
|
||||||
|
+ ", expected token " + Integer.toHexString(validateToken));
|
||||||
|
}
|
||||||
return mCurParcel;
|
return mCurParcel;
|
||||||
}
|
}
|
||||||
// We have run out of partial data, need to read another batch.
|
// We have run out of partial data, need to read another batch.
|
||||||
@@ -406,7 +423,7 @@ public class AssistStructure implements Parcelable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
WindowNode(ParcelTransferReader reader) {
|
WindowNode(ParcelTransferReader reader) {
|
||||||
Parcel in = reader.readParcel();
|
Parcel in = reader.readParcel(VALIDATE_WINDOW_TOKEN, 0);
|
||||||
reader.mNumReadWindows++;
|
reader.mNumReadWindows++;
|
||||||
mX = in.readInt();
|
mX = in.readInt();
|
||||||
mY = in.readInt();
|
mY = in.readInt();
|
||||||
@@ -414,7 +431,7 @@ public class AssistStructure implements Parcelable {
|
|||||||
mHeight = in.readInt();
|
mHeight = in.readInt();
|
||||||
mTitle = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in);
|
mTitle = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in);
|
||||||
mDisplayId = in.readInt();
|
mDisplayId = in.readInt();
|
||||||
mRoot = new ViewNode(reader);
|
mRoot = new ViewNode(reader, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void writeSelfToParcel(Parcel out, PooledStringWriter pwriter, float[] tmpMatrix) {
|
void writeSelfToParcel(Parcel out, PooledStringWriter pwriter, float[] tmpMatrix) {
|
||||||
@@ -548,8 +565,8 @@ public class AssistStructure implements Parcelable {
|
|||||||
ViewNode() {
|
ViewNode() {
|
||||||
}
|
}
|
||||||
|
|
||||||
ViewNode(ParcelTransferReader reader) {
|
ViewNode(ParcelTransferReader reader, int nestingLevel) {
|
||||||
final Parcel in = reader.readParcel();
|
final Parcel in = reader.readParcel(VALIDATE_VIEW_TOKEN, nestingLevel);
|
||||||
reader.mNumReadViews++;
|
reader.mNumReadViews++;
|
||||||
final PooledStringReader preader = reader.mStringReader;
|
final PooledStringReader preader = reader.mStringReader;
|
||||||
mClassName = preader.readString();
|
mClassName = preader.readString();
|
||||||
@@ -604,9 +621,13 @@ public class AssistStructure implements Parcelable {
|
|||||||
}
|
}
|
||||||
if ((flags&FLAGS_HAS_CHILDREN) != 0) {
|
if ((flags&FLAGS_HAS_CHILDREN) != 0) {
|
||||||
final int NCHILDREN = in.readInt();
|
final int NCHILDREN = in.readInt();
|
||||||
|
if (DEBUG_PARCEL_TREE || DEBUG_PARCEL_CHILDREN) Log.d(TAG,
|
||||||
|
"Preparing to read " + NCHILDREN
|
||||||
|
+ " children: @ #" + reader.mNumReadViews
|
||||||
|
+ ", level " + nestingLevel);
|
||||||
mChildren = new ViewNode[NCHILDREN];
|
mChildren = new ViewNode[NCHILDREN];
|
||||||
for (int i=0; i<NCHILDREN; i++) {
|
for (int i=0; i<NCHILDREN; i++) {
|
||||||
mChildren[i] = new ViewNode(reader);
|
mChildren[i] = new ViewNode(reader, nestingLevel + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user