Skip to content

Commit a70c74f

Browse files
authored
Merge branch 'master' into camera-zone
2 parents 28a031b + a854245 commit a70c74f

File tree

8 files changed

+292
-243
lines changed

8 files changed

+292
-243
lines changed

examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/provisioning/DeviceProvisioningFragment.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ class DeviceProvisioningFragment : Fragment() {
289289
override fun onICDRegistrationInfoRequired() {
290290
Log.d(TAG, "onICDRegistrationInfoRequired")
291291
deviceController.updateCommissioningICDRegistrationInfo(
292-
ICDRegistrationInfo.newBuilder().build()
292+
ICDRegistrationInfo.newBuilder().setICDStayActiveDurationMsec(30000L).build()
293293
)
294294
}
295295

src/app/InteractionModelEngine.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ CHIP_ERROR InteractionModelEngine::Init(Messaging::ExchangeManager * apExchangeM
8989
VerifyOrReturnError(apExchangeMgr != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
9090
VerifyOrReturnError(reportScheduler != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
9191

92+
mState = State::kInitializing;
9293
mpExchangeMgr = apExchangeMgr;
9394
mpFabricTable = apFabricTable;
9495
mpCASESessionMgr = apCASESessionMgr;
@@ -111,11 +112,14 @@ CHIP_ERROR InteractionModelEngine::Init(Messaging::ExchangeManager * apExchangeM
111112
ChipLogError(InteractionModel, "WARNING └────────────────────────────────────────────────────");
112113
#endif
113114

115+
mState = State::kInitialized;
114116
return CHIP_NO_ERROR;
115117
}
116118

117119
void InteractionModelEngine::Shutdown()
118120
{
121+
VerifyOrReturn(State::kUninitialized != mState);
122+
119123
mpExchangeMgr->GetSessionManager()->SystemLayer()->CancelTimer(ResumeSubscriptionsTimerCallback, this);
120124

121125
// TODO: individual object clears the entire command handler interface registry.
@@ -187,6 +191,8 @@ void InteractionModelEngine::Shutdown()
187191
//
188192
// mpFabricTable = nullptr;
189193
// mpExchangeMgr = nullptr;
194+
195+
mState = State::kUninitialized;
190196
}
191197

192198
uint32_t InteractionModelEngine::GetNumActiveReadHandlers() const

src/app/InteractionModelEngine.h

+8
Original file line numberDiff line numberDiff line change
@@ -713,6 +713,14 @@ class InteractionModelEngine : public Messaging::UnsolicitedMessageHandler,
713713
DataModel::Provider * mDataModelProvider = nullptr;
714714
Messaging::ExchangeContext * mCurrentExchange = nullptr;
715715

716+
enum class State : uint8_t
717+
{
718+
kUninitialized, // The object has not been initialized.
719+
kInitializing, // Initial setup is in progress (e.g. setting up mpExchangeMgr).
720+
kInitialized // The object has been fully initialized and is ready for use.
721+
};
722+
State mState = State::kUninitialized;
723+
716724
// Changes the current exchange context of a InteractionModelEngine to a given context
717725
class CurrentExchangeValueScope
718726
{

src/app/server/CommissioningWindowManager.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ void CommissioningWindowManager::OnPlatformEvent(const DeviceLayer::ChipDeviceEv
111111

112112
void CommissioningWindowManager::Shutdown()
113113
{
114+
VerifyOrReturn(nullptr != mServer);
115+
114116
StopAdvertisement(/* aShuttingDown = */ true);
115117

116118
ResetState();

src/controller/java/AndroidDeviceControllerWrapper.cpp

+20-4
Original file line numberDiff line numberDiff line change
@@ -508,28 +508,44 @@ CHIP_ERROR AndroidDeviceControllerWrapper::ApplyICDRegistrationInfo(chip::Contro
508508
VerifyOrReturnError(icdRegistrationInfo != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
509509

510510
JNIEnv * env = chip::JniReferences::GetInstance().GetEnvForCurrentThread();
511+
if (env == nullptr)
512+
{
513+
ChipLogError(Controller, "Failed to retrieve JNIEnv in %s.", __func__);
514+
return CHIP_ERROR_INCORRECT_STATE;
515+
}
516+
517+
jmethodID getICDStayActiveDurationMsecMethod;
518+
err = chip::JniReferences::GetInstance().FindMethod(env, icdRegistrationInfo, "getICDStayActiveDurationMsec",
519+
"()Ljava/lang/Long;", &getICDStayActiveDurationMsecMethod);
520+
ReturnErrorOnFailure(err);
521+
jobject jStayActiveMsec = env->CallObjectMethod(icdRegistrationInfo, getICDStayActiveDurationMsecMethod);
522+
if (jStayActiveMsec != 0)
523+
{
524+
params.SetICDStayActiveDurationMsec(chip::JniReferences::GetInstance().IntegerToPrimitive(jStayActiveMsec));
525+
}
526+
511527
jmethodID getCheckInNodeIdMethod;
512528
err = chip::JniReferences::GetInstance().FindMethod(env, icdRegistrationInfo, "getCheckInNodeId", "()Ljava/lang/Long;",
513529
&getCheckInNodeIdMethod);
514-
VerifyOrReturnError(err == CHIP_NO_ERROR, err);
530+
ReturnErrorOnFailure(err);
515531
jobject jCheckInNodeId = env->CallObjectMethod(icdRegistrationInfo, getCheckInNodeIdMethod);
516532

517533
jmethodID getMonitoredSubjectMethod;
518534
err = chip::JniReferences::GetInstance().FindMethod(env, icdRegistrationInfo, "getMonitoredSubject", "()Ljava/lang/Long;",
519535
&getMonitoredSubjectMethod);
520-
VerifyOrReturnError(err == CHIP_NO_ERROR, err);
536+
ReturnErrorOnFailure(err);
521537
jobject jMonitoredSubject = env->CallObjectMethod(icdRegistrationInfo, getMonitoredSubjectMethod);
522538

523539
jmethodID getSymmetricKeyMethod;
524540
err =
525541
chip::JniReferences::GetInstance().FindMethod(env, icdRegistrationInfo, "getSymmetricKey", "()[B", &getSymmetricKeyMethod);
526-
VerifyOrReturnError(err == CHIP_NO_ERROR, err);
542+
ReturnErrorOnFailure(err);
527543
jbyteArray jSymmetricKey = static_cast<jbyteArray>(env->CallObjectMethod(icdRegistrationInfo, getSymmetricKeyMethod));
528544

529545
jmethodID getClientTypeMethod;
530546
err = chip::JniReferences::GetInstance().FindMethod(env, icdRegistrationInfo, "getClientType", "()Ljava/lang/Integer;",
531547
&getClientTypeMethod);
532-
VerifyOrReturnError(err == CHIP_NO_ERROR, err);
548+
ReturnErrorOnFailure(err);
533549
jobject jClientType = env->CallObjectMethod(icdRegistrationInfo, getClientTypeMethod);
534550

535551
chip::NodeId checkInNodeId = chip::kUndefinedNodeId;

src/controller/java/src/chip/devicecontroller/ICDRegistrationInfo.java

+17
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,19 @@ public class ICDRegistrationInfo {
2525
@Nullable private final Long monitoredSubject;
2626
@Nullable private final byte[] symmetricKey;
2727
@Nullable private final Integer clientType;
28+
@Nullable private final Long stayActiveDurationMsec;
2829

2930
private ICDRegistrationInfo(Builder builder) {
3031
this.checkInNodeId = builder.checkInNodeId;
3132
this.monitoredSubject = builder.monitoredSubject;
3233
this.symmetricKey = builder.symmetricKey;
3334
this.clientType = builder.clientType;
35+
this.stayActiveDurationMsec = builder.stayActiveDurationMsec;
36+
}
37+
38+
/** Returns the duration period to stay active. */
39+
public Long getICDStayActiveDurationMsec() {
40+
return stayActiveDurationMsec;
3441
}
3542

3643
/** Returns the check in node ID. */
@@ -62,6 +69,7 @@ public static class Builder {
6269
@Nullable private Long monitoredSubject = null;
6370
@Nullable private byte[] symmetricKey = null;
6471
@Nullable private Integer clientType = null;
72+
@Nullable private Long stayActiveDurationMsec = null;
6573

6674
private Builder() {}
6775

@@ -93,6 +101,15 @@ public Builder setClientType(Integer clientType) {
93101
return this;
94102
}
95103

104+
/**
105+
* Request LIT device to stay active for specific duration after commission completes, the upper
106+
* bound is 30 seconds.
107+
*/
108+
public Builder setICDStayActiveDurationMsec(Long stayActiveDurationMsec) {
109+
this.stayActiveDurationMsec = stayActiveDurationMsec;
110+
return this;
111+
}
112+
96113
public ICDRegistrationInfo build() {
97114
return new ICDRegistrationInfo(this);
98115
}

0 commit comments

Comments
 (0)