Revised GPIO module interface + GPIO discovery logic
* The GpioHandler class is no longer a static singleton, rather an
ordinary object with a dynamic guard against multiple instances. This
makes testing/mocking a lot easier and simplifies implementation.
* It uses a basic, mockable udev interface; the module comes with
complete unit testing of the discovery mechanism.
* Corresponding changes to user classes, including UpdateAttempter and
UpdateCheckScheduler.
Note that the implementation of the test mode signaling protocol is
currently a no-op, always returning false, and hence has no effect on
the update process yet. This mechanism will be implemented in a later
CL.
BUG=chromium-os:25397
TEST=Builds and passes unit tests (including new ones)
Change-Id: I2f6254db6799ff5ef8616314890833f6e3269ff6
Reviewed-on: https://gerrit.chromium.org/gerrit/22869
Reviewed-by: Gilad Arnold <garnold@chromium.org>
Tested-by: Gilad Arnold <garnold@chromium.org>
Commit-Ready: Gilad Arnold <garnold@chromium.org>
diff --git a/update_attempter.cc b/update_attempter.cc
index 214f21a..d6c5496 100644
--- a/update_attempter.cc
+++ b/update_attempter.cc
@@ -106,7 +106,8 @@
UpdateAttempter::UpdateAttempter(PrefsInterface* prefs,
MetricsLibraryInterface* metrics_lib,
- DbusGlibInterface* dbus_iface)
+ DbusGlibInterface* dbus_iface,
+ GpioHandler* gpio_handler)
: processor_(new ActionProcessor()),
dbus_service_(NULL),
prefs_(prefs),
@@ -129,7 +130,9 @@
update_boot_flags_running_(false),
start_action_processor_(false),
policy_provider_(NULL),
- is_using_test_url_(false) {
+ is_using_test_url_(false),
+ is_test_update_attempted_(false),
+ gpio_handler_(gpio_handler) {
if (utils::FileExists(kUpdateCompletedMarker))
status_ = UPDATE_STATUS_UPDATED_NEED_REBOOT;
}
@@ -331,11 +334,11 @@
// Read GPIO signals and determine whether this is an automated test scenario.
// For safety, we only allow a test update to be performed once; subsequent
// update requests will be carried out normally.
- static bool is_test_used_once = false;
- bool is_test = !is_test_used_once && GpioHandler::IsGpioSignalingTest();
+ bool is_test = (!is_test_update_attempted_ && gpio_handler_ &&
+ gpio_handler_->IsTestModeSignaled());
if (is_test) {
LOG(INFO) << "test mode signaled";
- is_test_used_once = true;
+ is_test_update_attempted_ = true;
}
Update(app_version, omaha_url, true, true, is_test);