Loading core/java/android/util/StatsEvent.java +3 −3 Original line number Diff line number Diff line Loading @@ -175,7 +175,7 @@ public final class StatsEvent { * @hide **/ @VisibleForTesting public static final int ERROR_ATTRIBUTION_UIDS_TAGS_SIZES_NOT_EQUAL = 0x400; public static final int ERROR_ATTRIBUTION_UIDS_TAGS_SIZES_NOT_EQUAL = 0x1000; // Size limits. Loading Loading @@ -593,9 +593,9 @@ public final class StatsEvent { if (0 == mErrorMask) { mBuffer.putByte(POS_NUM_ELEMENTS, (byte) mNumElements); } else { mBuffer.putByte(0, TYPE_ERRORS); mBuffer.putByte(POS_NUM_ELEMENTS, (byte) 3); mPos += mBuffer.putByte(mPos, TYPE_ERRORS); mPos += mBuffer.putInt(mPos, mErrorMask); mBuffer.putByte(POS_NUM_ELEMENTS, (byte) 3); size = mPos; } Loading core/tests/coretests/src/android/util/StatsEventTest.java +5 −2 Original line number Diff line number Diff line Loading @@ -53,8 +53,8 @@ public class StatsEventTest { final ByteBuffer buffer = ByteBuffer.wrap(statsEvent.getBytes()).order(ByteOrder.LITTLE_ENDIAN); assertWithMessage("Root element in buffer is not TYPE_ERRORS") .that(buffer.get()).isEqualTo(StatsEvent.TYPE_ERRORS); assertWithMessage("Root element in buffer is not TYPE_OBJECT") .that(buffer.get()).isEqualTo(StatsEvent.TYPE_OBJECT); assertWithMessage("Incorrect number of elements in root object") .that(buffer.get()).isEqualTo(3); Loading @@ -71,6 +71,9 @@ public class StatsEventTest { assertWithMessage("Incorrect atom id") .that(buffer.getInt()).isEqualTo(expectedAtomId); assertWithMessage("Third element is not errors type") .that(buffer.get()).isEqualTo(StatsEvent.TYPE_ERRORS); final int errorMask = buffer.getInt(); assertWithMessage("ERROR_NO_ATOM_ID should be the only error in the error mask") Loading tools/stats_log_api_gen/java_writer.cpp +8 −5 Original line number Diff line number Diff line Loading @@ -83,7 +83,7 @@ static int write_java_methods( // Print method body. string indent(""); if (DEFAULT_MODULE_NAME != moduleName) { fprintf(out, " if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {\n"); fprintf(out, " if (Build.VERSION.SDK_INT > Build.VERSION_CODES.Q) {\n"); indent = " "; } Loading Loading @@ -116,16 +116,19 @@ static int write_java_methods( fprintf(out, "%s builder.writeString(arg%d);\n", indent.c_str(), argIndex); break; case JAVA_TYPE_BYTE_ARRAY: fprintf(out, "%s builder.writeByteArray(arg%d);\n", indent.c_str(), argIndex); fprintf(out, "%s builder.writeByteArray(null == arg%d ? new byte[0] : arg%d);\n", indent.c_str(), argIndex, argIndex); break; case JAVA_TYPE_ATTRIBUTION_CHAIN: { const char* uidName = attributionDecl.fields.front().name.c_str(); const char* tagName = attributionDecl.fields.back().name.c_str(); fprintf(out, "%s builder.writeAttributionChain(%s, %s);\n", indent.c_str(), uidName, tagName); fprintf(out, "%s builder.writeAttributionChain(\n", indent.c_str()); fprintf(out, "%s null == %s ? new int[0] : %s,\n", indent.c_str(), uidName, uidName); fprintf(out, "%s null == %s ? new String[0] : %s);\n", indent.c_str(), tagName, tagName); break; } case JAVA_TYPE_KEY_VALUE_PAIR: Loading Loading
core/java/android/util/StatsEvent.java +3 −3 Original line number Diff line number Diff line Loading @@ -175,7 +175,7 @@ public final class StatsEvent { * @hide **/ @VisibleForTesting public static final int ERROR_ATTRIBUTION_UIDS_TAGS_SIZES_NOT_EQUAL = 0x400; public static final int ERROR_ATTRIBUTION_UIDS_TAGS_SIZES_NOT_EQUAL = 0x1000; // Size limits. Loading Loading @@ -593,9 +593,9 @@ public final class StatsEvent { if (0 == mErrorMask) { mBuffer.putByte(POS_NUM_ELEMENTS, (byte) mNumElements); } else { mBuffer.putByte(0, TYPE_ERRORS); mBuffer.putByte(POS_NUM_ELEMENTS, (byte) 3); mPos += mBuffer.putByte(mPos, TYPE_ERRORS); mPos += mBuffer.putInt(mPos, mErrorMask); mBuffer.putByte(POS_NUM_ELEMENTS, (byte) 3); size = mPos; } Loading
core/tests/coretests/src/android/util/StatsEventTest.java +5 −2 Original line number Diff line number Diff line Loading @@ -53,8 +53,8 @@ public class StatsEventTest { final ByteBuffer buffer = ByteBuffer.wrap(statsEvent.getBytes()).order(ByteOrder.LITTLE_ENDIAN); assertWithMessage("Root element in buffer is not TYPE_ERRORS") .that(buffer.get()).isEqualTo(StatsEvent.TYPE_ERRORS); assertWithMessage("Root element in buffer is not TYPE_OBJECT") .that(buffer.get()).isEqualTo(StatsEvent.TYPE_OBJECT); assertWithMessage("Incorrect number of elements in root object") .that(buffer.get()).isEqualTo(3); Loading @@ -71,6 +71,9 @@ public class StatsEventTest { assertWithMessage("Incorrect atom id") .that(buffer.getInt()).isEqualTo(expectedAtomId); assertWithMessage("Third element is not errors type") .that(buffer.get()).isEqualTo(StatsEvent.TYPE_ERRORS); final int errorMask = buffer.getInt(); assertWithMessage("ERROR_NO_ATOM_ID should be the only error in the error mask") Loading
tools/stats_log_api_gen/java_writer.cpp +8 −5 Original line number Diff line number Diff line Loading @@ -83,7 +83,7 @@ static int write_java_methods( // Print method body. string indent(""); if (DEFAULT_MODULE_NAME != moduleName) { fprintf(out, " if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {\n"); fprintf(out, " if (Build.VERSION.SDK_INT > Build.VERSION_CODES.Q) {\n"); indent = " "; } Loading Loading @@ -116,16 +116,19 @@ static int write_java_methods( fprintf(out, "%s builder.writeString(arg%d);\n", indent.c_str(), argIndex); break; case JAVA_TYPE_BYTE_ARRAY: fprintf(out, "%s builder.writeByteArray(arg%d);\n", indent.c_str(), argIndex); fprintf(out, "%s builder.writeByteArray(null == arg%d ? new byte[0] : arg%d);\n", indent.c_str(), argIndex, argIndex); break; case JAVA_TYPE_ATTRIBUTION_CHAIN: { const char* uidName = attributionDecl.fields.front().name.c_str(); const char* tagName = attributionDecl.fields.back().name.c_str(); fprintf(out, "%s builder.writeAttributionChain(%s, %s);\n", indent.c_str(), uidName, tagName); fprintf(out, "%s builder.writeAttributionChain(\n", indent.c_str()); fprintf(out, "%s null == %s ? new int[0] : %s,\n", indent.c_str(), uidName, uidName); fprintf(out, "%s null == %s ? new String[0] : %s);\n", indent.c_str(), tagName, tagName); break; } case JAVA_TYPE_KEY_VALUE_PAIR: Loading