Loading core/java/android/util/proto/ProtoInputStream.java +3 −3 Original line number Original line Diff line number Diff line Loading @@ -96,7 +96,7 @@ public final class ProtoInputStream extends ProtoStream { private byte mState = 0; private byte mState = 0; /** /** * Keeps track of the currently read nested Objects, for end object sanity checking and debug * Keeps track of the currently read nested Objects, for end object checking and debug */ */ private ArrayList<Long> mExpectedObjectTokenStack = null; private ArrayList<Long> mExpectedObjectTokenStack = null; Loading Loading @@ -511,7 +511,7 @@ public final class ProtoInputStream extends ProtoStream { (int) fieldId, getOffset() + messageSize)); (int) fieldId, getOffset() + messageSize)); } } // Sanity check // Validation check if (mDepth > 0 if (mDepth > 0 && getOffsetFromToken(mExpectedObjectTokenStack.get(mDepth)) && getOffsetFromToken(mExpectedObjectTokenStack.get(mDepth)) > getOffsetFromToken(mExpectedObjectTokenStack.get(mDepth - 1))) { > getOffsetFromToken(mExpectedObjectTokenStack.get(mDepth - 1))) { Loading @@ -534,7 +534,7 @@ public final class ProtoInputStream extends ProtoStream { * @param token - token * @param token - token */ */ public void end(long token) { public void end(long token) { // Sanity check to make sure user is keeping track of their embedded messages // Make sure user is keeping track of their embedded messages if (mExpectedObjectTokenStack.get(mDepth) != token) { if (mExpectedObjectTokenStack.get(mDepth) != token) { throw new ProtoParseException( throw new ProtoParseException( "end token " + token + " does not match current message token " "end token " + token + " does not match current message token " Loading core/java/android/util/proto/ProtoOutputStream.java +4 −4 Original line number Original line Diff line number Diff line Loading @@ -59,10 +59,10 @@ import java.io.UnsupportedEncodingException; * cache the size, and then write the size-prefixed buffers. * cache the size, and then write the size-prefixed buffers. * * * We are trying to avoid too much generated code here, but this class still * We are trying to avoid too much generated code here, but this class still * needs to have a somewhat sane API. We can't have the multiple passes be * needs to have API. We can't have the multiple passes be done by the * done by the calling code. In addition, we want to avoid the memory high * calling code. In addition, we want to avoid the memory high water mark * water mark of duplicating all of the values into the traditional in-memory * of duplicating all of the values into the traditional in-memory Message * Message objects. We need to find another way. * objects. We need to find another way. * * * So what we do here is to let the calling code write the data into a * So what we do here is to let the calling code write the data into a * byte[] (actually a collection of them wrapped in the EncodedBuffer class), * byte[] (actually a collection of them wrapped in the EncodedBuffer class), Loading Loading
core/java/android/util/proto/ProtoInputStream.java +3 −3 Original line number Original line Diff line number Diff line Loading @@ -96,7 +96,7 @@ public final class ProtoInputStream extends ProtoStream { private byte mState = 0; private byte mState = 0; /** /** * Keeps track of the currently read nested Objects, for end object sanity checking and debug * Keeps track of the currently read nested Objects, for end object checking and debug */ */ private ArrayList<Long> mExpectedObjectTokenStack = null; private ArrayList<Long> mExpectedObjectTokenStack = null; Loading Loading @@ -511,7 +511,7 @@ public final class ProtoInputStream extends ProtoStream { (int) fieldId, getOffset() + messageSize)); (int) fieldId, getOffset() + messageSize)); } } // Sanity check // Validation check if (mDepth > 0 if (mDepth > 0 && getOffsetFromToken(mExpectedObjectTokenStack.get(mDepth)) && getOffsetFromToken(mExpectedObjectTokenStack.get(mDepth)) > getOffsetFromToken(mExpectedObjectTokenStack.get(mDepth - 1))) { > getOffsetFromToken(mExpectedObjectTokenStack.get(mDepth - 1))) { Loading @@ -534,7 +534,7 @@ public final class ProtoInputStream extends ProtoStream { * @param token - token * @param token - token */ */ public void end(long token) { public void end(long token) { // Sanity check to make sure user is keeping track of their embedded messages // Make sure user is keeping track of their embedded messages if (mExpectedObjectTokenStack.get(mDepth) != token) { if (mExpectedObjectTokenStack.get(mDepth) != token) { throw new ProtoParseException( throw new ProtoParseException( "end token " + token + " does not match current message token " "end token " + token + " does not match current message token " Loading
core/java/android/util/proto/ProtoOutputStream.java +4 −4 Original line number Original line Diff line number Diff line Loading @@ -59,10 +59,10 @@ import java.io.UnsupportedEncodingException; * cache the size, and then write the size-prefixed buffers. * cache the size, and then write the size-prefixed buffers. * * * We are trying to avoid too much generated code here, but this class still * We are trying to avoid too much generated code here, but this class still * needs to have a somewhat sane API. We can't have the multiple passes be * needs to have API. We can't have the multiple passes be done by the * done by the calling code. In addition, we want to avoid the memory high * calling code. In addition, we want to avoid the memory high water mark * water mark of duplicating all of the values into the traditional in-memory * of duplicating all of the values into the traditional in-memory Message * Message objects. We need to find another way. * objects. We need to find another way. * * * So what we do here is to let the calling code write the data into a * So what we do here is to let the calling code write the data into a * byte[] (actually a collection of them wrapped in the EncodedBuffer class), * byte[] (actually a collection of them wrapped in the EncodedBuffer class), Loading