From 70ba158c69b3c6402b1807165d1364c80d08fd2c Mon Sep 17 00:00:00 2001 From: Marek Pieta Date: Tue, 4 Jul 2023 09:32:02 +0200 Subject: [PATCH 1/2] bluetooth: fast_pair: Delete "reset" flag instead of storing false Change deletes Fast Pair storage manager's "reset" flag instead of storing it as false to ensure no data is left in settings after a successful factory reset operation. Jira: NCSDK-20219 Signed-off-by: Marek Pieta --- .../releases/release-notes-changelog.rst | 5 +++++ .../services/fast_pair/fp_storage/fp_storage_manager.c | 9 +++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/doc/nrf/releases_and_maturity/releases/release-notes-changelog.rst b/doc/nrf/releases_and_maturity/releases/release-notes-changelog.rst index af1945e261a6..34dceef410aa 100644 --- a/doc/nrf/releases_and_maturity/releases/release-notes-changelog.rst +++ b/doc/nrf/releases_and_maturity/releases/release-notes-changelog.rst @@ -345,6 +345,11 @@ Binary libraries Bluetooth libraries and services -------------------------------- +* :ref:`bt_fast_pair_readme` library: + + * Deleted reset in progress flag from settings storage instead of storing it as ``false`` on factory reset operation. + This is done to ensure that no Fast Pair data is left in the settings storage after the factory reset. + * :ref:`bt_mesh` library: * Added: diff --git a/subsys/bluetooth/services/fast_pair/fp_storage/fp_storage_manager.c b/subsys/bluetooth/services/fast_pair/fp_storage/fp_storage_manager.c index f97230869d55..af8a287440b1 100644 --- a/subsys/bluetooth/services/fast_pair/fp_storage/fp_storage_manager.c +++ b/subsys/bluetooth/services/fast_pair/fp_storage/fp_storage_manager.c @@ -76,8 +76,13 @@ static int reset_in_progress_set(bool in_progress) { int err; - err = settings_save_one(SETTINGS_RESET_IN_PROGRESS_FULL_NAME, &in_progress, - sizeof(in_progress)); + if (in_progress) { + err = settings_save_one(SETTINGS_RESET_IN_PROGRESS_FULL_NAME, &in_progress, + sizeof(in_progress)); + } else { + err = settings_delete(SETTINGS_RESET_IN_PROGRESS_FULL_NAME); + } + if (err) { return err; } From 123882d937c7d526629f337a3deabda5d96ca704 Mon Sep 17 00:00:00 2001 From: Marek Pieta Date: Tue, 4 Jul 2023 09:44:15 +0200 Subject: [PATCH 2/2] tests: fast_pair: Ensure reset in progress flag is deleted Change ensures that reset in progress flag is deleted during the Fast Pair factory reset operation. Jira: NCSDK-20219 Signed-off-by: Marek Pieta --- .../storage/factory_reset/src/main.c | 29 ------------------- 1 file changed, 29 deletions(-) diff --git a/tests/subsys/bluetooth/fast_pair/storage/factory_reset/src/main.c b/tests/subsys/bluetooth/fast_pair/storage/factory_reset/src/main.c index ed358bd00701..2f3f45d3b984 100644 --- a/tests/subsys/bluetooth/fast_pair/storage/factory_reset/src/main.c +++ b/tests/subsys/bluetooth/fast_pair/storage/factory_reset/src/main.c @@ -182,35 +182,6 @@ static int fp_settings_data_validate_empty_cb(const char *key, size_t len, setti return 0; } - if (!strncmp(key, SETTINGS_RESET_IN_PROGRESS_FULL_NAME, - sizeof(SETTINGS_RESET_IN_PROGRESS_FULL_NAME))) { - int rc; - bool reset_in_progress; - - if (len != sizeof(reset_in_progress)) { - *err = -EINVAL; - return *err; - } - - rc = read_cb(cb_arg, &reset_in_progress, len); - if (rc < 0) { - *err = rc; - return *err; - } - - if (rc != len) { - *err = -EINVAL; - return *err; - } - - if (reset_in_progress) { - *err = -EFAULT; - return *err; - } - - return 0; - } - *err = -EFAULT; return *err; }