1f857971dSopenharmony_ci/*
2f857971dSopenharmony_ci * Copyright (c) 2023-2024 Huawei Device Co., Ltd.
3f857971dSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4f857971dSopenharmony_ci * you may not use this file except in compliance with the License.
5f857971dSopenharmony_ci * You may obtain a copy of the License at
6f857971dSopenharmony_ci *
7f857971dSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8f857971dSopenharmony_ci *
9f857971dSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10f857971dSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11f857971dSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12f857971dSopenharmony_ci * See the License for the specific language governing permissions and
13f857971dSopenharmony_ci * limitations under the License.
14f857971dSopenharmony_ci */
15f857971dSopenharmony_ci
16f857971dSopenharmony_ci#include "cooperate_out.h"
17f857971dSopenharmony_ci
18f857971dSopenharmony_ci#include "devicestatus_define.h"
19f857971dSopenharmony_ci#include "utility.h"
20f857971dSopenharmony_ci
21f857971dSopenharmony_ci#undef LOG_TAG
22f857971dSopenharmony_ci#define LOG_TAG "CooperateOut"
23f857971dSopenharmony_ci
24f857971dSopenharmony_cinamespace OHOS {
25f857971dSopenharmony_cinamespace Msdp {
26f857971dSopenharmony_cinamespace DeviceStatus {
27f857971dSopenharmony_cinamespace Cooperate {
28f857971dSopenharmony_ci
29f857971dSopenharmony_ciCooperateOut::CooperateOut(IStateMachine &parent, IContext *env)
30f857971dSopenharmony_ci    : ICooperateState(parent), env_(env)
31f857971dSopenharmony_ci{
32f857971dSopenharmony_ci    initial_ = std::make_shared<Initial>(*this);
33f857971dSopenharmony_ci    Initial::BuildChains(initial_, *this);
34f857971dSopenharmony_ci    current_ = initial_;
35f857971dSopenharmony_ci}
36f857971dSopenharmony_ci
37f857971dSopenharmony_ciCooperateOut::~CooperateOut()
38f857971dSopenharmony_ci{
39f857971dSopenharmony_ci    Initial::RemoveChains(initial_);
40f857971dSopenharmony_ci}
41f857971dSopenharmony_ci
42f857971dSopenharmony_civoid CooperateOut::OnEvent(Context &context, const CooperateEvent &event)
43f857971dSopenharmony_ci{
44f857971dSopenharmony_ci    current_->OnEvent(context, event);
45f857971dSopenharmony_ci}
46f857971dSopenharmony_ci
47f857971dSopenharmony_civoid CooperateOut::OnEnterState(Context &context)
48f857971dSopenharmony_ci{
49f857971dSopenharmony_ci    CALL_INFO_TRACE;
50f857971dSopenharmony_ci    env_->GetInput().SetPointerVisibility(false);
51f857971dSopenharmony_ci}
52f857971dSopenharmony_ci
53f857971dSopenharmony_civoid CooperateOut::OnLeaveState(Context &context)
54f857971dSopenharmony_ci{
55f857971dSopenharmony_ci    CALL_INFO_TRACE;
56f857971dSopenharmony_ci    SetPointerVisible(context);
57f857971dSopenharmony_ci}
58f857971dSopenharmony_ci
59f857971dSopenharmony_civoid CooperateOut::SetPointerVisible(Context &context)
60f857971dSopenharmony_ci{
61f857971dSopenharmony_ci    CHKPV(env_);
62f857971dSopenharmony_ci    bool hasLocalPointerDevice =  env_->GetDeviceManager().HasLocalPointerDevice();
63f857971dSopenharmony_ci    bool visible = !context.NeedHideCursor() && hasLocalPointerDevice;
64f857971dSopenharmony_ci    FI_HILOGI("Set pointer visible:%{public}s, HasLocalPointerDevice:%{public}s",
65f857971dSopenharmony_ci        visible ? "true" : "false", hasLocalPointerDevice ? "true" : "false");
66f857971dSopenharmony_ci    env_->GetInput().SetPointerVisibility(visible, PRIORITY);
67f857971dSopenharmony_ci}
68f857971dSopenharmony_ci
69f857971dSopenharmony_civoid CooperateOut::Initial::BuildChains(std::shared_ptr<Initial> self, CooperateOut &parent)
70f857971dSopenharmony_ci{}
71f857971dSopenharmony_ci
72f857971dSopenharmony_civoid CooperateOut::Initial::RemoveChains(std::shared_ptr<Initial> self)
73f857971dSopenharmony_ci{}
74f857971dSopenharmony_ci
75f857971dSopenharmony_ciCooperateOut::Initial::Initial(CooperateOut &parent)
76f857971dSopenharmony_ci    : ICooperateStep(parent, nullptr), parent_(parent)
77f857971dSopenharmony_ci{
78f857971dSopenharmony_ci    AddHandler(CooperateEventType::DISABLE, [this](Context &context, const CooperateEvent &event) {
79f857971dSopenharmony_ci        this->OnDisable(context, event);
80f857971dSopenharmony_ci    });
81f857971dSopenharmony_ci    AddHandler(CooperateEventType::START, [this](Context &context, const CooperateEvent &event) {
82f857971dSopenharmony_ci        this->OnStart(context, event);
83f857971dSopenharmony_ci    });
84f857971dSopenharmony_ci    AddHandler(CooperateEventType::STOP, [this](Context &context, const CooperateEvent &event) {
85f857971dSopenharmony_ci        this->OnStop(context, event);
86f857971dSopenharmony_ci    });
87f857971dSopenharmony_ci    AddHandler(CooperateEventType::APP_CLOSED, [this](Context &context, const CooperateEvent &event) {
88f857971dSopenharmony_ci        this->OnAppClosed(context, event);
89f857971dSopenharmony_ci    });
90f857971dSopenharmony_ci    AddHandler(CooperateEventType::INPUT_HOTPLUG_EVENT, [this](Context &context, const CooperateEvent &event) {
91f857971dSopenharmony_ci        this->OnHotplug(context, event);
92f857971dSopenharmony_ci    });
93f857971dSopenharmony_ci    AddHandler(CooperateEventType::INPUT_POINTER_EVENT, [this](Context &context, const CooperateEvent &event) {
94f857971dSopenharmony_ci        this->OnPointerEvent(context, event);
95f857971dSopenharmony_ci    });
96f857971dSopenharmony_ci    AddHandler(CooperateEventType::DDM_BOARD_OFFLINE, [this](Context &context, const CooperateEvent &event) {
97f857971dSopenharmony_ci        this->OnBoardOffline(context, event);
98f857971dSopenharmony_ci    });
99f857971dSopenharmony_ci    AddHandler(CooperateEventType::DDP_COOPERATE_SWITCH_CHANGED,
100f857971dSopenharmony_ci        [this](Context &context, const CooperateEvent &event) {
101f857971dSopenharmony_ci            this->OnSwitchChanged(context, event);
102f857971dSopenharmony_ci    });
103f857971dSopenharmony_ci    AddHandler(CooperateEventType::DSOFTBUS_SESSION_CLOSED,
104f857971dSopenharmony_ci        [this](Context &context, const CooperateEvent &event) {
105f857971dSopenharmony_ci            this->OnSoftbusSessionClosed(context, event);
106f857971dSopenharmony_ci    });
107f857971dSopenharmony_ci    AddHandler(CooperateEventType::DSOFTBUS_COME_BACK,
108f857971dSopenharmony_ci        [this](Context &context, const CooperateEvent &event) {
109f857971dSopenharmony_ci            this->OnComeBack(context, event);
110f857971dSopenharmony_ci    });
111f857971dSopenharmony_ci    AddHandler(CooperateEventType::DSOFTBUS_START_COOPERATE,
112f857971dSopenharmony_ci        [this](Context &context, const CooperateEvent &event) {
113f857971dSopenharmony_ci            this->OnRemoteStart(context, event);
114f857971dSopenharmony_ci    });
115f857971dSopenharmony_ci    AddHandler(CooperateEventType::DSOFTBUS_STOP_COOPERATE,
116f857971dSopenharmony_ci        [this](Context &context, const CooperateEvent &event) {
117f857971dSopenharmony_ci            this->OnRemoteStop(context, event);
118f857971dSopenharmony_ci    });
119f857971dSopenharmony_ci    AddHandler(CooperateEventType::DSOFTBUS_RELAY_COOPERATE,
120f857971dSopenharmony_ci        [this](Context &context, const CooperateEvent &event) {
121f857971dSopenharmony_ci            this->OnRelay(context, event);
122f857971dSopenharmony_ci    });
123f857971dSopenharmony_ci}
124f857971dSopenharmony_ci
125f857971dSopenharmony_civoid CooperateOut::Initial::OnDisable(Context &context, const CooperateEvent &event)
126f857971dSopenharmony_ci{
127f857971dSopenharmony_ci    FI_HILOGI("[disable cooperation] Stop cooperation");
128f857971dSopenharmony_ci    parent_.StopCooperate(context, event);
129f857971dSopenharmony_ci}
130f857971dSopenharmony_ci
131f857971dSopenharmony_civoid CooperateOut::Initial::OnStart(Context &context, const CooperateEvent &event)
132f857971dSopenharmony_ci{
133f857971dSopenharmony_ci    StartCooperateEvent param = std::get<StartCooperateEvent>(event.event);
134f857971dSopenharmony_ci
135f857971dSopenharmony_ci    context.eventMgr_.StartCooperate(param);
136f857971dSopenharmony_ci    FI_HILOGI("[start] Start cooperation with \'%{public}s\', report success when out",
137f857971dSopenharmony_ci        Utility::Anonymize(context.Peer()).c_str());
138f857971dSopenharmony_ci    DSoftbusStartCooperateFinished failNotice {
139f857971dSopenharmony_ci        .success = false,
140f857971dSopenharmony_ci        .errCode = static_cast<int32_t>(CoordinationErrCode::UNEXPECTED_START_CALL)
141f857971dSopenharmony_ci    };
142f857971dSopenharmony_ci    context.eventMgr_.StartCooperateFinish(failNotice);
143f857971dSopenharmony_ci}
144f857971dSopenharmony_ci
145f857971dSopenharmony_civoid CooperateOut::Initial::OnStop(Context &context, const CooperateEvent &event)
146f857971dSopenharmony_ci{
147f857971dSopenharmony_ci    StopCooperateEvent param = std::get<StopCooperateEvent>(event.event);
148f857971dSopenharmony_ci
149f857971dSopenharmony_ci    context.eventMgr_.StopCooperate(param);
150f857971dSopenharmony_ci    FI_HILOGI("[stop] Stop cooperation with \'%{public}s\', unchain:%{public}d",
151f857971dSopenharmony_ci        Utility::Anonymize(context.Peer()).c_str(), param.isUnchained);
152f857971dSopenharmony_ci    parent_.StopCooperate(context, event);
153f857971dSopenharmony_ci
154f857971dSopenharmony_ci    param.networkId = context.Peer();
155f857971dSopenharmony_ci    DSoftbusStopCooperateFinished notice {
156f857971dSopenharmony_ci        .networkId = context.Peer(),
157f857971dSopenharmony_ci        .normal = true,
158f857971dSopenharmony_ci    };
159f857971dSopenharmony_ci    context.eventMgr_.StopCooperateFinish(notice);
160f857971dSopenharmony_ci
161f857971dSopenharmony_ci    parent_.UnchainConnections(context, param);
162f857971dSopenharmony_ci}
163f857971dSopenharmony_ci
164f857971dSopenharmony_civoid CooperateOut::Initial::OnComeBack(Context &context, const CooperateEvent &event)
165f857971dSopenharmony_ci{
166f857971dSopenharmony_ci    CALL_INFO_TRACE;
167f857971dSopenharmony_ci    DSoftbusComeBack notice = std::get<DSoftbusComeBack>(event.event);
168f857971dSopenharmony_ci
169f857971dSopenharmony_ci    if (!context.IsPeer(notice.networkId)) {
170f857971dSopenharmony_ci        return;
171f857971dSopenharmony_ci    }
172f857971dSopenharmony_ci    FI_HILOGI("[come back] From \'%{public}s\'", Utility::Anonymize(notice.networkId).c_str());
173f857971dSopenharmony_ci    context.OnRemoteStartCooperate(notice.extra);
174f857971dSopenharmony_ci    DSoftbusStartCooperate startEvent {
175f857971dSopenharmony_ci        .networkId = notice.networkId,
176f857971dSopenharmony_ci    };
177f857971dSopenharmony_ci    context.eventMgr_.RemoteStart(startEvent);
178f857971dSopenharmony_ci    context.inputEventInterceptor_.Disable();
179f857971dSopenharmony_ci
180f857971dSopenharmony_ci    context.RemoteStartSuccess(notice);
181f857971dSopenharmony_ci    context.eventMgr_.RemoteStartFinish(notice);
182f857971dSopenharmony_ci    TransiteTo(context, CooperateState::COOPERATE_STATE_FREE);
183f857971dSopenharmony_ci    context.OnBack();
184f857971dSopenharmony_ci}
185f857971dSopenharmony_ci
186f857971dSopenharmony_civoid CooperateOut::Initial::OnRemoteStart(Context &context, const CooperateEvent &event)
187f857971dSopenharmony_ci{
188f857971dSopenharmony_ci    DSoftbusStartCooperate notice = std::get<DSoftbusStartCooperate>(event.event);
189f857971dSopenharmony_ci
190f857971dSopenharmony_ci    if (context.IsLocal(notice.networkId)) {
191f857971dSopenharmony_ci        return;
192f857971dSopenharmony_ci    }
193f857971dSopenharmony_ci    FI_HILOGI("[remote start] Request from \'%{public}s\'", Utility::Anonymize(notice.networkId).c_str());
194f857971dSopenharmony_ci    if (context.IsPeer(notice.networkId)) {
195f857971dSopenharmony_ci        FI_HILOGI("[remote start] Reset on request from peer");
196f857971dSopenharmony_ci        parent_.StopCooperate(context, event);
197f857971dSopenharmony_ci        return;
198f857971dSopenharmony_ci    }
199f857971dSopenharmony_ci    context.OnResetCooperation();
200f857971dSopenharmony_ci    context.OnRemoteStartCooperate(notice.extra);
201f857971dSopenharmony_ci    context.eventMgr_.RemoteStart(notice);
202f857971dSopenharmony_ci    context.inputEventInterceptor_.Disable();
203f857971dSopenharmony_ci
204f857971dSopenharmony_ci    DSoftbusStopCooperate stopNotice {};
205f857971dSopenharmony_ci    context.dsoftbus_.StopCooperate(context.Peer(), stopNotice);
206f857971dSopenharmony_ci
207f857971dSopenharmony_ci    context.RemoteStartSuccess(notice);
208f857971dSopenharmony_ci    context.inputEventBuilder_.Enable(context);
209f857971dSopenharmony_ci    context.eventMgr_.RemoteStartFinish(notice);
210f857971dSopenharmony_ci    FI_HILOGI("[remote start] Cooperation with \'%{public}s\' established", Utility::Anonymize(context.Peer()).c_str());
211f857971dSopenharmony_ci    TransiteTo(context, CooperateState::COOPERATE_STATE_IN);
212f857971dSopenharmony_ci    context.OnTransitionIn();
213f857971dSopenharmony_ci}
214f857971dSopenharmony_ci
215f857971dSopenharmony_civoid CooperateOut::Initial::OnRemoteStop(Context &context, const CooperateEvent &event)
216f857971dSopenharmony_ci{
217f857971dSopenharmony_ci    DSoftbusStopCooperate notice = std::get<DSoftbusStopCooperate>(event.event);
218f857971dSopenharmony_ci
219f857971dSopenharmony_ci    if (!context.IsPeer(notice.networkId)) {
220f857971dSopenharmony_ci        return;
221f857971dSopenharmony_ci    }
222f857971dSopenharmony_ci    FI_HILOGI("[remote stop] Notification from \'%{public}s\'", Utility::Anonymize(notice.networkId).c_str());
223f857971dSopenharmony_ci    context.eventMgr_.RemoteStop(notice);
224f857971dSopenharmony_ci    context.inputEventInterceptor_.Disable();
225f857971dSopenharmony_ci    context.ResetCursorPosition();
226f857971dSopenharmony_ci    context.eventMgr_.RemoteStopFinish(notice);
227f857971dSopenharmony_ci    TransiteTo(context, CooperateState::COOPERATE_STATE_FREE);
228f857971dSopenharmony_ci    context.OnResetCooperation();
229f857971dSopenharmony_ci}
230f857971dSopenharmony_ci
231f857971dSopenharmony_civoid CooperateOut::Initial::OnRelay(Context &context, const CooperateEvent &event)
232f857971dSopenharmony_ci{
233f857971dSopenharmony_ci    DSoftbusRelayCooperate notice = std::get<DSoftbusRelayCooperate>(event.event);
234f857971dSopenharmony_ci    if (!context.IsPeer(notice.networkId)) {
235f857971dSopenharmony_ci        return;
236f857971dSopenharmony_ci    }
237f857971dSopenharmony_ci    DSoftbusRelayCooperateFinished resp {
238f857971dSopenharmony_ci        .targetNetworkId = notice.targetNetworkId,
239f857971dSopenharmony_ci    };
240f857971dSopenharmony_ci
241f857971dSopenharmony_ci    int32_t ret = context.dsoftbus_.OpenSession(notice.targetNetworkId);
242f857971dSopenharmony_ci    if (ret != RET_OK) {
243f857971dSopenharmony_ci        FI_HILOGE("[relay cooperate] Failed to connect to \'%{public}s\'",
244f857971dSopenharmony_ci            Utility::Anonymize(notice.targetNetworkId).c_str());
245f857971dSopenharmony_ci        resp.normal = false;
246f857971dSopenharmony_ci        context.dsoftbus_.RelayCooperateFinish(notice.networkId, resp);
247f857971dSopenharmony_ci        return;
248f857971dSopenharmony_ci    }
249f857971dSopenharmony_ci
250f857971dSopenharmony_ci    resp.normal = true;
251f857971dSopenharmony_ci    context.dsoftbus_.RelayCooperateFinish(notice.networkId, resp);
252f857971dSopenharmony_ci
253f857971dSopenharmony_ci    context.RelayCooperate(notice);
254f857971dSopenharmony_ci    context.inputEventInterceptor_.Update(context);
255f857971dSopenharmony_ci    FI_HILOGI("[relay cooperate] Relay cooperation to \'%{public}s\'", Utility::Anonymize(context.Peer()).c_str());
256f857971dSopenharmony_ci    context.OnRelayCooperation(context.Peer(), context.NormalizedCursorPosition());
257f857971dSopenharmony_ci}
258f857971dSopenharmony_ci
259f857971dSopenharmony_civoid CooperateOut::Initial::OnHotplug(Context &context, const CooperateEvent &event)
260f857971dSopenharmony_ci{
261f857971dSopenharmony_ci    InputHotplugEvent notice = std::get<InputHotplugEvent>(event.event);
262f857971dSopenharmony_ci    if (notice.deviceId != context.StartDeviceId()) {
263f857971dSopenharmony_ci        return;
264f857971dSopenharmony_ci    }
265f857971dSopenharmony_ci    FI_HILOGI("Stop cooperation on unplug of dedicated pointer");
266f857971dSopenharmony_ci    parent_.StopCooperate(context, event);
267f857971dSopenharmony_ci}
268f857971dSopenharmony_ci
269f857971dSopenharmony_civoid CooperateOut::Initial::OnAppClosed(Context &context, const CooperateEvent &event)
270f857971dSopenharmony_ci{
271f857971dSopenharmony_ci    FI_HILOGI("[app closed] Close all connections");
272f857971dSopenharmony_ci    context.dsoftbus_.CloseAllSessions();
273f857971dSopenharmony_ci    FI_HILOGI("[app closed] Stop cooperation");
274f857971dSopenharmony_ci    parent_.StopCooperate(context, event);
275f857971dSopenharmony_ci}
276f857971dSopenharmony_ci
277f857971dSopenharmony_civoid CooperateOut::Initial::OnPointerEvent(Context &context, const CooperateEvent &event)
278f857971dSopenharmony_ci{
279f857971dSopenharmony_ci    InputPointerEvent notice = std::get<InputPointerEvent>(event.event);
280f857971dSopenharmony_ci
281f857971dSopenharmony_ci    if ((notice.sourceType != MMI::PointerEvent::SOURCE_TYPE_MOUSE) ||
282f857971dSopenharmony_ci        (notice.deviceId == context.StartDeviceId()) ||
283f857971dSopenharmony_ci        (notice.deviceId < 0)) {
284f857971dSopenharmony_ci        return;
285f857971dSopenharmony_ci    }
286f857971dSopenharmony_ci    FI_HILOGI("Stop cooperation on operation of undedicated pointer");
287f857971dSopenharmony_ci    parent_.StopCooperate(context, event);
288f857971dSopenharmony_ci}
289f857971dSopenharmony_ci
290f857971dSopenharmony_civoid CooperateOut::Initial::OnBoardOffline(Context &context, const CooperateEvent &event)
291f857971dSopenharmony_ci{
292f857971dSopenharmony_ci    DDMBoardOfflineEvent notice = std::get<DDMBoardOfflineEvent>(event.event);
293f857971dSopenharmony_ci
294f857971dSopenharmony_ci    if (!context.IsPeer(notice.networkId)) {
295f857971dSopenharmony_ci        return;
296f857971dSopenharmony_ci    }
297f857971dSopenharmony_ci    FI_HILOGI("[board offline] Peer(\'%{public}s\') is offline", Utility::Anonymize(notice.networkId).c_str());
298f857971dSopenharmony_ci    parent_.StopCooperate(context, event);
299f857971dSopenharmony_ci}
300f857971dSopenharmony_ci
301f857971dSopenharmony_civoid CooperateOut::Initial::OnSwitchChanged(Context &context, const CooperateEvent &event)
302f857971dSopenharmony_ci{
303f857971dSopenharmony_ci    DDPCooperateSwitchChanged notice = std::get<DDPCooperateSwitchChanged>(event.event);
304f857971dSopenharmony_ci
305f857971dSopenharmony_ci    if (!context.IsPeer(notice.networkId) || notice.normal) {
306f857971dSopenharmony_ci        return;
307f857971dSopenharmony_ci    }
308f857971dSopenharmony_ci    FI_HILOGI("[switch off] Peer(\'%{public}s\') switch off", Utility::Anonymize(notice.networkId).c_str());
309f857971dSopenharmony_ci    parent_.StopCooperate(context, event);
310f857971dSopenharmony_ci}
311f857971dSopenharmony_ci
312f857971dSopenharmony_civoid CooperateOut::Initial::OnSoftbusSessionClosed(Context &context, const CooperateEvent &event)
313f857971dSopenharmony_ci{
314f857971dSopenharmony_ci    DSoftbusSessionClosed notice = std::get<DSoftbusSessionClosed>(event.event);
315f857971dSopenharmony_ci
316f857971dSopenharmony_ci    if (!context.IsPeer(notice.networkId)) {
317f857971dSopenharmony_ci        return;
318f857971dSopenharmony_ci    }
319f857971dSopenharmony_ci    FI_HILOGI("[dsoftbus session closed] Disconnected with \'%{public}s\'",
320f857971dSopenharmony_ci        Utility::Anonymize(notice.networkId).c_str());
321f857971dSopenharmony_ci    parent_.StopCooperate(context, event);
322f857971dSopenharmony_ci}
323f857971dSopenharmony_ci
324f857971dSopenharmony_civoid CooperateOut::Initial::OnProgress(Context &context, const CooperateEvent &event)
325f857971dSopenharmony_ci{}
326f857971dSopenharmony_ci
327f857971dSopenharmony_civoid CooperateOut::Initial::OnReset(Context &context, const CooperateEvent &event)
328f857971dSopenharmony_ci{}
329f857971dSopenharmony_ci
330f857971dSopenharmony_civoid CooperateOut::StopCooperate(Context &context, const CooperateEvent &event)
331f857971dSopenharmony_ci{
332f857971dSopenharmony_ci    context.inputEventInterceptor_.Disable();
333f857971dSopenharmony_ci
334f857971dSopenharmony_ci    DSoftbusStopCooperate notice {};
335f857971dSopenharmony_ci    context.dsoftbus_.StopCooperate(context.Peer(), notice);
336f857971dSopenharmony_ci
337f857971dSopenharmony_ci    context.ResetCursorPosition();
338f857971dSopenharmony_ci    TransiteTo(context, CooperateState::COOPERATE_STATE_FREE);
339f857971dSopenharmony_ci    context.OnResetCooperation();
340f857971dSopenharmony_ci}
341f857971dSopenharmony_ci
342f857971dSopenharmony_civoid CooperateOut::UnchainConnections(Context &context, const StopCooperateEvent &event) const
343f857971dSopenharmony_ci{
344f857971dSopenharmony_ci    if (event.isUnchained) {
345f857971dSopenharmony_ci        FI_HILOGI("Unchain all connections");
346f857971dSopenharmony_ci        context.dsoftbus_.CloseAllSessions();
347f857971dSopenharmony_ci        context.eventMgr_.OnUnchain(event);
348f857971dSopenharmony_ci    }
349f857971dSopenharmony_ci}
350f857971dSopenharmony_ci} // namespace Cooperate
351f857971dSopenharmony_ci} // namespace DeviceStatus
352f857971dSopenharmony_ci} // namespace Msdp
353f857971dSopenharmony_ci} // namespace OHOS
354