Move ember-specific attribute persistence providers into `src/util/persistence` (#36473)
* Move persistence providers code into util since they depend on ember.
Unit tests pass, will need to fix up apps.
* Fix up more includes
* Restyled by clang-format
* Fix up qpg build
* Also fix nrfconnect deferred attribute persistence use
* Fix path
* Add persistence to esp32 CMakeLists.txt
* Update examples/lighting-app/qpg/BUILD.gn
---------
Co-authored-by: Andrei Litvin <andreilitvin@google.com>
Co-authored-by: Restyled.io <commits@restyled.io>
diff --git a/examples/all-clusters-app/esp32/main/CMakeLists.txt b/examples/all-clusters-app/esp32/main/CMakeLists.txt
index 3129254..c35efdf 100644
--- a/examples/all-clusters-app/esp32/main/CMakeLists.txt
+++ b/examples/all-clusters-app/esp32/main/CMakeLists.txt
@@ -45,6 +45,7 @@
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/icd/server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/util"
+ "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/util/persistence"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/reporting"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/administrator-commissioning-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/air-quality-server"
diff --git a/examples/all-clusters-minimal-app/esp32/main/CMakeLists.txt b/examples/all-clusters-minimal-app/esp32/main/CMakeLists.txt
index f82f301..680d4a9 100644
--- a/examples/all-clusters-minimal-app/esp32/main/CMakeLists.txt
+++ b/examples/all-clusters-minimal-app/esp32/main/CMakeLists.txt
@@ -38,6 +38,7 @@
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/icd"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/util"
+ "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/util/persistence"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/reporting"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/administrator-commissioning-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/application-basic-server"
diff --git a/examples/bridge-app/esp32/main/CMakeLists.txt b/examples/bridge-app/esp32/main/CMakeLists.txt
index 3330f69..9d34b44 100644
--- a/examples/bridge-app/esp32/main/CMakeLists.txt
+++ b/examples/bridge-app/esp32/main/CMakeLists.txt
@@ -23,6 +23,7 @@
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/app-common/app-common/zap-generated"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/util"
+ "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/util/persistence"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/reporting"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/access-control-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/administrator-commissioning-server"
diff --git a/examples/chef/esp32/main/CMakeLists.txt b/examples/chef/esp32/main/CMakeLists.txt
index 5c8963f..a7905ff 100644
--- a/examples/chef/esp32/main/CMakeLists.txt
+++ b/examples/chef/esp32/main/CMakeLists.txt
@@ -79,6 +79,7 @@
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/app-common/app-common/zap-generated/attributes"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/util"
+ "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/util/persistence"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/reporting"
)
diff --git a/examples/energy-management-app/esp32/main/CMakeLists.txt b/examples/energy-management-app/esp32/main/CMakeLists.txt
index e545961..06623d3 100644
--- a/examples/energy-management-app/esp32/main/CMakeLists.txt
+++ b/examples/energy-management-app/esp32/main/CMakeLists.txt
@@ -44,6 +44,7 @@
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32/shell_extension"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/util"
+ "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/util/persistence"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/reporting"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/access-control-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/administrator-commissioning-server"
diff --git a/examples/light-switch-app/esp32/main/CMakeLists.txt b/examples/light-switch-app/esp32/main/CMakeLists.txt
index b4b6f59..92be835 100644
--- a/examples/light-switch-app/esp32/main/CMakeLists.txt
+++ b/examples/light-switch-app/esp32/main/CMakeLists.txt
@@ -30,6 +30,7 @@
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32/shell_extension"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/util"
+ "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/util/persistence"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/reporting"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/icd/server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/access-control-server"
diff --git a/examples/lighting-app/esp32/main/CMakeLists.txt b/examples/lighting-app/esp32/main/CMakeLists.txt
index d3dc342..1ad5bc1 100644
--- a/examples/lighting-app/esp32/main/CMakeLists.txt
+++ b/examples/lighting-app/esp32/main/CMakeLists.txt
@@ -34,6 +34,7 @@
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32/shell_extension"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/util"
+ "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/util/persistence"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/reporting"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/access-control-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/administrator-commissioning-server"
diff --git a/examples/lighting-app/nrfconnect/CMakeLists.txt b/examples/lighting-app/nrfconnect/CMakeLists.txt
index 59bf2f2..dd5b65a 100644
--- a/examples/lighting-app/nrfconnect/CMakeLists.txt
+++ b/examples/lighting-app/nrfconnect/CMakeLists.txt
@@ -51,6 +51,7 @@
main/AppTask.cpp
main/main.cpp
main/ZclCallbacks.cpp
+ ${CHIP_ROOT}/src/app/util/persistence/DeferredAttributePersistenceProvider.cpp
${NRFCONNECT_COMMON}/util/LEDWidget.cpp
${NRFCONNECT_COMMON}/util/PWMDevice.cpp)
diff --git a/examples/lighting-app/nrfconnect/main/AppTask.cpp b/examples/lighting-app/nrfconnect/main/AppTask.cpp
index 88964d9..0148497 100644
--- a/examples/lighting-app/nrfconnect/main/AppTask.cpp
+++ b/examples/lighting-app/nrfconnect/main/AppTask.cpp
@@ -26,13 +26,13 @@
#include <DeviceInfoProviderImpl.h>
#include <app-common/zap-generated/attributes/Accessors.h>
-#include <app/DeferredAttributePersistenceProvider.h>
#include <app/TestEventTriggerDelegate.h>
#include <app/clusters/identify-server/identify-server.h>
#include <app/clusters/ota-requestor/OTATestEventTriggerHandler.h>
#include <app/server/Dnssd.h>
#include <app/server/OnboardingCodesUtil.h>
#include <app/server/Server.h>
+#include <app/util/persistence/DeferredAttributePersistenceProvider.h>
#include <credentials/DeviceAttestationCredsProvider.h>
#include <credentials/examples/DeviceAttestationCredsExample.h>
#include <lib/core/ErrorStr.h>
diff --git a/examples/lighting-app/qpg/BUILD.gn b/examples/lighting-app/qpg/BUILD.gn
index 886c8aa..b4a2998 100644
--- a/examples/lighting-app/qpg/BUILD.gn
+++ b/examples/lighting-app/qpg/BUILD.gn
@@ -66,6 +66,7 @@
"${chip_root}/examples/lighting-app/lighting-common:color-format",
"${chip_root}/examples/lighting-app/qpg/zap/",
"${chip_root}/examples/providers:device_info_provider",
+ "${chip_root}/src/app/util/persistence:deferred",
"${chip_root}/src/lib",
"${chip_root}/src/platform/logging:default",
"${chip_root}/src/setup_payload",
diff --git a/examples/lighting-app/qpg/src/AppTask.cpp b/examples/lighting-app/qpg/src/AppTask.cpp
index 90f2e30..0c09e97 100644
--- a/examples/lighting-app/qpg/src/AppTask.cpp
+++ b/examples/lighting-app/qpg/src/AppTask.cpp
@@ -43,7 +43,7 @@
#include <app/util/attribute-storage.h>
#include <lib/support/TypeTraits.h>
-#include <app/DeferredAttributePersistenceProvider.h>
+#include <app/util/persistence/DeferredAttributePersistenceProvider.h>
#include <credentials/DeviceAttestationCredsProvider.h>
#include <credentials/examples/DeviceAttestationCredsExample.h>
diff --git a/examples/lit-icd-app/esp32/main/CMakeLists.txt b/examples/lit-icd-app/esp32/main/CMakeLists.txt
index 5f2850f..4d8fe2a 100644
--- a/examples/lit-icd-app/esp32/main/CMakeLists.txt
+++ b/examples/lit-icd-app/esp32/main/CMakeLists.txt
@@ -29,6 +29,7 @@
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/app-common/app-common/zap-generated"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/util"
+ "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/util/persistence"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/reporting"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/access-control-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/administrator-commissioning-server"
diff --git a/examples/lock-app/esp32/main/CMakeLists.txt b/examples/lock-app/esp32/main/CMakeLists.txt
index 5c5f46a..028a92a 100644
--- a/examples/lock-app/esp32/main/CMakeLists.txt
+++ b/examples/lock-app/esp32/main/CMakeLists.txt
@@ -49,6 +49,7 @@
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/app-common/app-common/zap-generated"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/util"
+ "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/util/persistence"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/reporting"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/icd/server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/access-control-server"
@@ -162,6 +163,7 @@
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32/common"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/util"
+ "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/util/persistence"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/reporting"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/icd/server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/access-control-server"
diff --git a/examples/ota-provider-app/esp32/main/CMakeLists.txt b/examples/ota-provider-app/esp32/main/CMakeLists.txt
index 41acd9e..d651ac7 100644
--- a/examples/ota-provider-app/esp32/main/CMakeLists.txt
+++ b/examples/ota-provider-app/esp32/main/CMakeLists.txt
@@ -26,6 +26,7 @@
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/app-common/app-common/zap-generated"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/util"
+ "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/util/persistence"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/reporting"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/access-control-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/administrator-commissioning-server"
diff --git a/examples/ota-requestor-app/esp32/main/CMakeLists.txt b/examples/ota-requestor-app/esp32/main/CMakeLists.txt
index fbda70f..2688fea 100644
--- a/examples/ota-requestor-app/esp32/main/CMakeLists.txt
+++ b/examples/ota-requestor-app/esp32/main/CMakeLists.txt
@@ -31,6 +31,7 @@
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/app-common/app-common/zap-generated"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/util"
+ "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/util/persistence"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/reporting"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/access-control-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/administrator-commissioning-server"
diff --git a/examples/temperature-measurement-app/esp32/main/CMakeLists.txt b/examples/temperature-measurement-app/esp32/main/CMakeLists.txt
index 8bc94f7..8036700 100644
--- a/examples/temperature-measurement-app/esp32/main/CMakeLists.txt
+++ b/examples/temperature-measurement-app/esp32/main/CMakeLists.txt
@@ -29,6 +29,7 @@
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/app-common/app-common/zap-generated"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/util"
+ "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/util/persistence"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/reporting"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/access-control-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/administrator-commissioning-server"
diff --git a/examples/thread-br-app/esp32/main/CMakeLists.txt b/examples/thread-br-app/esp32/main/CMakeLists.txt
index c0cb123..c1f8228 100644
--- a/examples/thread-br-app/esp32/main/CMakeLists.txt
+++ b/examples/thread-br-app/esp32/main/CMakeLists.txt
@@ -30,6 +30,7 @@
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32/shell_extension"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/util"
+ "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/util/persistence"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/reporting"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/icd/server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/access-control-server"
diff --git a/src/BUILD.gn b/src/BUILD.gn
index 722e0c8..3676c92 100644
--- a/src/BUILD.gn
+++ b/src/BUILD.gn
@@ -100,7 +100,10 @@
}
if (chip_device_platform != "efr32") {
- tests += [ "${chip_root}/src/app/tests" ]
+ tests += [
+ "${chip_root}/src/app/tests",
+ "${chip_root}/src/app/util/persistence/tests",
+ ]
# Disabled for EFR32 because _open is not implemented.
# https://github.com/project-chip/connectedhomeip/issues/35624
diff --git a/src/app/BUILD.gn b/src/app/BUILD.gn
index b0cde09..8b008c4 100644
--- a/src/app/BUILD.gn
+++ b/src/app/BUILD.gn
@@ -389,6 +389,18 @@
]
}
+source_set("attribute-persistence") {
+ sources = [ "SafeAttributePersistenceProvider.h" ]
+
+ public_deps = [
+ ":paths",
+ "${chip_root}/src/app/data-model:nullable",
+ "${chip_root}/src/app/util:types",
+ "${chip_root}/src/lib/support",
+ "${chip_root}/src/lib/support:span",
+ ]
+}
+
# Note to developpers, instead of continuously adding files in the app librabry, it is recommand to create smaller source_sets that app can depend on.
# This way, we can have a better understanding of dependencies and other componenets can depend on the different source_sets without needing to depend on the entire app library.
static_library("app") {
@@ -398,15 +410,10 @@
"AttributePathExpandIterator.cpp",
"AttributePathExpandIterator.h",
"AttributePathExpandIterator.h",
- "AttributePersistenceProvider.h",
"ChunkedWriteCallback.cpp",
"ChunkedWriteCallback.h",
"CommandResponseHelper.h",
"CommandResponseSender.cpp",
- "DefaultAttributePersistenceProvider.cpp",
- "DefaultAttributePersistenceProvider.h",
- "DeferredAttributePersistenceProvider.cpp",
- "DeferredAttributePersistenceProvider.h",
"EventLogging.h",
"EventManagement.cpp",
"EventManagement.h",
@@ -416,7 +423,6 @@
"GenericEventManagementTestEventTriggerHandler.h",
"OTAUserConsentCommon.h",
"ReadHandler.cpp",
- "SafeAttributePersistenceProvider.h",
"TimerDelegates.cpp",
"TimerDelegates.h",
"WriteHandler.cpp",
diff --git a/src/app/SafeAttributePersistenceProvider.h b/src/app/SafeAttributePersistenceProvider.h
index 8d11d95..b1e7148 100644
--- a/src/app/SafeAttributePersistenceProvider.h
+++ b/src/app/SafeAttributePersistenceProvider.h
@@ -18,12 +18,13 @@
#include <app/ConcreteAttributePath.h>
#include <app/data-model/Nullable.h>
#include <app/util/attribute-metadata.h>
-#include <cstring>
-#include <inttypes.h>
#include <lib/support/BufferReader.h>
#include <lib/support/BufferWriter.h>
#include <lib/support/Span.h>
+#include <cstring>
+#include <inttypes.h>
+
namespace chip {
namespace app {
diff --git a/src/app/chip_data_model.cmake b/src/app/chip_data_model.cmake
index 75e2d8a..0f62842 100644
--- a/src/app/chip_data_model.cmake
+++ b/src/app/chip_data_model.cmake
@@ -164,6 +164,7 @@
${CHIP_APP_BASE_DIR}/util/generic-callback-stubs.cpp
${CHIP_APP_BASE_DIR}/util/privilege-storage.cpp
${CHIP_APP_BASE_DIR}/util/util.cpp
+ ${CHIP_APP_BASE_DIR}/util/persistence/DefaultAttributePersistenceProvider.cpp
${CODEGEN_DATA_MODEL_SOURCES}
${APP_GEN_FILES}
${APP_TEMPLATES_GEN_FILES}
diff --git a/src/app/chip_data_model.gni b/src/app/chip_data_model.gni
index 9f4ed59..3be8df5 100644
--- a/src/app/chip_data_model.gni
+++ b/src/app/chip_data_model.gni
@@ -460,6 +460,7 @@
"${chip_root}/src/app/common:cluster-objects",
"${chip_root}/src/app/common:enums",
"${chip_root}/src/app/util:types",
+ "${chip_root}/src/app/util/persistence",
"${chip_root}/src/controller",
"${chip_root}/src/lib/core",
"${chip_root}/src/lib/support",
diff --git a/src/app/clusters/mode-base-server/mode-base-server.h b/src/app/clusters/mode-base-server/mode-base-server.h
index f787e9f..06c22f3 100644
--- a/src/app/clusters/mode-base-server/mode-base-server.h
+++ b/src/app/clusters/mode-base-server/mode-base-server.h
@@ -20,8 +20,8 @@
#include "mode-base-cluster-objects.h"
#include <app/AttributeAccessInterface.h>
-#include <app/AttributePersistenceProvider.h>
#include <app/CommandHandlerInterface.h>
+#include <app/util/persistence/AttributePersistenceProvider.h>
#include <lib/support/IntrusiveList.h>
namespace chip {
diff --git a/src/app/server/BUILD.gn b/src/app/server/BUILD.gn
index 42c4caf..43c9708 100644
--- a/src/app/server/BUILD.gn
+++ b/src/app/server/BUILD.gn
@@ -58,6 +58,7 @@
"${chip_root}/src/app:test-event-trigger",
"${chip_root}/src/app/icd/server:icd-server-config",
"${chip_root}/src/app/icd/server:observer",
+ "${chip_root}/src/app/util/persistence",
"${chip_root}/src/lib/address_resolve",
"${chip_root}/src/lib/dnssd",
"${chip_root}/src/lib/dnssd:naming",
diff --git a/src/app/server/Server.h b/src/app/server/Server.h
index 2f61197..fc6f7ac 100644
--- a/src/app/server/Server.h
+++ b/src/app/server/Server.h
@@ -24,7 +24,6 @@
#include <access/examples/ExampleAccessControlDelegate.h>
#include <app/CASEClientPool.h>
#include <app/CASESessionManager.h>
-#include <app/DefaultAttributePersistenceProvider.h>
#include <app/FailSafeContext.h>
#include <app/OperationalSessionSetupPool.h>
#include <app/SimpleSubscriptionResumptionStorage.h>
@@ -81,6 +80,11 @@
#endif // CHIP_CONFIG_ENABLE_ICD_CIP
#endif // CHIP_CONFIG_ENABLE_ICD_SERVER
+// TODO: https://github.com/project-chip/connectedhomeip/issues/36472
+// this strongly couples Server to Ember and this dependency should
+// be removed
+#include <app/util/persistence/DefaultAttributePersistenceProvider.h>
+
namespace chip {
inline constexpr size_t kMaxBlePendingPackets = 1;
diff --git a/src/app/tests/BUILD.gn b/src/app/tests/BUILD.gn
index 6f55c7b..105d09f 100644
--- a/src/app/tests/BUILD.gn
+++ b/src/app/tests/BUILD.gn
@@ -198,7 +198,6 @@
"TestAttributeAccessInterfaceCache.cpp",
"TestAttributePathExpandIterator.cpp",
"TestAttributePathParams.cpp",
- "TestAttributePersistenceProvider.cpp",
"TestAttributeValueDecoder.cpp",
"TestAttributeValueEncoder.cpp",
"TestBasicCommandPathRegistry.cpp",
diff --git a/src/app/util/attribute-storage.cpp b/src/app/util/attribute-storage.cpp
index 51c01c7..4d9cc23 100644
--- a/src/app/util/attribute-storage.cpp
+++ b/src/app/util/attribute-storage.cpp
@@ -20,7 +20,6 @@
#include <app/util/attribute-storage-detail.h>
#include <app/AttributeAccessInterfaceRegistry.h>
-#include <app/AttributePersistenceProvider.h>
#include <app/CommandHandlerInterfaceRegistry.h>
#include <app/InteractionModelEngine.h>
#include <app/reporting/reporting.h>
@@ -28,6 +27,7 @@
#include <app/util/ember-strings.h>
#include <app/util/endpoint-config-api.h>
#include <app/util/generic-callbacks.h>
+#include <app/util/persistence/AttributePersistenceProvider.h>
#include <lib/core/CHIPConfig.h>
#include <lib/support/CodeUtils.h>
#include <lib/support/logging/CHIPLogging.h>
diff --git a/src/app/AttributePersistenceProvider.h b/src/app/util/persistence/AttributePersistenceProvider.h
similarity index 100%
rename from src/app/AttributePersistenceProvider.h
rename to src/app/util/persistence/AttributePersistenceProvider.h
diff --git a/src/app/util/persistence/BUILD.gn b/src/app/util/persistence/BUILD.gn
new file mode 100644
index 0000000..dbc8dbe
--- /dev/null
+++ b/src/app/util/persistence/BUILD.gn
@@ -0,0 +1,47 @@
+# Copyright (c) 2024 Project CHIP Authors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import("//build_overrides/chip.gni")
+
+source_set("persistence") {
+ sources = [
+ "AttributePersistenceProvider.h",
+ "DefaultAttributePersistenceProvider.cpp",
+ "DefaultAttributePersistenceProvider.h",
+ ]
+
+ public_deps = [
+ "${chip_root}/src/app:attribute-persistence",
+ "${chip_root}/src/app:paths",
+ "${chip_root}/src/app/util:types",
+ "${chip_root}/src/lib/core",
+ "${chip_root}/src/lib/support",
+ "${chip_root}/src/lib/support:span",
+ ]
+}
+
+source_set("deferred") {
+ sources = [
+ "DeferredAttributePersistenceProvider.cpp",
+ "DeferredAttributePersistenceProvider.h",
+ ]
+
+ public_deps = [
+ ":persistence",
+ "${chip_root}/src/lib/support",
+ "${chip_root}/src/lib/support:span",
+ "${chip_root}/src/platform",
+ "${chip_root}/src/system",
+ ]
+}
diff --git a/src/app/DefaultAttributePersistenceProvider.cpp b/src/app/util/persistence/DefaultAttributePersistenceProvider.cpp
similarity index 98%
rename from src/app/DefaultAttributePersistenceProvider.cpp
rename to src/app/util/persistence/DefaultAttributePersistenceProvider.cpp
index 40ce521..70488e8 100644
--- a/src/app/DefaultAttributePersistenceProvider.cpp
+++ b/src/app/util/persistence/DefaultAttributePersistenceProvider.cpp
@@ -13,8 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+#include <app/util/persistence/DefaultAttributePersistenceProvider.h>
-#include <app/DefaultAttributePersistenceProvider.h>
#include <app/util/ember-strings.h>
#include <lib/support/CodeUtils.h>
#include <lib/support/DefaultStorageKeyAllocator.h>
diff --git a/src/app/DefaultAttributePersistenceProvider.h b/src/app/util/persistence/DefaultAttributePersistenceProvider.h
similarity index 97%
rename from src/app/DefaultAttributePersistenceProvider.h
rename to src/app/util/persistence/DefaultAttributePersistenceProvider.h
index 3e18808..a4796f2 100644
--- a/src/app/DefaultAttributePersistenceProvider.h
+++ b/src/app/util/persistence/DefaultAttributePersistenceProvider.h
@@ -15,8 +15,8 @@
*/
#pragma once
-#include <app/AttributePersistenceProvider.h>
#include <app/SafeAttributePersistenceProvider.h>
+#include <app/util/persistence/AttributePersistenceProvider.h>
#include <lib/core/CHIPPersistentStorageDelegate.h>
#include <lib/support/DefaultStorageKeyAllocator.h>
diff --git a/src/app/DeferredAttributePersistenceProvider.cpp b/src/app/util/persistence/DeferredAttributePersistenceProvider.cpp
similarity index 97%
rename from src/app/DeferredAttributePersistenceProvider.cpp
rename to src/app/util/persistence/DeferredAttributePersistenceProvider.cpp
index 26adcb1..6b1822f 100644
--- a/src/app/DeferredAttributePersistenceProvider.cpp
+++ b/src/app/util/persistence/DeferredAttributePersistenceProvider.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#include <app/DeferredAttributePersistenceProvider.h>
+#include <app/util/persistence/DeferredAttributePersistenceProvider.h>
#include <platform/CHIPDeviceLayer.h>
diff --git a/src/app/DeferredAttributePersistenceProvider.h b/src/app/util/persistence/DeferredAttributePersistenceProvider.h
similarity index 97%
rename from src/app/DeferredAttributePersistenceProvider.h
rename to src/app/util/persistence/DeferredAttributePersistenceProvider.h
index 6c641dc..592408b 100644
--- a/src/app/DeferredAttributePersistenceProvider.h
+++ b/src/app/util/persistence/DeferredAttributePersistenceProvider.h
@@ -15,7 +15,7 @@
*/
#pragma once
-#include <app/AttributePersistenceProvider.h>
+#include <app/util/persistence/AttributePersistenceProvider.h>
#include <lib/support/ScopedBuffer.h>
#include <lib/support/Span.h>
#include <system/SystemClock.h>
diff --git a/src/app/util/persistence/tests/BUILD.gn b/src/app/util/persistence/tests/BUILD.gn
new file mode 100644
index 0000000..7a0bd52
--- /dev/null
+++ b/src/app/util/persistence/tests/BUILD.gn
@@ -0,0 +1,34 @@
+# Copyright (c) 2024 Project CHIP Authors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import("//build_overrides/build.gni")
+import("//build_overrides/chip.gni")
+import("//build_overrides/pigweed.gni")
+
+import("${chip_root}/build/chip/chip_test_suite.gni")
+
+chip_test_suite("tests") {
+ output_name = "libAppUtilPersistenceTests"
+
+ test_sources = [ "TestAttributePersistenceProvider.cpp" ]
+
+ cflags = [ "-Wconversion" ]
+
+ public_deps = [
+ "${chip_root}/src/app/common:cluster-objects",
+ "${chip_root}/src/app/util/persistence",
+ "${chip_root}/src/lib/core:string-builder-adapters",
+ "${chip_root}/src/lib/support:testing",
+ ]
+}
diff --git a/src/app/tests/TestAttributePersistenceProvider.cpp b/src/app/util/persistence/tests/TestAttributePersistenceProvider.cpp
similarity index 99%
rename from src/app/tests/TestAttributePersistenceProvider.cpp
rename to src/app/util/persistence/tests/TestAttributePersistenceProvider.cpp
index 1b8c7ee..1324f37 100644
--- a/src/app/tests/TestAttributePersistenceProvider.cpp
+++ b/src/app/util/persistence/tests/TestAttributePersistenceProvider.cpp
@@ -17,7 +17,7 @@
*/
#include <app-common/zap-generated/cluster-objects.h>
-#include <app/DefaultAttributePersistenceProvider.h>
+#include <app/util/persistence/DefaultAttributePersistenceProvider.h>
#include <lib/core/StringBuilderAdapters.h>
#include <lib/support/TestPersistentStorageDelegate.h>
#include <pw_unit_test/framework.h>