From 69545b9cf95eff6e5afab13702063415036dcaa5 Mon Sep 17 00:00:00 2001 From: Romain Goyet Date: Fri, 4 May 2018 15:52:03 +0200 Subject: [PATCH] [apps] Handle Ion::Events::USBPlug in processEvent This gives apps a chance to catch this event. This is used in the hardware test. --- apps/apps_container.cpp | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/apps/apps_container.cpp b/apps/apps_container.cpp index 0e4501623..0f0eebdc4 100644 --- a/apps/apps_container.cpp +++ b/apps/apps_container.cpp @@ -86,19 +86,7 @@ bool AppsContainer::dispatchEvent(Ion::Events::Event event) { bool didProcessEvent = false; - if (event == Ion::Events::USBPlug) { - if (Ion::USB::isPlugged()) { - if (GlobalPreferences::sharedGlobalPreferences()->examMode() == GlobalPreferences::ExamMode::Activate) { - displayExamModePopUp(false); - } else { - Ion::USB::enable(); - } - Ion::Backlight::setBrightness(Ion::Backlight::MaxBrightness); - } else { - Ion::USB::disable(); - } - didProcessEvent = true; - } else if (event == Ion::Events::USBEnumeration) { + if (event == Ion::Events::USBEnumeration) { if (Ion::USB::isPlugged()) { App::Snapshot * activeSnapshot = (activeApp() == nullptr ? appSnapshotAtIndex(0) : activeApp()->snapshot()); switchTo(usbConnectedAppSnapshot()); @@ -132,6 +120,19 @@ bool AppsContainer::dispatchEvent(Ion::Events::Event event) { } bool AppsContainer::processEvent(Ion::Events::Event event) { + if (event == Ion::Events::USBPlug) { + if (Ion::USB::isPlugged()) { + if (GlobalPreferences::sharedGlobalPreferences()->examMode() == GlobalPreferences::ExamMode::Activate) { + displayExamModePopUp(false); + } else { + Ion::USB::enable(); + } + Ion::Backlight::setBrightness(Ion::Backlight::MaxBrightness); + } else { + Ion::USB::disable(); + } + return true; + } if (event == Ion::Events::Home || event == Ion::Events::Back) { switchTo(appSnapshotAtIndex(0)); return true;