Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d7004869 authored by Spandan Das's avatar Spandan Das Committed by Gerrit Code Review
Browse files

Merge "Disable monolithic hiddenapi flags generation for non java devices." into main

parents 99d9068b 81fe4d1d
Loading
Loading
Loading
Loading
+33 −5
Original line number Diff line number Diff line
@@ -5049,6 +5049,20 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) {
		// Make sure that the frameworks/base/Android.bp file exists as otherwise hidden API encoding
		// is disabled.
		android.FixtureAddTextFile("frameworks/base/Android.bp", ""),

		// Make sure that we have atleast one platform library so that we can check the monolithic hiddenapi
		// file creation.
		java.FixtureConfigureBootJars("platform:foo"),
		android.FixtureModifyMockFS(func(fs android.MockFS) {
			fs["platform/Android.bp"] = []byte(`
		java_library {
			name: "foo",
			srcs: ["Test.java"],
			compile_dex: true,
		}
		`)
			fs["platform/Test.java"] = nil
		}),
	)

	checkBootDexJarPath := func(t *testing.T, ctx *android.TestContext, stem string, bootDexJarPath string) {
@@ -5143,7 +5157,7 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) {
		checkBootDexJarPath(t, ctx, "libbar", "out/soong/.intermediates/prebuilt_myapex.deapexer/android_common/deapexer/javalib/libbar.jar")

		// Verify the correct module jars contribute to the hiddenapi index file.
		checkHiddenAPIIndexFromClassesInputs(t, ctx, ``)
		checkHiddenAPIIndexFromClassesInputs(t, ctx, `out/soong/.intermediates/platform/foo/android_common/javac/foo.jar`)
		checkHiddenAPIIndexFromFlagsInputs(t, ctx, `
			my-bootclasspath-fragment/index.csv
			out/soong/.intermediates/frameworks/base/boot/platform-bootclasspath/android_common/hiddenapi-monolithic/index-from-classes.csv
@@ -5221,7 +5235,7 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) {
		checkBootDexJarPath(t, ctx, "libbar", "out/soong/.intermediates/prebuilt_myapex.deapexer/android_common/deapexer/javalib/libbar.jar")

		// Verify the correct module jars contribute to the hiddenapi index file.
		checkHiddenAPIIndexFromClassesInputs(t, ctx, ``)
		checkHiddenAPIIndexFromClassesInputs(t, ctx, `out/soong/.intermediates/platform/foo/android_common/javac/foo.jar`)
		checkHiddenAPIIndexFromFlagsInputs(t, ctx, `
			my-bootclasspath-fragment/index.csv
			out/soong/.intermediates/frameworks/base/boot/platform-bootclasspath/android_common/hiddenapi-monolithic/index-from-classes.csv
@@ -5410,7 +5424,7 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) {
		checkBootDexJarPath(t, ctx, "libbar", "out/soong/.intermediates/prebuilt_myapex.deapexer/android_common/deapexer/javalib/libbar.jar")

		// Verify the correct module jars contribute to the hiddenapi index file.
		checkHiddenAPIIndexFromClassesInputs(t, ctx, ``)
		checkHiddenAPIIndexFromClassesInputs(t, ctx, `out/soong/.intermediates/platform/foo/android_common/javac/foo.jar`)
		checkHiddenAPIIndexFromFlagsInputs(t, ctx, `
			my-bootclasspath-fragment/index.csv
			out/soong/.intermediates/frameworks/base/boot/platform-bootclasspath/android_common/hiddenapi-monolithic/index-from-classes.csv
@@ -5507,7 +5521,7 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) {
		checkBootDexJarPath(t, ctx, "libbar", "out/soong/.intermediates/my-bootclasspath-fragment/android_common_myapex/hiddenapi-modular/encoded/libbar.jar")

		// Verify the correct module jars contribute to the hiddenapi index file.
		checkHiddenAPIIndexFromClassesInputs(t, ctx, ``)
		checkHiddenAPIIndexFromClassesInputs(t, ctx, `out/soong/.intermediates/platform/foo/android_common/javac/foo.jar`)
		checkHiddenAPIIndexFromFlagsInputs(t, ctx, `
			out/soong/.intermediates/frameworks/base/boot/platform-bootclasspath/android_common/hiddenapi-monolithic/index-from-classes.csv
			out/soong/.intermediates/my-bootclasspath-fragment/android_common_myapex/modular-hiddenapi/index.csv
@@ -5620,7 +5634,7 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) {
		checkBootDexJarPath(t, ctx, "libbar", "out/soong/.intermediates/prebuilt_myapex.deapexer/android_common/deapexer/javalib/libbar.jar")

		// Verify the correct module jars contribute to the hiddenapi index file.
		checkHiddenAPIIndexFromClassesInputs(t, ctx, ``)
		checkHiddenAPIIndexFromClassesInputs(t, ctx, `out/soong/.intermediates/platform/foo/android_common/javac/foo.jar`)
		checkHiddenAPIIndexFromFlagsInputs(t, ctx, `
			my-bootclasspath-fragment/index.csv
			out/soong/.intermediates/frameworks/base/boot/platform-bootclasspath/android_common/hiddenapi-monolithic/index-from-classes.csv
@@ -11239,6 +11253,20 @@ func TestBootDexJarsMultipleApexPrebuilts(t *testing.T) {
			android.FixtureMergeMockFs(map[string][]byte{
				"system/sepolicy/apex/com.android.foo-file_contexts": nil,
			}),
			// Make sure that we have atleast one platform library so that we can check the monolithic hiddenapi
			// file creation.
			java.FixtureConfigureBootJars("platform:foo"),
			android.FixtureModifyMockFS(func(fs android.MockFS) {
				fs["platform/Android.bp"] = []byte(`
		java_library {
			name: "foo",
			srcs: ["Test.java"],
			compile_dex: true,
		}
		`)
				fs["platform/Test.java"] = nil
			}),

			android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
				variables.BuildFlags = map[string]string{
					"RELEASE_APEX_CONTRIBUTIONS_ADSERVICES": tc.selectedApexContributions,
+10 −1
Original line number Diff line number Diff line
@@ -198,13 +198,22 @@ func TestHiddenAPISingletonSdks(t *testing.T) {
				hiddenApiFixtureFactory,
				tc.preparer,
				prepareForTestWithDefaultPlatformBootclasspath,
				// Make sure that we have atleast one platform library so that we can check the monolithic hiddenapi
				// file creation.
				FixtureConfigureBootJars("platform:foo"),
				android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
					variables.Always_use_prebuilt_sdks = proptools.BoolPtr(tc.unbundledBuild)
					variables.BuildFlags = map[string]string{
						"RELEASE_HIDDEN_API_EXPORTABLE_STUBS": "true",
					}
				}),
			).RunTest(t)
			).RunTestWithBp(t, `
		java_library {
			name: "foo",
			srcs: ["a.java"],
			compile_dex: true,
		}
		`)

			hiddenAPI := result.ModuleForTests("platform-bootclasspath", "android_common")
			hiddenapiRule := hiddenAPI.Rule("platform-bootclasspath-monolithic-hiddenapi-stub-flags")
+5 −0
Original line number Diff line number Diff line
@@ -325,6 +325,11 @@ func (b *platformBootclasspathModule) generateHiddenAPIBuildActions(ctx android.
	// the fragments will have already provided the flags that are needed.
	classesJars := monolithicInfo.ClassesJars

	if len(classesJars) == 0 {
		// This product does not include any monolithic jars. Monolithic hiddenapi flag generation is not required.
		return bootDexJarByModule
	}

	// Create the input to pass to buildRuleToGenerateHiddenAPIStubFlagsFile
	input := newHiddenAPIFlagInput()

+13 −0
Original line number Diff line number Diff line
@@ -281,6 +281,19 @@ func testSnapshotWithBootClasspathFragment_Contents(t *testing.T, sdk string, co
				"RELEASE_HIDDEN_API_EXPORTABLE_STUBS": "true",
			}
		}),
		// Make sure that we have atleast one platform library so that we can check the monolithic hiddenapi
		// file creation.
		java.FixtureConfigureBootJars("platform:foo"),
		android.FixtureModifyMockFS(func(fs android.MockFS) {
			fs["platform/Android.bp"] = []byte(`
		java_library {
			name: "foo",
			srcs: ["Test.java"],
			compile_dex: true,
		}
		`)
			fs["platform/Test.java"] = nil
		}),

		android.FixtureWithRootAndroidBp(sdk+`
			apex {