Skip to content

Commit

Permalink
[Android] Shutdown factory with device controller (project-chip#29881)
Browse files Browse the repository at this point in the history
This change adds shutdown to AndroidDeviceControllerWrapper, which wraps
CHIPDeviceController on the Android platform, so that
DeviceControllerFactory and CHIPDeviceController can be shutdown.
AndroidDeviceControllerWrapper initializes DeviceControllerFactory and
CHIPDeviceController, but since it supports only CHIPDeviceController
shutdown, DeviceControllerFactory shutdown is required.
If you reuse AndroidDeviceControllerWrapper with the call below without
shutting down DeviceControllerFactory, sometimes the
DeviceControllerSystemState of DeviceControllerFactory becomes
incorrect, causing AndroidDeviceControllerWrapper to operate
incorrectly, and the problem cannot be solved unless the process is
restarted.
- AndroidDeviceControllerWrapper::AllocateNew()
- AndroidDeviceControllerWrapper::Controller()->Shutdown()

Signed-off-by: Youngho Yoon <[email protected]>
Signed-off-by: Charles Kim <[email protected]>
Signed-off-by: Hunsup Jung <[email protected]>
Signed-off-by: sanghyukko <[email protected]>
Signed-off-by: Jaehoon You <[email protected]>
Signed-off-by: Kyu-Wook Lim <[email protected]>
  • Loading branch information
yhoyoon authored Oct 22, 2023
1 parent e0bdee7 commit d870e8c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/controller/java/AndroidDeviceControllerWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,12 @@ AndroidDeviceControllerWrapper * AndroidDeviceControllerWrapper::AllocateNew(
return wrapper.release();
}

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

CHIP_ERROR AndroidDeviceControllerWrapper::ApplyNetworkCredentials(chip::Controller::CommissioningParameters & params,
jobject networkCredentials)
{
Expand Down
2 changes: 2 additions & 0 deletions src/controller/java/AndroidDeviceControllerWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ class AndroidDeviceControllerWrapper : public chip::Controller::DevicePairingDel
uint16_t failsafeTimerSeconds, bool attemptNetworkScanWiFi, bool attemptNetworkScanThread,
bool skipCommissioningComplete, CHIP_ERROR * errInfoOnFailure);

void Shutdown();

#ifdef JAVA_MATTER_CONTROLLER_TEST
chip::Controller::ExampleOperationalCredentialsIssuer * GetAndroidOperationalCredentialsIssuer()
#else
Expand Down
2 changes: 1 addition & 1 deletion src/controller/java/CHIPDeviceController-JNI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1960,7 +1960,7 @@ JNI_METHOD(void, shutdownCommissioning)
StopIOThread();

AndroidDeviceControllerWrapper * wrapper = AndroidDeviceControllerWrapper::FromJNIHandle(handle);
wrapper->Controller()->Shutdown();
wrapper->Shutdown();
}

JNI_METHOD(jbyteArray, getAttestationChallenge)
Expand Down

0 comments on commit d870e8c

Please sign in to comment.