summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--api/test-current.txt2
-rw-r--r--core/java/android/util/proto/EncodedBuffer.java8
-rw-r--r--core/java/android/util/proto/ProtoOutputStream.java12
3 files changed, 22 insertions, 0 deletions
diff --git a/api/test-current.txt b/api/test-current.txt
index 049e0025a59b..c821ffa18567 100644
--- a/api/test-current.txt
+++ b/api/test-current.txt
@@ -2077,6 +2077,7 @@ package android.util.proto {
method public static int getRawZigZag64Size(long);
method public int getReadPos();
method public int getReadableSize();
+ method public int getSize();
method public int getWriteBufIndex();
method public int getWriteIndex();
method public int getWritePos();
@@ -2136,6 +2137,7 @@ package android.util.proto {
method @Deprecated public void endRepeatedObject(long);
method public void flush();
method public byte[] getBytes();
+ method public int getRawSize();
method public static long makeFieldId(int, long);
method public long start(long);
method @Deprecated public long startObject(long);
diff --git a/core/java/android/util/proto/EncodedBuffer.java b/core/java/android/util/proto/EncodedBuffer.java
index ed38e6ffd302..56a0bfa2adb1 100644
--- a/core/java/android/util/proto/EncodedBuffer.java
+++ b/core/java/android/util/proto/EncodedBuffer.java
@@ -147,6 +147,14 @@ public final class EncodedBuffer {
return mReadableSize;
}
+ /**
+ * Returns the buffer size
+ * @return the buffer size
+ */
+ public int getSize() {
+ return ((mBufferCount - 1) * mChunkSize) + mWriteIndex;
+ }
+
//
// Reading from the read position.
//
diff --git a/core/java/android/util/proto/ProtoOutputStream.java b/core/java/android/util/proto/ProtoOutputStream.java
index a1ee61c15f24..6efcfbfd05f8 100644
--- a/core/java/android/util/proto/ProtoOutputStream.java
+++ b/core/java/android/util/proto/ProtoOutputStream.java
@@ -188,6 +188,18 @@ public final class ProtoOutputStream extends ProtoStream {
}
/**
+ * Returns the uncompressed buffer size
+ * @return the uncompressed buffer size
+ */
+ public int getRawSize() {
+ if (mCompacted) {
+ return getBytes().length;
+ } else {
+ return mBuffer.getSize();
+ }
+ }
+
+ /**
* Write a value for the given fieldId.
*
* Will automatically convert for the following field types, and