Skip to content

Commit

Permalink
[Android] Modify chiptool crash when skipCommissioningComplete flag e…
Browse files Browse the repository at this point in the history
…nabled (project-chip#32807)

* Modify android chiptool crash

* Update src/controller/CHIPDeviceController.cpp

Co-authored-by: Boris Zbarsky <[email protected]>

* Change FindCommissionedDevice timing

* Change CommissioningStageComplete call timing

---------

Co-authored-by: Boris Zbarsky <[email protected]>
  • Loading branch information
2 people authored and lazarkov committed Jul 10, 2024
1 parent 180ee0d commit ecfb786
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/controller/CHIPDeviceController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1844,13 +1844,25 @@ void DeviceCommissioner::CleanupCommissioning(DeviceProxy * proxy, NodeId nodeId

if (completionStatus.err == CHIP_NO_ERROR)
{
// CommissioningStageComplete uses mDeviceBeingCommissioned, which can
// be commissionee if we are cleaning up before we've gone operational. Normally
// that would not happen in this non-error case, _except_ if we were told to skip sending
// CommissioningComplete: in that case we do not have an operational DeviceProxy, so
// we're using our CommissioneeDeviceProxy to do a successful cleanup.
//
// This means we have to call CommissioningStageComplete() before we destroy commissionee.
//
// This should be safe, because CommissioningStageComplete() does not call CleanupCommissioning
// when called in the cleanup stage (which is where we are), and StopPairing does not directly release
// mDeviceBeingCommissioned.
CommissioningStageComplete(CHIP_NO_ERROR);

CommissioneeDeviceProxy * commissionee = FindCommissioneeDevice(nodeId);
if (commissionee != nullptr)
{
ReleaseCommissioneeDevice(commissionee);
}
// Send the callbacks, we're done.
CommissioningStageComplete(CHIP_NO_ERROR);
SendCommissioningCompleteCallbacks(nodeId, mCommissioningCompletionStatus);
}
else if (completionStatus.err == CHIP_ERROR_CANCELLED)
Expand Down Expand Up @@ -1929,12 +1941,13 @@ void DeviceCommissioner::CleanupDoneAfterError()
VerifyOrReturn(mDeviceBeingCommissioned != nullptr);

NodeId nodeId = mDeviceBeingCommissioned->GetDeviceId();
// At this point, we also want to close off the pase session so we need to re-establish
CommissioneeDeviceProxy * commissionee = FindCommissioneeDevice(nodeId);

// Signal completion - this will reset mDeviceBeingCommissioned.
CommissioningStageComplete(CHIP_NO_ERROR);

// At this point, we also want to close off the pase session so we need to re-establish
CommissioneeDeviceProxy * commissionee = FindCommissioneeDevice(nodeId);

// If we've disarmed the failsafe, it's because we're starting again, so kill the pase connection.
if (commissionee != nullptr)
{
Expand Down

0 comments on commit ecfb786

Please sign in to comment.