Skip to content

Commit

Permalink
[Android] Shutdown factory with device controller (#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 <yho.yoon@samsung.com>
Signed-off-by: Charles Kim <chulspro.kim@samsung.com>
Signed-off-by: Hunsup Jung <hunsup.jung@samsung.com>
Signed-off-by: sanghyukko <sanghyuk.ko@samsung.com>
Signed-off-by: Jaehoon You <jaehoon.you@samsung.com>
Signed-off-by: Kyu-Wook Lim <kyuwook.lim@samsung.com>
  • Loading branch information
yhoyoon authored and pull[bot] committed Mar 5, 2024
1 parent 6051749 commit 1967264
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 1967264

Please sign in to comment.