diff --git a/src/messaging/ExchangeMgr.cpp b/src/messaging/ExchangeMgr.cpp index 210238c29905a1..2d070572523430 100644 --- a/src/messaging/ExchangeMgr.cpp +++ b/src/messaging/ExchangeMgr.cpp @@ -43,6 +43,11 @@ #include #include +#if CONFIG_DEVICE_LAYER +#include +#include +#endif + using namespace chip::Encoding; using namespace chip::Inet; using namespace chip::System; @@ -94,6 +99,10 @@ CHIP_ERROR ExchangeManager::Init(SecureSessionMgr * sessionMgr) CHIP_ERROR ExchangeManager::Shutdown() { +// TODO(#6919): This doesn't compile for Android, because Android has no device layer. +#if CONFIG_DEVICE_LAYER + DeviceLayer::PlatformMgr().LockChipStack(); +#endif mReliableMessageMgr.Shutdown(); mContextPool.ForEachActiveObject([](auto * ec) { @@ -109,6 +118,9 @@ CHIP_ERROR ExchangeManager::Shutdown() } mState = State::kState_NotInitialized; +#if CONFIG_DEVICE_LAYER + DeviceLayer::PlatformMgr().UnlockChipStack(); +#endif return CHIP_NO_ERROR; }