diff options
author | 2025-03-05 18:35:17 +0000 | |
---|---|---|
committer | 2025-03-08 00:57:14 +0000 | |
commit | 619b6ef5c5a06fe3eaaa3fd0bdbd44e6795b29e4 (patch) | |
tree | 06e14969e1014b1f55c2cc9f7c947b5d1e9fc24f /android/api_levels.go | |
parent | b31c77b9b8c8daca78c8ec5cceb6f185fe95dec9 (diff) |
Add Gob support of ApiLevel and applicableLicensesPropertyImpl.
Bug: 358427516
Test: Manual tests.
Change-Id: I23ada602ee6c2e21238271b0b286a42ea8461a14
Diffstat (limited to 'android/api_levels.go')
-rw-r--r-- | android/api_levels.go | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/android/api_levels.go b/android/api_levels.go index c042eebee..c83fae878 100644 --- a/android/api_levels.go +++ b/android/api_levels.go @@ -19,6 +19,8 @@ import ( "fmt" "strconv" "strings" + + "github.com/google/blueprint/gobtools" ) func init() { @@ -52,6 +54,34 @@ type ApiLevel struct { 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)) |