update_engine: Break instantiating system policies into their own files
This removes the use of __ANDROID__ for instantiating system
policies (Chrome OS vs. Android) by defining an interface and
implementing the interface in each individual code base.
BUG=none
TEST=FEATURES=test emerge update_engine
Did not build the android side, but hopefully it is correct as the code
change is minimal and problems can get caught in reviews.
Change-Id: I3931a9bed9ee4a9edfba5d712b05d487af1af813
Reviewed-on: https://chromium-review.googlesource.com/c/aosp/platform/system/update_engine/+/1755263
Tested-by: Amin Hassani <ahassani@chromium.org>
Commit-Queue: Amin Hassani <ahassani@chromium.org>
Reviewed-by: Sen Jiang <senj@chromium.org>
diff --git a/update_manager/update_manager.cc b/update_manager/update_manager.cc
index 0069496..5664a5c 100644
--- a/update_manager/update_manager.cc
+++ b/update_manager/update_manager.cc
@@ -15,12 +15,6 @@
//
#include "update_engine/update_manager/update_manager.h"
-
-#ifdef __ANDROID__
-#include "update_engine/update_manager/android_things_policy.h"
-#else
-#include "update_engine/update_manager/chromeos_policy.h"
-#endif // __ANDROID__
#include "update_engine/update_manager/state.h"
namespace chromeos_update_manager {
@@ -29,18 +23,13 @@
base::TimeDelta evaluation_timeout,
base::TimeDelta expiration_timeout,
State* state)
- : default_policy_(clock),
+ : policy_(GetSystemPolicy()),
+ default_policy_(clock),
state_(state),
clock_(clock),
evaluation_timeout_(evaluation_timeout),
expiration_timeout_(expiration_timeout),
- weak_ptr_factory_(this) {
-#ifdef __ANDROID__
- policy_.reset(new AndroidThingsPolicy());
-#else
- policy_.reset(new ChromeOSPolicy());
-#endif // __ANDROID__
-}
+ weak_ptr_factory_(this) {}
UpdateManager::~UpdateManager() {
// Remove pending main loop events associated with any of the outstanding