Add Gob support of ApiLevel and applicableLicensesPropertyImpl.
Bug: 358427516
Test: Manual tests.
Change-Id: I23ada602ee6c2e21238271b0b286a42ea8461a14
diff --git a/android/api_levels.go b/android/api_levels.go
index c042eeb..c83fae8 100644
--- a/android/api_levels.go
+++ b/android/api_levels.go
@@ -19,6 +19,8 @@
"fmt"
"strconv"
"strings"
+
+ "github.com/google/blueprint/gobtools"
)
func init() {
@@ -52,6 +54,34 @@
isPreview bool
}
+type apiLevelGob struct {
+ Value string
+ Number int
+ IsPreview bool
+}
+
+func (a *ApiLevel) ToGob() *apiLevelGob {
+ return &apiLevelGob{
+ Value: a.value,
+ Number: a.number,
+ IsPreview: a.isPreview,
+ }
+}
+
+func (a *ApiLevel) FromGob(data *apiLevelGob) {
+ a.value = data.Value
+ a.number = data.Number
+ a.isPreview = data.IsPreview
+}
+
+func (a ApiLevel) GobEncode() ([]byte, error) {
+ return gobtools.CustomGobEncode[apiLevelGob](&a)
+}
+
+func (a *ApiLevel) GobDecode(data []byte) error {
+ return gobtools.CustomGobDecode[apiLevelGob](data, a)
+}
+
func (this ApiLevel) FinalInt() int {
if this.IsInvalid() {
panic(fmt.Errorf("%v is not a recognized api_level\n", this))