summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--android/neverallow.go2
-rw-r--r--android/variable.go2
-rw-r--r--fsgen/Android.bp1
-rw-r--r--fsgen/filesystem_creator.go16
-rw-r--r--fsgen/fsgen_mutators.go3
-rw-r--r--fsgen/util.go60
6 files changed, 83 insertions, 1 deletions
diff --git a/android/neverallow.go b/android/neverallow.go
index 566d73c54..fdcbe1cc8 100644
--- a/android/neverallow.go
+++ b/android/neverallow.go
@@ -249,6 +249,7 @@ func createInstallInRootAllowingRules() []Rule {
NotModuleType("prebuilt_sbin").
NotModuleType("prebuilt_system").
NotModuleType("prebuilt_first_stage_ramdisk").
+ NotModuleType("prebuilt_res").
Because("install_in_root is only for init_first_stage or librecovery_ui_ext."),
}
}
@@ -344,7 +345,6 @@ func createPrebuiltEtcBpDefineRule() Rule {
"prebuilt_priv_app",
"prebuilt_rfs",
"prebuilt_framework",
- "prebuilt_res",
"prebuilt_wlc_upt",
"prebuilt_odm",
"prebuilt_vendor_dlkm",
diff --git a/android/variable.go b/android/variable.go
index 5b0af79e6..3829f483b 100644
--- a/android/variable.go
+++ b/android/variable.go
@@ -670,6 +670,8 @@ type PartitionVariables struct {
VendorRamdiskKernelOptionsFile string `json:",omitempty"`
ProductFsverityGenerateMetadata bool `json:",omitempty"`
+
+ TargetScreenDensity string `json:",omitempty"`
}
func boolPtr(v bool) *bool {
diff --git a/fsgen/Android.bp b/fsgen/Android.bp
index a0225811e..e8065f351 100644
--- a/fsgen/Android.bp
+++ b/fsgen/Android.bp
@@ -17,6 +17,7 @@ bootstrap_go_package {
"filesystem_creator.go",
"fsgen_mutators.go",
"prebuilt_etc_modules_gen.go",
+ "util.go",
"vbmeta_partitions.go",
],
testSrcs: [
diff --git a/fsgen/filesystem_creator.go b/fsgen/filesystem_creator.go
index cd29dfdfc..745aeaaa7 100644
--- a/fsgen/filesystem_creator.go
+++ b/fsgen/filesystem_creator.go
@@ -415,6 +415,22 @@ func partitionSpecificFsProps(ctx android.EarlyModuleContext, fsProps *filesyste
"first_stage_ramdisk/sys",
})
}
+ case "recovery":
+ // Following https://cs.android.com/android/platform/superproject/main/+/main:build/make/core/Makefile;l=2826;drc=ad7cfb56010cb22c3aa0e70cf71c804352553526
+ fsProps.Dirs = android.NewSimpleConfigurable([]string{
+ "sdcard",
+ "tmp",
+ })
+ fsProps.Symlinks = []filesystem.SymlinkDefinition{
+ {
+ Target: proptools.StringPtr("/system/bin/init"),
+ Name: proptools.StringPtr("init"),
+ },
+ {
+ Target: proptools.StringPtr("prop.default"),
+ Name: proptools.StringPtr("default.prop"),
+ },
+ }
}
}
diff --git a/fsgen/fsgen_mutators.go b/fsgen/fsgen_mutators.go
index b99e2dafa..f0a54db3a 100644
--- a/fsgen/fsgen_mutators.go
+++ b/fsgen/fsgen_mutators.go
@@ -162,6 +162,9 @@ func createFsGenState(ctx android.LoadHookContext, generatedPrebuiltEtcModuleNam
(*fsGenState.fsDeps["product"])["system_other_avbpubkey"] = defaultDepCandidateProps(ctx.Config())
}
+ // Add common resources `prebuilt_res` module as dep of recovery partition
+ (*fsGenState.fsDeps["recovery"])[fmt.Sprintf("recovery-resources-common-%s", getDpi(ctx))] = defaultDepCandidateProps(ctx.Config())
+
return &fsGenState
}).(*FsGenState)
}
diff --git a/fsgen/util.go b/fsgen/util.go
new file mode 100644
index 000000000..9ab3ad809
--- /dev/null
+++ b/fsgen/util.go
@@ -0,0 +1,60 @@
+// Copyright (C) 2024 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package fsgen
+
+import (
+ "android/soong/android"
+ "fmt"
+ "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 {
+ recoveryDensity := ctx.Config().ProductVariables().PartitionVarsForSoongMigrationOnlyDoNotUse.TargetScreenDensity
+ if len(recoveryDensity) == 0 {
+ aaptPreferredConfig := ctx.Config().ProductAAPTPreferredConfig()
+ if len(aaptPreferredConfig) > 0 {
+ recoveryDensity = aaptPreferredConfig
+ } else {
+ recoveryDensity = "mdpi"
+ }
+ }
+ if !android.InList(recoveryDensity, []string{"xxxhdpi", "xxhdpi", "xhdpi", "hdpi", "mdpi"}) {
+ recoveryDensity = strings.TrimSuffix(recoveryDensity, "dpi")
+ dpiInt, err := strconv.ParseInt(recoveryDensity, 10, 64)
+ if err != nil {
+ panic(fmt.Sprintf("Error in parsing recoveryDensity: %s", err.Error()))
+ }
+ if dpiInt >= 560 {
+ recoveryDensity = "xxxhdpi"
+ } else if dpiInt >= 400 {
+ recoveryDensity = "xxhdpi"
+ } else if dpiInt >= 280 {
+ recoveryDensity = "xhdpi"
+ } else if dpiInt >= 200 {
+ recoveryDensity = "hdpi"
+ } else {
+ recoveryDensity = "mdpi"
+ }
+ }
+
+ if p := android.ExistentPathForSource(ctx, fmt.Sprintf("bootable/recovery/res-%s", recoveryDensity)); !p.Valid() {
+ recoveryDensity = "xhdpi"
+ }
+
+ return recoveryDensity
+}