From 2a862d5a0de36eb7c25cb81dd0dbecc6643d14bc Mon Sep 17 00:00:00 2001 From: James Swan <122404367+swan-amazon@users.noreply.github.com> Date: Fri, 9 Aug 2024 22:49:07 +0000 Subject: [PATCH] --- examples/chip-tool/BUILD.gn | 2 -- examples/chip-tool/commands/pairing/PairingCommand.cpp | 2 +- .../general-commissioning-server.cpp | 2 +- src/app/server/DefaultEnhancedSetupFlowProvider.cpp | 8 ++++++++ src/app/server/DefaultEnhancedSetupFlowProvider.h | 2 ++ src/app/server/EnhancedSetupFlowProvider.h | 6 ++++++ src/app/server/Server.cpp | 2 ++ src/app/server/Server.h | 4 +++- src/controller/CommissioningDelegate.h | 1 - 9 files changed, 23 insertions(+), 6 deletions(-) diff --git a/examples/chip-tool/BUILD.gn b/examples/chip-tool/BUILD.gn index ebc800cf719484..c846b87405bb36 100644 --- a/examples/chip-tool/BUILD.gn +++ b/examples/chip-tool/BUILD.gn @@ -105,8 +105,6 @@ static_library("chip-tool-utils") { "${chip_root}/examples/common/tracing:commandline", "${chip_root}/src/app/icd/client:handler", "${chip_root}/src/app/icd/client:manager", - - # "${chip_root}/src/app/server", "${chip_root}/src/app/tests/suites/commands/interaction_model", "${chip_root}/src/controller/data_model", "${chip_root}/src/credentials:file_attestation_trust_store", diff --git a/examples/chip-tool/commands/pairing/PairingCommand.cpp b/examples/chip-tool/commands/pairing/PairingCommand.cpp index 8af21776e06e2b..fa3b9a8ae35c35 100644 --- a/examples/chip-tool/commands/pairing/PairingCommand.cpp +++ b/examples/chip-tool/commands/pairing/PairingCommand.cpp @@ -133,7 +133,7 @@ CommissioningParameters PairingCommand::GetCommissioningParameters() { params.SetRequireTermsAndConditionsAcknowledgement(mRequireTCAcknowledgements.Value()); } - else + else { // Default requiring TCs to false, to preserve release 1.3 chip-tool behavior params.SetRequireTermsAndConditionsAcknowledgement(false); diff --git a/src/app/clusters/general-commissioning-server/general-commissioning-server.cpp b/src/app/clusters/general-commissioning-server/general-commissioning-server.cpp index f94480ad411386..d8d781bb1891e7 100644 --- a/src/app/clusters/general-commissioning-server/general-commissioning-server.cpp +++ b/src/app/clusters/general-commissioning-server/general-commissioning-server.cpp @@ -165,7 +165,7 @@ class GeneralCommissioningAttrAccess : public AttributeAccessInterface } case TCAcknowledgementsRequired::Id: { auto provider = Server::GetInstance().GetEnhancedSetupFlowProvider(); - auto getter = &EnhancedSetupFlowProvider::GetTermsAndConditionsRequiredAcknowledgements; + auto getter = &EnhancedSetupFlowProvider::IsTermsAndConditionsAcceptanceRequired; return ReadIfSupported(provider, getter, aEncoder); } #endif diff --git a/src/app/server/DefaultEnhancedSetupFlowProvider.cpp b/src/app/server/DefaultEnhancedSetupFlowProvider.cpp index e82af06ad5b014..647e705c2b94db 100644 --- a/src/app/server/DefaultEnhancedSetupFlowProvider.cpp +++ b/src/app/server/DefaultEnhancedSetupFlowProvider.cpp @@ -78,6 +78,14 @@ CHIP_ERROR chip::app::DefaultEnhancedSetupFlowProvider::HasTermsAndConditionsReq return CHIP_NO_ERROR; } +CHIP_ERROR chip::app::DefaultEnhancedSetupFlowProvider::IsTermsAndConditionsAcceptanceRequired(bool & outValue) const +{ + // Default implementation requires terms and conditions check only if not previously accepted. Other implementations may skip + // requiring a terms and conditions check on secondary commissioning, in the case that the required terms and conditions may + // have changed. + return HasTermsAndConditionsRequiredAcknowledgementsVersionBeenAccepted(outValue); +} + CHIP_ERROR chip::app::DefaultEnhancedSetupFlowProvider::GetTermsAndConditionsRequiredAcknowledgements(uint16_t & outValue) const { uint16_t requiredAcknowledgements; diff --git a/src/app/server/DefaultEnhancedSetupFlowProvider.h b/src/app/server/DefaultEnhancedSetupFlowProvider.h index 52bbd7ab68ac4d..e5b9ed17ef5bfa 100644 --- a/src/app/server/DefaultEnhancedSetupFlowProvider.h +++ b/src/app/server/DefaultEnhancedSetupFlowProvider.h @@ -43,6 +43,8 @@ class DefaultEnhancedSetupFlowProvider : public EnhancedSetupFlowProvider CHIP_ERROR HasTermsAndConditionsRequiredAcknowledgementsVersionBeenAccepted(bool & outAccepted) const override; + CHIP_ERROR IsTermsAndConditionsAcceptanceRequired(bool & outValue) const override; + CHIP_ERROR GetTermsAndConditionsRequiredAcknowledgements(uint16_t & outValue) const override; CHIP_ERROR GetTermsAndConditionsRequiredAcknowledgementsVersion(uint16_t & outValue) const override; diff --git a/src/app/server/EnhancedSetupFlowProvider.h b/src/app/server/EnhancedSetupFlowProvider.h index 2d62fb186ec597..6a0846f119f513 100644 --- a/src/app/server/EnhancedSetupFlowProvider.h +++ b/src/app/server/EnhancedSetupFlowProvider.h @@ -43,6 +43,12 @@ class EnhancedSetupFlowProvider */ virtual CHIP_ERROR HasTermsAndConditionsRequiredAcknowledgementsVersionBeenAccepted(bool & outAccepted) const = 0; + /** + * @param[out] outValue true if terms and conditions acceptance is required before commissioning complete may succeed, false + * otherwise. + */ + virtual CHIP_ERROR IsTermsAndConditionsAcceptanceRequired(bool & outValue) const = 0; + /** * @param[out] outValue The version of the required acknowledgements. */ diff --git a/src/app/server/Server.cpp b/src/app/server/Server.cpp index 85f507f4cf6c43..25d03d1645b914 100644 --- a/src/app/server/Server.cpp +++ b/src/app/server/Server.cpp @@ -591,7 +591,9 @@ void Server::ScheduleFactoryReset() GetInstance().GetFabricTable().DeleteAllFabrics(); PlatformMgr().HandleServerShuttingDown(); ConfigurationMgr().InitiateFactoryReset(); +#if CHIP_CONFIG_TC_REQUIRED // Clear accepted terms and conditions +#endif }); } diff --git a/src/app/server/Server.h b/src/app/server/Server.h index be9b592432bf59..cb8ab12f40f547 100644 --- a/src/app/server/Server.h +++ b/src/app/server/Server.h @@ -36,9 +36,9 @@ #if CHIP_CONFIG_TC_REQUIRED #include #include -#endif #include #include +#endif #include #include #include @@ -185,10 +185,12 @@ struct ServerInitParams // Optional. Support for the ICD Check-In BackOff strategy. Must be initialized before being provided. // If the ICD Check-In protocol use-case is supported and no strategy is provided, server will use the default strategy. app::ICDCheckInBackOffStrategy * icdCheckInBackOffStrategy = nullptr; +#if CHIP_CONFIG_TC_REQUIRED // Optional. Enhanced setup flow provider to support terms and conditions acceptance check. app::EnhancedSetupFlowProvider * enhancedSetupFlowProvider = nullptr; // Optional. Terms and conditions provider to support enhanced setup flow feature. app::TermsAndConditionsProvider * termsAndConditionsProvider = nullptr; +#endif }; /** diff --git a/src/controller/CommissioningDelegate.h b/src/controller/CommissioningDelegate.h index 4936677786814c..9276fbdc2b6957 100644 --- a/src/controller/CommissioningDelegate.h +++ b/src/controller/CommissioningDelegate.h @@ -176,7 +176,6 @@ class CommissioningParameters // The country code to be used for the node, if set. Optional GetCountryCode() const { return mCountryCode; } - Optional GetRequireTermsAndConditionsAcknowledgement() const { return mRequireTermsAndConditionsAcknowledgement; } Optional GetTermsAndConditionsAcknowledgement() const