diff options
author | Yifan Hong <elsk@google.com> | 2019-07-23 14:04:39 -0700 |
---|---|---|
committer | Yifan Hong <elsk@google.com> | 2019-07-31 17:43:14 +0000 |
commit | 186bb68d4eb9a5767245b764522b26b466aa0cb6 (patch) | |
tree | 55eff6300fe72d0b2eaca5e08a8b93e4e1269996 /dynamic_partition_control_interface.h | |
parent | 012508efa3bb00b5b458caa918f2960653f41df2 (diff) |
[REFACTOR] DynamicPartitionControl: combine DAP feature flag APIs
Combine IsDynamicPartitionsEnabled/Retrofit into one API that
returns a FeatureFlag struct instead.
This allows us to add new feature flags more easily.
Test: unittest
Change-Id: I32f0f0c4d5c636d2eac3bf99d6f92fcc6b71c7a9
Diffstat (limited to 'dynamic_partition_control_interface.h')
-rw-r--r-- | dynamic_partition_control_interface.h | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/dynamic_partition_control_interface.h b/dynamic_partition_control_interface.h index 12e62e08..32fbbe4a 100644 --- a/dynamic_partition_control_interface.h +++ b/dynamic_partition_control_interface.h @@ -30,15 +30,25 @@ namespace chromeos_update_engine { +struct FeatureFlag { + enum class Value { NONE = 0, RETROFIT, LAUNCH }; + constexpr explicit FeatureFlag(Value value) : value_(value) {} + constexpr bool IsEnabled() const { return value_ != Value::NONE; } + constexpr bool IsRetrofit() const { return value_ == Value::RETROFIT; } + + private: + Value value_; +}; + class DynamicPartitionControlInterface { public: virtual ~DynamicPartitionControlInterface() = default; - // Return true iff dynamic partitions is enabled on this device. - virtual bool IsDynamicPartitionsEnabled() = 0; - - // Return true iff dynamic partitions is retrofitted on this device. - virtual bool IsDynamicPartitionsRetrofit() = 0; + // Return the feature flags of dynamic partitions on this device. + // Return RETROFIT iff dynamic partitions is retrofitted on this device, + // LAUNCH iff this device is launched with dynamic partitions, + // NONE iff dynamic partitions is disabled on this device. + virtual FeatureFlag GetDynamicPartitionsFeatureFlag() = 0; // Map logical partition on device-mapper. // |super_device| is the device path of the physical partition ("super"). |