Revert "Update golden_test.sh to be aware of RELEASE_AIDL_USE_UNFROZEN"

This reverts commit aa017d93b28b82fba3556b35ecab35ff1e8f9691.

Reason for revert: b/302231424 broke the 'next' checkbuild in git_main

Change-Id: I746b2d667c171e8a0f24bf0bd24ce30aa01c56c4
diff --git a/Android.bp b/Android.bp
index 142a659..743c955 100644
--- a/Android.bp
+++ b/Android.bp
@@ -785,7 +785,14 @@
     name: "aidl-golden-test-build-hook-gen",
     tools: ["aidl-golden-test"],
 
-    cmd: "$(location aidl-golden-test) check && " +
+    product_variables: {
+        release_aidl_use_unfrozen: {
+            cmd: "AIDL_USE_UNFROZEN=true $(location aidl-golden-test) check && " +
+                "echo 'int main(){return 0;}' > $(genDir)/TODO_b_37575883.cpp",
+        },
+    },
+
+    cmd: "AIDL_USE_UNFROZEN=false $(location aidl-golden-test) check && " +
         "echo 'int main(){return 0;}' > $(genDir)/TODO_b_37575883.cpp",
     srcs: [
         // warning: keep this list up to date with tests/golden_test.sh
diff --git a/build/aidl_gen_rule.go b/build/aidl_gen_rule.go
index 6a63547..119aeed 100644
--- a/build/aidl_gen_rule.go
+++ b/build/aidl_gen_rule.go
@@ -235,23 +235,10 @@
 	}
 	optionalFlags = append(optionalFlags, wrap("-p", g.deps.preprocessed.Strings(), "")...)
 
-	unfrozen_override := ctx.Config().Getenv("AIDL_USE_UNFROZEN_OVERRIDE")
-	var use_unfrozen bool
-	if unfrozen_override != "" {
-		if unfrozen_override == "True" {
-			use_unfrozen = true
-		} else if unfrozen_override == "False" {
-			use_unfrozen = false
-		} else {
-			ctx.PropertyErrorf("AIDL_USE_UNFROZEN_OVERRIDE has unexpected value of \"%s\". Should be \"True\" or \"False\".", unfrozen_override)
-		}
-	} else {
-		use_unfrozen = ctx.DeviceConfig().Release_aidl_use_unfrozen()
-	}
 	// If this is an unfrozen version of a previously frozen interface, we want (1) the location
 	// of the previously frozen source and (2) the previously frozen hash so the generated
 	// library can behave like both versions at run time.
-	if !use_unfrozen && previousVersion != "" &&
+	if !ctx.DeviceConfig().Release_aidl_use_unfrozen() && previousVersion != "" &&
 		!proptools.Bool(g.properties.Unstable) && g.hashFile == nil {
 		apiDirPath := android.ExistentPathForSource(ctx, previousApiDir)
 		if apiDirPath.Valid() {
diff --git a/build/aidl_test.go b/build/aidl_test.go
index 73a3dcd..42d2489 100644
--- a/build/aidl_test.go
+++ b/build/aidl_test.go
@@ -57,18 +57,6 @@
 	})
 }
 
-func setUseUnfrozenOverrideEnvTrue() android.FixturePreparer {
-	return android.FixtureMergeEnv(map[string]string{
-		"AIDL_USE_UNFROZEN_OVERRIDE": "True",
-	})
-}
-
-func setUseUnfrozenOverrideEnvFalse() android.FixturePreparer {
-	return android.FixtureMergeEnv(map[string]string{
-		"AIDL_USE_UNFROZEN_OVERRIDE": "False",
-	})
-}
-
 func setTransitiveFreezeEnv() android.FixturePreparer {
 	return android.FixtureMergeEnv(map[string]string{
 		"AIDL_TRANSITIVE_FREEZE": "true",
@@ -2356,43 +2344,3 @@
 			"-previous")
 	}
 }
-
-func TestAidlUseUnfrozenOverrideFalse(t *testing.T) {
-	customizer := withFiles(map[string][]byte{
-		"foo/Android.bp": []byte(`
-                        aidl_interface {
-                                name: "foo-iface",
-                                srcs: ["a/Foo.aidl"],
-                                versions: ["1"],
-                        }
-                `),
-		"foo/a/Foo.aidl": nil, "foo/aidl_api/foo-iface/current/a/Foo.aidl": nil,
-		"foo/aidl_api/foo-iface/1/a/Foo.aidl": nil, "foo/aidl_api/foo-iface/1/.hash": nil,
-	})
-	ctx, _ := testAidl(t, ``, setUseUnfrozenOverrideEnvFalse(), customizer)
-
-	rule := ctx.ModuleForTests("foo-iface-V2-cpp-source", "").Output("a/Foo.cpp")
-	android.AssertStringDoesContain(t, "Unfrozen interfaces should have -previous_api_dir set when overriding the RELEASE_AIDL_USE_UNFROZEN flag",
-		rule.Args["optionalFlags"],
-		"-previous")
-}
-
-func TestAidlUseUnfrozenOverrideTrue(t *testing.T) {
-	customizer := withFiles(map[string][]byte{
-		"foo/Android.bp": []byte(`
-                        aidl_interface {
-                                name: "foo-iface",
-                                srcs: ["a/Foo.aidl"],
-                                versions: ["1"],
-                        }
-                `),
-		"foo/a/Foo.aidl": nil, "foo/aidl_api/foo-iface/current/a/Foo.aidl": nil,
-		"foo/aidl_api/foo-iface/1/a/Foo.aidl": nil, "foo/aidl_api/foo-iface/1/.hash": nil,
-	})
-	ctx, _ := testAidl(t, ``, setUseUnfrozenOverrideEnvTrue(), customizer)
-
-	rule := ctx.ModuleForTests("foo-iface-V2-cpp-source", "").Output("a/Foo.cpp")
-	android.AssertStringDoesNotContain(t, "Unfrozen interfaces should not have -previous_api_dir set when overriding the RELEASE_AIDL_USE_UNFROZEN flag",
-		rule.Args["optionalFlags"],
-		"-previous")
-}
diff --git a/tests/golden_test.sh b/tests/golden_test.sh
index 336cf2e..fbd3088 100755
--- a/tests/golden_test.sh
+++ b/tests/golden_test.sh
@@ -30,7 +30,7 @@
       update=1
       ;;
     *)
-      echo "Argument must be 'check' or 'update' but is $1"
+      echo "Argument must be 'check' or 'update'"
       exit 1
       ;;
   esac
@@ -72,28 +72,32 @@
     "tests/trunk_stable_test/android.aidl.test.trunk-V2-rust-source"
   )
 
-  local use_unfrozen="$3"
-  # If override_unfrozen is true, we override the RELEASE_AIDL_USE_UNFROZEN build flag with an
-  # environment variable.
-  local override_unfrozen="$4"
-  local root="$2"
+  local root="."
+  if [ "$ANDROID_BUILD_TOP" != "" ]; then
+    root="$ANDROID_BUILD_TOP"
+  fi
+
   if [ "$update" = 1 ]; then
-    if [ "$override_unfrozen" == true ]; then
-      export AIDL_USE_UNFROZEN_OVERRIDE="$use_unfrozen"
-    fi
     "$root"/build/soong/soong_ui.bash --make-mode \
       $(for i in "${modules[@]}"; do
           echo "out/soong/.intermediates/system/tools/aidl/$i/timestamp"
-        done) ; export AIDL_USE_UNFROZEN_OVERRIDE=
+        done)
   fi
+
   local e=0
   for module in "${modules[@]}"; do
     local built="$root/out/soong/.intermediates/system/tools/aidl/$module/"
     local module_path
-    if [ "$use_unfrozen" == "True" ]; then
+    if [ "$AIDL_USE_UNFROZEN" == "true" ]; then
       module_path=$module
-    else
+    elif [ "$AIDL_USE_UNFROZEN" == "false" ]; then
       module_path="frozen/$module"
+    else
+      echo "ERROR: AIDL_USE_UNFROZEN must be set to true or false."
+      echo "ERROR: This should be the same value of the flag RELEASE_AIDL_USE_UNFROZEN"
+      echo "ERROR: when the interfaces were last built."
+      echo "ERROR:     AIDL_USE_UNFROZEN=true golden_test.sh update."
+      exit 1
     fi
 
     local golden="$root/system/tools/aidl/tests/golden_output/$module_path/"
@@ -110,7 +114,9 @@
   if [ "$e" = 1 ]; then
     echo "ERROR: The AIDL compiler is outputting files in an unknown way."
     echo "ERROR: to accept these changes, please run:"
-    echo "ERROR:     \$ANDROID_BUILD_TOP/system/tools/aidl/tests/golden_test.sh update"
+    echo "ERROR:     AIDL_USE_UNFROZEN=$AIDL_USE_UNFROZEN \$ANDROID_BUILD_TOP/system/tools/aidl/tests/golden_test.sh update"
+    echo "ERROR: Then, flip the RELEASE_AIDL_USE_UNFROZEN build flag and rebuild/regenerate the"
+    echo "ERROR: other set of golden output files."
     exit 1
   else
     if [ "$update" = 1 ]; then
@@ -119,26 +125,4 @@
   fi
 }
 
-root="."
-if [ "$ANDROID_BUILD_TOP" != "" ]; then
-  root="$ANDROID_BUILD_TOP"
-fi
-use_unfrozen=$(sed -rn 's/ *flag\(\"RELEASE_AIDL_USE_UNFROZEN\", ALL, (.*)\),/\1/p' "$root/build/release/build_flags.bzl")
-if [[ "$use_unfrozen" != "True" && "$use_unfrozen" != "False" ]]; then
-  echo "ERROR: Unexpected value of RELEASE_AIDL_USE_UNFROZEN in $root/build/release/build_flags.bzl of $use_unfrozen."
-  exit 1
-fi
-
-if [ "$1" == "update" ]; then
-  if [ "$use_unfrozen" == "True" ]; then
-    # build update the opposite value first, so we leave the intermediates
-    # in the state of the tree
-    _golden_test "$@" "$root" "False" true
-    _golden_test "$@" "$root" "True" false
-  else
-    _golden_test "$@" "$root" "True" true
-    _golden_test "$@" "$root" "False" false
-  fi
-else
-_golden_test "$@" "$root" "$use_unfrozen"
-fi
+_golden_test "$@"