Lockscreen: Separate 'Allow RPC While Locked' for USB/BLE (#343)

* Lockscreen: Separate 'Allow RPC While Locked' for USB/Bluetooth (BLE)

- #330, split of the `allow_locked_rpc_commands` bool into `allow_locked_rpc_usb` and `allow_locked_rpc_ble` to allow the connections separately.

* Shorter wording

* Update changelog

---------

Co-authored-by: Willy-JL <49810075+Willy-JL@users.noreply.github.com>
This commit is contained in:
Alexander Bays
2025-01-12 20:40:36 -06:00
committed by GitHub
parent 7d4ea20701
commit 34379f1fbe
6 changed files with 61 additions and 25 deletions

View File

@@ -1,3 +1,8 @@
### Breaking Changes:
- Lockscreen: Separate 'Allow RPC While Locked' settings for USB/BLE (#343 by @956MB)
- Both default to OFF like before
- If you had enabled this option before, you will need to re-enable
### Added:
- Apps:
- Games: Pinball0 (by @rdefeo)

View File

@@ -33,11 +33,20 @@ static void momentum_app_scene_interface_lockscreen_bad_pins_format_changed(Vari
}
static void
momentum_app_scene_interface_lockscreen_allow_locked_rpc_commands_changed(VariableItem* item) {
momentum_app_scene_interface_lockscreen_allow_locked_rpc_usb_changed(VariableItem* item) {
MomentumApp* app = variable_item_get_context(item);
bool value = variable_item_get_current_value_index(item);
variable_item_set_current_value_text(item, value ? "ON" : "OFF");
momentum_settings.allow_locked_rpc_commands = value;
momentum_settings.allow_locked_rpc_usb = value;
app->save_settings = true;
}
static void
momentum_app_scene_interface_lockscreen_allow_locked_rpc_ble_changed(VariableItem* item) {
MomentumApp* app = variable_item_get_context(item);
bool value = variable_item_get_current_value_index(item);
variable_item_set_current_value_text(item, value ? "ON" : "OFF");
momentum_settings.allow_locked_rpc_ble = value;
app->save_settings = true;
}
@@ -126,13 +135,23 @@ void momentum_app_scene_interface_lockscreen_on_enter(void* context) {
item = variable_item_list_add(
var_item_list,
"Allow RPC While Locked",
"Allow USB RPC While Locked",
2,
momentum_app_scene_interface_lockscreen_allow_locked_rpc_commands_changed,
momentum_app_scene_interface_lockscreen_allow_locked_rpc_usb_changed,
app);
variable_item_set_current_value_index(item, momentum_settings.allow_locked_rpc_commands);
variable_item_set_current_value_index(item, momentum_settings.allow_locked_rpc_usb);
variable_item_set_current_value_text(
item, momentum_settings.allow_locked_rpc_commands ? "ON" : "OFF");
item, momentum_settings.allow_locked_rpc_usb ? "ON" : "OFF");
item = variable_item_list_add(
var_item_list,
"Allow BLE RPC While Locked",
2,
momentum_app_scene_interface_lockscreen_allow_locked_rpc_ble_changed,
app);
variable_item_set_current_value_index(item, momentum_settings.allow_locked_rpc_ble);
variable_item_set_current_value_text(
item, momentum_settings.allow_locked_rpc_ble ? "ON" : "OFF");
item = variable_item_list_add(
var_item_list,

View File

@@ -391,13 +391,17 @@ void desktop_lock(Desktop* desktop, bool with_pin) {
furi_hal_rtc_set_pin_fails(0);
}
if(with_pin && !momentum_settings.allow_locked_rpc_commands) {
Cli* cli = furi_record_open(RECORD_CLI);
cli_session_close(cli);
furi_record_close(RECORD_CLI);
Bt* bt = furi_record_open(RECORD_BT);
bt_close_rpc_connection(bt);
furi_record_close(RECORD_BT);
if(with_pin) {
if(!momentum_settings.allow_locked_rpc_usb) {
Cli* cli = furi_record_open(RECORD_CLI);
cli_session_close(cli);
furi_record_close(RECORD_CLI);
}
if(!momentum_settings.allow_locked_rpc_ble) {
Bt* bt = furi_record_open(RECORD_BT);
bt_close_rpc_connection(bt);
furi_record_close(RECORD_BT);
}
}
desktop_auto_lock_inhibit(desktop);
@@ -426,12 +430,16 @@ void desktop_unlock(Desktop* desktop) {
furi_hal_rtc_set_pin_fails(0);
if(with_pin) {
Cli* cli = furi_record_open(RECORD_CLI);
cli_session_open(cli, &cli_vcp);
furi_record_close(RECORD_CLI);
Bt* bt = furi_record_open(RECORD_BT);
bt_open_rpc_connection(bt);
furi_record_close(RECORD_BT);
if(!momentum_settings.allow_locked_rpc_usb) {
Cli* cli = furi_record_open(RECORD_CLI);
cli_session_open(cli, &cli_vcp);
furi_record_close(RECORD_CLI);
}
if(!momentum_settings.allow_locked_rpc_ble) {
Bt* bt = furi_record_open(RECORD_BT);
bt_open_rpc_connection(bt);
furi_record_close(RECORD_BT);
}
}
DesktopStatus status = {.locked = false};

View File

@@ -385,9 +385,10 @@ static void
}
RpcSession* rpc_session_open(Rpc* rpc, RpcOwner owner) {
if(furi_hal_rtc_is_flag_set(FuriHalRtcFlagLock) &&
!momentum_settings.allow_locked_rpc_commands)
return NULL;
if(furi_hal_rtc_is_flag_set(FuriHalRtcFlagLock)) {
if(owner == RpcOwnerUsb && !momentum_settings.allow_locked_rpc_usb) return NULL;
if(owner == RpcOwnerBle && !momentum_settings.allow_locked_rpc_ble) return NULL;
}
furi_check(rpc);

View File

@@ -14,7 +14,8 @@ MomentumSettings momentum_settings = {
.menu_style = MenuStyleDsi, // DSi
.lock_on_boot = false, // OFF
.bad_pins_format = false, // OFF
.allow_locked_rpc_commands = false, // OFF
.allow_locked_rpc_usb = false, // OFF
.allow_locked_rpc_ble = false, // OFF
.lockscreen_poweroff = true, // ON
.lockscreen_time = true, // ON
.lockscreen_seconds = false, // OFF
@@ -82,7 +83,8 @@ static const struct {
{setting_bool(unlock_anims)},
{setting_enum(menu_style, MenuStyleCount)},
{setting_bool(bad_pins_format)},
{setting_bool(allow_locked_rpc_commands)},
{setting_bool(allow_locked_rpc_usb)},
{setting_bool(allow_locked_rpc_ble)},
{setting_bool(lock_on_boot)},
{setting_bool(lockscreen_poweroff)},
{setting_bool(lockscreen_time)},

View File

@@ -62,7 +62,8 @@ typedef struct {
MenuStyle menu_style;
bool lock_on_boot;
bool bad_pins_format;
bool allow_locked_rpc_commands;
bool allow_locked_rpc_usb;
bool allow_locked_rpc_ble;
bool lockscreen_poweroff;
bool lockscreen_time;
bool lockscreen_seconds;