Add platform_apis property to APEX module type
The property is used to allow non-updatable APEXes to use platform APIs
(e.g. symbols marked as "# platform-only").
Bug: 191637950
Test: m com.android.virt com.android.compos
Merged-In: Id2410b4e38a78ec2146a42298840954381a7c472
Change-Id: Id2410b4e38a78ec2146a42298840954381a7c472
(cherry picked from commit fb63625a7f147735f97d5cc9eaabf3f93cf0d0a2)
diff --git a/apex/apex.go b/apex/apex.go
index 7ffa6cc..80fb782 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -130,6 +130,10 @@
// symlinking to the system libs. Default is true.
Updatable *bool
+ // Whether this APEX can use platform APIs or not. Can be set to true only when `updatable:
+ // false`. Default is false.
+ Platform_apis *bool
+
// Whether this APEX is installable to one of the partitions like system, vendor, etc.
// Default: true.
Installable *bool
@@ -919,6 +923,7 @@
MinSdkVersion: minSdkVersion,
RequiredSdks: a.RequiredSdks(),
Updatable: a.Updatable(),
+ UsePlatformApis: a.UsePlatformApis(),
InApexVariants: []string{mctx.ModuleName()}, // could be com.android.foo
InApexModules: []string{a.Name()}, // could be com.mycompany.android.foo
ApexContents: []*android.ApexContents{apexContents},
@@ -1321,6 +1326,10 @@
return proptools.BoolDefault(a.properties.Updatable, true)
}
+func (a *apexBundle) UsePlatformApis() bool {
+ return proptools.BoolDefault(a.properties.Platform_apis, false)
+}
+
// getCertString returns the name of the cert that should be used to sign this APEX. This is
// basically from the "certificate" property, but could be overridden by the device config.
func (a *apexBundle) getCertString(ctx android.BaseModuleContext) string {
@@ -2374,6 +2383,9 @@
if String(a.properties.Min_sdk_version) == "" {
ctx.PropertyErrorf("updatable", "updatable APEXes should set min_sdk_version as well")
}
+ if a.UsePlatformApis() {
+ ctx.PropertyErrorf("updatable", "updatable APEXes can't use platform APIs")
+ }
a.checkJavaStableSdkVersion(ctx)
a.checkClasspathFragments(ctx)
}