• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef COORDINATION_HISYSEVENT_H
17 #define COORDINATION_HISYSEVENT_H
18 
19 #include <map>
20 #include <string>
21 
22 #include "coordination_sm.h"
23 #include "devicestatus_define.h"
24 #include "hisysevent.h"
25 
26 namespace OHOS {
27 namespace Msdp {
28 namespace DeviceStatus {
29 namespace {
30 constexpr int32_t SUB_LEN { 6 };
31 constexpr int32_t INIT_SIGN { 0 };
32 constexpr int32_t SESS_SIGN { 1 };
33 constexpr int32_t STATUS_SIGN { 2 };
34 } //namespace
35 enum CoorType : int32_t {
36     PREPARE_SUCC = 0,
37     PREPARE_FAIL = 1,
38     UNPREPARE_SUCC = 2,
39     UNPREPARE_FAIL = 3,
40     ACTIVATE_SUCC = 4,
41     ACTIVATE_FAIL = 5,
42     ACTIVATE_RESULT = 7,
43     DEACTIVATE_SUCC = 8,
44     DEACTIVATE_FAIL = 9,
45     DEACTIVATE_RESULT = 11,
46     OPEN_SOFUBUS_RESULT_ONE = 13,
47     OPEN_SOFUBUS_RESULT_TWO = 15,
48     OPEN_SOFUBUS_RESULT_THREE = 17,
49     INPUT_START_REMOTE_INPUT = 19,
50     INPUT_STOP_REMOTE_O = 21,
51     INPUT_STOP_REMOTE_T = 23,
52     INPUT_PRE_REMOTE_O = 25,
53     INPUT_PRE_REMOTE_T = 27,
54     INPUT_UNPRE_REMOTE_O = 29,
55     INPUT_UNPRE_REMOTE_T = 31,
56     COOP_DRAG_SUCC = 32,
57     COOP_DRAG_FAIL = 33,
58     COOP_DRAG_RESULT_SUCC = 34,
59     COOP_DRAG_RESULT_FAIL = 35,
60 };
61 
62 class CoordinationDFX {
63 public:
64     static int32_t WritePrepare(int32_t monitorId, OHOS::HiviewDFX::HiSysEvent::EventType type);
65     static int32_t WriteUnprepare(OHOS::HiviewDFX::HiSysEvent::EventType type);
66     static int32_t WriteActivate(const std::string &localNetworkId, const std::string &remoteNetworkId,
67         std::map<std::string, int32_t> sessionDevMap_, OHOS::HiviewDFX::HiSysEvent::EventType type);
68     static int32_t WriteActivateResult(const std::string &remoteNetworkId, bool isSuccess);
69     static int32_t WriteDeactivate(const std::string &remoteNetworkId, std::map<std::string, int32_t> sessionDevMap_,
70         OHOS::HiviewDFX::HiSysEvent::EventType type);
71     static int32_t WriteDeactivateResult(const std::string &remoteNetworkId,
72         std::map<std::string, int32_t> sessionDevMap_);
73     static int32_t WriteOpenSoftbusResult(const std::string &remoteNetworkId, int32_t para, int32_t type);
74     static int32_t WriteCooperateDrag(const std::string &remoteNetworkId, CoordinationState currentSta);
75     static int32_t WriteCooperateDrag(const std::string &remoteNetworkId, CoordinationState previousSta,
76         CoordinationState updateSta);
77     static int32_t WriteCooperateDragResult(const std::string &remoteNetworkId, const CoordinationState &currentSta,
78         OHOS::HiviewDFX::HiSysEvent::EventType type);
79     template<typename... Types>
80     static int32_t WriteInputFunc(const CoorType &coorType, Types... paras);
81 
82 private:
83     static std::map<CoordinationState, std::string> coordinationState_;
84     static std::map<CoorType, std::pair<std::string, std::string>> serialStr_;
85 };
86 } // namespace DeviceStatus
87 } // namespace Msdp
88 } // namespace OHOS
89 #endif // DEVICESTATUS_HISYSEVENT_H
90