Add SOONG_SDK_SNAPSHOT_PREFER support

By default the generated snapshot has prefer: false. Building it with
SOONG_SDK_SNAPSHOT_PREFER=true will force it to generate prefer: true.

Bug: 157884619
Test: m nothing
      m SOONG_SDK_SNAPSHOT_PREFER=true art-module-sdk
      - check the generated Android.bp file to make sure it contains
        prefer: true
Change-Id: Ied297b32d9bd4822a140fa99016f38e234c50f64
diff --git a/sdk/sdk_test.go b/sdk/sdk_test.go
index e9129e0..12545d6 100644
--- a/sdk/sdk_test.go
+++ b/sdk/sdk_test.go
@@ -525,4 +525,43 @@
 			`),
 		)
 	})
+
+	t.Run("SOONG_SDK_SNAPSHOT_PREFER=true", func(t *testing.T) {
+		result := android.GroupFixturePreparers(
+			preparer,
+			android.FixtureMergeEnv(map[string]string{
+				"SOONG_SDK_SNAPSHOT_PREFER": "true",
+			}),
+		).RunTest(t)
+
+		checkZipFile(t, result, "out/soong/.intermediates/mysdk/common_os/mysdk-current.zip")
+
+		CheckSnapshot(t, result, "mysdk", "",
+			checkAndroidBpContents(`
+// This is auto-generated. DO NOT EDIT.
+
+java_import {
+    name: "mysdk_myjavalib@current",
+    sdk_member_name: "myjavalib",
+    visibility: ["//visibility:public"],
+    apex_available: ["//apex_available:platform"],
+    jars: ["java/myjavalib.jar"],
+}
+
+java_import {
+    name: "myjavalib",
+    prefer: true,
+    visibility: ["//visibility:public"],
+    apex_available: ["//apex_available:platform"],
+    jars: ["java/myjavalib.jar"],
+}
+
+sdk_snapshot {
+    name: "mysdk@current",
+    visibility: ["//visibility:public"],
+    java_header_libs: ["mysdk_myjavalib@current"],
+}
+			`),
+		)
+	})
 }