!1575 新增穿越hisyevent

Merge pull request !1575 from yang123/master
This commit is contained in:
openharmony_ci 2024-05-16 01:52:17 +00:00 committed by Gitee
commit 1eba1cf3a5
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
12 changed files with 425 additions and 10 deletions

View File

@ -1,4 +1,4 @@
# Copyright (c) 2021-2022 Huawei Device Co., Ltd.
# Copyright (c) 2021-2024 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
@ -212,4 +212,81 @@ COOPERATE_DRAG_RESULT_FAILED:
MSG: {type: STRING, desc: Coordination Drag Result Failed}
DEVICEID: {type: STRING, desc: remotedeviceId}
SESSIONID: {type: STRING, desc: sessionId}
CURSTATE: {type: STRING, desc: CurCoordinationState}
CURSTATE: {type: STRING, desc: CurCoordinationState}
ENABLE_SUCCESS:
__BASE: {type: BEHAVIOR, level: MINOR, tag: deviceStatus, desc: enable cooperate}
MSG: {type: STRING, desc: Enable cooperate successfully}
ENABLE_FAILED:
__BASE: {type: FAULT, level: MINOR, tag: deviceStatus, desc: enable cooperate}
MSG: {type: STRING, desc: Enable cooperate failed}
DISABLE_SUCCESS:
__BASE: {type: BEHAVIOR, level: MINOR, tag: deviceStatus, desc: disable cooperate}
MSG: {type: STRING, desc: Disable cooperate successfully}
DISABLE_FAILED:
__BASE: {type: FAULT, level: MINOR, tag: deviceStatus, desc: disable cooperate}
MSG: {type: STRING, desc: Disable cooperate failed}
LOCAL_ACTIVATE_SUCCESS:
__BASE: {type: BEHAVIOR, level: MINOR, tag: deviceStatus, desc: local start cooperate}
MSG: {type: STRING, desc: Local start cooperate successfully}
LOCAL_ACTIVATE_FAILED:
__BASE: {type: FAULT, level: MINOR, tag: deviceStatus, desc: local start cooperate}
MSG: {type: STRING, desc: Local start cooperate failed}
REMOTE_ACTIVATE_SUCCESS:
__BASE: {type: BEHAVIOR, level: MINOR, tag: deviceStatus, desc: remote start cooperate}
MSG: {type: STRING, desc: Remote start cooperate successfully}
REMOTE_ACTIVATE_FAILED:
__BASE: {type: FAULT, level: MINOR, tag: deviceStatus, desc: remote start cooperate}
MSG: {type: STRING, desc: Remote start cooperate failed}
LOCAL_DEACTIVATE_SUCCESS:
__BASE: {type: BEHAVIOR, level: MINOR, tag: deviceStatus, desc: local stop cooperate}
MSG: {type: STRING, desc: Local stop cooperate successfully}
LOCAL_DEACTIVATE_FAILED:
__BASE: {type: FAULT, level: MINOR, tag: deviceStatus, desc: local stop cooperate}
MSG: {type: STRING, desc: Local stop cooperate failed}
REMOTE_DEACTIVATE_SUCCESS:
__BASE: {type: BEHAVIOR, level: MINOR, tag: deviceStatus, desc: remote stop cooperate}
MSG: {type: STRING, desc: Remote stop cooperate successfully}
REMOTE_DEACTIVATE_FAILED:
__BASE: {type: FAULT, level: MINOR, tag: deviceStatus, desc: remote stop cooperate}
MSG: {type: STRING, desc: Remote stop cooperate failed}
OPENSESSION_SUCCESS:
__BASE: {type: BEHAVIOR, level: MINOR, tag: deviceStatus, desc: open session}
MSG: {type: STRING, desc: Open session successfully}
OPENSESSION_FAILED:
__BASE: {type: FAULT, level: MINOR, tag: deviceStatus, desc: open session}
MSG: {type: STRING, desc: Open session failed}
UPDATESTATE_SUCCESS:
__BASE: {type: BEHAVIOR, level: MINOR, tag: deviceStatus, desc: Cooperate update}
MSG: {type: STRING, desc: Update cooperatestate successfully}
CURSTATE: {type: STRING, desc: CurrentState}
START_SUCCESS:
__BASE: {type: FAULT, level: MINOR, tag: deviceStatus, desc: Start client}
MSG: {type: STRING, desc: Start client successfully}
START_FAILED:
__BASE: {type: FAULT, level: MINOR, tag: deviceStatus, desc: Start client}
MSG: {type: STRING, desc: Start client failed}
STOP_SUCCESS:
__BASE: {type: FAULT, level: MINOR, tag: deviceStatus, desc: Stop client}
MSG: {type: STRING, desc: Stop client successfully}
STOP_FAILED:
__BASE: {type: FAULT, level: MINOR, tag: deviceStatus, desc: Stop client}
MSG: {type: STRING, desc: Stop client failed}

View File

@ -1,4 +1,4 @@
# Copyright (c) 2023 Huawei Device Co., Ltd.
# Copyright (c) 2023-2024 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
@ -41,6 +41,7 @@ ohos_source_set("intention_dsoftbus_adapter") {
defines = device_status_default_defines
deps = [
"${device_status_root_path}/intention/dfx:cooperate_dfx",
"${device_status_root_path}/intention/prototype:intention_prototype",
"${device_status_root_path}/utils/common:devicestatus_util",
"${device_status_root_path}/utils/ipc:devicestatus_ipc",

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Copyright (c) 2023-2024 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -22,6 +22,7 @@
#include <netinet/in.h>
#include <netinet/tcp.h>
#include "cooperate_hisysevent.h"
#include "dfs_session.h"
#include "securec.h"
#include "softbus_bus_center.h"
@ -119,6 +120,11 @@ int32_t DSoftbusAdapterImpl::OpenSession(const std::string &networkId)
std::chrono::steady_clock::now() - startStamp).count();
FI_HILOGI("[PERF] OpenSessionLocked ret:%{public}d, elapsed: %{public}lld ms", ret, openSessionDuration);
#endif // ENABLE_PERFORMANCE_CHECK
if (ret != RET_OK) {
CooperateDFX::WriteOpenSession(OHOS::HiviewDFX::HiSysEvent::EventType::FAULT);
} else {
CooperateDFX::WriteOpenSession(OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR);
}
return ret;
}

View File

@ -1,4 +1,4 @@
# Copyright (c) 2023 Huawei Device Co., Ltd.
# Copyright (c) 2023-2024 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
@ -46,6 +46,7 @@ ohos_source_set("intention_cooperate_client") {
deps = [
"${device_status_root_path}/intention/cooperate/data:intention_cooperate_data",
"${device_status_root_path}/intention/data:intention_data",
"${device_status_root_path}/intention/dfx:cooperate_dfx",
"${device_status_root_path}/intention/ipc/socket:intention_socket_connection",
"${device_status_root_path}/intention/ipc/tunnel:intention_tunnel_client",
"${device_status_root_path}/intention/prototype:intention_prototype",

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Copyright (c) 2023-2024 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -20,6 +20,7 @@
#include <numeric>
#endif // ENABLE_PERFORMANCE_CHECK
#include "cooperate_hisysevent.h"
#include "cooperate_params.h"
#include "default_params.h"
#include "devicestatus_define.h"
@ -148,10 +149,12 @@ int32_t CooperateClient::Start(ITunnelClient &tunnel, const std::string &remoteN
int32_t ret = tunnel.Start(Intention::COOPERATE, param, reply);
if (ret != RET_OK) {
CooperateDFX::WriteStart(OHOS::HiviewDFX::HiSysEvent::EventType::FAULT);
FI_HILOGE("Activate cooperate failed");
return ret;
}
devCooperateEvent_.insert_or_assign(param.userData, event);
CooperateDFX::WriteStart(OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR);
return RET_OK;
}
@ -166,9 +169,11 @@ int32_t CooperateClient::Stop(ITunnelClient &tunnel,
int32_t ret = tunnel.Stop(Intention::COOPERATE, param, reply);
if (ret != RET_OK) {
CooperateDFX::WriteStop(OHOS::HiviewDFX::HiSysEvent::EventType::FAULT);
FI_HILOGE("Deactivate cooperate failed");
return ret;
}
CooperateDFX::WriteStop(OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR);
devCooperateEvent_.insert_or_assign(param.userData, event);
return RET_OK;
}

View File

@ -1,4 +1,4 @@
# Copyright (c) 2023 Huawei Device Co., Ltd.
# Copyright (c) 2023-2024 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
@ -56,6 +56,7 @@ ohos_shared_library("intention_cooperate") {
"${device_status_root_path}/intention/adapters/ddm_adapter:intention_ddm_adapter",
"${device_status_root_path}/intention/adapters/ddp_adapter:intention_ddp_adapter",
"${device_status_root_path}/intention/common/channel:intention_channel",
"${device_status_root_path}/intention/dfx:cooperate_dfx",
"${device_status_root_path}/intention/prototype:intention_prototype",
"${device_status_root_path}/utils/common:devicestatus_util",
"${device_status_root_path}/utils/ipc:devicestatus_ipc",

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Copyright (c) 2023-2024 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -19,6 +19,7 @@
#include "display_manager.h"
#include "cooperate_hisysevent.h"
#include "ddm_adapter.h"
#include "ddp_adapter.h"
#include "devicestatus_define.h"
@ -261,7 +262,10 @@ void Context::EnableCooperate(const EnableCooperateEvent &event)
{
int32_t ret = env_->GetDP().UpdateCrossingSwitchState(true);
if (ret != RET_OK) {
CooperateDFX::WriteEnable(OHOS::HiviewDFX::HiSysEvent::EventType::FAULT);
FI_HILOGE("Failed to update switch status");
} else {
CooperateDFX::WriteEnable(OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR);
}
}
@ -269,7 +273,10 @@ void Context::DisableCooperate(const DisableCooperateEvent &event)
{
int32_t ret = env_->GetDP().UpdateCrossingSwitchState(false);
if (ret != RET_OK) {
CooperateDFX::WriteDisable(OHOS::HiviewDFX::HiSysEvent::EventType::FAULT);
FI_HILOGE("Failed to update switch status");
} else {
CooperateDFX::WriteDisable(OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR);
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Copyright (c) 2023-2024 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -15,6 +15,7 @@
#include "event_manager.h"
#include "cooperate_hisysevent.h"
#include "devicestatus_define.h"
#include "utility.h"
@ -96,6 +97,11 @@ void EventManager::StartCooperateFinish(const DSoftbusStartCooperateFinished &ev
CoordinationMessage::ACTIVATE_SUCCESS :
CoordinationMessage::ACTIVATE_FAIL);
NotifyCooperateMessage(eventInfo->pid, eventInfo->msgId, eventInfo->userData, eventInfo->networkId, msg);
if (msg == CoordinationMessage::ACTIVATE_SUCCESS) {
CooperateDFX::WriteLocalStart(OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR);
} else {
CooperateDFX::WriteLocalStart(OHOS::HiviewDFX::HiSysEvent::EventType::FAULT);
}
calls_[EventType::START] = nullptr;
}
@ -112,6 +118,11 @@ void EventManager::RemoteStartFinish(const DSoftbusStartCooperateFinished &event
CoordinationMessage::ACTIVATE_SUCCESS :
CoordinationMessage::ACTIVATE_FAIL };
OnCooperateMessage(msg, event.networkId);
if (msg == CoordinationMessage::ACTIVATE_SUCCESS) {
CooperateDFX::WriteRemoteStart(OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR);
} else {
CooperateDFX::WriteRemoteStart(OHOS::HiviewDFX::HiSysEvent::EventType::FAULT);
}
}
void EventManager::OnUnchain(const StopCooperateEvent &event)
@ -140,6 +151,11 @@ void EventManager::StopCooperateFinish(const DSoftbusStopCooperateFinished &even
CoordinationMessage::DEACTIVATE_SUCCESS :
CoordinationMessage::DEACTIVATE_FAIL);
NotifyCooperateMessage(eventInfo->pid, eventInfo->msgId, eventInfo->userData, eventInfo->networkId, msg);
if (msg == CoordinationMessage::DEACTIVATE_SUCCESS) {
CooperateDFX::WriteLocalStop(OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR);
} else {
CooperateDFX::WriteLocalStop(OHOS::HiviewDFX::HiSysEvent::EventType::FAULT);
}
calls_[EventType::STOP] = nullptr;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Copyright (c) 2023-2024 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -21,6 +21,7 @@
#include "cooperate_events.h"
#include "cooperate_free.h"
#include "cooperate_hisysevent.h"
#include "cooperate_in.h"
#include "cooperate_out.h"
#include "devicestatus_define.h"
@ -103,6 +104,8 @@ void StateMachine::TransiteTo(Context &context, CooperateState state)
states_[current_]->OnLeaveState(context);
current_ = state;
states_[current_]->OnEnterState(context);
auto curState = static_cast<OHOS::Msdp::DeviceStatus::CooperateState>(state);
CooperateDFX::WriteCooperateState(curState);
}
}

53
intention/dfx/BUILD.gn Normal file
View File

@ -0,0 +1,53 @@
# Copyright (c) 2024 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("../../device_status.gni")
config("cooperate_public_config") {
include_dirs = [ "include" ]
}
ohos_source_set("cooperate_dfx") {
sanitize = {
integer_overflow = true
ubsan = true
boundary_sanitize = true
cfi = true
cfi_cross_dso = true
debug = false
}
branch_protector_ret = "pac_ret"
include_dirs = [
"include",
"/third_party/cJSON",
]
sources = [ "src/cooperate_hisysevent.cpp" ]
public_configs = [ ":cooperate_public_config" ]
defines = device_status_default_defines
deps = [ "${device_status_utils_path}:devicestatus_util" ]
external_deps = [
"c_utils:utils",
"hilog:libhilog",
"hisysevent:libhisysevent",
]
subsystem_name = "${device_status_subsystem_name}"
part_name = "${device_status_part_name}"
}

View File

@ -0,0 +1,80 @@
/*
* Copyright (c) 2024 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef COOPERATE_HISYSEVENT_H
#define COOPERATE_HISYSEVENT_H
#include <map>
#include <string>
#include "devicestatus_define.h"
#include "hisysevent.h"
namespace OHOS {
namespace Msdp {
namespace DeviceStatus {
enum CooperateType : int32_t {
ENABLE_SUCC = 0,
ENABLE_FAIL = 1,
DISABLE_SUCC = 2,
DISABLE_FAIL = 3,
LOCAL_ACTIVATE_SUCC = 4,
LOCAL_ACTIVATE_FAIL = 5,
REMOTE_ACTIVATE_SUCC = 6,
REMOTE_ACTIVATE_FAIL = 7,
LOCAL_DEACTIVATE_SUCC = 8,
LOCAL_DEACTIVATE_FAIL = 9,
REMOTE_DEACTIVATE_SUCC = 10,
REMOTE_DEACTIVATE_FAIL = 11,
OPENSESSION_SUCC = 12,
OPENSESSION_FAIL = 13,
UPDATESTATE_SUCC = 14,
START_SUCC = 15,
START_FAIL = 16,
STOP_SUCC = 17,
STOP_FAIL = 18,
};
enum CooperateState : size_t {
COOPERATE_STATE_FREE = 0,
COOPERATE_STATE_OUT,
COOPERATE_STATE_IN,
N_COOPERATE_STATES,
};
class CooperateDFX {
public:
static int32_t WriteEnable(OHOS::HiviewDFX::HiSysEvent::EventType type);
static int32_t WriteDisable(OHOS::HiviewDFX::HiSysEvent::EventType type);
static int32_t WriteLocalStart(OHOS::HiviewDFX::HiSysEvent::EventType type);
static int32_t WriteLocalStop(OHOS::HiviewDFX::HiSysEvent::EventType type);
static int32_t WriteRemoteStart(OHOS::HiviewDFX::HiSysEvent::EventType type);
static int32_t WriteRemoteStop(OHOS::HiviewDFX::HiSysEvent::EventType type);
static int32_t WriteOpenSession(OHOS::HiviewDFX::HiSysEvent::EventType type);
static int32_t WriteStart(OHOS::HiviewDFX::HiSysEvent::EventType type);
static int32_t WriteStop(OHOS::HiviewDFX::HiSysEvent::EventType type);
static int32_t WriteCooperateState(CooperateState curState);
template<typename... Types>
static int32_t WriteInputFunc(const CooperateType &cooperateType,
OHOS::HiviewDFX::HiSysEvent::EventType eventType, Types... paras);
private:
static std::map<CooperateState, std::string> CooperateState_;
static std::map<CooperateType, std::pair<std::string, std::string>> serialStr_;
};
} // namespace DeviceStatus
} // namespace Msdp
} // namespace OHOS
#endif // COOPERATE_HISYSEVENT_H

View File

@ -0,0 +1,165 @@
/*
* Copyright (c) 2024 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "cooperate_hisysevent.h"
#include "fi_log.h"
#undef LOG_TAG
#define LOG_TAG "CooperateHiSysEvent"
namespace OHOS {
namespace Msdp {
namespace DeviceStatus {
std::map<CooperateState, std::string> CooperateDFX::CooperateState_ = {
{ CooperateState::COOPERATE_STATE_FREE, "STATE_FREE" },
{ CooperateState::COOPERATE_STATE_IN, "STATE_IN" },
{ CooperateState::COOPERATE_STATE_OUT, "STATE_OUT" },
};
std::map<CooperateType, std::pair<std::string, std::string>> CooperateDFX::serialStr_ = {
{ CooperateType::ENABLE_SUCC, { "ENABLE_SUCCESS", "Enable cooperate successfully" } },
{ CooperateType::ENABLE_FAIL, { "ENABLE_FAILED", "Enable cooperate failed" } },
{ CooperateType::DISABLE_SUCC, { "DISABLE_SUCCESS", "Disenable cooperate successfully" } },
{ CooperateType::DISABLE_FAIL, { "DISABLE_FAILED", "Disenable cooperate failed" } },
{ CooperateType::LOCAL_ACTIVATE_SUCC, { "LOCAL_ACTIVATE_SUCCESS", "Local start cooperate successfully" } },
{ CooperateType::LOCAL_ACTIVATE_FAIL, { "LOCAL_ACTIVATEE_FAILED", "Local start cooperate failed" } },
{ CooperateType::REMOTE_ACTIVATE_SUCC, { "REMOTE_ACTIVATE_SUCCESS", "Remote start cooperate successfully" } },
{ CooperateType::REMOTE_ACTIVATE_FAIL, { "REMOTE_ACTIVATE_FAILED", "Remote start cooperate failed" } },
{ CooperateType::LOCAL_DEACTIVATE_SUCC, { "LOCAL_DEACTIVATE_SUCCESS", "Local stop cooperate successfully" } },
{ CooperateType::LOCAL_DEACTIVATE_FAIL, { "LOCAL_DEACTIVATE_FAILED", "Local stop cooperate failed" } },
{ CooperateType::REMOTE_DEACTIVATE_SUCC, { "REMOTE_DEACTIVATE_SUCCESS", "Remote stop cooperate successfully" } },
{ CooperateType::REMOTE_DEACTIVATE_FAIL, { "REMOTE_DEACTIVATE_FAILED", "Remote stop cooperate failed" } },
{ CooperateType::OPENSESSION_SUCC, { "OPENSESSION_SUCCESS", "Open session successfully" } },
{ CooperateType::OPENSESSION_FAIL, { "OPENSESSION_FAILED", "Open session failed" } },
{ CooperateType::UPDATESTATE_SUCC, { "UPDATESTATE_SUCCESS", "Update cooperatestate successfully" } },
{ CooperateType::START_SUCC, { "START_SUCCESS", "Start client successfully" } },
{ CooperateType::START_FAIL, { "START_FAILED", "Start client failed" } },
{ CooperateType::STOP_SUCC, { "STOP_SUCCESS", "Stop client successfully" } },
{ CooperateType::STOP_FAIL, { "STOP_FAILED", "Stop client failed" } },
};
template<typename... Types>
int32_t CooperateDFX::WriteInputFunc(const CooperateType &cooperateType,
OHOS::HiviewDFX::HiSysEvent::EventType eventType, Types... paras)
{
if (serialStr_.find(cooperateType) == serialStr_.end()) {
FI_HILOGE("serialStr_ can't find the cooperate hisysevent type");
return RET_ERR;
}
auto &[label, dec] = serialStr_[cooperateType];
int32_t ret = HiSysEventWrite(
OHOS::HiviewDFX::HiSysEvent::Domain::MSDP,
label,
eventType,
paras...,
"MSG",
dec);
if (ret != RET_OK) {
FI_HILOGE("HiviewDFX write failed, ret:%{public}d", ret);
}
return ret;
}
int32_t CooperateDFX::WriteEnable(OHOS::HiviewDFX::HiSysEvent::EventType type)
{
if (type == OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR) {
return WriteInputFunc(CooperateType::ENABLE_SUCC, type);
}
return WriteInputFunc(CooperateType::ENABLE_FAIL, type);
}
int32_t CooperateDFX::WriteDisable(OHOS::HiviewDFX::HiSysEvent::EventType type)
{
if (type == OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR) {
return WriteInputFunc(CooperateType::DISABLE_SUCC, type);
}
return WriteInputFunc(CooperateType::DISABLE_FAIL, type);
}
int32_t CooperateDFX::WriteLocalStart(OHOS::HiviewDFX::HiSysEvent::EventType type)
{
if (type == OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR) {
return WriteInputFunc(CooperateType::LOCAL_ACTIVATE_SUCC, type);
}
return WriteInputFunc(CooperateType::LOCAL_ACTIVATE_FAIL, type);
}
int32_t CooperateDFX::WriteRemoteStart(OHOS::HiviewDFX::HiSysEvent::EventType type)
{
if (type == OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR) {
return WriteInputFunc(CooperateType::REMOTE_ACTIVATE_SUCC, type);
}
return WriteInputFunc(CooperateType::REMOTE_ACTIVATE_FAIL, type);
}
int32_t CooperateDFX::WriteLocalStop(OHOS::HiviewDFX::HiSysEvent::EventType type)
{
if (type == OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR) {
return WriteInputFunc(CooperateType::LOCAL_DEACTIVATE_SUCC, type);
}
return WriteInputFunc(CooperateType::LOCAL_DEACTIVATE_FAIL, type);
}
int32_t CooperateDFX::WriteRemoteStop(OHOS::HiviewDFX::HiSysEvent::EventType type)
{
if (type == OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR) {
return WriteInputFunc(CooperateType::REMOTE_DEACTIVATE_SUCC, type);
}
return WriteInputFunc(CooperateType::REMOTE_DEACTIVATE_FAIL, type);
}
int32_t CooperateDFX::WriteOpenSession(OHOS::HiviewDFX::HiSysEvent::EventType type)
{
if (type == OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR) {
return WriteInputFunc(CooperateType::OPENSESSION_SUCC, type);
}
return WriteInputFunc(CooperateType::OPENSESSION_FAIL, type);
}
int32_t CooperateDFX::WriteStart(OHOS::HiviewDFX::HiSysEvent::EventType type)
{
if (type == OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR) {
return WriteInputFunc(CooperateType::START_SUCC, type);
}
return WriteInputFunc(CooperateType::START_FAIL, type);
}
int32_t CooperateDFX::WriteStop(OHOS::HiviewDFX::HiSysEvent::EventType type)
{
if (type == OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR) {
return WriteInputFunc(CooperateType::STOP_SUCC, type);
}
return WriteInputFunc(CooperateType::STOP_FAIL, type);
}
int32_t CooperateDFX::WriteCooperateState(CooperateState curState)
{
if (curState == CooperateState::N_COOPERATE_STATES) {
return RET_ERR;
}
if (CooperateState_.find(curState) == CooperateState_.end()) {
FI_HILOGE("CooperateState_ can't find the current cooperate state");
return RET_ERR;
}
auto type = OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR;
std::string currentState = CooperateState_[curState];
return WriteInputFunc(CooperateType::UPDATESTATE_SUCC, type, "CurrentState", currentState);
}
} // namespace DeviceStatus
} // namespace Msdp
} // namespace OHOS