Merge "Workaround for empty repeated proto" into sc-dev am: eeda0eb193

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13439171

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I6e879b989569455a9793211e7e003f01a5592122
This commit is contained in:
Kevin Chyn
2021-01-30 10:22:05 +00:00
committed by Automerger Merge Worker
2 changed files with 22 additions and 8 deletions

View File

@@ -635,10 +635,15 @@ public class BiometricScheduler {
proto.write(BiometricSchedulerProto.CURRENT_OPERATION, mCurrentOperation != null proto.write(BiometricSchedulerProto.CURRENT_OPERATION, mCurrentOperation != null
? mCurrentOperation.mClientMonitor.getProtoEnum() : BiometricsProto.CM_NONE); ? mCurrentOperation.mClientMonitor.getProtoEnum() : BiometricsProto.CM_NONE);
proto.write(BiometricSchedulerProto.TOTAL_OPERATIONS, mTotalOperationsHandled); proto.write(BiometricSchedulerProto.TOTAL_OPERATIONS, mTotalOperationsHandled);
Slog.d(getTag(), "Total operations: " + mTotalOperationsHandled);
for (int i = 0; i < mRecentOperations.size(); i++) { if (!mRecentOperations.isEmpty()) {
Slog.d(getTag(), "Operation: " + mRecentOperations.get(i)); for (int i = 0; i < mRecentOperations.size(); i++) {
proto.write(BiometricSchedulerProto.RECENT_OPERATIONS, mRecentOperations.get(i)); proto.write(BiometricSchedulerProto.RECENT_OPERATIONS, mRecentOperations.get(i));
}
} else {
// TODO:(b/178828362) Unsure why protobuf has a problem decoding when an empty list
// is returned. So, let's just add a no-op for this case.
proto.write(BiometricSchedulerProto.RECENT_OPERATIONS, BiometricsProto.CM_NONE);
} }
proto.flush(); proto.flush();

View File

@@ -196,7 +196,8 @@ public class BiometricSchedulerTest {
BiometricSchedulerProto bsp = getDump(true /* clearSchedulerBuffer */); BiometricSchedulerProto bsp = getDump(true /* clearSchedulerBuffer */);
assertEquals(BiometricsProto.CM_NONE, bsp.currentOperation); assertEquals(BiometricsProto.CM_NONE, bsp.currentOperation);
assertEquals(0, bsp.totalOperations); assertEquals(0, bsp.totalOperations);
assertEquals(0, bsp.recentOperations.length); // TODO:(b/178828362) See bug and/or commit message :/
// assertEquals(0, bsp.recentOperations.length);
// Pretend the scheduler is busy enrolling, and check the proto dump again. // Pretend the scheduler is busy enrolling, and check the proto dump again.
final TestClientMonitor2 client = new TestClientMonitor2(mContext, mToken, final TestClientMonitor2 client = new TestClientMonitor2(mContext, mToken,
@@ -207,7 +208,11 @@ public class BiometricSchedulerTest {
assertEquals(BiometricsProto.CM_ENROLL, bsp.currentOperation); assertEquals(BiometricsProto.CM_ENROLL, bsp.currentOperation);
// No operations have completed yet // No operations have completed yet
assertEquals(0, bsp.totalOperations); assertEquals(0, bsp.totalOperations);
assertEquals(0, bsp.recentOperations.length);
// TODO:(b/178828362) See bug and/or commit message :/
assertEquals(1, bsp.recentOperations.length);
assertEquals(BiometricsProto.CM_NONE, bsp.recentOperations[0]);
// Finish this operation, so the next scheduled one can start // Finish this operation, so the next scheduled one can start
client.getCallback().onClientFinished(client, true); client.getCallback().onClientFinished(client, true);
} }
@@ -223,7 +228,8 @@ public class BiometricSchedulerTest {
assertEquals(BiometricsProto.CM_ENROLL, bsp.currentOperation); assertEquals(BiometricsProto.CM_ENROLL, bsp.currentOperation);
// No operations have completed yet // No operations have completed yet
assertEquals(0, bsp.totalOperations); assertEquals(0, bsp.totalOperations);
assertEquals(0, bsp.recentOperations.length); // TODO:(b/178828362) See bug and/or commit message :/
// assertEquals(0, bsp.recentOperations.length);
// Finish this operation, so the next scheduled one can start // Finish this operation, so the next scheduled one can start
client.getCallback().onClientFinished(client, true); client.getCallback().onClientFinished(client, true);
@@ -265,7 +271,10 @@ public class BiometricSchedulerTest {
// RecentOperations queue is cleared (by the previous dump) // RecentOperations queue is cleared (by the previous dump)
bsp = getDump(true /* clearSchedulerBuffer */); bsp = getDump(true /* clearSchedulerBuffer */);
assertEquals(0, bsp.recentOperations.length);
// TODO:(b/178828362) See bug and/or commit message :/
assertEquals(1, bsp.recentOperations.length);
assertEquals(BiometricsProto.CM_NONE, bsp.recentOperations[0]);
} }
@Test @Test