Use new bitwise operators for UpdateAttemptFlags
Switch the bitwise operator overloads to the new standardized ones from
libbrillo.
Test: unit-tests
Test: manual exercising of update_engine via APIs
Change-Id: Ia8bd7d90adc9469826a906c127c87bfac8272f6c
(cherry picked from commit 931b955fc5c8427b90a123859e1dab22baae7f7d)
diff --git a/client_library/include/update_engine/update_status.h b/client_library/include/update_engine/update_status.h
index d93ca91..d53daab 100644
--- a/client_library/include/update_engine/update_status.h
+++ b/client_library/include/update_engine/update_status.h
@@ -19,6 +19,8 @@
#include <string>
+#include <brillo/enum_flags.h>
+
namespace update_engine {
enum class UpdateStatus {
@@ -44,21 +46,8 @@
kFlagRestrictDownload = (1 << 1),
};
-// These bit-wise operators for the above flags allow for standard bit-wise
-// operations to return values in an expected manner, with the need to
-// continually cast the results back to UpdateAttemptFlags after the implicit
-// conversion to int from enum to perform the bitwise comparison using the
-// underlying type.
-inline UpdateAttemptFlags operator|(const UpdateAttemptFlags& l,
- const UpdateAttemptFlags& r) {
- return static_cast<UpdateAttemptFlags>(static_cast<const int32_t&>(l) |
- static_cast<const int32_t&>(r));
-}
-inline UpdateAttemptFlags operator&(const UpdateAttemptFlags& l,
- const UpdateAttemptFlags& r) {
- return static_cast<UpdateAttemptFlags>(static_cast<const int32_t&>(l) &
- static_cast<const int32_t&>(r));
-}
+// Enable bit-wise operators for the above enumeration of flag values.
+DECLARE_FLAGS_ENUM(UpdateAttemptFlags);
struct UpdateEngineStatus {
// When the update_engine last checked for updates (ms since Epoch)