Integrate RELEASE_R8_GLOBAL_CHECK_NOT_NULL_FLAGS into soong

Include the new set of `checknotnull.flags` based on the build flag,
allowing `-convertchecknotnull` R8 optimizations for a class of common
null checks.

Bug: 280633711
Test: build-flag set RELEASE_R8_GLOBAL_CHECK_NOT_NULL_FLAGS && m
Flag: RELEASE_R8_GLOBAL_CHECK_NOT_NULL_FLAGS
Change-Id: Idf015a3ea5bd9f6e11213f683da008b5706668e0
diff --git a/android/config.go b/android/config.go
index acaad60..82acfc3 100644
--- a/android/config.go
+++ b/android/config.go
@@ -2191,6 +2191,10 @@
 	return c.productVariables.GetBuildFlagBool("RELEASE_R8_STORE_STORE_FENCE_CONSTRUCTOR_INLINING")
 }
 
+func (c *config) UseR8GlobalCheckNotNullFlags() bool {
+	return c.productVariables.GetBuildFlagBool("RELEASE_R8_GLOBAL_CHECK_NOT_NULL_FLAGS")
+}
+
 func (c *config) UseDexV41() bool {
 	return c.productVariables.GetBuildFlagBool("RELEASE_USE_DEX_V41")
 }
diff --git a/java/dex.go b/java/dex.go
index 64465a2..1a61000 100644
--- a/java/dex.go
+++ b/java/dex.go
@@ -362,6 +362,11 @@
 		android.PathForSource(ctx, "build/make/core/proguard.flags"),
 	}
 
+	if ctx.Config().UseR8GlobalCheckNotNullFlags() {
+		flagFiles = append(flagFiles, android.PathForSource(ctx,
+			"build/make/core/proguard/checknotnull.flags"))
+	}
+
 	flagFiles = append(flagFiles, d.extraProguardFlagsFiles...)
 	// TODO(ccross): static android library proguard files