From 2b2a7984078d33aa91dfdbde2543491d5f487d8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=82=E3=81=8F?= Date: Sat, 29 Jan 2022 14:20:55 +0300 Subject: [PATCH] Pre-RC Bug Fixes and Gui lockdown mode. (#973) * Rfid: fix incorrect StringElement parameters * Gui, Desktop: add lockdown mode, integrate with desktop. * Gui: fix runglish in doxy --- applications/desktop/views/desktop_locked.c | 12 ++++ applications/gui/gui.c | 64 +++++++++++++++--- applications/gui/gui.h | 10 +++ applications/gui/gui_i.h | 1 + .../scene/lfrfid_app_scene_read_success.cpp | 2 +- assets/compiled/assets_icons.c | 4 ++ assets/compiled/assets_icons.h | 1 + assets/icons/StatusBar/Attention_5x8.png | Bin 0 -> 1690 bytes 8 files changed, 84 insertions(+), 10 deletions(-) create mode 100644 assets/icons/StatusBar/Attention_5x8.png diff --git a/applications/desktop/views/desktop_locked.c b/applications/desktop/views/desktop_locked.c index bbb9978a..d8102f57 100644 --- a/applications/desktop/views/desktop_locked.c +++ b/applications/desktop/views/desktop_locked.c @@ -208,6 +208,10 @@ void desktop_locked_lock(DesktopLockedView* locked_view) { view_commit_model(locked_view->view, true); desktop_locked_reset_door_pos(locked_view); xTimerChangePeriod(locked_view->timer, DOOR_MOVING_INTERVAL_MS, portMAX_DELAY); + + Gui* gui = furi_record_open("gui"); + gui_set_lockdown(gui, true); + furi_record_close("gui"); } void desktop_locked_lock_pincode(DesktopLockedView* locked_view, PinCode pincode) { @@ -219,6 +223,10 @@ void desktop_locked_lock_pincode(DesktopLockedView* locked_view, PinCode pincode view_commit_model(locked_view->view, true); desktop_locked_reset_door_pos(locked_view); xTimerChangePeriod(locked_view->timer, DOOR_MOVING_INTERVAL_MS, portMAX_DELAY); + + Gui* gui = furi_record_open("gui"); + gui_set_lockdown(gui, true); + furi_record_close("gui"); } static void desktop_locked_unlock(DesktopLockedView* locked_view) { @@ -232,4 +240,8 @@ static void desktop_locked_unlock(DesktopLockedView* locked_view) { view_commit_model(locked_view->view, true); locked_view->callback(DesktopMainEventUnlocked, locked_view->context); xTimerChangePeriod(locked_view->timer, UNLOCKED_HINT_TIMEOUT_MS, portMAX_DELAY); + + Gui* gui = furi_record_open("gui"); + gui_set_lockdown(gui, false); + furi_record_close("gui"); } diff --git a/applications/gui/gui.c b/applications/gui/gui.c index 9d9b0900..bc333bb1 100644 --- a/applications/gui/gui.c +++ b/applications/gui/gui.c @@ -45,7 +45,7 @@ bool gui_redraw_fs(Gui* gui) { } } -void gui_redraw_status_bar(Gui* gui) { +static void gui_redraw_status_bar(Gui* gui, bool need_attention) { ViewPortArray_it_t it; uint8_t x; uint8_t x_used = 0; @@ -140,6 +140,30 @@ void gui_redraw_status_bar(Gui* gui) { } ViewPortArray_next(it); } + + if(need_attention) { + width = icon_get_width(&I_Attention_5x8); + canvas_frame_set(gui->canvas, 0, GUI_STATUS_BAR_Y, x + width + 5, GUI_STATUS_BAR_HEIGHT); + canvas_draw_rframe( + gui->canvas, 0, 0, canvas_width(gui->canvas), canvas_height(gui->canvas), 1); + canvas_draw_line(gui->canvas, 1, 1, 1, canvas_height(gui->canvas) - 2); + canvas_draw_line( + gui->canvas, + 2, + canvas_height(gui->canvas) - 2, + canvas_width(gui->canvas) - 2, + canvas_height(gui->canvas) - 2); + + canvas_frame_set(gui->canvas, x, GUI_STATUS_BAR_Y, width + 5, GUI_STATUS_BAR_HEIGHT); + + canvas_set_color(gui->canvas, ColorWhite); + canvas_draw_box(gui->canvas, 2, 1, width + 2, 10); + canvas_set_color(gui->canvas, ColorBlack); + + canvas_frame_set( + gui->canvas, x + 3, GUI_STATUS_BAR_Y + 2, width, GUI_STATUS_BAR_WORKAREA_HEIGHT); + canvas_draw_icon(gui->canvas, 0, 0, &I_Attention_5x8); + } } bool gui_redraw_window(Gui* gui) { @@ -171,11 +195,19 @@ void gui_redraw(Gui* gui) { canvas_reset(gui->canvas); - if(!gui_redraw_fs(gui)) { - if(!gui_redraw_window(gui)) { - gui_redraw_desktop(gui); + if(gui->lockdown) { + gui_redraw_desktop(gui); + bool need_attention = + (gui_view_port_find_enabled(gui->layers[GuiLayerWindow]) != 0 || + gui_view_port_find_enabled(gui->layers[GuiLayerFullscreen]) != 0); + gui_redraw_status_bar(gui, need_attention); + } else { + if(!gui_redraw_fs(gui)) { + if(!gui_redraw_window(gui)) { + gui_redraw_desktop(gui); + } + gui_redraw_status_bar(gui, false); } - gui_redraw_status_bar(gui); } canvas_commit(gui->canvas); @@ -210,9 +242,15 @@ void gui_input(Gui* gui, InputEvent* input_event) { gui_lock(gui); - ViewPort* view_port = gui_view_port_find_enabled(gui->layers[GuiLayerFullscreen]); - if(!view_port) view_port = gui_view_port_find_enabled(gui->layers[GuiLayerWindow]); - if(!view_port) view_port = gui_view_port_find_enabled(gui->layers[GuiLayerDesktop]); + ViewPort* view_port = NULL; + + if(gui->lockdown) { + view_port = gui_view_port_find_enabled(gui->layers[GuiLayerDesktop]); + } else { + view_port = gui_view_port_find_enabled(gui->layers[GuiLayerFullscreen]); + if(!view_port) view_port = gui_view_port_find_enabled(gui->layers[GuiLayerWindow]); + if(!view_port) view_port = gui_view_port_find_enabled(gui->layers[GuiLayerDesktop]); + } if(!(gui->ongoing_input & ~key_bit) && input_event->type == InputTypePress) { gui->ongoing_input_view_port = view_port; @@ -366,10 +404,18 @@ void gui_set_framebuffer_callback(Gui* gui, GuiCanvasCommitCallback callback, vo gui_unlock(gui); if(callback != NULL) { - gui_redraw(gui); + gui_update(gui); } } +void gui_set_lockdown(Gui* gui, bool lockdown) { + furi_assert(gui); + gui_lock(gui); + gui->lockdown = lockdown; + gui_unlock(gui); + gui_update(gui); +} + Gui* gui_alloc() { Gui* gui = furi_alloc(sizeof(Gui)); // Thread ID diff --git a/applications/gui/gui.h b/applications/gui/gui.h index a5fb8a11..5c209362 100644 --- a/applications/gui/gui.h +++ b/applications/gui/gui.h @@ -79,6 +79,16 @@ void gui_view_port_send_to_back(Gui* gui, ViewPort* view_port); */ void gui_set_framebuffer_callback(Gui* gui, GuiCanvasCommitCallback callback, void* context); +/** Set lockdown mode + * + * When lockdown mode is enabled, only GuiLayerDesktop is shown. + * This feature prevents services from showing sensitive information when flipper is locked. + * + * @param gui Gui instance + * @param lockdown bool, true if enabled + */ +void gui_set_lockdown(Gui* gui, bool lockdown); + #ifdef __cplusplus } #endif diff --git a/applications/gui/gui_i.h b/applications/gui/gui_i.h index 0046e85a..479b5592 100644 --- a/applications/gui/gui_i.h +++ b/applications/gui/gui_i.h @@ -49,6 +49,7 @@ struct Gui { osMutexId_t mutex; // Layers and Canvas + bool lockdown; ViewPortArray_t layers[GuiLayerMAX]; Canvas* canvas; GuiCanvasCommitCallback canvas_callback; diff --git a/applications/lfrfid/scene/lfrfid_app_scene_read_success.cpp b/applications/lfrfid/scene/lfrfid_app_scene_read_success.cpp index 46ff90ef..a86f77e6 100644 --- a/applications/lfrfid/scene/lfrfid_app_scene_read_success.cpp +++ b/applications/lfrfid/scene/lfrfid_app_scene_read_success.cpp @@ -22,7 +22,7 @@ void LfRfidAppSceneReadSuccess::on_enter(LfRfidApp* app, bool need_restore) { icon->set_icon(3, 12, &I_RFIDBigChip_37x36); auto header = container->add(); - header->set_text(app->worker.key.get_type_text(), 89, 3, AlignCenter); + header->set_text(app->worker.key.get_type_text(), 89, 3, 0, AlignCenter); auto line_1_text = container->add(); auto line_2_text = container->add(); diff --git a/assets/compiled/assets_icons.c b/assets/compiled/assets_icons.c index bb540f5a..409f7034 100644 --- a/assets/compiled/assets_icons.c +++ b/assets/compiled/assets_icons.c @@ -522,6 +522,9 @@ const uint8_t *_I_SDQuestion_35x43[] = {_I_SDQuestion_35x43_0}; const uint8_t _I_Cry_dolph_55x52_0[] = {0x01,0x00,0xe8,0x00,0x00,0x0f,0xe3,0xff,0x01,0x03,0x1f,0xfb,0xff,0x0f,0x02,0x96,0x02,0x0f,0x00,0x9f,0x01,0x8b,0xc0,0x12,0x1f,0x80,0x18,0xae,0x00,0x21,0xe0,0x07,0x0a,0x30,0x0a,0x28,0x18,0x08,0x61,0x80,0x62,0x83,0x00,0x90,0x14,0x61,0x02,0x0c,0x16,0x00,0x76,0x60,0x66,0x98,0x0b,0x04,0x90,0x60,0x66,0xb0,0x00,0x48,0x0d,0x21,0x21,0x03,0x30,0x74,0x40,0xd3,0x80,0x03,0x34,0x04,0xc0,0x52,0x00,0x32,0xc7,0xa0,0x18,0x80,0x31,0x80,0x07,0xe1,0x01,0x37,0x18,0x50,0x80,0xc2,0x92,0x10,0x31,0xe8,0x23,0xe9,0x63,0x86,0x54,0x3f,0xe0,0xe1,0x0d,0x96,0x83,0xfc,0x06,0x40,0x69,0x6c,0x3c,0x60,0xd2,0xfc,0xc0,0x60,0x58,0x48,0x0c,0x1b,0x81,0x08,0x14,0x9c,0x1a,0x81,0x04,0x03,0x46,0x80,0x0c,0x50,0x26,0x21,0xc1,0x94,0x26,0x14,0x27,0x8a,0x40,0xc0,0xc2,0xe7,0x26,0x40,0x81,0x86,0xc0,0x6b,0x28,0x64,0x0f,0x01,0x10,0x4e,0x14,0x60,0x0c,0x29,0x02,0x48,0x8b,0x5c,0x45,0x22,0x01,0x10,0x31,0x3a,0x4c,0x0c,0x34,0x06,0xf1,0xd8,0x00,0xc5,0x1a,0x64,0x94,0x0c,0xc0,0x37,0x52,0x20,0x81,0x84,0x26,0x3e,0x88,0x0c,0x38,0x28,0x54,0x0e,0xac,0x1f,0xe1,0x3f,0x06,0x96,0x82,0x7e,0x29,0x4a,0xaf,0xfd,0x76,0x30,0x3a,0x41,0x14,0x7f,0xd0,0xf8,0x78,0x18,0xaa,0x9f,0xd4,0xe0,0x83,0x4f,0xf5,0xf7,0x38,0x0b,0x9c,0x6a,0x1f,0x5b,0x5c,0x00,}; const uint8_t *_I_Cry_dolph_55x52[] = {_I_Cry_dolph_55x52_0}; +const uint8_t _I_Attention_5x8_0[] = {0x00,0x0E,0x0A,0x0A,0x0A,0x0E,0x04,0x00,0x0E,}; +const uint8_t *_I_Attention_5x8[] = {_I_Attention_5x8_0}; + const uint8_t _I_BT_Pair_9x8_0[] = {0x00,0x11,0x01,0x35,0x00,0x58,0x01,0x31,0x00,0x30,0x01,0x59,0x00,0x34,0x01,0x11,0x01,}; const uint8_t *_I_BT_Pair_9x8[] = {_I_BT_Pair_9x8_0}; @@ -749,6 +752,7 @@ const Icon I_RFIDDolphinSuccess_108x57 = {.width=108,.height=57,.frame_count=1,. const Icon I_SDError_43x35 = {.width=43,.height=35,.frame_count=1,.frame_rate=0,.frames=_I_SDError_43x35}; const Icon I_SDQuestion_35x43 = {.width=35,.height=43,.frame_count=1,.frame_rate=0,.frames=_I_SDQuestion_35x43}; const Icon I_Cry_dolph_55x52 = {.width=55,.height=52,.frame_count=1,.frame_rate=0,.frames=_I_Cry_dolph_55x52}; +const Icon I_Attention_5x8 = {.width=5,.height=8,.frame_count=1,.frame_rate=0,.frames=_I_Attention_5x8}; const Icon I_BT_Pair_9x8 = {.width=9,.height=8,.frame_count=1,.frame_rate=0,.frames=_I_BT_Pair_9x8}; const Icon I_Background_128x11 = {.width=128,.height=11,.frame_count=1,.frame_rate=0,.frames=_I_Background_128x11}; const Icon I_BadUsb_9x8 = {.width=9,.height=8,.frame_count=1,.frame_rate=0,.frames=_I_BadUsb_9x8}; diff --git a/assets/compiled/assets_icons.h b/assets/compiled/assets_icons.h index a8351f97..3b756c1b 100644 --- a/assets/compiled/assets_icons.h +++ b/assets/compiled/assets_icons.h @@ -135,6 +135,7 @@ extern const Icon I_RFIDDolphinSuccess_108x57; extern const Icon I_SDError_43x35; extern const Icon I_SDQuestion_35x43; extern const Icon I_Cry_dolph_55x52; +extern const Icon I_Attention_5x8; extern const Icon I_BT_Pair_9x8; extern const Icon I_Background_128x11; extern const Icon I_BadUsb_9x8; diff --git a/assets/icons/StatusBar/Attention_5x8.png b/assets/icons/StatusBar/Attention_5x8.png new file mode 100644 index 0000000000000000000000000000000000000000..137d4c4d054227f27ad6a7e3e374b100d975d9af GIT binary patch literal 1690 zcmb7EO>Em_7aL~8bUpz^|omTDs`GNSf+{#+5sqt{|hGs2M~O=v!q!&5C=eV3yqN$cH8pR6>G`RwG(RWBWbEkJK-^_v zfiiGJ)Gcee&AJ@s*Ja^vFHB&lPjTirEXNCI!mt3!;0#V;V*_a1k`*?Se7T(rPaIZq z9Frx8YPE`2qqt!e2`Uzg5hP8}bObUYc1?FgH=^77yb?i;B(Nn*H67K^QLm<0Fe(m* zVGu{##eu7KtLt`qd?*CrAq0h!#Ado#G91G$8D^)Wo}3Q6CDBopN8IBfTj)@}?Qd{J zb2~E6|2w^0?is^&CeJ`2+M@Q1@ZbVFTQdQX0k%=GBrtgf=*~W02~QU`VQ7Xm4Xpt< z>=465nJy%#F3@sGwG4C{3eRB=V>6quBYs{-wxBL=$gnK+5R^_N1j|rV4PwVEP_rdb z189;VeV(Txn=Xq*a2)7Gr^I1F>2Ca#DtqCe8$av~r&T<6oX}M$2i>id>tY;sm?nZ| z{H&R6A^5^r9y(hV9Wg07ut%DN&LpV_9m`UqEJ?9cbcBquWYDkAH)K_*{TJJFGa83{ zo@Z04?HE?g4+R#V2CoOF;Has-w>@`zd{OeI<1o`QtkQxz>RQG_p- z!zL6(g*wzw!818Z;S`CF_GVN|09M;PS(IfMc9d>UMr_-Q@3u$w5}^O5mmp(nFTE6#P!fSmv-=dmoM}mdU2?9`nd!3^}k+g