Merge changes Icbdf4979,I1a6f135d am: 70415ceb9e
am: 89af2c6c22
Change-Id: I7a4cd049ea18127cc989eaba328107a8b8e79606
This commit is contained in:
@@ -228,6 +228,14 @@ func UpdateApexDependency(apexName string, moduleName string, directDep bool) {
|
|||||||
apexNames[apexName] = apexNames[apexName] || directDep
|
apexNames[apexName] = apexNames[apexName] || directDep
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO(b/146393795): remove this when b/146393795 is fixed
|
||||||
|
func ClearApexDependency() {
|
||||||
|
m := apexNamesMap()
|
||||||
|
for k := range m {
|
||||||
|
delete(m, k)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Tests whether a module named moduleName is directly depended on by an APEX
|
// Tests whether a module named moduleName is directly depended on by an APEX
|
||||||
// named apexName.
|
// named apexName.
|
||||||
func DirectlyInApex(apexName string, moduleName string) bool {
|
func DirectlyInApex(apexName string, moduleName string) bool {
|
||||||
|
@@ -1095,7 +1095,7 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|||||||
// don't include it in this APEX
|
// don't include it in this APEX
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if !a.Host() && (cc.IsStubs() || cc.HasStubsVariants()) {
|
if !a.Host() && !android.DirectlyInApex(ctx.ModuleName(), ctx.OtherModuleName(cc)) && (cc.IsStubs() || cc.HasStubsVariants()) {
|
||||||
// If the dependency is a stubs lib, don't include it in this APEX,
|
// If the dependency is a stubs lib, don't include it in this APEX,
|
||||||
// but make sure that the lib is installed on the device.
|
// but make sure that the lib is installed on the device.
|
||||||
// In case no APEX is having the lib, the lib is installed to the system
|
// In case no APEX is having the lib, the lib is installed to the system
|
||||||
|
@@ -92,6 +92,7 @@ func withBinder32bit(fs map[string][]byte, config android.Config) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func testApexContext(t *testing.T, bp string, handlers ...testCustomizer) (*android.TestContext, android.Config) {
|
func testApexContext(t *testing.T, bp string, handlers ...testCustomizer) (*android.TestContext, android.Config) {
|
||||||
|
android.ClearApexDependency()
|
||||||
config := android.TestArchConfig(buildDir, nil)
|
config := android.TestArchConfig(buildDir, nil)
|
||||||
config.TestProductVariables.DeviceVndkVersion = proptools.StringPtr("current")
|
config.TestProductVariables.DeviceVndkVersion = proptools.StringPtr("current")
|
||||||
config.TestProductVariables.DefaultAppCertificate = proptools.StringPtr("vendor/foo/devkeys/test")
|
config.TestProductVariables.DefaultAppCertificate = proptools.StringPtr("vendor/foo/devkeys/test")
|
||||||
@@ -739,6 +740,12 @@ func TestApexWithStubs(t *testing.T) {
|
|||||||
|
|
||||||
// Ensure that genstub is invoked with --apex
|
// Ensure that genstub is invoked with --apex
|
||||||
ensureContains(t, "--apex", ctx.ModuleForTests("mylib2", "android_arm64_armv8-a_static_3_myapex").Rule("genStubSrc").Args["flags"])
|
ensureContains(t, "--apex", ctx.ModuleForTests("mylib2", "android_arm64_armv8-a_static_3_myapex").Rule("genStubSrc").Args["flags"])
|
||||||
|
|
||||||
|
ensureExactContents(t, ctx, "myapex", []string{
|
||||||
|
"lib64/mylib.so",
|
||||||
|
"lib64/mylib3.so",
|
||||||
|
"lib64/mylib4.so",
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestApexWithExplicitStubsDependency(t *testing.T) {
|
func TestApexWithExplicitStubsDependency(t *testing.T) {
|
||||||
@@ -1312,6 +1319,134 @@ func TestKeys(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestCertificate(t *testing.T) {
|
||||||
|
t.Run("if unspecified, it defaults to DefaultAppCertificate", func(t *testing.T) {
|
||||||
|
ctx, _ := testApex(t, `
|
||||||
|
apex {
|
||||||
|
name: "myapex",
|
||||||
|
key: "myapex.key",
|
||||||
|
}
|
||||||
|
apex_key {
|
||||||
|
name: "myapex.key",
|
||||||
|
public_key: "testkey.avbpubkey",
|
||||||
|
private_key: "testkey.pem",
|
||||||
|
}`)
|
||||||
|
rule := ctx.ModuleForTests("myapex", "android_common_myapex_image").Rule("signapk")
|
||||||
|
expected := "vendor/foo/devkeys/test.x509.pem vendor/foo/devkeys/test.pk8"
|
||||||
|
if actual := rule.Args["certificates"]; actual != expected {
|
||||||
|
t.Errorf("certificates should be %q, not %q", expected, actual)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
t.Run("override when unspecified", func(t *testing.T) {
|
||||||
|
ctx, _ := testApex(t, `
|
||||||
|
apex {
|
||||||
|
name: "myapex_keytest",
|
||||||
|
key: "myapex.key",
|
||||||
|
file_contexts: ":myapex-file_contexts",
|
||||||
|
}
|
||||||
|
apex_key {
|
||||||
|
name: "myapex.key",
|
||||||
|
public_key: "testkey.avbpubkey",
|
||||||
|
private_key: "testkey.pem",
|
||||||
|
}
|
||||||
|
android_app_certificate {
|
||||||
|
name: "myapex.certificate.override",
|
||||||
|
certificate: "testkey.override",
|
||||||
|
}`)
|
||||||
|
rule := ctx.ModuleForTests("myapex_keytest", "android_common_myapex_keytest_image").Rule("signapk")
|
||||||
|
expected := "testkey.override.x509.pem testkey.override.pk8"
|
||||||
|
if actual := rule.Args["certificates"]; actual != expected {
|
||||||
|
t.Errorf("certificates should be %q, not %q", expected, actual)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
t.Run("if specified as :module, it respects the prop", func(t *testing.T) {
|
||||||
|
ctx, _ := testApex(t, `
|
||||||
|
apex {
|
||||||
|
name: "myapex",
|
||||||
|
key: "myapex.key",
|
||||||
|
certificate: ":myapex.certificate",
|
||||||
|
}
|
||||||
|
apex_key {
|
||||||
|
name: "myapex.key",
|
||||||
|
public_key: "testkey.avbpubkey",
|
||||||
|
private_key: "testkey.pem",
|
||||||
|
}
|
||||||
|
android_app_certificate {
|
||||||
|
name: "myapex.certificate",
|
||||||
|
certificate: "testkey",
|
||||||
|
}`)
|
||||||
|
rule := ctx.ModuleForTests("myapex", "android_common_myapex_image").Rule("signapk")
|
||||||
|
expected := "testkey.x509.pem testkey.pk8"
|
||||||
|
if actual := rule.Args["certificates"]; actual != expected {
|
||||||
|
t.Errorf("certificates should be %q, not %q", expected, actual)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
t.Run("override when specifiec as <:module>", func(t *testing.T) {
|
||||||
|
ctx, _ := testApex(t, `
|
||||||
|
apex {
|
||||||
|
name: "myapex_keytest",
|
||||||
|
key: "myapex.key",
|
||||||
|
file_contexts: ":myapex-file_contexts",
|
||||||
|
certificate: ":myapex.certificate",
|
||||||
|
}
|
||||||
|
apex_key {
|
||||||
|
name: "myapex.key",
|
||||||
|
public_key: "testkey.avbpubkey",
|
||||||
|
private_key: "testkey.pem",
|
||||||
|
}
|
||||||
|
android_app_certificate {
|
||||||
|
name: "myapex.certificate.override",
|
||||||
|
certificate: "testkey.override",
|
||||||
|
}`)
|
||||||
|
rule := ctx.ModuleForTests("myapex_keytest", "android_common_myapex_keytest_image").Rule("signapk")
|
||||||
|
expected := "testkey.override.x509.pem testkey.override.pk8"
|
||||||
|
if actual := rule.Args["certificates"]; actual != expected {
|
||||||
|
t.Errorf("certificates should be %q, not %q", expected, actual)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
t.Run("if specified as name, finds it from DefaultDevKeyDir", func(t *testing.T) {
|
||||||
|
ctx, _ := testApex(t, `
|
||||||
|
apex {
|
||||||
|
name: "myapex",
|
||||||
|
key: "myapex.key",
|
||||||
|
certificate: "testkey",
|
||||||
|
}
|
||||||
|
apex_key {
|
||||||
|
name: "myapex.key",
|
||||||
|
public_key: "testkey.avbpubkey",
|
||||||
|
private_key: "testkey.pem",
|
||||||
|
}`)
|
||||||
|
rule := ctx.ModuleForTests("myapex", "android_common_myapex_image").Rule("signapk")
|
||||||
|
expected := "vendor/foo/devkeys/testkey.x509.pem vendor/foo/devkeys/testkey.pk8"
|
||||||
|
if actual := rule.Args["certificates"]; actual != expected {
|
||||||
|
t.Errorf("certificates should be %q, not %q", expected, actual)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
t.Run("override when specified as <name>", func(t *testing.T) {
|
||||||
|
ctx, _ := testApex(t, `
|
||||||
|
apex {
|
||||||
|
name: "myapex_keytest",
|
||||||
|
key: "myapex.key",
|
||||||
|
file_contexts: ":myapex-file_contexts",
|
||||||
|
certificate: "testkey",
|
||||||
|
}
|
||||||
|
apex_key {
|
||||||
|
name: "myapex.key",
|
||||||
|
public_key: "testkey.avbpubkey",
|
||||||
|
private_key: "testkey.pem",
|
||||||
|
}
|
||||||
|
android_app_certificate {
|
||||||
|
name: "myapex.certificate.override",
|
||||||
|
certificate: "testkey.override",
|
||||||
|
}`)
|
||||||
|
rule := ctx.ModuleForTests("myapex_keytest", "android_common_myapex_keytest_image").Rule("signapk")
|
||||||
|
expected := "testkey.override.x509.pem testkey.override.pk8"
|
||||||
|
if actual := rule.Args["certificates"]; actual != expected {
|
||||||
|
t.Errorf("certificates should be %q, not %q", expected, actual)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
func TestMacro(t *testing.T) {
|
func TestMacro(t *testing.T) {
|
||||||
ctx, _ := testApex(t, `
|
ctx, _ := testApex(t, `
|
||||||
apex {
|
apex {
|
||||||
|
@@ -495,15 +495,17 @@ func (a *apexBundle) buildFlattenedApex(ctx android.ModuleContext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *apexBundle) setCertificateAndPrivateKey(ctx android.ModuleContext) {
|
func (a *apexBundle) setCertificateAndPrivateKey(ctx android.ModuleContext) {
|
||||||
cert := String(a.properties.Certificate)
|
if a.container_certificate_file == nil {
|
||||||
if cert != "" && android.SrcIsModule(cert) == "" {
|
cert := String(a.properties.Certificate)
|
||||||
defaultDir := ctx.Config().DefaultAppCertificateDir(ctx)
|
if cert == "" {
|
||||||
a.container_certificate_file = defaultDir.Join(ctx, cert+".x509.pem")
|
pem, key := ctx.Config().DefaultAppCertificate(ctx)
|
||||||
a.container_private_key_file = defaultDir.Join(ctx, cert+".pk8")
|
a.container_certificate_file = pem
|
||||||
} else if cert == "" {
|
a.container_private_key_file = key
|
||||||
pem, key := ctx.Config().DefaultAppCertificate(ctx)
|
} else {
|
||||||
a.container_certificate_file = pem
|
defaultDir := ctx.Config().DefaultAppCertificateDir(ctx)
|
||||||
a.container_private_key_file = key
|
a.container_certificate_file = defaultDir.Join(ctx, cert+".x509.pem")
|
||||||
|
a.container_private_key_file = defaultDir.Join(ctx, cert+".pk8")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user