Use readonly version of 'report_postgc_memory_metrics'

Isolated Process will crash if it involves reading a flag value that
is READ_WRITE. Gantry doesn't allow updating an existing flag from
READ_WRITE to READ_ONLY, we will thus introduce a readonly version of
the flag and use that in the code.

Once the new aconfig storage API is landed, which is supposedly to
help Isolated Process with accessing of the flag values, we could
then switch back to the READ_WRITE version of this flag, which allows
us to enable/disable the feature at runtime.

Bug: 363965015
Flag: report_postgc_memory_metrics_readonly

Change-Id: Ia2fc232a2ca56cf40572b5edb5eac24e3fb8f227
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java
index b0a8b1b..5225174 100644
--- a/core/java/android/app/ActivityThread.java
+++ b/core/java/android/app/ActivityThread.java
@@ -7681,7 +7681,7 @@
         });
 
         // Register callback to report native memory metrics post GC cleanup
-        if (Flags.reportPostgcMemoryMetrics() &&
+        if (Flags.reportPostgcMemoryMetricsReadonly() &&
             com.android.libcore.readonly.Flags.postCleanupApis()) {
             VMRuntime.addPostCleanupCallback(new Runnable() {
                 @Override public void run() {
diff --git a/core/java/android/app/metrics.aconfig b/core/java/android/app/metrics.aconfig
index 488f1c7..55d9c2d 100644
--- a/core/java/android/app/metrics.aconfig
+++ b/core/java/android/app/metrics.aconfig
@@ -8,3 +8,12 @@
      description: "Controls whether to report memory metrics post GC cleanup"
      bug: "331243037"
 }
+
+flag {
+     namespace: "system_performance"
+     name: "report_postgc_memory_metrics_readonly"
+     is_exported: false
+     description: "Controls whether to report memory metrics post GC cleanup (readonly)"
+     bug: "331243037"
+     is_fixed_read_only: true
+}