diff --git a/src/controller/java/AndroidDeviceControllerWrapper.cpp b/src/controller/java/AndroidDeviceControllerWrapper.cpp index ada814133734fc..b4a8c6714ec9eb 100644 --- a/src/controller/java/AndroidDeviceControllerWrapper.cpp +++ b/src/controller/java/AndroidDeviceControllerWrapper.cpp @@ -70,8 +70,8 @@ void AndroidDeviceControllerWrapper::CallJavaMethod(const char * methodName, jin } AndroidDeviceControllerWrapper * AndroidDeviceControllerWrapper::AllocateNew( - JavaVM * vm, jobject deviceControllerObj, chip::NodeId nodeId, const chip::CATValues & cats, chip::System::Layer * systemLayer, - chip::Inet::EndPointManager * tcpEndPointManager, + 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, AndroidOperationalCredentialsIssuerPtr opCredsIssuerPtr, jobject keypairDelegate, jbyteArray rootCertificate, jbyteArray intermediateCertificate, jbyteArray nodeOperationalCertificate, jbyteArray ipkEpochKey, uint16_t listenPort, uint16_t controllerVendorId, uint16_t failsafeTimerSeconds, @@ -237,9 +237,8 @@ AndroidDeviceControllerWrapper * AndroidDeviceControllerWrapper::AllocateNew( setupParams.operationalKeypair = &ephemeralKey; setupParams.hasExternallyOwnedOperationalKeypair = false; - *errInfoOnFailure = opCredsIssuer->GenerateNOCChainAfterValidation(nodeId, - /* fabricId = */ 1, cats, ephemeralKey.Pubkey(), - rcacSpan, icacSpan, nocSpan); + *errInfoOnFailure = opCredsIssuer->GenerateNOCChainAfterValidation(nodeId, fabricId, cats, ephemeralKey.Pubkey(), rcacSpan, + icacSpan, nocSpan); if (*errInfoOnFailure != CHIP_NO_ERROR) { diff --git a/src/controller/java/AndroidDeviceControllerWrapper.h b/src/controller/java/AndroidDeviceControllerWrapper.h index 2890d5f6e976ba..799cd374e32439 100644 --- a/src/controller/java/AndroidDeviceControllerWrapper.h +++ b/src/controller/java/AndroidDeviceControllerWrapper.h @@ -141,8 +141,9 @@ class AndroidDeviceControllerWrapper : public chip::Controller::DevicePairingDel * @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, const chip::CATValues & cats, - chip::System::Layer * systemLayer, chip::Inet::EndPointManager * tcpEndPointManager, + 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, AndroidOperationalCredentialsIssuerPtr opCredsIssuer, jobject keypairDelegate, jbyteArray rootCertificate, jbyteArray intermediateCertificate, jbyteArray nodeOperationalCertificate, jbyteArray ipkEpochKey, diff --git a/src/controller/java/CHIPDeviceController-JNI.cpp b/src/controller/java/CHIPDeviceController-JNI.cpp index 2f2ccb58cd9d5a..9a46972dd54d79 100644 --- a/src/controller/java/CHIPDeviceController-JNI.cpp +++ b/src/controller/java/CHIPDeviceController-JNI.cpp @@ -258,6 +258,10 @@ JNI_METHOD(jlong, newDeviceController)(JNIEnv * env, jobject self, jobject contr ChipLogProgress(Controller, "newDeviceController() called"); // Retrieve initialization params. + jmethodID getFabricId; + err = chip::JniReferences::GetInstance().FindMethod(env, controllerParams, "getFabricId", "()J", &getFabricId); + SuccessOrExit(err); + jmethodID getUdpListenPort; err = chip::JniReferences::GetInstance().FindMethod(env, controllerParams, "getUdpListenPort", "()I", &getUdpListenPort); SuccessOrExit(err); @@ -309,6 +313,7 @@ JNI_METHOD(jlong, newDeviceController)(JNIEnv * env, jobject self, jobject contr SuccessOrExit(err); { + uint64_t fabricId = env->CallLongMethod(controllerParams, getFabricId); uint16_t listenPort = env->CallIntMethod(controllerParams, getUdpListenPort); uint16_t controllerVendorId = env->CallIntMethod(controllerParams, getControllerVendorId); jobject keypairDelegate = env->CallObjectMethod(controllerParams, getKeypairDelegate); @@ -324,10 +329,10 @@ JNI_METHOD(jlong, newDeviceController)(JNIEnv * env, jobject self, jobject contr std::unique_ptr opCredsIssuer( new chip::Controller::AndroidOperationalCredentialsIssuer()); wrapper = AndroidDeviceControllerWrapper::AllocateNew( - sJVM, self, kLocalDeviceId, chip::kUndefinedCATs, &DeviceLayer::SystemLayer(), DeviceLayer::TCPEndPointManager(), - DeviceLayer::UDPEndPointManager(), std::move(opCredsIssuer), keypairDelegate, rootCertificate, intermediateCertificate, - operationalCertificate, ipk, listenPort, controllerVendorId, failsafeTimerSeconds, attemptNetworkScanWiFi, - attemptNetworkScanThread, &err); + sJVM, self, kLocalDeviceId, fabricId, chip::kUndefinedCATs, &DeviceLayer::SystemLayer(), + DeviceLayer::TCPEndPointManager(), DeviceLayer::UDPEndPointManager(), std::move(opCredsIssuer), keypairDelegate, + rootCertificate, intermediateCertificate, operationalCertificate, ipk, listenPort, controllerVendorId, + failsafeTimerSeconds, attemptNetworkScanWiFi, attemptNetworkScanThread, &err); SuccessOrExit(err); if (adminSubject != kUndefinedNodeId) diff --git a/src/controller/java/src/chip/devicecontroller/ControllerParams.java b/src/controller/java/src/chip/devicecontroller/ControllerParams.java index b0413cf4a8abf0..612079bfa29361 100644 --- a/src/controller/java/src/chip/devicecontroller/ControllerParams.java +++ b/src/controller/java/src/chip/devicecontroller/ControllerParams.java @@ -5,6 +5,7 @@ /** Parameters representing initialization arguments for {@link ChipDeviceController}. */ public final class ControllerParams { + private final long fabricId; private final int udpListenPort; private final int controllerVendorId; private final int failsafeTimerSeconds; @@ -21,6 +22,7 @@ public final class ControllerParams { /** @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; this.controllerVendorId = builder.controllerVendorId; this.failsafeTimerSeconds = builder.failsafeTimerSeconds; @@ -34,6 +36,10 @@ private ControllerParams(Builder builder) { this.adminSubject = builder.adminSubject; } + public long getFabricId() { + return fabricId; + } + /** Gets the UDP listening port; 0 indicates "any available port" */ public int getUdpListenPort() { return udpListenPort; @@ -100,6 +106,7 @@ public static Builder newBuilder(OperationalKeyConfig operationalKeyConfig) { /** Builder for {@link ControllerParams}. */ public static class Builder { + private long fabricId = 1; private int udpListenPort = LEGACY_GLOBAL_CHIP_PORT + 1; private int controllerVendorId = 0xFFFF; private int failsafeTimerSeconds = 30; @@ -114,6 +121,14 @@ public static class Builder { private Builder() {} + public Builder setFabricId(long fabricId) { + if (fabricId < 1) { + throw new IllegalArgumentException("fabricId must be > 0"); + } + this.fabricId = fabricId; + return this; + } + public Builder setUdpListenPort(int udpListenPort) { if (udpListenPort < 0) { throw new IllegalArgumentException("udpListenPort must be >= 0");