From 398e209e49d6860cf388593971cdbaccc6f41d7c Mon Sep 17 00:00:00 2001 From: Joonhaeng Heo Date: Wed, 28 Feb 2024 08:38:43 +0900 Subject: [PATCH 1/9] Add Android Checkin --- .../main/java/com/google/chip/chiptool/ChipClient.kt | 7 ++++++- .../java/AndroidDeviceControllerWrapper.cpp | 11 ++++++++++- src/controller/java/AndroidDeviceControllerWrapper.h | 6 +++++- src/controller/java/CHIPDeviceController-JNI.cpp | 7 ++++++- .../src/chip/devicecontroller/ControllerParams.java | 12 ++++++++++++ .../java/src/matter/controller/ControllerParams.kt | 1 + .../src/matter/controller/MatterControllerImpl.kt | 1 + 7 files changed, 41 insertions(+), 4 deletions(-) diff --git a/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/ChipClient.kt b/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/ChipClient.kt index 77c59d75d00c36..6372b14c5fa71f 100644 --- a/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/ChipClient.kt +++ b/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/ChipClient.kt @@ -48,7 +48,12 @@ object ChipClient { if (!this::chipDeviceController.isInitialized) { chipDeviceController = - ChipDeviceController(ControllerParams.newBuilder().setControllerVendorId(VENDOR_ID).build()) + ChipDeviceController( + ControllerParams.newBuilder() + .setControllerVendorId(VENDOR_ID) + .setEnableServerInteractions(true) + .build() + ) // Set delegate for attestation trust store for device attestation verifier. // It will replace the default attestation trust store. diff --git a/src/controller/java/AndroidDeviceControllerWrapper.cpp b/src/controller/java/AndroidDeviceControllerWrapper.cpp index c965bb0f17584b..828449f34b3fc5 100644 --- a/src/controller/java/AndroidDeviceControllerWrapper.cpp +++ b/src/controller/java/AndroidDeviceControllerWrapper.cpp @@ -104,7 +104,7 @@ AndroidDeviceControllerWrapper * AndroidDeviceControllerWrapper::AllocateNew( jobject keypairDelegate, jbyteArray rootCertificate, jbyteArray intermediateCertificate, jbyteArray nodeOperationalCertificate, jbyteArray ipkEpochKey, uint16_t listenPort, uint16_t controllerVendorId, uint16_t failsafeTimerSeconds, bool attemptNetworkScanWiFi, bool attemptNetworkScanThread, bool skipCommissioningComplete, - bool skipAttestationCertificateValidation, jstring countryCode, CHIP_ERROR * errInfoOnFailure) + bool skipAttestationCertificateValidation, jstring countryCode, bool enableServerInteractions, CHIP_ERROR * errInfoOnFailure) { if (errInfoOnFailure == nullptr) { @@ -351,6 +351,9 @@ AndroidDeviceControllerWrapper * AndroidDeviceControllerWrapper::AllocateNew( setupParams.controllerNOC = nocSpan; } + initParams.enableServerInteractions = enableServerInteractions; + setupParams.enableServerInteractions = enableServerInteractions; + *errInfoOnFailure = DeviceControllerFactory::GetInstance().Init(initParams); if (*errInfoOnFailure != CHIP_NO_ERROR) { @@ -393,6 +396,11 @@ AndroidDeviceControllerWrapper * AndroidDeviceControllerWrapper::AllocateNew( wrapper->getICDClientStorage()->UpdateFabricList(wrapper->Controller()->GetFabricIndex()); + auto engine = chip::app::InteractionModelEngine::GetInstance(); + *errInfoOnFailure = wrapper->mCheckInDelegate.Init(&wrapper->mICDClientStorage, engine); + *errInfoOnFailure = wrapper->mCheckInHandler.Init(DeviceControllerFactory::GetInstance().GetSystemState()->ExchangeMgr(), + &wrapper->mICDClientStorage, &wrapper->mCheckInDelegate, engine); + memset(ipkBuffer.data(), 0, ipkBuffer.size()); if (*errInfoOnFailure != CHIP_NO_ERROR) @@ -769,6 +777,7 @@ void AndroidDeviceControllerWrapper::OnReadCommissioningInfo(const chip::Control // For ICD mUserActiveModeTriggerHint = info.icd.userActiveModeTriggerHint; + memset(mUserActiveModeTriggerInstructionBuffer, 0x00, kUserActiveModeTriggerInstructionBufferLen); CopyCharSpanToMutableCharSpan(info.icd.userActiveModeTriggerInstruction, mUserActiveModeTriggerInstruction); env->CallVoidMethod(mJavaObjectRef.ObjectRef(), onReadCommissioningInfoMethod, static_cast(info.basic.vendorId), diff --git a/src/controller/java/AndroidDeviceControllerWrapper.h b/src/controller/java/AndroidDeviceControllerWrapper.h index 5ccb2edb3b2050..638acd79459a0f 100644 --- a/src/controller/java/AndroidDeviceControllerWrapper.h +++ b/src/controller/java/AndroidDeviceControllerWrapper.h @@ -24,6 +24,8 @@ #include +#include +#include #include #include #include @@ -182,7 +184,7 @@ class AndroidDeviceControllerWrapper : public chip::Controller::DevicePairingDel jobject keypairDelegate, jbyteArray rootCertificate, jbyteArray intermediateCertificate, jbyteArray nodeOperationalCertificate, jbyteArray ipkEpochKey, uint16_t listenPort, uint16_t controllerVendorId, uint16_t failsafeTimerSeconds, bool attemptNetworkScanWiFi, bool attemptNetworkScanThread, bool skipCommissioningComplete, - bool skipAttestationCertificateValidation, jstring countryCode, CHIP_ERROR * errInfoOnFailure); + bool skipAttestationCertificateValidation, jstring countryCode, bool enableServerInteractions, CHIP_ERROR * errInfoOnFailure); void Shutdown(); @@ -221,6 +223,8 @@ class AndroidDeviceControllerWrapper : public chip::Controller::DevicePairingDel chip::Crypto::RawKeySessionKeystore mSessionKeystore; chip::app::DefaultICDClientStorage mICDClientStorage; + chip::app::DefaultCheckInDelegate mCheckInDelegate; + chip::app::CheckInHandler mCheckInHandler; JavaVM * mJavaVM = nullptr; chip::JniGlobalReference mJavaObjectRef; diff --git a/src/controller/java/CHIPDeviceController-JNI.cpp b/src/controller/java/CHIPDeviceController-JNI.cpp index f1c7487e4e3f87..5aad00e971aa22 100644 --- a/src/controller/java/CHIPDeviceController-JNI.cpp +++ b/src/controller/java/CHIPDeviceController-JNI.cpp @@ -350,6 +350,10 @@ JNI_METHOD(jlong, newDeviceController)(JNIEnv * env, jobject self, jobject contr err = chip::JniReferences::GetInstance().FindMethod(env, controllerParams, "getAdminSubject", "()J", &getAdminSubject); SuccessOrExit(err); + jmethodID getEnableServerInteractions; + err = chip::JniReferences::GetInstance().FindMethod(env, controllerParams, "getEnableServerInteractions", "()Z", &getEnableServerInteractions); + SuccessOrExit(err); + { uint64_t fabricId = static_cast(env->CallLongMethod(controllerParams, getFabricId)); uint16_t listenPort = static_cast(env->CallIntMethod(controllerParams, getUdpListenPort)); @@ -370,6 +374,7 @@ JNI_METHOD(jlong, newDeviceController)(JNIEnv * env, jobject self, jobject contr uint64_t adminSubject = static_cast(env->CallLongMethod(controllerParams, getAdminSubject)); jobject countryCodeOptional = env->CallObjectMethod(controllerParams, getCountryCode); jobject regulatoryLocationOptional = env->CallObjectMethod(controllerParams, getRegulatoryLocation); + bool enableServerInteractions = env->CallBooleanMethod(controllerParams, getEnableServerInteractions) == JNI_TRUE; jobject countryCode; err = chip::JniReferences::GetInstance().GetOptionalValue(countryCodeOptional, countryCode); @@ -387,7 +392,7 @@ JNI_METHOD(jlong, newDeviceController)(JNIEnv * env, jobject self, jobject contr DeviceLayer::TCPEndPointManager(), DeviceLayer::UDPEndPointManager(), std::move(opCredsIssuer), keypairDelegate, rootCertificate, intermediateCertificate, operationalCertificate, ipk, listenPort, controllerVendorId, failsafeTimerSeconds, attemptNetworkScanWiFi, attemptNetworkScanThread, skipCommissioningComplete, - skipAttestationCertificateValidation, static_cast(countryCode), &err); + skipAttestationCertificateValidation, static_cast(countryCode), enableServerInteractions, &err); SuccessOrExit(err); if (caseFailsafeTimerSeconds > 0) diff --git a/src/controller/java/src/chip/devicecontroller/ControllerParams.java b/src/controller/java/src/chip/devicecontroller/ControllerParams.java index ca41cf900902af..cc48570b91826e 100644 --- a/src/controller/java/src/chip/devicecontroller/ControllerParams.java +++ b/src/controller/java/src/chip/devicecontroller/ControllerParams.java @@ -23,6 +23,7 @@ public final class ControllerParams { @Nullable private final byte[] operationalCertificate; @Nullable private final byte[] ipk; private final long adminSubject; + private final boolean enableServerInteractions; /** @param udpListenPort the UDP listening port, or 0 to pick any available port. */ private ControllerParams(Builder builder) { @@ -43,6 +44,7 @@ private ControllerParams(Builder builder) { this.operationalCertificate = builder.operationalCertificate; this.ipk = builder.ipk; this.adminSubject = builder.adminSubject; + this.enableServerInteractions = builder.enableServerInteractions; } public long getFabricId() { @@ -114,6 +116,10 @@ public long getAdminSubject() { return adminSubject; } + public boolean getEnableServerInteractions() { + return enableServerInteractions; + } + /** Returns parameters with ephemerally generated operational credentials */ public static Builder newBuilder() { return new Builder(); @@ -152,6 +158,7 @@ public static class Builder { @Nullable private byte[] operationalCertificate = null; @Nullable private byte[] ipk = null; private long adminSubject = 0; + private boolean enableServerInteractions = false; private Builder() {} @@ -357,6 +364,11 @@ public Builder setAdminSubject(long adminSubject) { return this; } + public Builder setEnableServerInteractions(boolean enableServerInteractions) { + this.enableServerInteractions = enableServerInteractions; + return this; + } + public ControllerParams build() { return new ControllerParams(this); } diff --git a/src/controller/java/src/matter/controller/ControllerParams.kt b/src/controller/java/src/matter/controller/ControllerParams.kt index d0fb23222ea68e..35ac25549910a7 100644 --- a/src/controller/java/src/matter/controller/ControllerParams.kt +++ b/src/controller/java/src/matter/controller/ControllerParams.kt @@ -32,6 +32,7 @@ constructor( val udpListenPort: Int = UDP_PORT_AUTO, val vendorId: Int = VENDOR_ID_TEST, val countryCode: String? = null, + val enableServerInteractions: Boolean = false, ) { companion object { /** Matter assigned vendor ID for Google. */ diff --git a/src/controller/java/src/matter/controller/MatterControllerImpl.kt b/src/controller/java/src/matter/controller/MatterControllerImpl.kt index 6ae71f33a0faac..dde29eeb7c5354 100644 --- a/src/controller/java/src/matter/controller/MatterControllerImpl.kt +++ b/src/controller/java/src/matter/controller/MatterControllerImpl.kt @@ -543,6 +543,7 @@ class MatterControllerImpl(params: ControllerParams) : MatterController { .setUdpListenPort(params.udpListenPort) .setControllerVendorId(params.vendorId) .setCountryCode(params.countryCode) + .setEnableServerInteractions(params.enableServerInteractions) if (config != null) { val intermediateCertificate = config.certificateData.intermediateCertificate From 373edd5270813bb621d50f07f4e54daaf5908514 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Fri, 8 Mar 2024 08:29:24 +0000 Subject: [PATCH 2/9] Restyled by clang-format --- .../java/AndroidDeviceControllerWrapper.cpp | 6 ++--- .../java/AndroidDeviceControllerWrapper.h | 22 ++++++++++--------- .../java/CHIPDeviceController-JNI.cpp | 5 +++-- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/src/controller/java/AndroidDeviceControllerWrapper.cpp b/src/controller/java/AndroidDeviceControllerWrapper.cpp index 828449f34b3fc5..0143d36e8d3c8e 100644 --- a/src/controller/java/AndroidDeviceControllerWrapper.cpp +++ b/src/controller/java/AndroidDeviceControllerWrapper.cpp @@ -351,7 +351,7 @@ AndroidDeviceControllerWrapper * AndroidDeviceControllerWrapper::AllocateNew( setupParams.controllerNOC = nocSpan; } - initParams.enableServerInteractions = enableServerInteractions; + initParams.enableServerInteractions = enableServerInteractions; setupParams.enableServerInteractions = enableServerInteractions; *errInfoOnFailure = DeviceControllerFactory::GetInstance().Init(initParams); @@ -396,10 +396,10 @@ AndroidDeviceControllerWrapper * AndroidDeviceControllerWrapper::AllocateNew( wrapper->getICDClientStorage()->UpdateFabricList(wrapper->Controller()->GetFabricIndex()); - auto engine = chip::app::InteractionModelEngine::GetInstance(); + auto engine = chip::app::InteractionModelEngine::GetInstance(); *errInfoOnFailure = wrapper->mCheckInDelegate.Init(&wrapper->mICDClientStorage, engine); *errInfoOnFailure = wrapper->mCheckInHandler.Init(DeviceControllerFactory::GetInstance().GetSystemState()->ExchangeMgr(), - &wrapper->mICDClientStorage, &wrapper->mCheckInDelegate, engine); + &wrapper->mICDClientStorage, &wrapper->mCheckInDelegate, engine); memset(ipkBuffer.data(), 0, ipkBuffer.size()); diff --git a/src/controller/java/AndroidDeviceControllerWrapper.h b/src/controller/java/AndroidDeviceControllerWrapper.h index 638acd79459a0f..cf8fc4c8900b86 100644 --- a/src/controller/java/AndroidDeviceControllerWrapper.h +++ b/src/controller/java/AndroidDeviceControllerWrapper.h @@ -172,19 +172,21 @@ class AndroidDeviceControllerWrapper : public chip::Controller::DevicePairingDel * @param[in] skipCommissioningComplete whether to skip the CASE commissioningComplete command during commissioning * @param[out] errInfoOnFailure a pointer to a CHIP_ERROR that will be populated if this method returns nullptr */ - static AndroidDeviceControllerWrapper * AllocateNew( - JavaVM * vm, jobject deviceControllerObj, chip::NodeId nodeId, chip::FabricId fabricId, const chip::CATValues & cats, - chip::System::Layer * systemLayer, chip::Inet::EndPointManager * tcpEndPointManager, - chip::Inet::EndPointManager * udpEndPointManager, + static AndroidDeviceControllerWrapper * + AllocateNew(JavaVM * vm, jobject deviceControllerObj, chip::NodeId nodeId, chip::FabricId fabricId, + const chip::CATValues & cats, chip::System::Layer * systemLayer, + chip::Inet::EndPointManager * tcpEndPointManager, + chip::Inet::EndPointManager * udpEndPointManager, #ifdef JAVA_MATTER_CONTROLLER_TEST - ExampleOperationalCredentialsIssuerPtr opCredsIssuer, + ExampleOperationalCredentialsIssuerPtr opCredsIssuer, #else - AndroidOperationalCredentialsIssuerPtr opCredsIssuer, + AndroidOperationalCredentialsIssuerPtr opCredsIssuer, #endif - jobject keypairDelegate, jbyteArray rootCertificate, jbyteArray intermediateCertificate, - jbyteArray nodeOperationalCertificate, jbyteArray ipkEpochKey, uint16_t listenPort, uint16_t controllerVendorId, - uint16_t failsafeTimerSeconds, bool attemptNetworkScanWiFi, bool attemptNetworkScanThread, bool skipCommissioningComplete, - bool skipAttestationCertificateValidation, jstring countryCode, bool enableServerInteractions, CHIP_ERROR * errInfoOnFailure); + jobject keypairDelegate, jbyteArray rootCertificate, jbyteArray intermediateCertificate, + jbyteArray nodeOperationalCertificate, jbyteArray ipkEpochKey, uint16_t listenPort, uint16_t controllerVendorId, + uint16_t failsafeTimerSeconds, bool attemptNetworkScanWiFi, bool attemptNetworkScanThread, + bool skipCommissioningComplete, bool skipAttestationCertificateValidation, jstring countryCode, + bool enableServerInteractions, CHIP_ERROR * errInfoOnFailure); void Shutdown(); diff --git a/src/controller/java/CHIPDeviceController-JNI.cpp b/src/controller/java/CHIPDeviceController-JNI.cpp index 5aad00e971aa22..30c4c573541e96 100644 --- a/src/controller/java/CHIPDeviceController-JNI.cpp +++ b/src/controller/java/CHIPDeviceController-JNI.cpp @@ -351,7 +351,8 @@ JNI_METHOD(jlong, newDeviceController)(JNIEnv * env, jobject self, jobject contr SuccessOrExit(err); jmethodID getEnableServerInteractions; - err = chip::JniReferences::GetInstance().FindMethod(env, controllerParams, "getEnableServerInteractions", "()Z", &getEnableServerInteractions); + err = chip::JniReferences::GetInstance().FindMethod(env, controllerParams, "getEnableServerInteractions", "()Z", + &getEnableServerInteractions); SuccessOrExit(err); { @@ -374,7 +375,7 @@ JNI_METHOD(jlong, newDeviceController)(JNIEnv * env, jobject self, jobject contr uint64_t adminSubject = static_cast(env->CallLongMethod(controllerParams, getAdminSubject)); jobject countryCodeOptional = env->CallObjectMethod(controllerParams, getCountryCode); jobject regulatoryLocationOptional = env->CallObjectMethod(controllerParams, getRegulatoryLocation); - bool enableServerInteractions = env->CallBooleanMethod(controllerParams, getEnableServerInteractions) == JNI_TRUE; + bool enableServerInteractions = env->CallBooleanMethod(controllerParams, getEnableServerInteractions) == JNI_TRUE; jobject countryCode; err = chip::JniReferences::GetInstance().GetOptionalValue(countryCodeOptional, countryCode); From a2efedce2947e2470819d305d1b474c1449fc5a7 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Fri, 8 Mar 2024 08:31:08 +0000 Subject: [PATCH 3/9] Restyled by clang-format --- src/controller/java/AndroidDeviceControllerWrapper.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/controller/java/AndroidDeviceControllerWrapper.h b/src/controller/java/AndroidDeviceControllerWrapper.h index cf8fc4c8900b86..fe56c02646942c 100644 --- a/src/controller/java/AndroidDeviceControllerWrapper.h +++ b/src/controller/java/AndroidDeviceControllerWrapper.h @@ -180,7 +180,7 @@ class AndroidDeviceControllerWrapper : public chip::Controller::DevicePairingDel #ifdef JAVA_MATTER_CONTROLLER_TEST ExampleOperationalCredentialsIssuerPtr opCredsIssuer, #else - AndroidOperationalCredentialsIssuerPtr opCredsIssuer, + AndroidOperationalCredentialsIssuerPtr opCredsIssuer, #endif jobject keypairDelegate, jbyteArray rootCertificate, jbyteArray intermediateCertificate, jbyteArray nodeOperationalCertificate, jbyteArray ipkEpochKey, uint16_t listenPort, uint16_t controllerVendorId, From eccd66faff6192e902bf5f13e0cbf24d9540e04e Mon Sep 17 00:00:00 2001 From: Joonhaeng Heo Date: Fri, 8 Mar 2024 17:46:47 +0900 Subject: [PATCH 4/9] Add enableServerInteractions comment --- .../devicecontroller/ControllerParams.java | 126 +++++++++++++----- 1 file changed, 90 insertions(+), 36 deletions(-) diff --git a/src/controller/java/src/chip/devicecontroller/ControllerParams.java b/src/controller/java/src/chip/devicecontroller/ControllerParams.java index cc48570b91826e..ce48dac9287362 100644 --- a/src/controller/java/src/chip/devicecontroller/ControllerParams.java +++ b/src/controller/java/src/chip/devicecontroller/ControllerParams.java @@ -3,7 +3,10 @@ import java.util.Optional; import javax.annotation.Nullable; -/** Parameters representing initialization arguments for {@link ChipDeviceController}. */ +/** + * Parameters representing initialization arguments for + * {@link ChipDeviceController}. + */ public final class ControllerParams { private final long fabricId; @@ -17,15 +20,22 @@ public final class ControllerParams { private final boolean skipAttestationCertificateValidation; private final Optional countryCode; private final Optional regulatoryLocationType; - @Nullable private final KeypairDelegate keypairDelegate; - @Nullable private final byte[] rootCertificate; - @Nullable private final byte[] intermediateCertificate; - @Nullable private final byte[] operationalCertificate; - @Nullable private final byte[] ipk; + @Nullable + private final KeypairDelegate keypairDelegate; + @Nullable + private final byte[] rootCertificate; + @Nullable + private final byte[] intermediateCertificate; + @Nullable + private final byte[] operationalCertificate; + @Nullable + private final byte[] ipk; private final long adminSubject; private final boolean enableServerInteractions; - /** @param udpListenPort the UDP listening port, or 0 to pick any available port. */ + /** + * @param udpListenPort the UDP listening port, or 0 to pick any available port. + */ private ControllerParams(Builder builder) { this.fabricId = builder.fabricId; this.udpListenPort = builder.udpListenPort; @@ -126,7 +136,8 @@ public static Builder newBuilder() { } /** - * Returns parameters which uses the provided {@code operationalKeyConfig} as its operating + * Returns parameters which uses the provided {@code operationalKeyConfig} as + * its operating * credentials. You must set a vendor ID, 0xFFF4 is a test vendor ID * ControllerParams.newBuilder().setControllerVendorId(0xFFF4).build() */ @@ -152,15 +163,21 @@ public static class Builder { private boolean skipAttestationCertificateValidation = false; private Optional countryCode = Optional.empty(); private Optional regulatoryLocationType = Optional.empty(); - @Nullable private KeypairDelegate keypairDelegate = null; - @Nullable private byte[] rootCertificate = null; - @Nullable private byte[] intermediateCertificate = null; - @Nullable private byte[] operationalCertificate = null; - @Nullable private byte[] ipk = null; + @Nullable + private KeypairDelegate keypairDelegate = null; + @Nullable + private byte[] rootCertificate = null; + @Nullable + private byte[] intermediateCertificate = null; + @Nullable + private byte[] operationalCertificate = null; + @Nullable + private byte[] ipk = null; private long adminSubject = 0; private boolean enableServerInteractions = false; - private Builder() {} + private Builder() { + } public Builder setFabricId(long fabricId) { this.fabricId = fabricId; @@ -181,11 +198,15 @@ public Builder setControllerVendorId(int controllerVendorId) { } /** - * Sets the FailsafeTimer duration passed to ChipDeviceCommissioner's CommissioningParameters. - * Increasing this value from its default will allow more time for network scans, cloud op cert + * Sets the FailsafeTimer duration passed to ChipDeviceCommissioner's + * CommissioningParameters. + * Increasing this value from its default will allow more time for network + * scans, cloud op cert * signing calls, and user interaction. * - *

Note: It is also possible for internal logic (within Autocommissioner, etc) to re-call + *

+ * Note: It is also possible for internal logic (within Autocommissioner, etc) + * to re-call * ArmFailSafe to account for network config delays. * * @param failsafeTimerSeconds @@ -200,11 +221,15 @@ public Builder setFailsafeTimerSeconds(int failsafeTimerSeconds) { } /** - * Sets the CASEFailsafeExpirySeconds duration passed to ChipDeviceCommissioner's - * CommissioningParameters. After PASE session has finished, the failsafe is rearmed with the + * Sets the CASEFailsafeExpirySeconds duration passed to + * ChipDeviceCommissioner's + * CommissioningParameters. After PASE session has finished, the failsafe is + * rearmed with the * specified expiry before continuing commissioning. * - *

Note: If CASEFailsafeExpirySeconds is not set (or is 0), the failsafe will not be rearmed. + *

+ * Note: If CASEFailsafeExpirySeconds is not set (or is 0), the failsafe will + * not be rearmed. * * @param caseFailsafeExpirySeconds * @return @@ -221,10 +246,14 @@ public Builder setCASEFailsafeTimerSeconds(int failsafeTimerSeconds) { * Enable/disable wifi network scan during commissioning in the the default * CommissioningDelegate used by the ChipDeviceCommissioner. * - *

Specifically, this sets AttemptWiFiNetworkScan in the CommissioningParameters passed to + *

+ * Specifically, this sets AttemptWiFiNetworkScan in the CommissioningParameters + * passed to * the CommissioningDelegate. * - *

When a WiFi scan is attempted, the result will be propagated to the ScanNetworksListener + *

+ * When a WiFi scan is attempted, the result will be propagated to the + * ScanNetworksListener * assigned to the ChipDeviceController. * * @param attemptNetworkScanWiFi @@ -239,10 +268,14 @@ public Builder setAttemptNetworkScanWiFi(boolean attemptNetworkScanWiFi) { * Enable/disable Thread network scan during commissioning in the the default * CommissioningDelegate used by the ChipDeviceCommissioner. * - *

Specifically, this sets AttemptThreadNetworkScan in the CommissioningParameters passed to + *

+ * Specifically, this sets AttemptThreadNetworkScan in the + * CommissioningParameters passed to * the CommissioningDelegate. * - *

When a Thread scan is attempted, the result will be propagated to the ScanNetworksListener + *

+ * When a Thread scan is attempted, the result will be propagated to the + * ScanNetworksListener * assigned to the ChipDeviceController. * * @param attemptNetworkScanWiFi @@ -254,13 +287,18 @@ public Builder setAttemptNetworkScanThread(boolean attemptNetworkScanThread) { } /** - * Disable the CASE phase of commissioning when the CommissioningComplete command is sent by + * Disable the CASE phase of commissioning when the CommissioningComplete + * command is sent by * this ChipDeviceCommissioner. * - *

Specifically, this sets SkipCommissioningComplete in the CommissioningParameters passed to + *

+ * Specifically, this sets SkipCommissioningComplete in the + * CommissioningParameters passed to * the CommissioningDelegate. * - *

A controller will set this to true when the CASE phase of commissioning is done by a + *

+ * A controller will set this to true when the CASE phase of commissioning is + * done by a * separate process, for example, by a Hub on the network. * * @param skipCommissioningComplete @@ -274,7 +312,8 @@ public Builder setSkipCommissioningComplete(boolean skipCommissioningComplete) { /** * Used when the Commissioner disables Attestation Certificate Validation. * - *

Specifically, this sets SkipAttestationCertificateValidation in the + *

+ * Specifically, this sets SkipAttestationCertificateValidation in the * CommissioningParameters passed to the CommissioningDelegate. * * @param skipAttestationCertificateValidation @@ -290,11 +329,14 @@ public Builder setSkipAttestationCertificateValidation( * Sets the Regulatory Location country code passed to ChipDeviceCommissioner's * CommissioningParameters. * - *

Setting the country code will set the CountryCode when the SetRegulatoryConfig command is + *

+ * Setting the country code will set the CountryCode when the + * SetRegulatoryConfig command is * sent by this ChipDeviceCommissioner. * - * @param countryCode an ISO 3166-1 alpha-2 code to represent the country, dependent territory, - * or special area of geographic interest + * @param countryCode an ISO 3166-1 alpha-2 code to represent the country, + * dependent territory, + * or special area of geographic interest * @return */ public Builder setCountryCode(final String countryCode) { @@ -309,11 +351,14 @@ public Builder setCountryCode(final String countryCode) { * Sets the Regulatory Location capability passed to ChipDeviceCommissioner's * CommissioningParameters. * - *

Setting the regulatory location type will set the NewRegulatoryConfig when the + *

+ * Setting the regulatory location type will set the NewRegulatoryConfig when + * the * SetRegulatoryConfig command is sent by this ChipDeviceCommissioner. * - * @param regulatoryLocation an app::Clusters::GeneralCommissioning::RegulatoryLocationTypeEnum - * enum value + * @param regulatoryLocation an + * app::Clusters::GeneralCommissioning::RegulatoryLocationTypeEnum + * enum value * @return */ public Builder setRegulatoryLocation(int regulatoryLocation) { @@ -352,8 +397,10 @@ public Builder setIpk(byte[] ipk) { } /** - * Sets the AdminSubject value passed to ChipDeviceCommissioner's CommissioningParameters. This - * value is passed in the AddNoc command sent to the commissionee and represents the subject of + * Sets the AdminSubject value passed to ChipDeviceCommissioner's + * CommissioningParameters. This + * value is passed in the AddNoc command sent to the commissionee and represents + * the subject of * the default ACL created by that call. * * @param adminSubject @@ -364,6 +411,13 @@ public Builder setAdminSubject(long adminSubject) { return this; } + /** + * Controls enabling server interactions on a controller. + * For ICD check-in message, this feature has to enable. + * + * @param enableServerInteractions + * @return + */ public Builder setEnableServerInteractions(boolean enableServerInteractions) { this.enableServerInteractions = enableServerInteractions; return this; From c1420efb311a1955f108123a994febcfe1b163eb Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Fri, 8 Mar 2024 08:47:11 +0000 Subject: [PATCH 5/9] Restyled by whitespace --- .../java/src/chip/devicecontroller/ControllerParams.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/controller/java/src/chip/devicecontroller/ControllerParams.java b/src/controller/java/src/chip/devicecontroller/ControllerParams.java index ce48dac9287362..c79c4742442b7c 100644 --- a/src/controller/java/src/chip/devicecontroller/ControllerParams.java +++ b/src/controller/java/src/chip/devicecontroller/ControllerParams.java @@ -414,7 +414,7 @@ public Builder setAdminSubject(long adminSubject) { /** * Controls enabling server interactions on a controller. * For ICD check-in message, this feature has to enable. - * + * * @param enableServerInteractions * @return */ From 3692e04e0dcbfa493ac93c731f36881d9b7f8f8c Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Fri, 8 Mar 2024 08:47:15 +0000 Subject: [PATCH 6/9] Restyled by google-java-format --- .../devicecontroller/ControllerParams.java | 123 ++++++------------ 1 file changed, 38 insertions(+), 85 deletions(-) diff --git a/src/controller/java/src/chip/devicecontroller/ControllerParams.java b/src/controller/java/src/chip/devicecontroller/ControllerParams.java index c79c4742442b7c..f24b2ca38409c1 100644 --- a/src/controller/java/src/chip/devicecontroller/ControllerParams.java +++ b/src/controller/java/src/chip/devicecontroller/ControllerParams.java @@ -3,10 +3,7 @@ import java.util.Optional; import javax.annotation.Nullable; -/** - * Parameters representing initialization arguments for - * {@link ChipDeviceController}. - */ +/** Parameters representing initialization arguments for {@link ChipDeviceController}. */ public final class ControllerParams { private final long fabricId; @@ -20,22 +17,15 @@ public final class ControllerParams { private final boolean skipAttestationCertificateValidation; private final Optional countryCode; private final Optional regulatoryLocationType; - @Nullable - private final KeypairDelegate keypairDelegate; - @Nullable - private final byte[] rootCertificate; - @Nullable - private final byte[] intermediateCertificate; - @Nullable - private final byte[] operationalCertificate; - @Nullable - private final byte[] ipk; + @Nullable private final KeypairDelegate keypairDelegate; + @Nullable private final byte[] rootCertificate; + @Nullable private final byte[] intermediateCertificate; + @Nullable private final byte[] operationalCertificate; + @Nullable private final byte[] ipk; private final long adminSubject; private final boolean enableServerInteractions; - /** - * @param udpListenPort the UDP listening port, or 0 to pick any available port. - */ + /** @param udpListenPort the UDP listening port, or 0 to pick any available port. */ private ControllerParams(Builder builder) { this.fabricId = builder.fabricId; this.udpListenPort = builder.udpListenPort; @@ -136,8 +126,7 @@ public static Builder newBuilder() { } /** - * Returns parameters which uses the provided {@code operationalKeyConfig} as - * its operating + * Returns parameters which uses the provided {@code operationalKeyConfig} as its operating * credentials. You must set a vendor ID, 0xFFF4 is a test vendor ID * ControllerParams.newBuilder().setControllerVendorId(0xFFF4).build() */ @@ -163,21 +152,15 @@ public static class Builder { private boolean skipAttestationCertificateValidation = false; private Optional countryCode = Optional.empty(); private Optional regulatoryLocationType = Optional.empty(); - @Nullable - private KeypairDelegate keypairDelegate = null; - @Nullable - private byte[] rootCertificate = null; - @Nullable - private byte[] intermediateCertificate = null; - @Nullable - private byte[] operationalCertificate = null; - @Nullable - private byte[] ipk = null; + @Nullable private KeypairDelegate keypairDelegate = null; + @Nullable private byte[] rootCertificate = null; + @Nullable private byte[] intermediateCertificate = null; + @Nullable private byte[] operationalCertificate = null; + @Nullable private byte[] ipk = null; private long adminSubject = 0; private boolean enableServerInteractions = false; - private Builder() { - } + private Builder() {} public Builder setFabricId(long fabricId) { this.fabricId = fabricId; @@ -198,15 +181,11 @@ public Builder setControllerVendorId(int controllerVendorId) { } /** - * Sets the FailsafeTimer duration passed to ChipDeviceCommissioner's - * CommissioningParameters. - * Increasing this value from its default will allow more time for network - * scans, cloud op cert + * Sets the FailsafeTimer duration passed to ChipDeviceCommissioner's CommissioningParameters. + * Increasing this value from its default will allow more time for network scans, cloud op cert * signing calls, and user interaction. * - *

- * Note: It is also possible for internal logic (within Autocommissioner, etc) - * to re-call + *

Note: It is also possible for internal logic (within Autocommissioner, etc) to re-call * ArmFailSafe to account for network config delays. * * @param failsafeTimerSeconds @@ -221,15 +200,11 @@ public Builder setFailsafeTimerSeconds(int failsafeTimerSeconds) { } /** - * Sets the CASEFailsafeExpirySeconds duration passed to - * ChipDeviceCommissioner's - * CommissioningParameters. After PASE session has finished, the failsafe is - * rearmed with the + * Sets the CASEFailsafeExpirySeconds duration passed to ChipDeviceCommissioner's + * CommissioningParameters. After PASE session has finished, the failsafe is rearmed with the * specified expiry before continuing commissioning. * - *

- * Note: If CASEFailsafeExpirySeconds is not set (or is 0), the failsafe will - * not be rearmed. + *

Note: If CASEFailsafeExpirySeconds is not set (or is 0), the failsafe will not be rearmed. * * @param caseFailsafeExpirySeconds * @return @@ -246,14 +221,10 @@ public Builder setCASEFailsafeTimerSeconds(int failsafeTimerSeconds) { * Enable/disable wifi network scan during commissioning in the the default * CommissioningDelegate used by the ChipDeviceCommissioner. * - *

- * Specifically, this sets AttemptWiFiNetworkScan in the CommissioningParameters - * passed to + *

Specifically, this sets AttemptWiFiNetworkScan in the CommissioningParameters passed to * the CommissioningDelegate. * - *

- * When a WiFi scan is attempted, the result will be propagated to the - * ScanNetworksListener + *

When a WiFi scan is attempted, the result will be propagated to the ScanNetworksListener * assigned to the ChipDeviceController. * * @param attemptNetworkScanWiFi @@ -268,14 +239,10 @@ public Builder setAttemptNetworkScanWiFi(boolean attemptNetworkScanWiFi) { * Enable/disable Thread network scan during commissioning in the the default * CommissioningDelegate used by the ChipDeviceCommissioner. * - *

- * Specifically, this sets AttemptThreadNetworkScan in the - * CommissioningParameters passed to + *

Specifically, this sets AttemptThreadNetworkScan in the CommissioningParameters passed to * the CommissioningDelegate. * - *

- * When a Thread scan is attempted, the result will be propagated to the - * ScanNetworksListener + *

When a Thread scan is attempted, the result will be propagated to the ScanNetworksListener * assigned to the ChipDeviceController. * * @param attemptNetworkScanWiFi @@ -287,18 +254,13 @@ public Builder setAttemptNetworkScanThread(boolean attemptNetworkScanThread) { } /** - * Disable the CASE phase of commissioning when the CommissioningComplete - * command is sent by + * Disable the CASE phase of commissioning when the CommissioningComplete command is sent by * this ChipDeviceCommissioner. * - *

- * Specifically, this sets SkipCommissioningComplete in the - * CommissioningParameters passed to + *

Specifically, this sets SkipCommissioningComplete in the CommissioningParameters passed to * the CommissioningDelegate. * - *

- * A controller will set this to true when the CASE phase of commissioning is - * done by a + *

A controller will set this to true when the CASE phase of commissioning is done by a * separate process, for example, by a Hub on the network. * * @param skipCommissioningComplete @@ -312,8 +274,7 @@ public Builder setSkipCommissioningComplete(boolean skipCommissioningComplete) { /** * Used when the Commissioner disables Attestation Certificate Validation. * - *

- * Specifically, this sets SkipAttestationCertificateValidation in the + *

Specifically, this sets SkipAttestationCertificateValidation in the * CommissioningParameters passed to the CommissioningDelegate. * * @param skipAttestationCertificateValidation @@ -329,14 +290,11 @@ public Builder setSkipAttestationCertificateValidation( * Sets the Regulatory Location country code passed to ChipDeviceCommissioner's * CommissioningParameters. * - *

- * Setting the country code will set the CountryCode when the - * SetRegulatoryConfig command is + *

Setting the country code will set the CountryCode when the SetRegulatoryConfig command is * sent by this ChipDeviceCommissioner. * - * @param countryCode an ISO 3166-1 alpha-2 code to represent the country, - * dependent territory, - * or special area of geographic interest + * @param countryCode an ISO 3166-1 alpha-2 code to represent the country, dependent territory, + * or special area of geographic interest * @return */ public Builder setCountryCode(final String countryCode) { @@ -351,14 +309,11 @@ public Builder setCountryCode(final String countryCode) { * Sets the Regulatory Location capability passed to ChipDeviceCommissioner's * CommissioningParameters. * - *

- * Setting the regulatory location type will set the NewRegulatoryConfig when - * the + *

Setting the regulatory location type will set the NewRegulatoryConfig when the * SetRegulatoryConfig command is sent by this ChipDeviceCommissioner. * - * @param regulatoryLocation an - * app::Clusters::GeneralCommissioning::RegulatoryLocationTypeEnum - * enum value + * @param regulatoryLocation an app::Clusters::GeneralCommissioning::RegulatoryLocationTypeEnum + * enum value * @return */ public Builder setRegulatoryLocation(int regulatoryLocation) { @@ -397,10 +352,8 @@ public Builder setIpk(byte[] ipk) { } /** - * Sets the AdminSubject value passed to ChipDeviceCommissioner's - * CommissioningParameters. This - * value is passed in the AddNoc command sent to the commissionee and represents - * the subject of + * Sets the AdminSubject value passed to ChipDeviceCommissioner's CommissioningParameters. This + * value is passed in the AddNoc command sent to the commissionee and represents the subject of * the default ACL created by that call. * * @param adminSubject @@ -412,8 +365,8 @@ public Builder setAdminSubject(long adminSubject) { } /** - * Controls enabling server interactions on a controller. - * For ICD check-in message, this feature has to enable. + * Controls enabling server interactions on a controller. For ICD check-in message, this feature + * has to enable. * * @param enableServerInteractions * @return From b657acfe5cefbf3f418e4a1b3efac03d24e125bc Mon Sep 17 00:00:00 2001 From: yunhanw-google Date: Mon, 11 Mar 2024 11:24:19 -0700 Subject: [PATCH 7/9] Update src/controller/java/src/chip/devicecontroller/ControllerParams.java Co-authored-by: mkardous-silabs <84793247+mkardous-silabs@users.noreply.github.com> --- .../java/src/chip/devicecontroller/ControllerParams.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/controller/java/src/chip/devicecontroller/ControllerParams.java b/src/controller/java/src/chip/devicecontroller/ControllerParams.java index f24b2ca38409c1..4f29f400431c28 100644 --- a/src/controller/java/src/chip/devicecontroller/ControllerParams.java +++ b/src/controller/java/src/chip/devicecontroller/ControllerParams.java @@ -366,7 +366,7 @@ public Builder setAdminSubject(long adminSubject) { /** * Controls enabling server interactions on a controller. For ICD check-in message, this feature - * has to enable. + * has to be enabled. * * @param enableServerInteractions * @return From 9f5818d931984eb444b385a8459b4722fe04b16d Mon Sep 17 00:00:00 2001 From: yunhanw-google Date: Mon, 11 Mar 2024 11:26:18 -0700 Subject: [PATCH 8/9] Update ControllerParams.java address comment --- .../java/src/chip/devicecontroller/ControllerParams.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/controller/java/src/chip/devicecontroller/ControllerParams.java b/src/controller/java/src/chip/devicecontroller/ControllerParams.java index 4f29f400431c28..e6e820a6806677 100644 --- a/src/controller/java/src/chip/devicecontroller/ControllerParams.java +++ b/src/controller/java/src/chip/devicecontroller/ControllerParams.java @@ -368,8 +368,8 @@ public Builder setAdminSubject(long adminSubject) { * Controls enabling server interactions on a controller. For ICD check-in message, this feature * has to be enabled. * - * @param enableServerInteractions - * @return + * @param enableServerInteractions indicates whether to enable server interactions. + * */ public Builder setEnableServerInteractions(boolean enableServerInteractions) { this.enableServerInteractions = enableServerInteractions; From 32fcfb60364069bc3e7396dbfe830a52140e363b Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Mon, 11 Mar 2024 18:27:17 +0000 Subject: [PATCH 9/9] Restyled by google-java-format --- .../java/src/chip/devicecontroller/ControllerParams.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/controller/java/src/chip/devicecontroller/ControllerParams.java b/src/controller/java/src/chip/devicecontroller/ControllerParams.java index e6e820a6806677..88459305d9068e 100644 --- a/src/controller/java/src/chip/devicecontroller/ControllerParams.java +++ b/src/controller/java/src/chip/devicecontroller/ControllerParams.java @@ -369,7 +369,6 @@ public Builder setAdminSubject(long adminSubject) { * has to be enabled. * * @param enableServerInteractions indicates whether to enable server interactions. - * */ public Builder setEnableServerInteractions(boolean enableServerInteractions) { this.enableServerInteractions = enableServerInteractions;