Skip to content

Commit 4e44586

Browse files
Feature/enhanced setup flow feature (project-chip#34065)
* Add initial feature logic for Terms and Conditions (TC) acknowledgements This commit introduces the initial logic for handling Terms and Conditions (TC) acknowledgements in the General Commissioning cluster. The logic includes support for setting and checking TC acknowledgements and versions during the commissioning process. Changes include: - Handling TC acknowledgements and TC acknowledgement version in the pairing command. - Logic to read TC attributes and check TC acceptance in the General Commissioning server. - Introduction of classes to manage TC acceptance logic. - Initialization and use of TC providers in the server setup. - Addition of a new commissioning stage for TC acknowledgements in the commissioning flow. The feature logic is currently disabled and will be enabled in an example in a subsequent commit. * ./scripts/helpers/restyle-diff.sh @{u} * Ignore file reference check on TermsAndConditionsManager.cpp The TermsAndConditionsManager.cpp file is only referenced within sample apps that utilize the Terms and Conditions feature. * Make `terms and conditions required` build configurable: - Moved the configuration from core into app buildconfig - renamed the flag to expand `TC` into `TERMS AND CONDITIONS` - updated includes in general-commissioning to include the right header - added the configuration as a build option into targets.py/host.py - updated unit test * Move terms and conditions to its own target and include cpp file - Create a separate source set for terms and conditions - include the manager cpp in that file - make the build conditional (this required flag moving) - fixed typo in targets.py to make things compile Compile-tested only (the -terms-and-conditions variant of all clusters compiled) * Fix mangled license blurb * Remove edited date for CHIPConfig.h * Fix unit tests dependencies * Add back some includes --------- Co-authored-by: Andrei Litvin <andy314@gmail.com>
1 parent e3277eb commit 4e44586

19 files changed

+1587
-53
lines changed

scripts/build/build/targets.py

+1
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ def BuildHostTarget():
197197
target.AppendModifier('disable-dnssd-tests', enable_dnssd_tests=False).OnlyIfRe('-tests')
198198
target.AppendModifier('chip-casting-simplified', chip_casting_simplified=True).OnlyIfRe('-tv-casting-app')
199199
target.AppendModifier('googletest', use_googletest=True).OnlyIfRe('-tests')
200+
target.AppendModifier('terms-and-conditions', terms_and_conditions_required=True)
200201

201202
return target
202203

scripts/build/builders/host.py

+7
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,7 @@ def __init__(self, root, runner, app: HostApp, board=HostBoard.NATIVE,
336336
chip_casting_simplified: Optional[bool] = None,
337337
disable_shell=False,
338338
use_googletest=False,
339+
terms_and_conditions_required: Optional[bool] = None,
339340
):
340341
super(HostBuilder, self).__init__(
341342
root=os.path.join(root, 'examples', app.ExamplePath()),
@@ -459,6 +460,12 @@ def __init__(self, root, runner, app: HostApp, board=HostBoard.NATIVE,
459460
if chip_casting_simplified is not None:
460461
self.extra_gn_options.append(f'chip_casting_simplified={str(chip_casting_simplified).lower()}')
461462

463+
if terms_and_conditions_required is not None:
464+
if terms_and_conditions_required:
465+
self.extra_gn_options.append('chip_terms_and_conditions_required=true')
466+
else:
467+
self.extra_gn_options.append('chip_terms_and_conditions_required=false')
468+
462469
if self.board == HostBoard.ARM64:
463470
if not use_clang:
464471
raise Exception("Cross compile only supported using clang")

scripts/build/testdata/all_targets_linux_x64.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ efr32-{brd2704b,brd4316a,brd4317a,brd4318a,brd4319a,brd4186a,brd4187a,brd2601b,b
99
esp32-{m5stack,c3devkit,devkitc,qemu}-{all-clusters,all-clusters-minimal,energy-management,ota-provider,ota-requestor,shell,light,lock,bridge,temperature-measurement,ota-requestor,tests}[-rpc][-ipv6only][-tracing]
1010
genio-lighting-app
1111
linux-fake-tests[-mbedtls][-boringssl][-asan][-tsan][-ubsan][-libfuzzer][-ossfuzz][-pw-fuzztest][-coverage][-dmalloc][-clang]
12-
linux-{x64,arm64}-{rpc-console,all-clusters,all-clusters-minimal,chip-tool,thermostat,java-matter-controller,kotlin-matter-controller,minmdns,light,light-data-model-no-unique-id,lock,shell,ota-provider,ota-requestor,simulated-app1,simulated-app2,python-bindings,tv-app,tv-casting-app,bridge,fabric-admin,fabric-bridge,fabric-sync,tests,chip-cert,address-resolve-tool,contact-sensor,dishwasher,microwave-oven,refrigerator,rvc,air-purifier,lit-icd,air-quality-sensor,network-manager,energy-management,water-leak-detector}[-nodeps][-nlfaultinject][-platform-mdns][-minmdns-verbose][-libnl][-same-event-loop][-no-interactive][-ipv6only][-no-ble][-no-wifi][-no-thread][-no-shell][-mbedtls][-boringssl][-asan][-tsan][-ubsan][-libfuzzer][-ossfuzz][-pw-fuzztest][-coverage][-dmalloc][-clang][-test][-rpc][-with-ui][-evse-test-event][-enable-dnssd-tests][-disable-dnssd-tests][-chip-casting-simplified][-googletest]
12+
linux-{x64,arm64}-{rpc-console,all-clusters,all-clusters-minimal,chip-tool,thermostat,java-matter-controller,kotlin-matter-controller,minmdns,light,light-data-model-no-unique-id,lock,shell,ota-provider,ota-requestor,simulated-app1,simulated-app2,python-bindings,tv-app,tv-casting-app,bridge,fabric-admin,fabric-bridge,fabric-sync,tests,chip-cert,address-resolve-tool,contact-sensor,dishwasher,microwave-oven,refrigerator,rvc,air-purifier,lit-icd,air-quality-sensor,network-manager,energy-management,water-leak-detector}[-nodeps][-nlfaultinject][-platform-mdns][-minmdns-verbose][-libnl][-same-event-loop][-no-interactive][-ipv6only][-no-ble][-no-wifi][-no-thread][-no-shell][-mbedtls][-boringssl][-asan][-tsan][-ubsan][-libfuzzer][-ossfuzz][-pw-fuzztest][-coverage][-dmalloc][-clang][-test][-rpc][-with-ui][-evse-test-event][-enable-dnssd-tests][-disable-dnssd-tests][-chip-casting-simplified][-googletest][-terms-and-conditions]
1313
linux-x64-efr32-test-runner[-clang]
1414
imx-{chip-tool,lighting-app,thermostat,all-clusters-app,all-clusters-minimal-app,ota-provider-app}[-release]
1515
infineon-psoc6-{lock,light,all-clusters,all-clusters-minimal}[-ota][-updateimage][-trustm]

src/app/BUILD.gn

+1
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ buildconfig_header("app_buildconfig") {
7676
"CHIP_DEVICE_CONFIG_DYNAMIC_SERVER=${chip_build_controller_dynamic_server}",
7777
"CHIP_CONFIG_ENABLE_BUSY_HANDLING_FOR_OPERATIONAL_SESSION_SETUP=${chip_enable_busy_handling_for_operational_session_setup}",
7878
"CHIP_CONFIG_DATA_MODEL_EXTRA_LOGGING=${chip_data_model_extra_logging}",
79+
"CHIP_CONFIG_TERMS_AND_CONDITIONS_REQUIRED=${chip_terms_and_conditions_required}",
7980
]
8081

8182
visibility = [ ":app_config" ]

src/app/FailSafeContext.cpp

+6-3
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,12 @@ void FailSafeContext::ScheduleFailSafeCleanup(FabricIndex fabricIndex, bool addN
8686
SetFailSafeArmed(false);
8787

8888
ChipDeviceEvent event{ .Type = DeviceEventType::kFailSafeTimerExpired,
89-
.FailSafeTimerExpired = { .fabricIndex = fabricIndex,
90-
.addNocCommandHasBeenInvoked = addNocCommandInvoked,
91-
.updateNocCommandHasBeenInvoked = updateNocCommandInvoked } };
89+
.FailSafeTimerExpired = {
90+
.fabricIndex = fabricIndex,
91+
.addNocCommandHasBeenInvoked = addNocCommandInvoked,
92+
.updateNocCommandHasBeenInvoked = updateNocCommandInvoked,
93+
.updateTermsAndConditionsHasBeenInvoked = mUpdateTermsAndConditionsHasBeenInvoked,
94+
} };
9295
CHIP_ERROR status = PlatformMgr().PostEvent(&event);
9396

9497
if (status != CHIP_NO_ERROR)

src/app/FailSafeContext.h

+11-7
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ class FailSafeContext
5656
void SetUpdateNocCommandInvoked() { mUpdateNocCommandHasBeenInvoked = true; }
5757
void SetAddTrustedRootCertInvoked() { mAddTrustedRootCertHasBeenInvoked = true; }
5858
void SetCsrRequestForUpdateNoc(bool isForUpdateNoc) { mIsCsrRequestForUpdateNoc = isForUpdateNoc; }
59+
void SetUpdateTermsAndConditionsHasBeenInvoked() { mUpdateTermsAndConditionsHasBeenInvoked = true; }
5960

6061
/**
6162
* @brief
@@ -91,6 +92,7 @@ class FailSafeContext
9192
bool UpdateNocCommandHasBeenInvoked() const { return mUpdateNocCommandHasBeenInvoked; }
9293
bool AddTrustedRootCertHasBeenInvoked() const { return mAddTrustedRootCertHasBeenInvoked; }
9394
bool IsCsrRequestForUpdateNoc() const { return mIsCsrRequestForUpdateNoc; }
95+
bool UpdateTermsAndConditionsHasBeenInvoked() { return mUpdateTermsAndConditionsHasBeenInvoked; }
9496

9597
FabricIndex GetFabricIndex() const
9698
{
@@ -109,8 +111,9 @@ class FailSafeContext
109111
bool mUpdateNocCommandHasBeenInvoked = false;
110112
bool mAddTrustedRootCertHasBeenInvoked = false;
111113
// The fact of whether a CSR occurred at all is stored elsewhere.
112-
bool mIsCsrRequestForUpdateNoc = false;
113-
FabricIndex mFabricIndex = kUndefinedFabricIndex;
114+
bool mIsCsrRequestForUpdateNoc = false;
115+
FabricIndex mFabricIndex = kUndefinedFabricIndex;
116+
bool mUpdateTermsAndConditionsHasBeenInvoked = false;
114117

115118
/**
116119
* @brief
@@ -140,11 +143,12 @@ class FailSafeContext
140143
{
141144
SetFailSafeArmed(false);
142145

143-
mAddNocCommandHasBeenInvoked = false;
144-
mUpdateNocCommandHasBeenInvoked = false;
145-
mAddTrustedRootCertHasBeenInvoked = false;
146-
mFailSafeBusy = false;
147-
mIsCsrRequestForUpdateNoc = false;
146+
mAddNocCommandHasBeenInvoked = false;
147+
mUpdateNocCommandHasBeenInvoked = false;
148+
mAddTrustedRootCertHasBeenInvoked = false;
149+
mFailSafeBusy = false;
150+
mIsCsrRequestForUpdateNoc = false;
151+
mUpdateTermsAndConditionsHasBeenInvoked = false;
148152
}
149153

150154
void FailSafeTimerExpired();

src/app/chip_data_model.cmake

+2-1
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,9 @@ function(chip_configure_data_model APP_TARGET)
8181
${CHIP_APP_BASE_DIR}/SafeAttributePersistenceProvider.cpp
8282
${CHIP_APP_BASE_DIR}/StorageDelegateWrapper.cpp
8383
${CHIP_APP_BASE_DIR}/server/AclStorage.cpp
84-
${CHIP_APP_BASE_DIR}/server/DefaultAclStorage.cpp
8584
${CHIP_APP_BASE_DIR}/server/CommissioningWindowManager.cpp
85+
${CHIP_APP_BASE_DIR}/server/DefaultAclStorage.cpp
86+
${CHIP_APP_BASE_DIR}/server/DefaultTermsAndConditionsProvider.cpp
8687
${CHIP_APP_BASE_DIR}/server/Dnssd.cpp
8788
${CHIP_APP_BASE_DIR}/server/EchoHandler.cpp
8889
${CHIP_APP_BASE_DIR}/server/OnboardingCodesUtil.cpp

0 commit comments

Comments
 (0)