codegen: add primitive arrays type

Primitive Arrays Parcel can handle null objects directly.
There is no need to use a flag in parcel for special handling
This can generate more efficient code for variables declared as
nullable.

Bug: 233795798
Test: codegen
$ANDROID_BUILD_TOP/packages/services/Car/car-lib/src/android/car/vms/VmsProviderInfo.java

Change-Id: I09a1fcd70d6692b51c5796073001b2c67ad04979
diff --git a/tools/codegen/src/com/android/codegen/Generators.kt b/tools/codegen/src/com/android/codegen/Generators.kt
index 5fc800b..6857333 100644
--- a/tools/codegen/src/com/android/codegen/Generators.kt
+++ b/tools/codegen/src/com/android/codegen/Generators.kt
@@ -393,7 +393,7 @@
 fun ClassPrinter.generateParcelable() {
     val booleanFields = fields.filter { it.Type == "boolean" }
     val objectFields = fields.filter { it.Type !in PRIMITIVE_TYPES }
-    val nullableFields = objectFields.filter { it.mayBeNull }
+    val nullableFields = objectFields.filter { it.mayBeNull && it.Type !in PRIMITIVE_ARRAY_TYPES }
     val nonBooleanFields = fields - booleanFields
 
 
@@ -457,7 +457,7 @@
                     hasAnnotation("@$DataClassEnum") ->
                         +"dest.writeInt($internalGetter == null ? -1 : $internalGetter.ordinal());"
                     else -> {
-                        if (mayBeNull) !"if ($internalGetter != null) "
+                        if (mayBeNull && Type !in PRIMITIVE_ARRAY_TYPES) !"if ($internalGetter != null) "
                         var args = internalGetter
                         if (ParcelMethodsSuffix.startsWith("Parcelable")
                                 || ParcelMethodsSuffix.startsWith("TypedObject")
@@ -529,7 +529,7 @@
                     if (passContainer) {
                         methodArgs.add(_name)
                         !"$Type $_name = "
-                        if (mayBeNull) {
+                        if (mayBeNull && Type !in PRIMITIVE_ARRAY_TYPES) {
                             +"null;"
                             !"if ((flg & $fieldBit) != 0) {"
                             pushIndent()
@@ -539,7 +539,9 @@
                         +"$containerInitExpr;"
                     } else {
                         !"$Type $_name = "
-                        if (mayBeNull) !"(flg & $fieldBit) == 0 ? null : "
+                        if (mayBeNull && Type !in PRIMITIVE_ARRAY_TYPES) {
+                            !"(flg & $fieldBit) == 0 ? null : "
+                        }
                         if (ParcelMethodsSuffix == "StrongInterface") {
                             !"$FieldClass.Stub.asInterface("
                         } else if (Type !in PRIMITIVE_TYPES + "String" + "Bundle" &&
@@ -578,7 +580,7 @@
                     +";"
 
                     // Cleanup if passContainer
-                    if (passContainer && mayBeNull) {
+                    if (passContainer && mayBeNull && Type !in PRIMITIVE_ARRAY_TYPES) {
                         popIndent()
                         rmEmptyLine()
                         +"\n}"
@@ -949,4 +951,4 @@
     +""
     +"@Deprecated"
     +"private void __metadata() {}\n"
-}
\ No newline at end of file
+}
diff --git a/tools/codegen/src/com/android/codegen/Main.kt b/tools/codegen/src/com/android/codegen/Main.kt
index 4b508d0..bcc6230 100755
--- a/tools/codegen/src/com/android/codegen/Main.kt
+++ b/tools/codegen/src/com/android/codegen/Main.kt
@@ -10,6 +10,7 @@
 const val INDENT_SINGLE = "    "
 
 val PRIMITIVE_TYPES = listOf("byte", "short", "int", "long", "char", "float", "double", "boolean")
+val PRIMITIVE_ARRAY_TYPES = listOf("byte[]", "short[]", "int[]", "long[]", "char[]", "float[]", "double[]", "boolean[]")
 val BOXED_PRIMITIVE_TYPES = PRIMITIVE_TYPES.map { it.capitalize() } - "Int" + "Integer" - "Char" + "Character"
 
 val BUILTIN_SPECIAL_PARCELLINGS = listOf("Pattern")
@@ -133,4 +134,4 @@
         System.exit(0)
     }
     return cliArgs - "--update-only"
-}
\ No newline at end of file
+}