Handle nullable sysprop for tryParseBoolean am: c573b71d2a am: 89d47269e3 am: 5ca629b479

Original change: https://android-review.googlesource.com/c/platform/system/tools/sysprop/+/2261078

Change-Id: I407772af0d995351f10337b08a45f749e25bf44e
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/JavaGen.cpp b/JavaGen.cpp
index fa4c106..55d5ae4 100644
--- a/JavaGen.cpp
+++ b/JavaGen.cpp
@@ -54,6 +54,7 @@
 
 constexpr const char* kJavaParsersAndFormatters =
     R"s(private static Boolean tryParseBoolean(String str) {
+    if (str == null) return null;
     switch (str.toLowerCase(Locale.US)) {
         case "1":
         case "true":
diff --git a/tests/JavaGenTest.cpp b/tests/JavaGenTest.cpp
index 6ae0474..be04a4f 100644
--- a/tests/JavaGenTest.cpp
+++ b/tests/JavaGenTest.cpp
@@ -122,6 +122,7 @@
     private TestProperties () {}
 
     private static Boolean tryParseBoolean(String str) {
+        if (str == null) return null;
         switch (str.toLowerCase(Locale.US)) {
             case "1":
             case "true":
@@ -342,6 +343,7 @@
     private TestProperties () {}
 
     private static Boolean tryParseBoolean(String str) {
+        if (str == null) return null;
         switch (str.toLowerCase(Locale.US)) {
             case "1":
             case "true":