aboutsummaryrefslogtreecommitdiff
path: root/fsgen/util.go
diff options
context:
space:
mode:
Diffstat (limited to 'fsgen/util.go')
-rw-r--r--fsgen/util.go55
1 files changed, 54 insertions, 1 deletions
diff --git a/fsgen/util.go b/fsgen/util.go
index 008f9fef3..356fdbb90 100644
--- a/fsgen/util.go
+++ b/fsgen/util.go
@@ -16,15 +16,17 @@ package fsgen
import (
"android/soong/android"
+ "android/soong/etc"
"android/soong/filesystem"
"fmt"
+ "github.com/google/blueprint/proptools"
"strconv"
"strings"
)
// Returns the appropriate dpi for recovery common resources selection. Replicates the logic in
// https://cs.android.com/android/platform/superproject/main/+/main:build/make/core/Makefile;l=2536;drc=a6af369e71ded123734523ea640b97b70a557cb9
-func getDpi(ctx android.LoadHookContext) string {
+func getDpi(ctx android.EarlyModuleContext) string {
recoveryDensity := ctx.Config().ProductVariables().PartitionVarsForSoongMigrationOnlyDoNotUse.TargetScreenDensity
if len(recoveryDensity) == 0 {
aaptPreferredConfig := ctx.Config().ProductAAPTPreferredConfig()
@@ -69,6 +71,31 @@ func getRecoveryFontModuleName(ctx android.LoadHookContext) string {
return "recovery-fonts-12"
}
+// Returns the module name and image width for recovery background image generation.
+// https://source.corp.google.com/h/googleplex-android/platform/build/+/f1cb088a1446adc54950bd6b447eac9fc90831f6:core/Makefile;l=2539-2556;drc=acc8d6594498f50db20f04e0e05fff09750c412c;bpv=1;bpt=0
+func getRecoveryBackgroundPicturesGeneratorModuleName(ctx android.EarlyModuleContext) (string, int64) {
+ dpi := getDpi(ctx)
+ if !android.InList(dpi, []string{"xxxhdpi", "xxhdpi"}) {
+ return "", -1
+ }
+ var recoveryUiScreenWidth int64
+ if dpi == "xxxhdpi" {
+ recoveryUiScreenWidth = 1440 - 10
+ } else { // xxhdpi
+ recoveryUiScreenWidth = 1080 - 10
+ }
+
+ if marginWidth, exists := ctx.Config().ProductVariables().PartitionVarsForSoongMigrationOnlyDoNotUse.PrivateRecoveryUiProperties["margin_width"]; exists && marginWidth != "" {
+ if marginWidth, err := strconv.ParseInt(marginWidth, 10, 64); err == nil {
+ recoveryUiScreenWidth -= marginWidth
+ } else {
+ ctx.ModuleErrorf("Error parsing TARGET_RECOVERY_UI_MARGIN_WIDTH %s", err)
+ }
+ }
+
+ return generatedModuleNameForPartition(ctx.Config(), "background_recovery_images"), recoveryUiScreenWidth
+}
+
// Returns a new list of symlinks with prefix added to the dest directory for all symlinks
func symlinksWithNamePrefix(symlinks []filesystem.SymlinkDefinition, prefix string) []filesystem.SymlinkDefinition {
ret := make([]filesystem.SymlinkDefinition, len(symlinks))
@@ -77,3 +104,29 @@ func symlinksWithNamePrefix(symlinks []filesystem.SymlinkDefinition, prefix stri
}
return ret
}
+
+// Creates a prebuilt_etc for recovery partition if TARGET_RECOVERY_WIPE is not empty.
+// Returns the name of the autogenerated module.
+func createTargetRecoveryWipeModuleName(ctx android.LoadHookContext) string {
+ recoveryWipe := ctx.Config().ProductVariables().PartitionVarsForSoongMigrationOnlyDoNotUse.TargetRecoveryWipe
+ if recoveryWipe == "" {
+ return ""
+ }
+ name := generatedModuleName(ctx.Config(), "target_recovery_wipe")
+ ctx.CreateModuleInDirectory(
+ etc.PrebuiltEtcFactory,
+ ".",
+ &struct {
+ Name *string
+ Srcs []string
+ Dsts []string
+ Recovery *bool
+ }{
+ Name: proptools.StringPtr(name),
+ Srcs: []string{recoveryWipe},
+ Dsts: []string{"recovery.wipe"},
+ Recovery: proptools.BoolPtr(true),
+ },
+ )
+ return name
+}