diff --git a/examples/all-clusters-app/linux/BUILD.gn b/examples/all-clusters-app/linux/BUILD.gn index 3d52ef748de90d..6217aa54a97dbc 100644 --- a/examples/all-clusters-app/linux/BUILD.gn +++ b/examples/all-clusters-app/linux/BUILD.gn @@ -142,6 +142,7 @@ if (is_libfuzzer) { deps = [ ":chip-all-clusters-common", "${chip_root}/examples/platform/linux:app-main", + "${chip_root}/src/app/server:server-full", ] cflags = [ "-Wconversion" ] diff --git a/src/app/server/DefaultTermsAndConditionsProvider.cpp b/src/app/server/DefaultTermsAndConditionsProvider.cpp index e0f34e0e5414f2..f341ed207aa9a7 100644 --- a/src/app/server/DefaultTermsAndConditionsProvider.cpp +++ b/src/app/server/DefaultTermsAndConditionsProvider.cpp @@ -21,21 +21,32 @@ #include #include +#ifndef CHIP_CONFIG_TC_REQUIRED_ACKNOWLEDGEMENTS +#error "CHIP_CONFIG_TC_REQUIRED_ACKNOWLEDGEMENTS is not defined!" +#endif + +#ifndef CHIP_CONFIG_TC_REQUIRED_ACKNOWLEDGEMENTS_VERSION +#error "CHIP_CONFIG_TC_REQUIRED_ACKNOWLEDGEMENTS_VERSION is not defined!" +#endif + CHIP_ERROR -chip::app::DefaultTermsAndConditionsProvider::Init(chip::DeviceLayer::PersistedStorage::KeyValueStoreManager * const inKvsManager) +chip::app::DefaultTermsAndConditionsProvider::Init(chip::PersistentStorageDelegate * inPersistentStorageDelegate) { - mKeyValueStoreManager = inKvsManager; + mPersistentStorageDelegate = inPersistentStorageDelegate; return CHIP_NO_ERROR; } CHIP_ERROR chip::app::DefaultTermsAndConditionsProvider::GetAcceptance(uint16_t & outAcknowledgementsValue, uint16_t & outAcknowledgementsVersionValue) { - uint16_t acknowledgements = 0; - uint16_t acknowledgementsVersion = 0; + uint16_t acknowledgements = 0; + uint16_t acknowledgementsSize = sizeof(acknowledgementsSize); + uint16_t acknowledgementsVersion = 0; + uint16_t acknowledgementsVersionSize = sizeof(acknowledgementsVersion); - mKeyValueStoreManager->Get(kAcceptedAcknowledgementsKeyName, &acknowledgements, sizeof(acknowledgements)); - mKeyValueStoreManager->Get(kAcceptedAcknowledgementsVersionKeyName, &acknowledgementsVersion, sizeof(acknowledgementsVersion)); + mPersistentStorageDelegate->SyncGetKeyValue(kAcceptedAcknowledgementsKeyName, &acknowledgements, acknowledgementsSize); + mPersistentStorageDelegate->SyncGetKeyValue(kAcceptedAcknowledgementsVersionKeyName, &acknowledgementsVersion, + acknowledgementsVersionSize); outAcknowledgementsValue = acknowledgements; outAcknowledgementsVersionValue = acknowledgementsVersion; @@ -43,14 +54,6 @@ CHIP_ERROR chip::app::DefaultTermsAndConditionsProvider::GetAcceptance(uint16_t return CHIP_NO_ERROR; } -#ifndef CHIP_CONFIG_TC_REQUIRED_ACKNOWLEDGEMENTS -#error "CHIP_CONFIG_TC_REQUIRED_ACKNOWLEDGEMENTS is not defined!" -#endif - -#ifndef CHIP_CONFIG_TC_REQUIRED_ACKNOWLEDGEMENTS_VERSION -#error "CHIP_CONFIG_TC_REQUIRED_ACKNOWLEDGEMENTS_VERSION is not defined!" -#endif - CHIP_ERROR chip::app::DefaultTermsAndConditionsProvider::GetRequirements(uint16_t & outAcknowledgementsValue, uint16_t & outAcknowledgementsVersionValue) { @@ -62,9 +65,9 @@ CHIP_ERROR chip::app::DefaultTermsAndConditionsProvider::GetRequirements(uint16_ CHIP_ERROR chip::app::DefaultTermsAndConditionsProvider::SetAcceptance(uint16_t inAcceptedAcknowledgementsValue, uint16_t inAcceptedAcknowledgementsVersionValue) { - mKeyValueStoreManager->Put(kAcceptedAcknowledgementsKeyName, &inAcceptedAcknowledgementsValue, - sizeof(inAcceptedAcknowledgementsValue)); - mKeyValueStoreManager->Put(kAcceptedAcknowledgementsVersionKeyName, &inAcceptedAcknowledgementsVersionValue, - sizeof(inAcceptedAcknowledgementsVersionValue)); + mPersistentStorageDelegate->SyncSetKeyValue(kAcceptedAcknowledgementsKeyName, &inAcceptedAcknowledgementsValue, + sizeof(inAcceptedAcknowledgementsValue)); + mPersistentStorageDelegate->SyncSetKeyValue(kAcceptedAcknowledgementsVersionKeyName, &inAcceptedAcknowledgementsVersionValue, + sizeof(inAcceptedAcknowledgementsVersionValue)); return CHIP_NO_ERROR; } diff --git a/src/app/server/DefaultTermsAndConditionsProvider.h b/src/app/server/DefaultTermsAndConditionsProvider.h index 36f7c21eb57973..024f96c0b75f82 100644 --- a/src/app/server/DefaultTermsAndConditionsProvider.h +++ b/src/app/server/DefaultTermsAndConditionsProvider.h @@ -23,7 +23,7 @@ #include #include -#include +#include namespace chip { namespace app { @@ -36,10 +36,10 @@ class DefaultTermsAndConditionsProvider : public TermsAndConditionsProvider /** * @brief Initializes the TermsAndConditionsProvider. * - * @param[in] inKvsManager The KVS manager dependency. + * @param[in] inPersistentStorageDelegate Persistent storage delegate dependency. * @return CHIP_ERROR On success returns CHIP_NO_ERROR, otherwise returns an error code. */ - virtual CHIP_ERROR Init(chip::DeviceLayer::PersistedStorage::KeyValueStoreManager * inKvsManager); + virtual CHIP_ERROR Init(chip::PersistentStorageDelegate * inPersistentStorageDelegate); /** * @brief Retrieves the acceptance status of the required terms and conditions. @@ -69,7 +69,7 @@ class DefaultTermsAndConditionsProvider : public TermsAndConditionsProvider virtual CHIP_ERROR SetAcceptance(uint16_t inAcknowledgementsValue, uint16_t inAcknowledgementsVersionValue); private: - chip::DeviceLayer::PersistedStorage::KeyValueStoreManager * mKeyValueStoreManager; + chip::PersistentStorageDelegate * mPersistentStorageDelegate; }; }; // namespace app diff --git a/src/app/server/Server.cpp b/src/app/server/Server.cpp index eb1e8805e7aa20..14cb938259d9aa 100644 --- a/src/app/server/Server.cpp +++ b/src/app/server/Server.cpp @@ -148,7 +148,7 @@ CHIP_ERROR CommonCaseDeviceServerInitParams::InitializeStaticResourcesBeforeServ if (this->termsAndConditionsProvider == nullptr) { - ReturnErrorOnFailure(sDefaultTermsAndConditionsProviderInstance.Init(&kvsManager)); + ReturnErrorOnFailure(sDefaultTermsAndConditionsProviderInstance.Init(this->persistentStorageDelegate)); this->termsAndConditionsProvider = sDefaultTermsAndConditionsProvider; } diff --git a/src/controller/BUILD.gn b/src/controller/BUILD.gn index 5bfd71c5c728bf..38bcd14da515cf 100644 --- a/src/controller/BUILD.gn +++ b/src/controller/BUILD.gn @@ -113,7 +113,7 @@ static_library("controller") { public_deps = [ "${chip_root}/src/app", - "${chip_root}/src/app/server:server-full", + "${chip_root}/src/app/server:server", "${chip_root}/src/lib/core", "${chip_root}/src/lib/dnssd", "${chip_root}/src/lib/support",