flipperzero-firmware/applications/gpio/scenes/gpio_scene_usb_uart_close_rpc.c
Nikolay Minaylov 38e92cf789
[FL-2315] USB Mode switch lock (#1036)
* usb mode switch lock
* lock_mutex removed
* Wait for session termination in rpc_cli, lock badusb and u2f if rpc session is opened

Co-authored-by: あく <alleteam@gmail.com>
2022-03-24 18:45:03 +03:00

54 lines
1.5 KiB
C

#include "../gpio_app_i.h"
#include "../gpio_custom_event.h"
static void gpio_scene_usb_uart_close_rpc_event_callback(
GuiButtonType result,
InputType type,
void* context) {
furi_assert(context);
GpioApp* app = context;
if((result == GuiButtonTypeLeft) && (type == InputTypeShort)) {
view_dispatcher_send_custom_event(app->view_dispatcher, GpioCustomEventErrorBack);
}
}
void gpio_scene_usb_uart_close_rpc_on_enter(void* context) {
GpioApp* app = context;
widget_add_string_multiline_element(
app->widget,
63,
10,
AlignCenter,
AlignTop,
FontSecondary,
"Disconnect from\ncompanion app\nto use this function");
widget_add_button_element(
app->widget, GuiButtonTypeLeft, "Back", gpio_scene_usb_uart_close_rpc_event_callback, app);
view_dispatcher_switch_to_view(app->view_dispatcher, GpioAppViewUsbUartCloseRpc);
}
bool gpio_scene_usb_uart_close_rpc_on_event(void* context, SceneManagerEvent event) {
GpioApp* app = context;
bool consumed = false;
if(event.type == SceneManagerEventTypeCustom) {
if(event.event == GpioCustomEventErrorBack) {
if(!scene_manager_previous_scene(app->scene_manager)) {
scene_manager_stop(app->scene_manager);
view_dispatcher_stop(app->view_dispatcher);
}
consumed = true;
}
}
return consumed;
}
void gpio_scene_usb_uart_close_rpc_on_exit(void* context) {
GpioApp* app = context;
widget_reset(app->widget);
}