Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev' into release-candidate
Browse files Browse the repository at this point in the history
  • Loading branch information
skotopes committed Apr 20, 2023
2 parents 728320b + 4d015a1 commit 085c800
Show file tree
Hide file tree
Showing 60 changed files with 686 additions and 274 deletions.
44 changes: 39 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ jobs:

- name: 'Find Previous Comment'
if: ${{ !github.event.pull_request.head.repo.fork && github.event.pull_request }}
uses: peter-evans/find-comment@v1
uses: peter-evans/find-comment@v2
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
Expand All @@ -148,7 +148,7 @@ jobs:

- name: 'Create or update comment'
if: ${{ !github.event.pull_request.head.repo.fork && github.event.pull_request}}
uses: peter-evans/create-or-update-comment@v1
uses: peter-evans/create-or-update-comment@v3
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
Expand All @@ -162,6 +162,9 @@ jobs:
compact:
if: ${{ !startsWith(github.ref, 'refs/tags') }}
runs-on: [self-hosted,FlipperZeroShell]
strategy:
matrix:
target: [f7, f18]
steps:
- name: 'Wipe workspace'
run: find ./ -mount -maxdepth 1 -exec rm -rf {} \;
Expand All @@ -185,9 +188,40 @@ jobs:
python3 scripts/get_env.py "--event_file=${{ github.event_path }}" "--type=$TYPE" || cat "${{ github.event_path }}"
- name: 'Build the firmware'
id: build-fw
run: |
set -e
for TARGET in ${TARGETS}; do
TARGET="$(echo "${TARGET}" | sed 's/f//')"; \
./fbt TARGET_HW=$TARGET DEBUG=0 COMPACT=1 fap_dist updater_package
TARGET="$(echo '${{ matrix.target }}' | sed 's/f//')"; \
./fbt TARGET_HW=$TARGET DEBUG=0 COMPACT=1 fap_dist updater_package
echo "sdk-file=$(ls dist/${{ matrix.target }}-*/flipper-z-${{ matrix.target }}-sdk-*.zip)" >> $GITHUB_OUTPUT
- name: Deploy uFBT with SDK
uses: flipperdevices/[email protected]
with:
task: setup
sdk-file: ${{ steps.build-fw.outputs.sdk-file }}

- name: Build test app with SDK
run: |
mkdir testapp
cd testapp
ufbt create APPID=testapp
ufbt
- name: Build example & external apps with uFBT
run: |
for appdir in 'applications/external' 'applications/examples'; do
for app in $(find "$appdir" -maxdepth 1 -mindepth 1 -type d); do
pushd $app
TARGETS_FAM=$(grep "targets" application.fam || echo "${{ matrix.target }}")
if ! grep -q "${{ matrix.target }}" <<< $TARGETS_FAM ; then
echo Skipping unsupported app: $app
popd
continue
fi
echo Building $app
ufbt
popd
done
done
34 changes: 29 additions & 5 deletions .github/workflows/lint_and_submodule_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
COMMITS_IN_BRANCH="$(git rev-list --count dev)";
if [ $COMMITS_IN_BRANCH -lt $SUB_COMMITS_MIN ]; then
echo "name=fails::error" >> $GITHUB_OUTPUT;
echo "::error::Error: Too low commits in $SUB_BRANCH of submodule $SUB_PATH: $COMMITS_IN_BRANCH(expected $SUB_COMMITS_MIN+)";
echo "::error::Error: Too few commits in $SUB_BRANCH of submodule $SUB_PATH: $COMMITS_IN_BRANCH(expected $SUB_COMMITS_MIN+)";
exit 1;
fi
if ! grep -q "/$SUB_BRANCH" <<< "$BRANCHES"; then
Expand All @@ -51,12 +51,36 @@ jobs:
- name: 'Check Python code formatting'
id: syntax_check_py
run: ./fbt lint_py 2>&1 >/dev/null || echo "errors=1" >> $GITHUB_OUTPUT

run: |
set +e;
./fbt -s lint_py 2>&1 | tee lint-py.log;
if [ "${PIPESTATUS[0]}" -ne 0 ]; then
# Save multiline output
echo "errors=1" >> $GITHUB_OUTPUT;
printf "Python Lint errors:\n\`\`\`\n" >> $GITHUB_STEP_SUMMARY;
echo "$(cat lint-py.log)" >> $GITHUB_STEP_SUMMARY;
printf "\n\`\`\`\n" >> $GITHUB_STEP_SUMMARY;
exit 1;
else
echo "Python Lint: all good ✨" >> $GITHUB_STEP_SUMMARY;
fi
- name: 'Check C++ code formatting'
if: always()
id: syntax_check_cpp
run: ./fbt lint 2>&1 >/dev/null || echo "errors=1" >> $GITHUB_OUTPUT
if: always()
run: |
set +e;
./fbt -s lint 2>&1 | tee lint-cpp.log;
if [ "${PIPESTATUS[0]}" -ne 0 ]; then
# Save multiline output
echo "errors=1" >> $GITHUB_OUTPUT;
printf "C Lint errors:\n\`\`\`\n" >> $GITHUB_STEP_SUMMARY;
echo "$(cat lint-cpp.log)" >> $GITHUB_STEP_SUMMARY;
printf "\n\`\`\`\n" >> $GITHUB_STEP_SUMMARY;
exit 1;
else
echo "C Lint: all good ✨" >> $GITHUB_STEP_SUMMARY;
fi
- name: Report code formatting errors
if: ( steps.syntax_check_py.outputs.errors || steps.syntax_check_cpp.outputs.errors ) && github.event.pull_request
Expand Down
4 changes: 2 additions & 2 deletions applications/debug/unit_tests/rpc/rpc_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ static void test_rpc_setup(void) {

rpc = furi_record_open(RECORD_RPC);
for(int i = 0; !(rpc_session[0].session) && (i < 10000); ++i) {
rpc_session[0].session = rpc_session_open(rpc);
rpc_session[0].session = rpc_session_open(rpc, RpcOwnerUnknown);
furi_delay_tick(1);
}
furi_check(rpc_session[0].session);
Expand All @@ -104,7 +104,7 @@ static void test_rpc_setup_second_session(void) {
furi_check(!(rpc_session[1].session));

for(int i = 0; !(rpc_session[1].session) && (i < 10000); ++i) {
rpc_session[1].session = rpc_session_open(rpc);
rpc_session[1].session = rpc_session_open(rpc, RpcOwnerUnknown);
furi_delay_tick(1);
}
furi_check(rpc_session[1].session);
Expand Down
5 changes: 4 additions & 1 deletion applications/external/picopass/picopass_worker.c
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ void picopass_worker_elite_dict_attack(PicopassWorker* picopass_worker) {
picopass_worker->callback(PicopassWorkerEventFail, picopass_worker->context);
break;
}
picopass_worker->callback(PicopassWorkerEventSuccess, picopass_worker->context);
picopass_worker->callback(PicopassWorkerEventAborted, picopass_worker->context);
break;
}

Expand All @@ -596,6 +596,9 @@ int32_t picopass_worker_task(void* context) {
picopass_worker_write_key(picopass_worker);
} else if(picopass_worker->state == PicopassWorkerStateEliteDictAttack) {
picopass_worker_elite_dict_attack(picopass_worker);
} else if(picopass_worker->state == PicopassWorkerStateStop) {
FURI_LOG_D(TAG, "Worker state stop");
// no-op
} else {
FURI_LOG_W(TAG, "Unknown state %d", picopass_worker->state);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,7 @@ bool picopass_scene_elite_dict_attack_on_event(void* context, SceneManagerEvent
uint32_t state =
scene_manager_get_scene_state(picopass->scene_manager, PicopassSceneEliteDictAttack);
if(event.type == SceneManagerEventTypeCustom) {
if(event.event == PicopassWorkerEventSuccess ||
event.event == PicopassWorkerEventAborted) {
if(event.event == PicopassWorkerEventSuccess) {
if(state == DictAttackStateUserDictInProgress ||
state == DictAttackStateStandardDictInProgress) {
picopass_worker_stop(picopass->worker);
Expand All @@ -127,6 +126,9 @@ bool picopass_scene_elite_dict_attack_on_event(void* context, SceneManagerEvent
scene_manager_next_scene(picopass->scene_manager, PicopassSceneReadCardSuccess);
consumed = true;
}
} else if(event.event == PicopassWorkerEventAborted) {
scene_manager_next_scene(picopass->scene_manager, PicopassSceneReadCardSuccess);
consumed = true;
} else if(event.event == PicopassWorkerEventCardDetected) {
dict_attack_set_card_detected(picopass->dict_attack);
consumed = true;
Expand Down
5 changes: 2 additions & 3 deletions applications/main/fap_loader/fap_loader_app.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "fap_loader_app.h"

#include <furi.h>
#include <furi_hal_debug.h>

#include <assets_icons.h>
#include <gui/gui.h>
Expand All @@ -23,8 +24,6 @@ struct FapLoader {
Loading* loading;
};

volatile bool fap_loader_debug_active = false;

bool fap_loader_load_name_and_icon(
FuriString* path,
Storage* storage,
Expand Down Expand Up @@ -111,7 +110,7 @@ static bool fap_loader_run_selected_app(FapLoader* loader) {
FuriThread* thread = flipper_application_spawn(loader->app, NULL);

/* This flag is set by the debugger - to break on app start */
if(fap_loader_debug_active) {
if(furi_hal_debug_is_gdb_session_active()) {
FURI_LOG_W(TAG, "Triggering BP for debugger");
/* After hitting this, you can set breakpoints in your .fap's code
* Note that you have to toggle breakpoints that were set before */
Expand Down
2 changes: 1 addition & 1 deletion applications/services/bt/bt_service/bt.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ static bool bt_on_gap_event_callback(GapEvent event, void* context) {
furi_event_flag_clear(bt->rpc_event, BT_RPC_EVENT_DISCONNECTED);
if(bt->profile == BtProfileSerial) {
// Open RPC session
bt->rpc_session = rpc_session_open(bt->rpc);
bt->rpc_session = rpc_session_open(bt->rpc, RpcOwnerBle);
if(bt->rpc_session) {
FURI_LOG_I(TAG, "Open RPC connection");
rpc_session_set_send_bytes_callback(bt->rpc_session, bt_rpc_send_bytes_callback);
Expand Down
29 changes: 29 additions & 0 deletions applications/services/desktop/desktop.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ static void desktop_dummy_mode_icon_draw_callback(Canvas* canvas, void* context)
canvas_draw_icon(canvas, 0, 0, &I_GameMode_11x8);
}

static void desktop_stealth_mode_icon_draw_callback(Canvas* canvas, void* context) {
UNUSED(context);
furi_assert(canvas);
canvas_draw_icon(canvas, 0, 0, &I_Muted_8x8);
}

static bool desktop_custom_event_callback(void* context, uint32_t event) {
furi_assert(context);
Desktop* desktop = (Desktop*)context;
Expand Down Expand Up @@ -153,6 +159,17 @@ void desktop_set_dummy_mode_state(Desktop* desktop, bool enabled) {
desktop->in_transition = false;
}

void desktop_set_stealth_mode_state(Desktop* desktop, bool enabled) {
desktop->in_transition = true;
if(enabled) {
furi_hal_rtc_set_flag(FuriHalRtcFlagStealthMode);
} else {
furi_hal_rtc_reset_flag(FuriHalRtcFlagStealthMode);
}
view_port_enabled_set(desktop->stealth_mode_icon_viewport, enabled);
desktop->in_transition = false;
}

Desktop* desktop_alloc() {
Desktop* desktop = malloc(sizeof(Desktop));

Expand Down Expand Up @@ -244,6 +261,18 @@ Desktop* desktop_alloc() {
view_port_enabled_set(desktop->dummy_mode_icon_viewport, false);
gui_add_view_port(desktop->gui, desktop->dummy_mode_icon_viewport, GuiLayerStatusBarLeft);

// Stealth mode icon
desktop->stealth_mode_icon_viewport = view_port_alloc();
view_port_set_width(desktop->stealth_mode_icon_viewport, icon_get_width(&I_Muted_8x8));
view_port_draw_callback_set(
desktop->stealth_mode_icon_viewport, desktop_stealth_mode_icon_draw_callback, desktop);
if(furi_hal_rtc_is_flag_set(FuriHalRtcFlagStealthMode)) {
view_port_enabled_set(desktop->stealth_mode_icon_viewport, true);
} else {
view_port_enabled_set(desktop->stealth_mode_icon_viewport, false);
}
gui_add_view_port(desktop->gui, desktop->stealth_mode_icon_viewport, GuiLayerStatusBarLeft);

// Special case: autostart application is already running
desktop->loader = furi_record_open(RECORD_LOADER);
if(loader_is_locked(desktop->loader) &&
Expand Down
2 changes: 2 additions & 0 deletions applications/services/desktop/desktop_i.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ struct Desktop {

ViewPort* lock_icon_viewport;
ViewPort* dummy_mode_icon_viewport;
ViewPort* stealth_mode_icon_viewport;

AnimationManager* animation_manager;

Expand All @@ -79,3 +80,4 @@ void desktop_free(Desktop* desktop);
void desktop_lock(Desktop* desktop);
void desktop_unlock(Desktop* desktop);
void desktop_set_dummy_mode_state(Desktop* desktop, bool enabled);
void desktop_set_stealth_mode_state(Desktop* desktop, bool enabled);
12 changes: 12 additions & 0 deletions applications/services/desktop/scenes/desktop_scene_lock_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ void desktop_scene_lock_menu_on_enter(void* context) {
desktop_lock_menu_set_callback(desktop->lock_menu, desktop_scene_lock_menu_callback, desktop);
desktop_lock_menu_set_pin_state(desktop->lock_menu, desktop->settings.pin_code.length > 0);
desktop_lock_menu_set_dummy_mode_state(desktop->lock_menu, desktop->settings.dummy_mode);
desktop_lock_menu_set_stealth_mode_state(
desktop->lock_menu, furi_hal_rtc_is_flag_set(FuriHalRtcFlagStealthMode));
desktop_lock_menu_set_idx(desktop->lock_menu, 0);

view_dispatcher_switch_to_view(desktop->view_dispatcher, DesktopViewIdLockMenu);
Expand Down Expand Up @@ -78,6 +80,16 @@ bool desktop_scene_lock_menu_on_event(void* context, SceneManagerEvent event) {
scene_manager_search_and_switch_to_previous_scene(
desktop->scene_manager, DesktopSceneMain);
break;
case DesktopLockMenuEventStealthModeOn:
desktop_set_stealth_mode_state(desktop, true);
scene_manager_search_and_switch_to_previous_scene(
desktop->scene_manager, DesktopSceneMain);
break;
case DesktopLockMenuEventStealthModeOff:
desktop_set_stealth_mode_state(desktop, false);
scene_manager_search_and_switch_to_previous_scene(
desktop->scene_manager, DesktopSceneMain);
break;
default:
break;
}
Expand Down
2 changes: 2 additions & 0 deletions applications/services/desktop/views/desktop_events.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ typedef enum {
DesktopLockMenuEventPinLock,
DesktopLockMenuEventDummyModeOn,
DesktopLockMenuEventDummyModeOff,
DesktopLockMenuEventStealthModeOn,
DesktopLockMenuEventStealthModeOff,

DesktopAnimationEventCheckAnimation,
DesktopAnimationEventNewIdleAnimation,
Expand Down
38 changes: 29 additions & 9 deletions applications/services/desktop/views/desktop_view_lock_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

typedef enum {
DesktopLockMenuIndexLock,
DesktopLockMenuIndexPinLock,
DesktopLockMenuIndexStealth,
DesktopLockMenuIndexDummy,

DesktopLockMenuIndexTotalCount
Expand Down Expand Up @@ -39,6 +39,14 @@ void desktop_lock_menu_set_dummy_mode_state(DesktopLockMenuView* lock_menu, bool
true);
}

void desktop_lock_menu_set_stealth_mode_state(DesktopLockMenuView* lock_menu, bool stealth_mode) {
with_view_model(
lock_menu->view,
DesktopLockMenuViewModel * model,
{ model->stealth_mode = stealth_mode; },
true);
}

void desktop_lock_menu_set_idx(DesktopLockMenuView* lock_menu, uint8_t idx) {
furi_assert(idx < DesktopLockMenuIndexTotalCount);
with_view_model(
Expand All @@ -58,11 +66,11 @@ void desktop_lock_menu_draw_callback(Canvas* canvas, void* model) {

if(i == DesktopLockMenuIndexLock) {
str = "Lock";
} else if(i == DesktopLockMenuIndexPinLock) {
if(m->pin_is_set) {
str = "Lock with PIN";
} else if(i == DesktopLockMenuIndexStealth) {
if(m->stealth_mode) {
str = "Sound Mode";
} else {
str = "Set PIN";
str = "Stealth Mode";
}
} else if(i == DesktopLockMenuIndexDummy) { //-V547
if(m->dummy_mode) {
Expand Down Expand Up @@ -93,6 +101,8 @@ bool desktop_lock_menu_input_callback(InputEvent* event, void* context) {
uint8_t idx = 0;
bool consumed = false;
bool dummy_mode = false;
bool stealth_mode = false;
bool pin_is_set = false;
bool update = false;

with_view_model(
Expand Down Expand Up @@ -120,14 +130,24 @@ bool desktop_lock_menu_input_callback(InputEvent* event, void* context) {
}
idx = model->idx;
dummy_mode = model->dummy_mode;
stealth_mode = model->stealth_mode;
pin_is_set = model->pin_is_set;
},
update);

if(event->key == InputKeyOk) {
if((idx == DesktopLockMenuIndexLock) && (event->type == InputTypeShort)) {
lock_menu->callback(DesktopLockMenuEventLock, lock_menu->context);
} else if((idx == DesktopLockMenuIndexPinLock) && (event->type == InputTypeShort)) {
lock_menu->callback(DesktopLockMenuEventPinLock, lock_menu->context);
if((idx == DesktopLockMenuIndexLock)) {
if((pin_is_set) && (event->type == InputTypeShort)) {
lock_menu->callback(DesktopLockMenuEventPinLock, lock_menu->context);
} else if((pin_is_set == false) && (event->type == InputTypeShort)) {
lock_menu->callback(DesktopLockMenuEventLock, lock_menu->context);
}
} else if(idx == DesktopLockMenuIndexStealth) {
if((stealth_mode == false) && (event->type == InputTypeShort)) {
lock_menu->callback(DesktopLockMenuEventStealthModeOn, lock_menu->context);
} else if((stealth_mode == true) && (event->type == InputTypeShort)) {
lock_menu->callback(DesktopLockMenuEventStealthModeOff, lock_menu->context);
}
} else if(idx == DesktopLockMenuIndexDummy) {
if((dummy_mode == false) && (event->type == InputTypeShort)) {
lock_menu->callback(DesktopLockMenuEventDummyModeOn, lock_menu->context);
Expand Down
Loading

0 comments on commit 085c800

Please sign in to comment.