Allow extending of the list of directories to be scanned for VSDK

Bug: 180925851
Bug: 181564692
Test: m nothing, manually
Change-Id: Ifff95db4c9ec362322fecca08f7fd1a7b60755c0
This commit is contained in:
Justin DeMartino
2021-02-24 10:49:43 -08:00
parent 05f72de083
commit 383bfb392f
5 changed files with 125 additions and 70 deletions

View File

@@ -1411,6 +1411,62 @@ func (c *deviceConfig) RecoverySnapshotModules() map[string]bool {
return c.config.productVariables.RecoverySnapshotModules
}
func createDirsMap(previous map[string]bool, dirs []string) (map[string]bool, error) {
var ret = make(map[string]bool)
for _, dir := range dirs {
clean := filepath.Clean(dir)
if previous[clean] || ret[clean] {
return nil, fmt.Errorf("Duplicate entry %s", dir)
}
ret[clean] = true
}
return ret, nil
}
func (c *deviceConfig) createDirsMapOnce(onceKey OnceKey, previous map[string]bool, dirs []string) map[string]bool {
dirMap := c.Once(onceKey, func() interface{} {
ret, err := createDirsMap(previous, dirs)
if err != nil {
panic(fmt.Errorf("%s: %w", onceKey.key, err))
}
return ret
})
if dirMap == nil {
return nil
}
return dirMap.(map[string]bool)
}
var vendorSnapshotDirsExcludedKey = NewOnceKey("VendorSnapshotDirsExcludedMap")
func (c *deviceConfig) VendorSnapshotDirsExcludedMap() map[string]bool {
return c.createDirsMapOnce(vendorSnapshotDirsExcludedKey, nil,
c.config.productVariables.VendorSnapshotDirsExcluded)
}
var vendorSnapshotDirsIncludedKey = NewOnceKey("VendorSnapshotDirsIncludedMap")
func (c *deviceConfig) VendorSnapshotDirsIncludedMap() map[string]bool {
excludedMap := c.VendorSnapshotDirsExcludedMap()
return c.createDirsMapOnce(vendorSnapshotDirsIncludedKey, excludedMap,
c.config.productVariables.VendorSnapshotDirsIncluded)
}
var recoverySnapshotDirsExcludedKey = NewOnceKey("RecoverySnapshotDirsExcludedMap")
func (c *deviceConfig) RecoverySnapshotDirsExcludedMap() map[string]bool {
return c.createDirsMapOnce(recoverySnapshotDirsExcludedKey, nil,
c.config.productVariables.RecoverySnapshotDirsExcluded)
}
var recoverySnapshotDirsIncludedKey = NewOnceKey("RecoverySnapshotDirsIncludedMap")
func (c *deviceConfig) RecoverySnapshotDirsIncludedMap() map[string]bool {
excludedMap := c.RecoverySnapshotDirsExcludedMap()
return c.createDirsMapOnce(recoverySnapshotDirsIncludedKey, excludedMap,
c.config.productVariables.RecoverySnapshotDirsIncluded)
}
func (c *deviceConfig) ShippingApiLevel() ApiLevel {
if c.config.productVariables.ShippingApiLevel == nil {
return NoneApiLevel