• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 Shenzhen Kaihong Digital Industry Development 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 OHOS_SHARING_HISYSEVENT_H
17 #define OHOS_SHARING_HISYSEVENT_H
18 
19 #include <string>
20 #include "common/event_comm.h"
21 
22 namespace OHOS {
23 namespace Sharing {
24 constexpr char WFD_SOURCE[] = "wfdSourceSession";
25 constexpr char P2P_PKG[] = "WIFI_P2P";
26 enum class BIZSceneType : int32_t {
27     WFD_SOURCE_PLAY,
28     P2P_START_DISCOVERY,
29     P2P_CONNECT_DEVICE,
30     P2P_DISCONNECT_DEVICE,
31 };
32 
33 enum class StageResType : int32_t {
34     STAGE_RES_IDLE = 0,
35     STAGE_RES_SUCCESS,
36     STAGE_RES_FAILED,
37     STAGE_RES_CANCEL,
38     STAGE_RES_UNKNOWN
39 };
40 
41 enum class BIZStateType : int32_t {
42     BIZ_STATE_BEGIN = 1,
43     BIZ_STATE_END,
44     BIZ_STATE_IDLE,
45 };
46 
47 enum class BIZSceneStage : int32_t {
48     // scene5
49     WFD_SOURCE_PLAY_TCP_SERVER = 1,
50     WFD_SOURCE_PLAY_SEND_M1_REQ, // OPTIONS
51     WFD_SOURCE_PLAY_RECV_M1_RSP,
52     WFD_SOURCE_PLAY_RECV_M2_REQ, // OPTIONS
53     WFD_SOURCE_PLAY_SEND_M2_RSP,
54     WFD_SOURCE_PLAY_SEND_M3_REQ, // GET_PARAMETER
55     WFD_SOURCE_PLAY_RECV_M3_RSP,
56     WFD_SOURCE_PLAY_SEND_M4_REQ, // SET_PARAMETER
57     WFD_SOURCE_PLAY_RECV_M4_RSP,
58     WFD_SOURCE_PLAY_SEND_M5_REQ, // SET_PARAMETER wfd_trigger_method: SETUP
59     WFD_SOURCE_PLAY_RECV_M5_RSP,
60     WFD_SOURCE_PLAY_RECV_M6_REQ, // SETUP
61     WFD_SOURCE_PLAY_SEND_M6_RSP,
62     WFD_SOURCE_PLAY_RECV_M7_REQ, // PLAY
63     WFD_SOURCE_PLAY_SEND_M7_RSP,
64     WFD_SOURCE_PLAY_RECV_M8_REQ, // TEARDOWN
65     WFD_SOURCE_PLAY_SEND_M8_RSP,
66     // scene2  P2P_START_DISCOVERY
67     P2P_START_DISCOVERY = 1,
68     P2P_DEVICE_FOUND,
69     // scene P2P_CONNECT_DEVICE
70     P2P_CONNECT_DEVICE = 1,
71 
72     // scene P2P_DISCONNECT_DEVICE
73     P2P_DISCONNECT_DEVICE = 1,
74 
75     WFD_SOURCE_SCENE_REMOVE_DEVICE,
76     WFD_SOUCE_SCENE_STOP_DISCOVERY,
77 };
78 
79 enum class BlzErrorCode : int32_t {
80     ERROR_NONE = 0,
81     ERROR_FAIL,
82 };
83 
84 class SharingHiSysEvent {
85 public:
86     using Ptr = std::shared_ptr<SharingHiSysEvent>;
87     explicit SharingHiSysEvent(BIZSceneType scene, std::string callPkg);
88     ~SharingHiSysEvent();
89     void ReportStart(std::string funcName, BIZSceneStage stage);
90     void ReportEnd(std::string funcName, BIZSceneStage stage, BlzErrorCode error = BlzErrorCode::ERROR_NONE);
91     void Report(std::string funcName, BIZSceneStage stage, StageResType resType = StageResType::STAGE_RES_SUCCESS,
92                 std::string peerMac = "");
93     void SetCallPkg(const std::string callPkg);
94     void SetLocalMac(const std::string mac);
95     void SetPeerMac(const std::string mac);
96     void ChangeScene(BIZSceneType scene);
97     int32_t GetScene() const;
98 
99 private:
100     int32_t bizScene_ = 0;
101     std::string toCallPkg_ = "";
102     std::string localMac_ = "";
103     std::string peerMac_ = "";
104     BIZSceneStage lastStage_;
105     bool sceneDisposed = false;
106 };
107 
108 } // namespace Sharing
109 } // namespace OHOS
110 #endif