AU: disable GPIOs in production; some structural changes
Since we are not making use of the GPIO funcionality in UE for the
moment, it's been advised that it should be disabled. This CL does just
that, plus a few small changes:
* Adds a "no-op" GPIO implementation, which simply returns a constant
value every time it's being asked whether test-mode was signaled (in
this case, we set it to return false).
* The GPIO handler is embedded in SystemState. This makes sense from
both the conceptual and usability standpoint. The SystemState object
can be parametrized to initialize either a real or a no-op GPIO
handler.
BUG=chromium-os:32263
TEST=passes unit tests; does not engage GPIO protocol on x86-alex
Change-Id: I8121647baa7611041073dcf305beddab57c0e49c
Reviewed-on: https://gerrit.chromium.org/gerrit/40633
Reviewed-by: Jay Srinivasan <jaysri@chromium.org>
Commit-Queue: Gilad Arnold <garnold@chromium.org>
Tested-by: Gilad Arnold <garnold@chromium.org>
diff --git a/gpio_handler.h b/gpio_handler.h
index 0868cb5..1e25009 100644
--- a/gpio_handler.h
+++ b/gpio_handler.h
@@ -303,6 +303,26 @@
DISALLOW_COPY_AND_ASSIGN(StandardGpioHandler);
};
+
+// A "no-op" GPIO handler, initialized to return either test or normal mode
+// signal. This is useful for disabling the GPIO functionality in production
+// code.
+class NoopGpioHandler : public GpioHandler {
+ public:
+ // This constructor accepts a single argument, which is the value to be
+ // returned by repeated calls to IsTestModeSignaled().
+ NoopGpioHandler(bool is_test_mode) : is_test_mode_(is_test_mode) {}
+
+ // Returns the constant Boolean value handed to the constructor.
+ virtual bool IsTestModeSignaled();
+
+ private:
+ // Stores the constant value to return on subsequent test mode checks.
+ bool is_test_mode_;
+
+ DISALLOW_COPY_AND_ASSIGN(NoopGpioHandler);
+};
+
} // namespace chromeos_update_engine
#endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_GPIO_HANDLER_H__