Merge "Use aapt2 flag --rename-resources-package in soong" am: f32bbf89de
am: 4a313bf0c1
Change-Id: I2cd24a2e311fb453388eb0155014e8b8982609a8
This commit is contained in:
commit
8cb6ac7820
12
java/app.go
12
java/app.go
|
@ -491,6 +491,16 @@ func (a *AndroidApp) shouldEmbedJnis(ctx android.BaseModuleContext) bool {
|
||||||
!a.IsForPlatform() || a.appProperties.AlwaysPackageNativeLibs
|
!a.IsForPlatform() || a.appProperties.AlwaysPackageNativeLibs
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func generateAaptRenamePackageFlags(packageName string) []string {
|
||||||
|
aaptFlags := []string{}
|
||||||
|
aaptFlags = append(aaptFlags, "--rename-manifest-package "+packageName)
|
||||||
|
// --rename-resources-package renames the package within the resources table to packageName.
|
||||||
|
// Note: this will *not* rename the R.java file because the base module .R
|
||||||
|
// package may be directly referenced in code.
|
||||||
|
aaptFlags = append(aaptFlags, "--rename-resources-package "+packageName)
|
||||||
|
return aaptFlags
|
||||||
|
}
|
||||||
|
|
||||||
func (a *AndroidApp) OverriddenManifestPackageName() string {
|
func (a *AndroidApp) OverriddenManifestPackageName() string {
|
||||||
return a.overriddenManifestPackageName
|
return a.overriddenManifestPackageName
|
||||||
}
|
}
|
||||||
|
@ -527,7 +537,7 @@ func (a *AndroidApp) aaptBuildActions(ctx android.ModuleContext) {
|
||||||
if !overridden {
|
if !overridden {
|
||||||
manifestPackageName = *a.overridableAppProperties.Package_name
|
manifestPackageName = *a.overridableAppProperties.Package_name
|
||||||
}
|
}
|
||||||
aaptLinkFlags = append(aaptLinkFlags, "--rename-manifest-package "+manifestPackageName)
|
aaptLinkFlags = append(aaptLinkFlags, generateAaptRenamePackageFlags(manifestPackageName)...)
|
||||||
a.overriddenManifestPackageName = manifestPackageName
|
a.overriddenManifestPackageName = manifestPackageName
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1748,7 +1748,7 @@ func TestOverrideAndroidApp(t *testing.T) {
|
||||||
certFlag string
|
certFlag string
|
||||||
lineageFlag string
|
lineageFlag string
|
||||||
overrides []string
|
overrides []string
|
||||||
aaptFlag string
|
packageFlag string
|
||||||
logging_parent string
|
logging_parent string
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
|
@ -1758,7 +1758,7 @@ func TestOverrideAndroidApp(t *testing.T) {
|
||||||
certFlag: "build/make/target/product/security/expiredkey.x509.pem build/make/target/product/security/expiredkey.pk8",
|
certFlag: "build/make/target/product/security/expiredkey.x509.pem build/make/target/product/security/expiredkey.pk8",
|
||||||
lineageFlag: "",
|
lineageFlag: "",
|
||||||
overrides: []string{"qux"},
|
overrides: []string{"qux"},
|
||||||
aaptFlag: "",
|
packageFlag: "",
|
||||||
logging_parent: "",
|
logging_parent: "",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -1768,7 +1768,7 @@ func TestOverrideAndroidApp(t *testing.T) {
|
||||||
certFlag: "cert/new_cert.x509.pem cert/new_cert.pk8",
|
certFlag: "cert/new_cert.x509.pem cert/new_cert.pk8",
|
||||||
lineageFlag: "--lineage lineage.bin",
|
lineageFlag: "--lineage lineage.bin",
|
||||||
overrides: []string{"qux", "foo"},
|
overrides: []string{"qux", "foo"},
|
||||||
aaptFlag: "",
|
packageFlag: "",
|
||||||
logging_parent: "bah",
|
logging_parent: "bah",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -1778,7 +1778,7 @@ func TestOverrideAndroidApp(t *testing.T) {
|
||||||
certFlag: "build/make/target/product/security/expiredkey.x509.pem build/make/target/product/security/expiredkey.pk8",
|
certFlag: "build/make/target/product/security/expiredkey.x509.pem build/make/target/product/security/expiredkey.pk8",
|
||||||
lineageFlag: "",
|
lineageFlag: "",
|
||||||
overrides: []string{"qux", "foo"},
|
overrides: []string{"qux", "foo"},
|
||||||
aaptFlag: "--rename-manifest-package org.dandroid.bp",
|
packageFlag: "org.dandroid.bp",
|
||||||
logging_parent: "",
|
logging_parent: "",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -1826,12 +1826,11 @@ func TestOverrideAndroidApp(t *testing.T) {
|
||||||
expected.logging_parent, logging_parent)
|
expected.logging_parent, logging_parent)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check the package renaming flag, if exists.
|
// Check the package renaming flags, if exists.
|
||||||
res := variant.Output("package-res.apk")
|
res := variant.Output("package-res.apk")
|
||||||
aapt2Flags := res.Args["flags"]
|
aapt2Flags := res.Args["flags"]
|
||||||
if !strings.Contains(aapt2Flags, expected.aaptFlag) {
|
checkAapt2LinkFlag(t, aapt2Flags, "rename-manifest-package", expected.packageFlag)
|
||||||
t.Errorf("package renaming flag, %q is missing in aapt2 link flags, %q", expected.aaptFlag, aapt2Flags)
|
checkAapt2LinkFlag(t, aapt2Flags, "rename-resources-package", expected.packageFlag)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1968,6 +1967,7 @@ func TestOverrideAndroidTest(t *testing.T) {
|
||||||
res := variant.Output("package-res.apk")
|
res := variant.Output("package-res.apk")
|
||||||
aapt2Flags := res.Args["flags"]
|
aapt2Flags := res.Args["flags"]
|
||||||
checkAapt2LinkFlag(t, aapt2Flags, "rename-manifest-package", expected.packageFlag)
|
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)
|
checkAapt2LinkFlag(t, aapt2Flags, "rename-instrumentation-target-package", expected.targetPackageFlag)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue