Skip to content

Commit

Permalink
[Android] Unify AndroidDeviceControllerWrapper::Shutdown()
Browse files Browse the repository at this point in the history
Fix AndroidDeviceControllerWrapper::Shutdown() and make destructor call
this shutdown, and further create mInitialized state to guarantee
shutdown proceudre can be executed only once
  • Loading branch information
yunhanw-google committed Dec 11, 2024
1 parent 2be9877 commit 6bd9cfa
Showing 1 changed file with 26 additions and 26 deletions.
52 changes: 26 additions & 26 deletions src/controller/java/AndroidDeviceControllerWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,32 +49,7 @@ using namespace TLV;

AndroidDeviceControllerWrapper::~AndroidDeviceControllerWrapper()
{
getICDClientStorage()->Shutdown();
mController->Shutdown();

if (mKeypairBridge != nullptr)
{
chip::Platform::Delete(mKeypairBridge);
mKeypairBridge = nullptr;
}

if (mDeviceAttestationDelegateBridge != nullptr)
{
delete mDeviceAttestationDelegateBridge;
mDeviceAttestationDelegateBridge = nullptr;
}

if (mDeviceAttestationVerifier != nullptr)
{
delete mDeviceAttestationVerifier;
mDeviceAttestationVerifier = nullptr;
}

if (mAttestationTrustStoreBridge != nullptr)
{
delete mAttestationTrustStoreBridge;
mAttestationTrustStoreBridge = nullptr;
}
shutdown();
}

void AndroidDeviceControllerWrapper::SetJavaObjectRef(JavaVM * vm, jobject obj)
Expand Down Expand Up @@ -418,8 +393,33 @@ AndroidDeviceControllerWrapper * AndroidDeviceControllerWrapper::AllocateNew(

void AndroidDeviceControllerWrapper::Shutdown()
{
getICDClientStorage()->Shutdown();
mController->Shutdown();
DeviceControllerFactory::GetInstance().Shutdown();

if (mKeypairBridge != nullptr)
{
chip::Platform::Delete(mKeypairBridge);
mKeypairBridge = nullptr;
}

if (mDeviceAttestationDelegateBridge != nullptr)
{
delete mDeviceAttestationDelegateBridge;
mDeviceAttestationDelegateBridge = nullptr;
}

if (mDeviceAttestationVerifier != nullptr)
{
delete mDeviceAttestationVerifier;
mDeviceAttestationVerifier = nullptr;
}

if (mAttestationTrustStoreBridge != nullptr)
{
delete mAttestationTrustStoreBridge;
mAttestationTrustStoreBridge = nullptr;
}
}

CHIP_ERROR AndroidDeviceControllerWrapper::ApplyNetworkCredentials(chip::Controller::CommissioningParameters & params,
Expand Down

0 comments on commit 6bd9cfa

Please sign in to comment.