Add support for rollback_index to android_filesystem module
Bug: 287593065
Test: m
Change-Id: I01e986b2d8e3d992533dc7e2c07e4cdbeaca2c00
diff --git a/filesystem/filesystem.go b/filesystem/filesystem.go
index e640c5d..61127bf 100644
--- a/filesystem/filesystem.go
+++ b/filesystem/filesystem.go
@@ -20,6 +20,7 @@
"io"
"path/filepath"
"slices"
+ "strconv"
"strings"
"android/soong/android"
@@ -82,6 +83,9 @@
// 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 @@
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