diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2024-03-04 22:01:51 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2024-03-04 22:01:51 +0000 |
commit | 87b825ba38f9bd620f557fd2ba0ca98b6d331288 (patch) | |
tree | 2d7c74e749a36376e7b99efa1175b0a4d36ef3e3 | |
parent | 297425fbe15aef8430e77c95775bfbac38178b39 (diff) | |
parent | 0a1a82391d8cb8aca62973082641edf75e5025eb (diff) | |
download | ot-br-posix-simpleperf-release.tar.gz |
Snap for 11526323 from 0a1a82391d8cb8aca62973082641edf75e5025eb to simpleperf-releasesimpleperf-release
Change-Id: I2b5ebafb6d353cee0bf57cab514dd9913f4c5001
-rw-r--r-- | src/android/otdaemon_server.cpp | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/src/android/otdaemon_server.cpp b/src/android/otdaemon_server.cpp index 005400b6..ce985bb5 100644 --- a/src/android/otdaemon_server.cpp +++ b/src/android/otdaemon_server.cpp @@ -153,7 +153,14 @@ void OtDaemonServer::StateCallback(otChangedFlags aFlags) } if (aFlags & OT_CHANGED_THREAD_BACKBONE_ROUTER_STATE) { - mCallback->onBackboneRouterStateChanged(GetBackboneRouterState()); + if (mCallback == nullptr) + { + otbrLogWarning("Ignoring OT backbone router state changes: callback is not set"); + } + else + { + mCallback->onBackboneRouterStateChanged(GetBackboneRouterState()); + } } } @@ -264,17 +271,14 @@ exit: BackboneRouterState OtDaemonServer::GetBackboneRouterState() { BackboneRouterState state; - otBackboneRouterState bbrState = otBackboneRouterGetState(GetOtInstance()); + otBackboneRouterState bbrState; otBackboneRouterMulticastListenerInfo info; otBackboneRouterMulticastListenerIterator iter = OT_BACKBONE_ROUTER_MULTICAST_LISTENER_ITERATOR_INIT; state.listeningAddresses = std::vector<std::string>(); - if (mCallback == nullptr) - { - otbrLogWarning("OT daemon callback is not set"); - return state; - } + VerifyOrExit(GetOtInstance() != nullptr, otbrLogWarning("Can't get bbr state: OT is not initialized")); + bbrState = otBackboneRouterGetState(GetOtInstance()); switch (bbrState) { case OT_BACKBONE_ROUTER_STATE_DISABLED: @@ -295,6 +299,7 @@ BackboneRouterState OtDaemonServer::GetBackboneRouterState() state.listeningAddresses.push_back(string); } +exit: return state; } @@ -310,7 +315,15 @@ void OtDaemonServer::HandleBackboneMulticastListenerEvent(void otbrLogDebug("Multicast forwarding address changed, %s is %s", addressString, (aEvent == OT_BACKBONE_ROUTER_MULTICAST_LISTENER_ADDED) ? "added" : "removed"); + if (thisServer->mCallback == nullptr) + { + otbrLogWarning("Ignoring OT multicast listener event: callback is not set"); + ExitNow(); + } thisServer->mCallback->onBackboneRouterStateChanged(thisServer->GetBackboneRouterState()); + +exit: + return; } otInstance *OtDaemonServer::GetOtInstance() @@ -534,7 +547,7 @@ Status OtDaemonServer::join(const std::vector<uint8_t> &aActiveOpD message = "Thread is disabling"); VerifyOrExit(mThreadEnabled == IOtDaemon::OT_STATE_ENABLED, - error = static_cast<int>(IOtDaemon::ErrorCode::OT_ERROR_THREAD_DISABLED), + error = static_cast<int>(IOtDaemon::ErrorCode::OT_ERROR_THREAD_DISABLED), message = "Thread is disabled"); otbrLogInfo("Start joining..."); @@ -658,7 +671,7 @@ Status OtDaemonServer::scheduleMigration(const std::vector<uint8_t> message = "Thread is disabling"); VerifyOrExit(mThreadEnabled == IOtDaemon::OT_STATE_ENABLED, - error = static_cast<int>(IOtDaemon::ErrorCode::OT_ERROR_THREAD_DISABLED), + error = static_cast<int>(IOtDaemon::ErrorCode::OT_ERROR_THREAD_DISABLED), message = "Thread is disabled"); if (GetOtInstance() == nullptr) |