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

Commit a6d3667b authored by Jooyung Han's avatar Jooyung Han
Browse files

apex supports ".apex" tag

Tests can embed non-compressed .apex output with the tag.

Bug: 221024307
Test: soong test
Change-Id: Id4a239d1897237105a064cea8c97029f5b996a98
parent 315352e7
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -416,8 +416,12 @@ type apexBundle struct {
	mergedNotices android.NoticeOutputs

	// The built APEX file. This is the main product.
	// Could be .apex or .capex
	outputFile android.WritablePath

	// The built uncompressed .apex file.
	outputApexFile android.WritablePath

	// The built APEX file in app bundle format. This file is not directly installed to the
	// device. For an APEX, multiple app bundles are created each of which is for a specific ABI
	// like arm, arm64, x86, etc. Then they are processed again (outside of the Android build
@@ -1284,6 +1288,12 @@ func (a *apexBundle) OutputFiles(tag string) (android.Paths, error) {
	case "", android.DefaultDistTag:
		// This is the default dist path.
		return android.Paths{a.outputFile}, nil
	case imageApexSuffix:
		// uncompressed one
		if a.outputApexFile != nil {
			return android.Paths{a.outputApexFile}, nil
		}
		fallthrough
	default:
		return nil, fmt.Errorf("unsupported module reference tag %q", tag)
	}
+48 −0
Original line number Diff line number Diff line
@@ -8661,6 +8661,54 @@ func TestAndroidMk_RequiredModules(t *testing.T) {
	ensureContains(t, androidMk, "LOCAL_REQUIRED_MODULES += otherapex")
}

func TestApexOutputFileProducer(t *testing.T) {
	for _, tc := range []struct {
		name          string
		ref           string
		expected_data []string
	}{
		{
			name:          "test_using_output",
			ref:           ":myapex",
			expected_data: []string{"out/soong/.intermediates/myapex/android_common_myapex_image/myapex.capex:myapex.capex"},
		},
		{
			name:          "test_using_apex",
			ref:           ":myapex{.apex}",
			expected_data: []string{"out/soong/.intermediates/myapex/android_common_myapex_image/myapex.apex:myapex.apex"},
		},
	} {
		t.Run(tc.name, func(t *testing.T) {
			ctx := testApex(t, `
					apex {
						name: "myapex",
						key: "myapex.key",
						compressible: true,
						updatable: false,
					}

					apex_key {
						name: "myapex.key",
						public_key: "testkey.avbpubkey",
						private_key: "testkey.pem",
					}

					java_test {
						name: "`+tc.name+`",
						srcs: ["a.java"],
						data: ["`+tc.ref+`"],
					}
				`,
				android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
					variables.CompressedApex = proptools.BoolPtr(true)
				}))
			javaTest := ctx.ModuleForTests(tc.name, "android_common").Module().(*java.Test)
			data := android.AndroidMkEntriesForTest(t, ctx, javaTest)[0].EntryMap["LOCAL_COMPATIBILITY_SUPPORT_FILES"]
			android.AssertStringPathsRelativeToTopEquals(t, "data", ctx.Config(), tc.expected_data, data)
		})
	}
}

func TestSdkLibraryCanHaveHigherMinSdkVersion(t *testing.T) {
	preparer := android.GroupFixturePreparers(
		PrepareForTestWithApexBuildComponents,
+3 −0
Original line number Diff line number Diff line
@@ -810,6 +810,9 @@ func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext) {
		Implicits:   implicits,
		Args:        args,
	})
	if suffix == imageApexSuffix {
		a.outputApexFile = signedOutputFile
	}
	a.outputFile = signedOutputFile

	if ctx.ModuleDir() != "system/apex/apexd/apexd_testdata" && a.testOnlyShouldForceCompression() {