Disable() must not be enabled unexpectedly

When a module is disabled by calling Disable(), it could be
unexpectedly enabled by the archMutator. For example, a module has
```
enabled : false,
arch : {
    arm64 : {
        enabled : true,
    },
}
```
When this modules is disabled by calling Disable() before the
archMutator, it became enabled again ignoring Disable() command.
By defining the `ForcedDisabled` property, we can disable a module
regardless of `Enabled` property.

Bug: 161565086
Test: m
Change-Id: I443720715edbac25cb6d7c3d9eb1bc9806719161
This commit is contained in:
Justin Yun 2020-07-31 23:07:17 +09:00
parent 359d4f3374
commit 32f053b97e
1 changed files with 7 additions and 1 deletions

View File

@ -548,6 +548,9 @@ type commonProperties struct {
SkipInstall bool `blueprint:"mutated"`
// Disabled by mutators. If set to true, it overrides Enabled property.
ForcedDisabled bool `blueprint:"mutated"`
NamespaceExportedToMake bool `blueprint:"mutated"`
MissingDeps []string `blueprint:"mutated"`
@ -1022,6 +1025,9 @@ func (m *ModuleBase) PartitionTag(config DeviceConfig) string {
}
func (m *ModuleBase) Enabled() bool {
if m.commonProperties.ForcedDisabled {
return false
}
if m.commonProperties.Enabled == nil {
return !m.Os().DefaultDisabled
}
@ -1029,7 +1035,7 @@ func (m *ModuleBase) Enabled() bool {
}
func (m *ModuleBase) Disable() {
m.commonProperties.Enabled = proptools.BoolPtr(false)
m.commonProperties.ForcedDisabled = true
}
func (m *ModuleBase) SkipInstall() {