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

Commit 35dcf77f authored by Cole Faust's avatar Cole Faust Committed by Gerrit Code Review
Browse files

Merge "Remove special handling of prebuilt_framework-res"

parents 141dcbb6 d580613a
Loading
Loading
Loading
Loading
+9 −21
Original line number Diff line number Diff line
@@ -17,9 +17,10 @@ package java
// This file contains the module implementations for android_app_import and android_test_import.

import (
	"github.com/google/blueprint"
	"reflect"

	"github.com/google/blueprint"

	"github.com/google/blueprint/proptools"

	"android/soong/android"
@@ -177,10 +178,6 @@ func MergePropertiesFromVariant(ctx android.EarlyModuleContext,
	}
}

func (a *AndroidAppImport) isPrebuiltFrameworkRes() bool {
	return a.Name() == "prebuilt_framework-res"
}

func (a *AndroidAppImport) DepsMutator(ctx android.BottomUpMutatorContext) {
	cert := android.SrcIsModule(String(a.properties.Certificate))
	if cert != "" {
@@ -197,7 +194,7 @@ func (a *AndroidAppImport) DepsMutator(ctx android.BottomUpMutatorContext) {
		}
	}

	a.usesLibrary.deps(ctx, !a.isPrebuiltFrameworkRes())
	a.usesLibrary.deps(ctx, true)
}

func (a *AndroidAppImport) uncompressEmbeddedJniLibs(
@@ -243,6 +240,10 @@ func (a *AndroidAppImport) InstallApkName() string {
}

func (a *AndroidAppImport) generateAndroidBuildActions(ctx android.ModuleContext) {
	if a.Name() == "prebuilt_framework-res" {
		ctx.ModuleErrorf("prebuilt_framework-res found. This used to have special handling in soong, but was removed due to prebuilt_framework-res no longer existing. This check is to ensure it doesn't come back without readding the special handling.")
	}

	apexInfo := ctx.Provider(android.ApexInfoProvider).(android.ApexInfo)
	if !apexInfo.IsForPlatform() {
		a.hideApexVariantFromMake = true
@@ -278,14 +279,7 @@ func (a *AndroidAppImport) generateAndroidBuildActions(ctx android.ModuleContext
	var pathFragments []string
	relInstallPath := String(a.properties.Relative_install_path)

	if a.isPrebuiltFrameworkRes() {
		// framework-res.apk is installed as system/framework/framework-res.apk
		if relInstallPath != "" {
			ctx.PropertyErrorf("relative_install_path", "Relative_install_path cannot be set for framework-res")
		}
		pathFragments = []string{"framework"}
		a.preprocessed = true
	} else if Bool(a.properties.Privileged) {
	if Bool(a.properties.Privileged) {
		pathFragments = []string{"priv-app", relInstallPath, a.BaseModuleName()}
	} else if ctx.InstallInTestcases() {
		pathFragments = []string{relInstallPath, a.BaseModuleName(), ctx.DeviceConfig().DeviceArch()}
@@ -323,13 +317,7 @@ func (a *AndroidAppImport) generateAndroidBuildActions(ctx android.ModuleContext

	// Sign or align the package if package has not been preprocessed

	if a.isPrebuiltFrameworkRes() {
		a.outputFile = srcApk
		a.certificate, certificates = processMainCert(a.ModuleBase, String(a.properties.Certificate), certificates, ctx)
		if len(certificates) != 1 {
			ctx.ModuleErrorf("Unexpected number of certificates were extracted: %q", certificates)
		}
	} else if a.preprocessed {
	if a.preprocessed {
		a.outputFile = srcApk
		a.certificate = PresignedCertificate
	} else if !Bool(a.properties.Presigned) {
+0 −73
Original line number Diff line number Diff line
@@ -505,67 +505,6 @@ func TestAndroidAppImport_overridesDisabledAndroidApp(t *testing.T) {
	}
}

func TestAndroidAppImport_frameworkRes(t *testing.T) {
	ctx, _ := testJava(t, `
		android_app_import {
			name: "framework-res",
			certificate: "platform",
			apk: "package-res.apk",
			prefer: true,
			export_package_resources: true,
			// Disable dexpreopt and verify_uses_libraries check as the app
			// contains no Java code to be dexpreopted.
			enforce_uses_libs: false,
			dex_preopt: {
				enabled: false,
			},
		}
		`)

	mod := ctx.ModuleForTests("prebuilt_framework-res", "android_common").Module()
	a := mod.(*AndroidAppImport)

	if !a.preprocessed {
		t.Errorf("prebuilt framework-res is not preprocessed")
	}

	expectedInstallPath := "out/soong/target/product/test_device/system/framework/framework-res.apk"

	android.AssertPathRelativeToTopEquals(t, "prebuilt framework-res install location", expectedInstallPath, a.dexpreopter.installPath)

	entries := android.AndroidMkEntriesForTest(t, ctx, mod)[0]

	expectedPath := "."
	// From apk property above, in the root of the source tree.
	expectedPrebuiltModuleFile := "package-res.apk"
	// Verify that the apk is preprocessed: The export package is the same
	// as the prebuilt.
	expectedSoongResourceExportPackage := expectedPrebuiltModuleFile

	actualPath := entries.EntryMap["LOCAL_PATH"]
	actualPrebuiltModuleFile := entries.EntryMap["LOCAL_PREBUILT_MODULE_FILE"]
	actualSoongResourceExportPackage := entries.EntryMap["LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE"]

	if len(actualPath) != 1 {
		t.Errorf("LOCAL_PATH incorrect len %d", len(actualPath))
	} else if actualPath[0] != expectedPath {
		t.Errorf("LOCAL_PATH mismatch, actual: %s, expected: %s", actualPath[0], expectedPath)
	}

	if len(actualPrebuiltModuleFile) != 1 {
		t.Errorf("LOCAL_PREBUILT_MODULE_FILE incorrect len %d", len(actualPrebuiltModuleFile))
	} else if actualPrebuiltModuleFile[0] != expectedPrebuiltModuleFile {
		t.Errorf("LOCAL_PREBUILT_MODULE_FILE mismatch, actual: %s, expected: %s", actualPrebuiltModuleFile[0], expectedPrebuiltModuleFile)
	}

	if len(actualSoongResourceExportPackage) != 1 {
		t.Errorf("LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE incorrect len %d", len(actualSoongResourceExportPackage))
	} else if actualSoongResourceExportPackage[0] != expectedSoongResourceExportPackage {
		t.Errorf("LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE mismatch, actual: %s, expected: %s", actualSoongResourceExportPackage[0], expectedSoongResourceExportPackage)
	}
	android.AssertStringEquals(t, "unexpected LOCAL_SOONG_MODULE_TYPE", "android_app_import", entries.EntryMap["LOCAL_SOONG_MODULE_TYPE"][0])
}

func TestAndroidAppImport_relativeInstallPath(t *testing.T) {
	bp := `
		android_app_import {
@@ -581,13 +520,6 @@ func TestAndroidAppImport_relativeInstallPath(t *testing.T) {
			relative_install_path: "my/path",
		}

		android_app_import {
			name: "framework-res",
			apk: "prebuilts/apk/app.apk",
			presigned: true,
			prefer: true,
		}

		android_app_import {
			name: "privileged_relative_install_path",
			apk: "prebuilts/apk/app.apk",
@@ -611,11 +543,6 @@ func TestAndroidAppImport_relativeInstallPath(t *testing.T) {
			expectedInstallPath: "out/soong/target/product/test_device/system/app/my/path/relative_install_path/relative_install_path.apk",
			errorMessage:        "Install path is not correct for app when relative_install_path is present",
		},
		{
			name:                "prebuilt_framework-res",
			expectedInstallPath: "out/soong/target/product/test_device/system/framework/framework-res.apk",
			errorMessage:        "Install path is not correct for framework-res",
		},
		{
			name:                "privileged_relative_install_path",
			expectedInstallPath: "out/soong/target/product/test_device/system/priv-app/my/path/privileged_relative_install_path/privileged_relative_install_path.apk",