mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2024-11-27 06:50:21 +00:00
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
This commit is contained in:
parent
6264ee8c3b
commit
2b2a798407
8 changed files with 84 additions and 10 deletions
|
@ -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");
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -49,6 +49,7 @@ struct Gui {
|
|||
osMutexId_t mutex;
|
||||
|
||||
// Layers and Canvas
|
||||
bool lockdown;
|
||||
ViewPortArray_t layers[GuiLayerMAX];
|
||||
Canvas* canvas;
|
||||
GuiCanvasCommitCallback canvas_callback;
|
||||
|
|
|
@ -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<StringElement>();
|
||||
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<StringElement>();
|
||||
auto line_2_text = container->add<StringElement>();
|
||||
|
|
|
@ -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};
|
||||
|
|
|
@ -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;
|
||||
|
|
BIN
assets/icons/StatusBar/Attention_5x8.png
Normal file
BIN
assets/icons/StatusBar/Attention_5x8.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.7 KiB |
Loading…
Reference in a new issue