Merge "Merge Android R"
This commit is contained in:
52
java/app.go
52
java/app.go
@@ -118,17 +118,17 @@ var TargetCpuAbi = map[string]string{
|
||||
}
|
||||
|
||||
func SupportedAbis(ctx android.ModuleContext) []string {
|
||||
abiName := func(archVar string, deviceArch string) string {
|
||||
abiName := func(targetIdx int, deviceArch string) string {
|
||||
if abi, found := TargetCpuAbi[deviceArch]; found {
|
||||
return abi
|
||||
}
|
||||
ctx.ModuleErrorf("Invalid %s: %s", archVar, deviceArch)
|
||||
ctx.ModuleErrorf("Target %d has invalid Arch: %s", targetIdx, deviceArch)
|
||||
return "BAD_ABI"
|
||||
}
|
||||
|
||||
result := []string{abiName("TARGET_ARCH", ctx.DeviceConfig().DeviceArch())}
|
||||
if s := ctx.DeviceConfig().DeviceSecondaryArch(); s != "" {
|
||||
result = append(result, abiName("TARGET_2ND_ARCH", s))
|
||||
var result []string
|
||||
for i, target := range ctx.Config().Targets[android.Android] {
|
||||
result = append(result, abiName(i, target.Arch.ArchType.String()))
|
||||
}
|
||||
return result
|
||||
}
|
||||
@@ -268,6 +268,9 @@ type overridableAppProperties struct {
|
||||
|
||||
// the logging parent of this app.
|
||||
Logging_parent *string
|
||||
|
||||
// Whether to rename the package in resources to the override name rather than the base name. Defaults to true.
|
||||
Rename_resources_package *bool
|
||||
}
|
||||
|
||||
// runtime_resource_overlay properties that can be overridden by override_runtime_resource_overlay
|
||||
@@ -505,10 +508,23 @@ func (a *AndroidApp) shouldEmbedJnis(ctx android.BaseModuleContext) bool {
|
||||
!a.IsForPlatform() || a.appProperties.AlwaysPackageNativeLibs
|
||||
}
|
||||
|
||||
func generateAaptRenamePackageFlags(packageName string, renameResourcesPackage bool) []string {
|
||||
aaptFlags := []string{"--rename-manifest-package " + packageName}
|
||||
if renameResourcesPackage {
|
||||
// Required to rename the package name in the resources table.
|
||||
aaptFlags = append(aaptFlags, "--rename-resources-package "+packageName)
|
||||
}
|
||||
return aaptFlags
|
||||
}
|
||||
|
||||
func (a *AndroidApp) OverriddenManifestPackageName() string {
|
||||
return a.overriddenManifestPackageName
|
||||
}
|
||||
|
||||
func (a *AndroidApp) renameResourcesPackage() bool {
|
||||
return proptools.BoolDefault(a.overridableAppProperties.Rename_resources_package, true)
|
||||
}
|
||||
|
||||
func (a *AndroidApp) aaptBuildActions(ctx android.ModuleContext) {
|
||||
a.aapt.usesNonSdkApis = Bool(a.Module.deviceProperties.Platform_apis)
|
||||
|
||||
@@ -541,7 +557,7 @@ func (a *AndroidApp) aaptBuildActions(ctx android.ModuleContext) {
|
||||
if !overridden {
|
||||
manifestPackageName = *a.overridableAppProperties.Package_name
|
||||
}
|
||||
aaptLinkFlags = append(aaptLinkFlags, "--rename-manifest-package "+manifestPackageName)
|
||||
aaptLinkFlags = append(aaptLinkFlags, generateAaptRenamePackageFlags(manifestPackageName, a.renameResourcesPackage())...)
|
||||
a.overriddenManifestPackageName = manifestPackageName
|
||||
}
|
||||
|
||||
@@ -801,18 +817,32 @@ func (a *AndroidApp) generateAndroidBuildActions(ctx android.ModuleContext) {
|
||||
|
||||
// Build a final signed app package.
|
||||
packageFile := android.PathForModuleOut(ctx, a.installApkName+".apk")
|
||||
v4SigningRequested := Bool(a.Module.deviceProperties.V4_signature)
|
||||
var v4SignatureFile android.WritablePath = nil
|
||||
if v4SigningRequested {
|
||||
v4SignatureFile = android.PathForModuleOut(ctx, a.installApkName+".apk.idsig")
|
||||
}
|
||||
var lineageFile android.Path
|
||||
if lineage := String(a.overridableAppProperties.Lineage); lineage != "" {
|
||||
lineageFile = android.PathForModuleSrc(ctx, lineage)
|
||||
}
|
||||
CreateAndSignAppPackage(ctx, packageFile, a.exportPackage, jniJarFile, dexJarFile, certificates, apkDeps, lineageFile)
|
||||
CreateAndSignAppPackage(ctx, packageFile, a.exportPackage, jniJarFile, dexJarFile, certificates, apkDeps, v4SignatureFile, lineageFile)
|
||||
a.outputFile = packageFile
|
||||
if v4SigningRequested {
|
||||
a.extraOutputFiles = append(a.extraOutputFiles, v4SignatureFile)
|
||||
}
|
||||
|
||||
for _, split := range a.aapt.splits {
|
||||
// Sign the split APKs
|
||||
packageFile := android.PathForModuleOut(ctx, a.installApkName+"_"+split.suffix+".apk")
|
||||
CreateAndSignAppPackage(ctx, packageFile, split.path, nil, nil, certificates, apkDeps, lineageFile)
|
||||
if v4SigningRequested {
|
||||
v4SignatureFile = android.PathForModuleOut(ctx, a.installApkName+"_"+split.suffix+".apk.idsig")
|
||||
}
|
||||
CreateAndSignAppPackage(ctx, packageFile, split.path, nil, nil, certificates, apkDeps, v4SignatureFile, lineageFile)
|
||||
a.extraOutputFiles = append(a.extraOutputFiles, packageFile)
|
||||
if v4SigningRequested {
|
||||
a.extraOutputFiles = append(a.extraOutputFiles, v4SignatureFile)
|
||||
}
|
||||
}
|
||||
|
||||
// Build an app bundle.
|
||||
@@ -1528,7 +1558,7 @@ func (a *AndroidAppImport) generateAndroidBuildActions(ctx android.ModuleContext
|
||||
if lineage := String(a.properties.Lineage); lineage != "" {
|
||||
lineageFile = android.PathForModuleSrc(ctx, lineage)
|
||||
}
|
||||
SignAppPackage(ctx, signed, dexOutput, certificates, lineageFile)
|
||||
SignAppPackage(ctx, signed, dexOutput, certificates, nil, lineageFile)
|
||||
a.outputFile = signed
|
||||
} else {
|
||||
alignedApk := android.PathForModuleOut(ctx, "zip-aligned", apkFilename)
|
||||
@@ -1801,7 +1831,7 @@ func (r *RuntimeResourceOverlay) GenerateAndroidBuildActions(ctx android.ModuleC
|
||||
if !overridden {
|
||||
manifestPackageName = *r.overridableProperties.Package_name
|
||||
}
|
||||
aaptLinkFlags = append(aaptLinkFlags, "--rename-manifest-package "+manifestPackageName)
|
||||
aaptLinkFlags = append(aaptLinkFlags, generateAaptRenamePackageFlags(manifestPackageName, false)...)
|
||||
}
|
||||
if r.overridableProperties.Target_package_name != nil {
|
||||
aaptLinkFlags = append(aaptLinkFlags,
|
||||
@@ -1817,7 +1847,7 @@ func (r *RuntimeResourceOverlay) GenerateAndroidBuildActions(ctx android.ModuleC
|
||||
if lineage := String(r.properties.Lineage); lineage != "" {
|
||||
lineageFile = android.PathForModuleSrc(ctx, lineage)
|
||||
}
|
||||
SignAppPackage(ctx, signed, r.aapt.exportPackage, certificates, lineageFile)
|
||||
SignAppPackage(ctx, signed, r.aapt.exportPackage, certificates, nil, lineageFile)
|
||||
r.certificate = certificates[0]
|
||||
|
||||
r.outputFile = signed
|
||||
|
@@ -52,7 +52,7 @@ var combineApk = pctx.AndroidStaticRule("combineApk",
|
||||
})
|
||||
|
||||
func CreateAndSignAppPackage(ctx android.ModuleContext, outputFile android.WritablePath,
|
||||
packageFile, jniJarFile, dexJarFile android.Path, certificates []Certificate, deps android.Paths, lineageFile android.Path) {
|
||||
packageFile, jniJarFile, dexJarFile android.Path, certificates []Certificate, deps android.Paths, v4SignatureFile android.WritablePath, lineageFile android.Path) {
|
||||
|
||||
unsignedApkName := strings.TrimSuffix(outputFile.Base(), ".apk") + "-unsigned.apk"
|
||||
unsignedApk := android.PathForModuleOut(ctx, unsignedApkName)
|
||||
@@ -73,10 +73,10 @@ func CreateAndSignAppPackage(ctx android.ModuleContext, outputFile android.Writa
|
||||
Implicits: deps,
|
||||
})
|
||||
|
||||
SignAppPackage(ctx, outputFile, unsignedApk, certificates, lineageFile)
|
||||
SignAppPackage(ctx, outputFile, unsignedApk, certificates, v4SignatureFile, lineageFile)
|
||||
}
|
||||
|
||||
func SignAppPackage(ctx android.ModuleContext, signedApk android.WritablePath, unsignedApk android.Path, certificates []Certificate, lineageFile android.Path) {
|
||||
func SignAppPackage(ctx android.ModuleContext, signedApk android.WritablePath, unsignedApk android.Path, certificates []Certificate, v4SignatureFile android.WritablePath, lineageFile android.Path) {
|
||||
|
||||
var certificateArgs []string
|
||||
var deps android.Paths
|
||||
@@ -87,6 +87,11 @@ func SignAppPackage(ctx android.ModuleContext, signedApk android.WritablePath, u
|
||||
|
||||
outputFiles := android.WritablePaths{signedApk}
|
||||
var flags []string
|
||||
if v4SignatureFile != nil {
|
||||
outputFiles = append(outputFiles, v4SignatureFile)
|
||||
flags = append(flags, "--enable-v4")
|
||||
}
|
||||
|
||||
if lineageFile != nil {
|
||||
flags = append(flags, "--lineage", lineageFile.String())
|
||||
deps = append(deps, lineageFile)
|
||||
|
360
java/app_test.go
360
java/app_test.go
@@ -176,16 +176,17 @@ func TestAndroidAppSet_Variants(t *testing.T) {
|
||||
set: "prebuilts/apks/app.apks",
|
||||
}`
|
||||
testCases := []struct {
|
||||
name string
|
||||
deviceArch *string
|
||||
deviceSecondaryArch *string
|
||||
aaptPrebuiltDPI []string
|
||||
sdkVersion int
|
||||
expected map[string]string
|
||||
name string
|
||||
targets []android.Target
|
||||
aaptPrebuiltDPI []string
|
||||
sdkVersion int
|
||||
expected map[string]string
|
||||
}{
|
||||
{
|
||||
name: "One",
|
||||
deviceArch: proptools.StringPtr("x86"),
|
||||
name: "One",
|
||||
targets: []android.Target{
|
||||
{Os: android.Android, Arch: android.Arch{ArchType: android.X86}},
|
||||
},
|
||||
aaptPrebuiltDPI: []string{"ldpi", "xxhdpi"},
|
||||
sdkVersion: 29,
|
||||
expected: map[string]string{
|
||||
@@ -197,11 +198,13 @@ func TestAndroidAppSet_Variants(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Two",
|
||||
deviceArch: proptools.StringPtr("x86_64"),
|
||||
deviceSecondaryArch: proptools.StringPtr("x86"),
|
||||
aaptPrebuiltDPI: nil,
|
||||
sdkVersion: 30,
|
||||
name: "Two",
|
||||
targets: []android.Target{
|
||||
{Os: android.Android, Arch: android.Arch{ArchType: android.X86_64}},
|
||||
{Os: android.Android, Arch: android.Arch{ArchType: android.X86}},
|
||||
},
|
||||
aaptPrebuiltDPI: nil,
|
||||
sdkVersion: 30,
|
||||
expected: map[string]string{
|
||||
"abis": "X86_64,X86",
|
||||
"allow-prereleased": "false",
|
||||
@@ -216,8 +219,7 @@ func TestAndroidAppSet_Variants(t *testing.T) {
|
||||
config := testAppConfig(nil, bp, nil)
|
||||
config.TestProductVariables.AAPTPrebuiltDPI = test.aaptPrebuiltDPI
|
||||
config.TestProductVariables.Platform_sdk_version = &test.sdkVersion
|
||||
config.TestProductVariables.DeviceArch = test.deviceArch
|
||||
config.TestProductVariables.DeviceSecondaryArch = test.deviceSecondaryArch
|
||||
config.Targets[android.Android] = test.targets
|
||||
ctx := testContext()
|
||||
run(t, ctx, config)
|
||||
module := ctx.ModuleForTests("foo", "android_common")
|
||||
@@ -1655,6 +1657,66 @@ func TestCertificates(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestRequestV4SigningFlag(t *testing.T) {
|
||||
testCases := []struct {
|
||||
name string
|
||||
bp string
|
||||
expected string
|
||||
}{
|
||||
{
|
||||
name: "default",
|
||||
bp: `
|
||||
android_app {
|
||||
name: "foo",
|
||||
srcs: ["a.java"],
|
||||
sdk_version: "current",
|
||||
}
|
||||
`,
|
||||
expected: "",
|
||||
},
|
||||
{
|
||||
name: "default",
|
||||
bp: `
|
||||
android_app {
|
||||
name: "foo",
|
||||
srcs: ["a.java"],
|
||||
sdk_version: "current",
|
||||
v4_signature: false,
|
||||
}
|
||||
`,
|
||||
expected: "",
|
||||
},
|
||||
{
|
||||
name: "module certificate property",
|
||||
bp: `
|
||||
android_app {
|
||||
name: "foo",
|
||||
srcs: ["a.java"],
|
||||
sdk_version: "current",
|
||||
v4_signature: true,
|
||||
}
|
||||
`,
|
||||
expected: "--enable-v4",
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range testCases {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
config := testAppConfig(nil, test.bp, nil)
|
||||
ctx := testContext()
|
||||
|
||||
run(t, ctx, config)
|
||||
foo := ctx.ModuleForTests("foo", "android_common")
|
||||
|
||||
signapk := foo.Output("foo.apk")
|
||||
signFlags := signapk.Args["flags"]
|
||||
if test.expected != signFlags {
|
||||
t.Errorf("Incorrect signing flags, expected: %q, got: %q", test.expected, signFlags)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestPackageNameOverride(t *testing.T) {
|
||||
testCases := []struct {
|
||||
name string
|
||||
@@ -1777,52 +1839,125 @@ func TestOverrideAndroidApp(t *testing.T) {
|
||||
base: "foo",
|
||||
package_name: "org.dandroid.bp",
|
||||
}
|
||||
|
||||
override_android_app {
|
||||
name: "baz_no_rename_resources",
|
||||
base: "foo",
|
||||
package_name: "org.dandroid.bp",
|
||||
rename_resources_package: false,
|
||||
}
|
||||
|
||||
android_app {
|
||||
name: "foo_no_rename_resources",
|
||||
srcs: ["a.java"],
|
||||
certificate: "expiredkey",
|
||||
overrides: ["qux"],
|
||||
rename_resources_package: false,
|
||||
sdk_version: "current",
|
||||
}
|
||||
|
||||
override_android_app {
|
||||
name: "baz_base_no_rename_resources",
|
||||
base: "foo_no_rename_resources",
|
||||
package_name: "org.dandroid.bp",
|
||||
}
|
||||
|
||||
override_android_app {
|
||||
name: "baz_override_base_rename_resources",
|
||||
base: "foo_no_rename_resources",
|
||||
package_name: "org.dandroid.bp",
|
||||
rename_resources_package: true,
|
||||
}
|
||||
`)
|
||||
|
||||
expectedVariants := []struct {
|
||||
moduleName string
|
||||
variantName string
|
||||
apkName string
|
||||
apkPath string
|
||||
certFlag string
|
||||
lineageFlag string
|
||||
overrides []string
|
||||
aaptFlag string
|
||||
logging_parent string
|
||||
name string
|
||||
moduleName string
|
||||
variantName string
|
||||
apkName string
|
||||
apkPath string
|
||||
certFlag string
|
||||
lineageFlag string
|
||||
overrides []string
|
||||
packageFlag string
|
||||
renameResources bool
|
||||
logging_parent string
|
||||
}{
|
||||
{
|
||||
moduleName: "foo",
|
||||
variantName: "android_common",
|
||||
apkPath: "/target/product/test_device/system/app/foo/foo.apk",
|
||||
certFlag: "build/make/target/product/security/expiredkey.x509.pem build/make/target/product/security/expiredkey.pk8",
|
||||
lineageFlag: "",
|
||||
overrides: []string{"qux"},
|
||||
aaptFlag: "",
|
||||
logging_parent: "",
|
||||
name: "foo",
|
||||
moduleName: "foo",
|
||||
variantName: "android_common",
|
||||
apkPath: "/target/product/test_device/system/app/foo/foo.apk",
|
||||
certFlag: "build/make/target/product/security/expiredkey.x509.pem build/make/target/product/security/expiredkey.pk8",
|
||||
lineageFlag: "",
|
||||
overrides: []string{"qux"},
|
||||
packageFlag: "",
|
||||
renameResources: false,
|
||||
logging_parent: "",
|
||||
},
|
||||
{
|
||||
moduleName: "bar",
|
||||
variantName: "android_common_bar",
|
||||
apkPath: "/target/product/test_device/system/app/bar/bar.apk",
|
||||
certFlag: "cert/new_cert.x509.pem cert/new_cert.pk8",
|
||||
lineageFlag: "--lineage lineage.bin",
|
||||
overrides: []string{"qux", "foo"},
|
||||
aaptFlag: "",
|
||||
logging_parent: "bah",
|
||||
name: "foo",
|
||||
moduleName: "bar",
|
||||
variantName: "android_common_bar",
|
||||
apkPath: "/target/product/test_device/system/app/bar/bar.apk",
|
||||
certFlag: "cert/new_cert.x509.pem cert/new_cert.pk8",
|
||||
lineageFlag: "--lineage lineage.bin",
|
||||
overrides: []string{"qux", "foo"},
|
||||
packageFlag: "",
|
||||
renameResources: false,
|
||||
logging_parent: "bah",
|
||||
},
|
||||
{
|
||||
moduleName: "baz",
|
||||
variantName: "android_common_baz",
|
||||
apkPath: "/target/product/test_device/system/app/baz/baz.apk",
|
||||
certFlag: "build/make/target/product/security/expiredkey.x509.pem build/make/target/product/security/expiredkey.pk8",
|
||||
lineageFlag: "",
|
||||
overrides: []string{"qux", "foo"},
|
||||
aaptFlag: "--rename-manifest-package org.dandroid.bp",
|
||||
logging_parent: "",
|
||||
name: "foo",
|
||||
moduleName: "baz",
|
||||
variantName: "android_common_baz",
|
||||
apkPath: "/target/product/test_device/system/app/baz/baz.apk",
|
||||
certFlag: "build/make/target/product/security/expiredkey.x509.pem build/make/target/product/security/expiredkey.pk8",
|
||||
lineageFlag: "",
|
||||
overrides: []string{"qux", "foo"},
|
||||
packageFlag: "org.dandroid.bp",
|
||||
renameResources: true,
|
||||
logging_parent: "",
|
||||
},
|
||||
{
|
||||
name: "foo",
|
||||
moduleName: "baz_no_rename_resources",
|
||||
variantName: "android_common_baz_no_rename_resources",
|
||||
apkPath: "/target/product/test_device/system/app/baz_no_rename_resources/baz_no_rename_resources.apk",
|
||||
certFlag: "build/make/target/product/security/expiredkey.x509.pem build/make/target/product/security/expiredkey.pk8",
|
||||
lineageFlag: "",
|
||||
overrides: []string{"qux", "foo"},
|
||||
packageFlag: "org.dandroid.bp",
|
||||
renameResources: false,
|
||||
logging_parent: "",
|
||||
},
|
||||
{
|
||||
name: "foo_no_rename_resources",
|
||||
moduleName: "baz_base_no_rename_resources",
|
||||
variantName: "android_common_baz_base_no_rename_resources",
|
||||
apkPath: "/target/product/test_device/system/app/baz_base_no_rename_resources/baz_base_no_rename_resources.apk",
|
||||
certFlag: "build/make/target/product/security/expiredkey.x509.pem build/make/target/product/security/expiredkey.pk8",
|
||||
lineageFlag: "",
|
||||
overrides: []string{"qux", "foo_no_rename_resources"},
|
||||
packageFlag: "org.dandroid.bp",
|
||||
renameResources: false,
|
||||
logging_parent: "",
|
||||
},
|
||||
{
|
||||
name: "foo_no_rename_resources",
|
||||
moduleName: "baz_override_base_rename_resources",
|
||||
variantName: "android_common_baz_override_base_rename_resources",
|
||||
apkPath: "/target/product/test_device/system/app/baz_override_base_rename_resources/baz_override_base_rename_resources.apk",
|
||||
certFlag: "build/make/target/product/security/expiredkey.x509.pem build/make/target/product/security/expiredkey.pk8",
|
||||
lineageFlag: "",
|
||||
overrides: []string{"qux", "foo_no_rename_resources"},
|
||||
packageFlag: "org.dandroid.bp",
|
||||
renameResources: true,
|
||||
logging_parent: "",
|
||||
},
|
||||
}
|
||||
for _, expected := range expectedVariants {
|
||||
variant := ctx.ModuleForTests("foo", expected.variantName)
|
||||
variant := ctx.ModuleForTests(expected.name, expected.variantName)
|
||||
|
||||
// Check the final apk name
|
||||
outputs := variant.AllOutputs()
|
||||
@@ -1868,9 +2003,12 @@ func TestOverrideAndroidApp(t *testing.T) {
|
||||
// Check the package renaming flag, if exists.
|
||||
res := variant.Output("package-res.apk")
|
||||
aapt2Flags := res.Args["flags"]
|
||||
if !strings.Contains(aapt2Flags, expected.aaptFlag) {
|
||||
t.Errorf("package renaming flag, %q is missing in aapt2 link flags, %q", expected.aaptFlag, aapt2Flags)
|
||||
checkAapt2LinkFlag(t, aapt2Flags, "rename-manifest-package", expected.packageFlag)
|
||||
expectedPackage := expected.packageFlag
|
||||
if !expected.renameResources {
|
||||
expectedPackage = ""
|
||||
}
|
||||
checkAapt2LinkFlag(t, aapt2Flags, "rename-resources-package", expectedPackage)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2007,6 +2145,7 @@ func TestOverrideAndroidTest(t *testing.T) {
|
||||
res := variant.Output("package-res.apk")
|
||||
aapt2Flags := res.Args["flags"]
|
||||
checkAapt2LinkFlag(t, aapt2Flags, "rename-manifest-package", expected.packageFlag)
|
||||
checkAapt2LinkFlag(t, aapt2Flags, "rename-resources-package", expected.packageFlag)
|
||||
checkAapt2LinkFlag(t, aapt2Flags, "rename-instrumentation-target-package", expected.targetPackageFlag)
|
||||
}
|
||||
}
|
||||
@@ -3131,6 +3270,65 @@ func TestRuntimeResourceOverlay(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestRuntimeResourceOverlay_JavaDefaults(t *testing.T) {
|
||||
ctx, config := testJava(t, `
|
||||
java_defaults {
|
||||
name: "rro_defaults",
|
||||
theme: "default_theme",
|
||||
product_specific: true,
|
||||
aaptflags: ["--keep-raw-values"],
|
||||
}
|
||||
|
||||
runtime_resource_overlay {
|
||||
name: "foo_with_defaults",
|
||||
defaults: ["rro_defaults"],
|
||||
}
|
||||
|
||||
runtime_resource_overlay {
|
||||
name: "foo_barebones",
|
||||
}
|
||||
`)
|
||||
|
||||
//
|
||||
// RRO module with defaults
|
||||
//
|
||||
m := ctx.ModuleForTests("foo_with_defaults", "android_common")
|
||||
|
||||
// Check AAPT2 link flags.
|
||||
aapt2Flags := strings.Split(m.Output("package-res.apk").Args["flags"], " ")
|
||||
expectedFlags := []string{"--keep-raw-values", "--no-resource-deduping", "--no-resource-removal"}
|
||||
absentFlags := android.RemoveListFromList(expectedFlags, aapt2Flags)
|
||||
if len(absentFlags) > 0 {
|
||||
t.Errorf("expected values, %q are missing in aapt2 link flags, %q", absentFlags, aapt2Flags)
|
||||
}
|
||||
|
||||
// Check device location.
|
||||
path := android.AndroidMkEntriesForTest(t, config, "", m.Module())[0].EntryMap["LOCAL_MODULE_PATH"]
|
||||
expectedPath := []string{"/tmp/target/product/test_device/product/overlay/default_theme"}
|
||||
if !reflect.DeepEqual(path, expectedPath) {
|
||||
t.Errorf("Unexpected LOCAL_MODULE_PATH value: %q, expected: %q", path, expectedPath)
|
||||
}
|
||||
|
||||
//
|
||||
// RRO module without defaults
|
||||
//
|
||||
m = ctx.ModuleForTests("foo_barebones", "android_common")
|
||||
|
||||
// Check AAPT2 link flags.
|
||||
aapt2Flags = strings.Split(m.Output("package-res.apk").Args["flags"], " ")
|
||||
unexpectedFlags := "--keep-raw-values"
|
||||
if inList(unexpectedFlags, aapt2Flags) {
|
||||
t.Errorf("unexpected value, %q is present in aapt2 link flags, %q", unexpectedFlags, aapt2Flags)
|
||||
}
|
||||
|
||||
// Check device location.
|
||||
path = android.AndroidMkEntriesForTest(t, config, "", m.Module())[0].EntryMap["LOCAL_MODULE_PATH"]
|
||||
expectedPath = []string{"/tmp/target/product/test_device/system/overlay"}
|
||||
if !reflect.DeepEqual(path, expectedPath) {
|
||||
t.Errorf("Unexpected LOCAL_MODULE_PATH value: %v, expected: %v", path, expectedPath)
|
||||
}
|
||||
}
|
||||
|
||||
func TestOverrideRuntimeResourceOverlay(t *testing.T) {
|
||||
ctx, _ := testJava(t, `
|
||||
runtime_resource_overlay {
|
||||
@@ -3202,65 +3400,7 @@ func TestOverrideRuntimeResourceOverlay(t *testing.T) {
|
||||
res := variant.Output("package-res.apk")
|
||||
aapt2Flags := res.Args["flags"]
|
||||
checkAapt2LinkFlag(t, aapt2Flags, "rename-manifest-package", expected.packageFlag)
|
||||
checkAapt2LinkFlag(t, aapt2Flags, "rename-resources-package", "")
|
||||
checkAapt2LinkFlag(t, aapt2Flags, "rename-overlay-target-package", expected.targetPackageFlag)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRuntimeResourceOverlay_JavaDefaults(t *testing.T) {
|
||||
ctx, config := testJava(t, `
|
||||
java_defaults {
|
||||
name: "rro_defaults",
|
||||
theme: "default_theme",
|
||||
product_specific: true,
|
||||
aaptflags: ["--keep-raw-values"],
|
||||
}
|
||||
|
||||
runtime_resource_overlay {
|
||||
name: "foo_with_defaults",
|
||||
defaults: ["rro_defaults"],
|
||||
}
|
||||
|
||||
runtime_resource_overlay {
|
||||
name: "foo_barebones",
|
||||
}
|
||||
`)
|
||||
|
||||
//
|
||||
// RRO module with defaults
|
||||
//
|
||||
m := ctx.ModuleForTests("foo_with_defaults", "android_common")
|
||||
|
||||
// Check AAPT2 link flags.
|
||||
aapt2Flags := strings.Split(m.Output("package-res.apk").Args["flags"], " ")
|
||||
expectedFlags := []string{"--keep-raw-values", "--no-resource-deduping", "--no-resource-removal"}
|
||||
absentFlags := android.RemoveListFromList(expectedFlags, aapt2Flags)
|
||||
if len(absentFlags) > 0 {
|
||||
t.Errorf("expected values, %q are missing in aapt2 link flags, %q", absentFlags, aapt2Flags)
|
||||
}
|
||||
|
||||
// Check device location.
|
||||
path := android.AndroidMkEntriesForTest(t, config, "", m.Module())[0].EntryMap["LOCAL_MODULE_PATH"]
|
||||
expectedPath := []string{"/tmp/target/product/test_device/product/overlay/default_theme"}
|
||||
if !reflect.DeepEqual(path, expectedPath) {
|
||||
t.Errorf("Unexpected LOCAL_MODULE_PATH value: %q, expected: %q", path, expectedPath)
|
||||
}
|
||||
|
||||
//
|
||||
// RRO module without defaults
|
||||
//
|
||||
m = ctx.ModuleForTests("foo_barebones", "android_common")
|
||||
|
||||
// Check AAPT2 link flags.
|
||||
aapt2Flags = strings.Split(m.Output("package-res.apk").Args["flags"], " ")
|
||||
unexpectedFlags := "--keep-raw-values"
|
||||
if inList(unexpectedFlags, aapt2Flags) {
|
||||
t.Errorf("unexpected value, %q is present in aapt2 link flags, %q", unexpectedFlags, aapt2Flags)
|
||||
}
|
||||
|
||||
// Check device location.
|
||||
path = android.AndroidMkEntriesForTest(t, config, "", m.Module())[0].EntryMap["LOCAL_MODULE_PATH"]
|
||||
expectedPath = []string{"/tmp/target/product/test_device/system/overlay"}
|
||||
if !reflect.DeepEqual(path, expectedPath) {
|
||||
t.Errorf("Unexpected LOCAL_MODULE_PATH value: %v, expected: %v", path, expectedPath)
|
||||
}
|
||||
}
|
||||
|
@@ -41,6 +41,7 @@ var (
|
||||
|
||||
InstrumentFrameworkModules = []string{
|
||||
"framework",
|
||||
"framework-minus-apex",
|
||||
"telephony-common",
|
||||
"services",
|
||||
"android.car",
|
||||
@@ -51,6 +52,7 @@ var (
|
||||
"core-libart",
|
||||
// TODO: Could this be all updatable bootclasspath jars?
|
||||
"updatable-media",
|
||||
"framework-mediaprovider",
|
||||
"framework-sdkextensions",
|
||||
"android.net.ipsec.ike",
|
||||
}
|
||||
|
@@ -1600,6 +1600,15 @@ func (d *Droidstubs) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||
d.apiLintReport = android.PathForModuleOut(ctx, "api_lint_report.txt")
|
||||
cmd.FlagWithOutput("--report-even-if-suppressed ", d.apiLintReport) // TODO: Change to ":api-lint"
|
||||
|
||||
// TODO(b/154317059): Clean up this whitelist by baselining and/or checking in last-released.
|
||||
if d.Name() != "android.car-system-stubs-docs" &&
|
||||
d.Name() != "android.car-stubs-docs" &&
|
||||
d.Name() != "system-api-stubs-docs" &&
|
||||
d.Name() != "test-api-stubs-docs" {
|
||||
cmd.Flag("--lints-as-errors")
|
||||
cmd.Flag("--warnings-as-errors") // Most lints are actually warnings.
|
||||
}
|
||||
|
||||
baselineFile := android.OptionalPathForModuleSrc(ctx, d.properties.Check_api.Api_lint.Baseline_file)
|
||||
updatedBaselineOutput := android.PathForModuleOut(ctx, "api_lint_baseline.txt")
|
||||
d.apiLintTimestamp = android.PathForModuleOut(ctx, "api_lint.timestamp")
|
||||
|
@@ -207,6 +207,15 @@ func stubFlagsRule(ctx android.SingletonContext) {
|
||||
rule.Build(pctx, ctx, "hiddenAPIStubFlagsFile", "hiddenapi stub flags")
|
||||
}
|
||||
|
||||
func moduleForGreyListRemovedApis(ctx android.SingletonContext, module android.Module) bool {
|
||||
switch ctx.ModuleName(module) {
|
||||
case "api-stubs-docs", "system-api-stubs-docs", "android.car-stubs-docs", "android.car-system-stubs-docs":
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// flagsRule creates a rule to build hiddenapi-flags.csv out of flags.csv files generated for boot image modules and
|
||||
// the unsupported API.
|
||||
func flagsRule(ctx android.SingletonContext) android.Path {
|
||||
@@ -222,7 +231,7 @@ func flagsRule(ctx android.SingletonContext) android.Path {
|
||||
// Track @removed public and system APIs via corresponding droidstubs targets.
|
||||
// These APIs are not present in the stubs, however, we have to keep allowing access
|
||||
// to them at runtime.
|
||||
if m := ctx.ModuleName(module); m == "api-stubs-docs" || m == "system-api-stubs-docs" {
|
||||
if moduleForGreyListRemovedApis(ctx, module) {
|
||||
greylistRemovedApis = append(greylistRemovedApis, ds.removedDexApiFile)
|
||||
}
|
||||
}
|
||||
|
@@ -324,6 +324,10 @@ type CompilerDeviceProperties struct {
|
||||
Stem *string
|
||||
|
||||
IsSDKLibrary bool `blueprint:"mutated"`
|
||||
|
||||
// If true, generate the signature file of APK Signing Scheme V4, along side the signed APK file.
|
||||
// Defaults to false.
|
||||
V4_signature *bool
|
||||
}
|
||||
|
||||
// Functionality common to Module and Import
|
||||
|
@@ -19,6 +19,10 @@ import (
|
||||
"android/soong/java/config"
|
||||
)
|
||||
|
||||
// This variable is effectively unused in pre-master branches, and is
|
||||
// included (with the same value as it has in AOSP) only to ease
|
||||
// merges between branches (see the comment in the
|
||||
// useLegacyCorePlatformApi() function):
|
||||
var legacyCorePlatformApiModules = []string{
|
||||
"ahat-test-dump",
|
||||
"android.car",
|
||||
@@ -132,6 +136,10 @@ var legacyCorePlatformApiModules = []string{
|
||||
"wifi-service",
|
||||
}
|
||||
|
||||
// This variable is effectively unused in pre-master branches, and is
|
||||
// included (with the same value as it has in AOSP) only to ease
|
||||
// merges between branches (see the comment in the
|
||||
// useLegacyCorePlatformApi() function):
|
||||
var legacyCorePlatformApiLookup = make(map[string]struct{})
|
||||
|
||||
func init() {
|
||||
@@ -141,8 +149,12 @@ func init() {
|
||||
}
|
||||
|
||||
func useLegacyCorePlatformApi(ctx android.EarlyModuleContext) bool {
|
||||
_, found := legacyCorePlatformApiLookup[ctx.ModuleName()]
|
||||
return found
|
||||
// In pre-master branches, we don't attempt to force usage of the stable
|
||||
// version of the core/platform API. Instead, we always use the legacy
|
||||
// version --- except in tests, where we always use stable, so that we
|
||||
// can make the test assertions the same as other branches.
|
||||
// This should be false in tests and true otherwise:
|
||||
return ctx.Config().TestProductVariables == nil
|
||||
}
|
||||
|
||||
func corePlatformSystemModules(ctx android.EarlyModuleContext) string {
|
||||
|
@@ -95,11 +95,10 @@ func TestConfig(buildDir string, env map[string]string, bp string, fs map[string
|
||||
MAIN_FILE = '%main%'`),
|
||||
|
||||
// For java_sdk_library
|
||||
"api/module-lib-current.txt": nil,
|
||||
"api/module-lib-removed.txt": nil,
|
||||
"api/system-server-current.txt": nil,
|
||||
"api/system-server-removed.txt": nil,
|
||||
"build/soong/scripts/gen-java-current-api-files.sh": nil,
|
||||
"api/module-lib-current.txt": nil,
|
||||
"api/module-lib-removed.txt": nil,
|
||||
"api/system-server-current.txt": nil,
|
||||
"api/system-server-removed.txt": nil,
|
||||
}
|
||||
|
||||
cc.GatherRequiredFilesForTest(mockFS)
|
||||
|
Reference in New Issue
Block a user