Add support for rollback_index to android_filesystem module

Bug: 287593065
Test: m
Change-Id: I01e986b2d8e3d992533dc7e2c07e4cdbeaca2c00
This commit is contained in:
Nikita Ioffe
2024-03-27 22:19:30 +00:00
parent 576b4f1a77
commit 2c8cdc6166

View File

@@ -20,6 +20,7 @@ import (
"io"
"path/filepath"
"slices"
"strconv"
"strings"
"android/soong/android"
@@ -82,6 +83,9 @@ type filesystemProperties struct {
// avbtool. Default used by avbtool is sha1.
Avb_hash_algorithm *string
// The index used to prevent rollback of the image. Only used if use_avb is true.
Rollback_index *int64
// Name of the partition stored in vbmeta desc. Defaults to the name of this module.
Partition_name *string
@@ -352,6 +356,13 @@ func (f *filesystem) buildPropFile(ctx android.ModuleContext) (propFile android.
if hashAlgorithm := proptools.String(f.properties.Avb_hash_algorithm); hashAlgorithm != "" {
avb_add_hashtree_footer_args += " --hash_algorithm " + hashAlgorithm
}
if f.properties.Rollback_index != nil {
rollbackIndex := proptools.Int(f.properties.Rollback_index)
if rollbackIndex < 0 {
ctx.PropertyErrorf("rollback_index", "Rollback index must be non-negative")
}
avb_add_hashtree_footer_args += " --rollback_index " + strconv.Itoa(rollbackIndex)
}
securityPatchKey := "com.android.build." + f.partitionName() + ".security_patch"
securityPatchValue := ctx.Config().PlatformSecurityPatch()
avb_add_hashtree_footer_args += " --prop " + securityPatchKey + ":" + securityPatchValue