Fix the build

Change-Id: I770ed6fd8de0479655f587db68a09882eb6cceb5
diff --git a/libs/protoutil/tests/EncodedBuffer_test.cpp b/libs/protoutil/tests/EncodedBuffer_test.cpp
index 964fc8e..398af60 100644
--- a/libs/protoutil/tests/EncodedBuffer_test.cpp
+++ b/libs/protoutil/tests/EncodedBuffer_test.cpp
@@ -16,6 +16,7 @@
 #include <gtest/gtest.h>
 
 using namespace android::util;
+using android::sp;
 
 constexpr size_t TEST_CHUNK_SIZE = 16UL;
 constexpr size_t TEST_CHUNK_HALF_SIZE = TEST_CHUNK_SIZE / 2;
@@ -122,33 +123,30 @@
     for (size_t i = 0; i < TEST_CHUNK_3X_SIZE; i++) {
         buffer.writeRawByte(i);
     }
-    auto iter = buffer.begin();
-    EXPECT_EQ(iter.size(), TEST_CHUNK_3X_SIZE);
-    EXPECT_EQ(iter.bytesRead(), 0);
+    sp<ProtoReader> reader1 = buffer.read();
+    EXPECT_EQ(reader1->size(), TEST_CHUNK_3X_SIZE);
+    EXPECT_EQ(reader1->bytesRead(), 0);
 
-    expectPointer(iter.rp(), 0);
-    while (iter.readBuffer() != NULL) {
-        iter.rp()->move(iter.currentToRead());
+    while (reader1->readBuffer() != NULL) {
+        reader1->move(reader1->currentToRead());
     }
-    EXPECT_EQ(iter.bytesRead(), TEST_CHUNK_3X_SIZE);
-    expectPointer(iter.rp(), TEST_CHUNK_3X_SIZE);
+    EXPECT_EQ(reader1->bytesRead(), TEST_CHUNK_3X_SIZE);
 
-    iter.rp()->rewind();
-    expectPointer(iter.rp(), 0);
+    sp<ProtoReader> reader2 = buffer.read();
     uint8_t val = 0;
-    while (iter.hasNext()) {
-        EXPECT_EQ(iter.next(), val);
+    while (reader2->hasNext()) {
+        EXPECT_EQ(reader2->next(), val);
         val++;
     }
-    EXPECT_EQ(iter.bytesRead(), TEST_CHUNK_3X_SIZE);
-    expectPointer(iter.rp(), TEST_CHUNK_3X_SIZE);
+    EXPECT_EQ(reader2->bytesRead(), TEST_CHUNK_3X_SIZE);
+    EXPECT_EQ(reader1->bytesRead(), TEST_CHUNK_3X_SIZE);
 }
 
 TEST(EncodedBufferTest, ReadVarint) {
     EncodedBuffer buffer;
     uint64_t val = UINT64_C(1522865904593);
     size_t len = buffer.writeRawVarint64(val);
-    auto iter = buffer.begin();
-    EXPECT_EQ(iter.size(), len);
-    EXPECT_EQ(iter.readRawVarint(), val);
+    sp<ProtoReader> reader = buffer.read();
+    EXPECT_EQ(reader->size(), len);
+    EXPECT_EQ(reader->readRawVarint(), val);
 }
diff --git a/libs/protoutil/tests/ProtoOutputStream_test.cpp b/libs/protoutil/tests/ProtoOutputStream_test.cpp
index 27ee13d..9d357f3 100644
--- a/libs/protoutil/tests/ProtoOutputStream_test.cpp
+++ b/libs/protoutil/tests/ProtoOutputStream_test.cpp
@@ -21,6 +21,7 @@
 
 #include "frameworks/base/libs/protoutil/tests/test.pb.h"
 
+using android::sp;
 using namespace android::base;
 using namespace android::util;
 using ::testing::StrEq;
@@ -38,9 +39,9 @@
 static std::string iterateToString(ProtoOutputStream* proto) {
     std::string content;
     content.reserve(proto->size());
-    auto iter = proto->data();
-    while (iter.hasNext()) {
-        content.push_back(iter.next());
+    sp<ProtoReader> reader = proto->data();
+    while (reader->hasNext()) {
+        content.push_back(reader->next());
     }
     return content;
 }
@@ -198,7 +199,6 @@
     // no proto.end called
     EXPECT_NE(proto.bytesWritten(), 0);
     EXPECT_EQ(proto.size(), 0);
-    EXPECT_EQ(proto.data().size(), 0);
     EXPECT_FALSE(proto.flush(STDOUT_FILENO));
 }
 
@@ -211,7 +211,6 @@
     proto.end(token);
     EXPECT_NE(proto.bytesWritten(), 0);
     EXPECT_EQ(proto.size(), 0);
-    EXPECT_EQ(proto.data().size(), 0);
     EXPECT_FALSE(proto.flush(STDOUT_FILENO));
 }
 
@@ -223,6 +222,5 @@
     proto.end(wrongToken);
     EXPECT_NE(proto.bytesWritten(), 0);
     EXPECT_EQ(proto.size(), 0);
-    EXPECT_EQ(proto.data().size(), 0);
     EXPECT_FALSE(proto.flush(STDOUT_FILENO));
 }