Add TARGET_FORCE_APEX_SYMLINK_OPTIMIZATION
The APEX symlink optimization is a build-time trick to save the
storage/RAM usage of APEX by replacing some files in APEX with symlinks
to the files in the system partition. The optimization however is
automatically turned off for 'updatable: true' APEXes because doing the
optimization for them will hide the sys-health implication until when
the APEXes are built unbundled (i.e. prebuilt) and thus the
optimization is impossible.
TARGET_FORCE_APEX_SYMLINK_OPTIMIZATION forcibly disables the safety net.
When it is set to true, the symlink optimization is done regardless of
the 'updatable' property. This is useful for some of the devices like Go
where most APEXes (even the 'updatable: true' ones) should be
effectively non-updatable.
Bug: 175630508
Test: TARGET_FORCE_APEX_SYMLINK_OPTIMIZATION=true m and check that
updatable APEXes have symlinks to system libs
Change-Id: I26f72e5d5ebccc2d1e09c2a2f743db14937eb39a
diff --git a/android/config.go b/android/config.go
index 89467d8..89964a6 100644
--- a/android/config.go
+++ b/android/config.go
@@ -1272,6 +1272,10 @@
return Bool(c.productVariables.Flatten_apex)
}
+func (c *config) ForceApexSymlinkOptimization() bool {
+ return Bool(c.productVariables.ForceApexSymlinkOptimization)
+}
+
func (c *config) CompressedApex() bool {
return Bool(c.productVariables.CompressedApex)
}
diff --git a/android/variable.go b/android/variable.go
index 753ddd7..3310e5f 100644
--- a/android/variable.go
+++ b/android/variable.go
@@ -320,9 +320,10 @@
Ndk_abis *bool `json:",omitempty"`
Exclude_draft_ndk_apis *bool `json:",omitempty"`
- Flatten_apex *bool `json:",omitempty"`
- CompressedApex *bool `json:",omitempty"`
- Aml_abis *bool `json:",omitempty"`
+ Flatten_apex *bool `json:",omitempty"`
+ ForceApexSymlinkOptimization *bool `json:",omitempty"`
+ CompressedApex *bool `json:",omitempty"`
+ Aml_abis *bool `json:",omitempty"`
DexpreoptGlobalConfig *string `json:",omitempty"`
diff --git a/apex/apex.go b/apex/apex.go
index 9fb616d..2182069 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -1913,9 +1913,11 @@
a.linkToSystemLib = false
}
+ forced := ctx.Config().ForceApexSymlinkOptimization()
+
// We don't need the optimization for updatable APEXes, as it might give false signal
- // to the system health when the APEXes are still bundled (b/149805758)
- if a.Updatable() && a.properties.ApexType == imageApex {
+ // to the system health when the APEXes are still bundled (b/149805758).
+ if !forced && a.Updatable() && a.properties.ApexType == imageApex {
a.linkToSystemLib = false
}