From 34ed38743ee3d03886d5990330242e6f9367129c Mon Sep 17 00:00:00 2001 From: Dmitry Shmidt Date: Mon, 7 Oct 2019 12:43:36 -0700 Subject: light: Allow blank_screen utiltiy to get color from command line Bug: 142058809 Test: blank_screen 0xFFFFFFFF Change-Id: I4efdaaa2397b076e5699a75852bb15bfb1f6c5f8 Signed-off-by: Dmitry Shmidt --- light/utils/main.cpp | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'light/utils/main.cpp') diff --git a/light/utils/main.cpp b/light/utils/main.cpp index d07e799ab9..b83413246b 100644 --- a/light/utils/main.cpp +++ b/light/utils/main.cpp @@ -25,7 +25,7 @@ void error(const std::string& msg) { std::cerr << msg << std::endl; } -int main() { +int main(int argc, char* argv[]) { using ::android::hardware::hidl_vec; using ::android::hardware::light::V2_0::Brightness; using ::android::hardware::light::V2_0::Flash; @@ -41,10 +41,29 @@ int main() { return -1; } - const static LightState off = { - .color = 0u, .flashMode = Flash::NONE, .brightnessMode = Brightness::USER, + static LightState off = { + .color = 0u, + .flashMode = Flash::NONE, + .brightnessMode = Brightness::USER, }; + if (argc > 2) { + error("Usage: blank_screen [color]"); + return -1; + } + + if (argc > 1) { + char* col_ptr; + unsigned int col_new; + + col_new = strtoul(argv[1], &col_ptr, 0); + if (*col_ptr != '\0') { + error("Failed to convert " + std::string(argv[1]) + " to number"); + return -1; + } + off.color = col_new; + } + service->getSupportedTypes([&](const hidl_vec& types) { for (Type type : types) { Status ret = service->setLight(type, off); -- cgit v1.2.3