Permissions XML file for java_sdk_library is mutated for APEX
This change fixes a regression that was introduced with
I597bccbb177b6b6320c3a3edeff467243230d384. With the change, the content
of the permissions XML file for a java_sdk_library was determined before
the java_sdk_library is mutated for an APEX. As a result, the file path
to the implementation jar library was always set to
/system/framework/*.jar regardless of whether the java_sdk_library is
part of an APEX or not.
This change fixes the problem, by creating the permissions XML file via
a new module type. The content of the xml file is determined after the
xml file is mutated for APEXes.
Bug: 149600642
Test: m
Change-Id: Id21f8d8285df49b0b3be1daf0f101f2bc978eeb0
diff --git a/apex/apex.go b/apex/apex.go
index 54a335a..84043a5 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -2111,13 +2111,6 @@
return false
}
filesInfo = append(filesInfo, af)
-
- pf := sdkLib.XmlPermissionsFile()
- if pf == nil {
- ctx.PropertyErrorf("java_libs", "%q failed to generate permission XML", depName)
- return false
- }
- filesInfo = append(filesInfo, newApexFile(ctx, pf, pf.Base(), "etc/permissions", etc, nil))
return true // track transitive dependencies
} else {
ctx.PropertyErrorf("java_libs", "%q of type %q is not supported", depName, ctx.OtherModuleType(child))
@@ -2230,6 +2223,10 @@
}
} else if java.IsJniDepTag(depTag) {
return true
+ } else if java.IsXmlPermissionsFileDepTag(depTag) {
+ if prebuilt, ok := child.(android.PrebuiltEtcModule); ok {
+ filesInfo = append(filesInfo, apexFileForPrebuiltEtc(ctx, prebuilt, depName))
+ }
} else if am.CanHaveApexVariants() && am.IsInstallableToApex() {
ctx.ModuleErrorf("unexpected tag %q for indirect dependency %q", depTag, depName)
}
diff --git a/apex/apex_test.go b/apex/apex_test.go
index 0420586..c08a11e 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -3488,9 +3488,8 @@
"etc/permissions/foo.xml",
})
// Permission XML should point to the activated path of impl jar of java_sdk_library
- sdkLibrary := ctx.ModuleForTests("foo", "android_common_myapex").Module().(*java.SdkLibrary)
- xml := sdkLibrary.XmlPermissionsFileContent()
- ensureContains(t, xml, `<library name="foo" file="/apex/myapex/javalib/foo.jar"`)
+ sdkLibrary := ctx.ModuleForTests("foo.xml", "android_common_myapex").Rule("java_sdk_xml")
+ ensureContains(t, sdkLibrary.RuleParams.Command, `<library name=\"foo\" file=\"/apex/myapex/javalib/foo.jar\"`)
}
func TestCompatConfig(t *testing.T) {