From 3c0a63099bf401859d16cce9f52f5621bc70affe Mon Sep 17 00:00:00 2001 From: Mathieu Kardous Date: Mon, 17 Jun 2024 16:02:10 -0400 Subject: [PATCH] Preliminary support for the Android controller --- .../java/AndroidDeviceControllerWrapper.cpp | 12 ++++++++++++ .../chip/devicecontroller/ICDRegistrationInfo.java | 12 ++++++++++++ ...pDeviceController-ScriptDevicePairingDelegate.cpp | 1 + 3 files changed, 25 insertions(+) diff --git a/src/controller/java/AndroidDeviceControllerWrapper.cpp b/src/controller/java/AndroidDeviceControllerWrapper.cpp index 87f53735bcf617..c0a86717505dfa 100644 --- a/src/controller/java/AndroidDeviceControllerWrapper.cpp +++ b/src/controller/java/AndroidDeviceControllerWrapper.cpp @@ -526,6 +526,12 @@ CHIP_ERROR AndroidDeviceControllerWrapper::ApplyICDRegistrationInfo(chip::Contro VerifyOrReturnError(err == CHIP_NO_ERROR, err); jbyteArray jSymmetricKey = static_cast(env->CallObjectMethod(icdRegistrationInfo, getSymmetricKeyMethod)); + jmethodID getClientTypeMethod; + err = chip::JniReferences::GetInstance().FindMethod(env, icdRegistrationInfo, "getClientType", "()Ljava/lang/Short", + &getClientTypeMethod); + VerifyOrReturnError(err == CHIP_NO_ERROR, err); + jobject jClientType = env->CallObjectMethod(icdRegistrationInfo, getClientTypeMethod); + chip::NodeId checkInNodeId = chip::kUndefinedNodeId; if (jCheckInNodeId != nullptr) { @@ -556,6 +562,12 @@ CHIP_ERROR AndroidDeviceControllerWrapper::ApplyICDRegistrationInfo(chip::Contro } params.SetICDSymmetricKey(chip::ByteSpan(mICDSymmetricKey)); + chip::app::Clusters::IcdManagement::ClientTypeEnum clientType = chip::app::Clusters::IcdManagement::ClientTypeEnum::kPermanent; + if (jClientType != nullptr) + { + clientType = static_cast(jClientType) + } + return err; } diff --git a/src/controller/java/src/chip/devicecontroller/ICDRegistrationInfo.java b/src/controller/java/src/chip/devicecontroller/ICDRegistrationInfo.java index be978fae28fee6..135206f48489d8 100644 --- a/src/controller/java/src/chip/devicecontroller/ICDRegistrationInfo.java +++ b/src/controller/java/src/chip/devicecontroller/ICDRegistrationInfo.java @@ -24,11 +24,13 @@ public class ICDRegistrationInfo { @Nullable private final Long checkInNodeId; @Nullable private final Long monitoredSubject; @Nullable private final byte[] symmetricKey; + @Nullable private final Short clientType; private ICDRegistrationInfo(Builder builder) { this.checkInNodeId = builder.checkInNodeId; this.monitoredSubject = builder.monitoredSubject; this.symmetricKey = builder.symmetricKey; + this.clientType = builder.clientType; } /** Returns the check in node ID. */ @@ -46,6 +48,10 @@ public byte[] getSymmetricKey() { return symmetricKey; } + public Short getClientType() { + reutnr clientType; + } + public static Builder newBuilder() { return new Builder(); } @@ -55,6 +61,7 @@ public static class Builder { @Nullable private Long checkInNodeId = null; @Nullable private Long monitoredSubject = null; @Nullable private byte[] symmetricKey = null; + @Nullable private Short clientType = null; private Builder() {} @@ -81,6 +88,11 @@ public Builder setSymmetricKey(byte[] symmetricKey) { return this; } + public Builder setClientType(Short clientType) { + this.clientType = clientType; + return this; + } + public ICDRegistrationInfo build() { return new ICDRegistrationInfo(this); } diff --git a/src/controller/python/ChipDeviceController-ScriptDevicePairingDelegate.cpp b/src/controller/python/ChipDeviceController-ScriptDevicePairingDelegate.cpp index c979e0d9cd77a3..c04481a45a11ea 100644 --- a/src/controller/python/ChipDeviceController-ScriptDevicePairingDelegate.cpp +++ b/src/controller/python/ChipDeviceController-ScriptDevicePairingDelegate.cpp @@ -191,6 +191,7 @@ void ScriptDevicePairingDelegate::OnICDRegistrationComplete(ScopedNodeId nodeId, clientInfo.peer_node = nodeId; clientInfo.monitored_subject = sCommissioningParameters.GetICDMonitoredSubject().Value(); clientInfo.start_icd_counter = icdCounter; + clientInfo.client_type = sCommissioningParameters.GetICDClientType().Value(); CHIP_ERROR err = sICDClientStorage.SetKey(clientInfo, ByteSpan(sICDSymmetricKey)); if (err == CHIP_NO_ERROR)