1e0e9324cSopenharmony_ci/*
2e0e9324cSopenharmony_ci * Copyright (c) 2023 Shenzhen Kaihong Digital Industry Development Co., Ltd.
3e0e9324cSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4e0e9324cSopenharmony_ci * you may not use this file except in compliance with the License.
5e0e9324cSopenharmony_ci * You may obtain a copy of the License at
6e0e9324cSopenharmony_ci *
7e0e9324cSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8e0e9324cSopenharmony_ci *
9e0e9324cSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10e0e9324cSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11e0e9324cSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12e0e9324cSopenharmony_ci * See the License for the specific language governing permissions and
13e0e9324cSopenharmony_ci * limitations under the License.
14e0e9324cSopenharmony_ci */
15e0e9324cSopenharmony_ci
16e0e9324cSopenharmony_ci#ifndef OHOS_SHARING_HISYSEVENT_H
17e0e9324cSopenharmony_ci#define OHOS_SHARING_HISYSEVENT_H
18e0e9324cSopenharmony_ci
19e0e9324cSopenharmony_ci#include <string>
20e0e9324cSopenharmony_ci#include "common/event_comm.h"
21e0e9324cSopenharmony_ci
22e0e9324cSopenharmony_cinamespace OHOS {
23e0e9324cSopenharmony_cinamespace Sharing {
24e0e9324cSopenharmony_ciconstexpr char WFD_SOURCE[] = "wfdSourceSession";
25e0e9324cSopenharmony_ciconstexpr char P2P_PKG[] = "WIFI_P2P";
26e0e9324cSopenharmony_cienum class BIZSceneType : int32_t {
27e0e9324cSopenharmony_ci    WFD_SOURCE_PLAY,
28e0e9324cSopenharmony_ci    P2P_START_DISCOVERY,
29e0e9324cSopenharmony_ci    P2P_CONNECT_DEVICE,
30e0e9324cSopenharmony_ci    P2P_DISCONNECT_DEVICE,
31e0e9324cSopenharmony_ci};
32e0e9324cSopenharmony_ci
33e0e9324cSopenharmony_cienum class StageResType : int32_t {
34e0e9324cSopenharmony_ci    STAGE_RES_IDLE = 0,
35e0e9324cSopenharmony_ci    STAGE_RES_SUCCESS,
36e0e9324cSopenharmony_ci    STAGE_RES_FAILED,
37e0e9324cSopenharmony_ci    STAGE_RES_CANCEL,
38e0e9324cSopenharmony_ci    STAGE_RES_UNKNOWN
39e0e9324cSopenharmony_ci};
40e0e9324cSopenharmony_ci
41e0e9324cSopenharmony_cienum class BIZStateType : int32_t {
42e0e9324cSopenharmony_ci    BIZ_STATE_BEGIN = 1,
43e0e9324cSopenharmony_ci    BIZ_STATE_END,
44e0e9324cSopenharmony_ci    BIZ_STATE_IDLE,
45e0e9324cSopenharmony_ci};
46e0e9324cSopenharmony_ci
47e0e9324cSopenharmony_cienum class BIZSceneStage : int32_t {
48e0e9324cSopenharmony_ci    // scene5
49e0e9324cSopenharmony_ci    WFD_SOURCE_PLAY_TCP_SERVER = 1,
50e0e9324cSopenharmony_ci    WFD_SOURCE_PLAY_SEND_M1_REQ, // OPTIONS
51e0e9324cSopenharmony_ci    WFD_SOURCE_PLAY_RECV_M1_RSP,
52e0e9324cSopenharmony_ci    WFD_SOURCE_PLAY_RECV_M2_REQ, // OPTIONS
53e0e9324cSopenharmony_ci    WFD_SOURCE_PLAY_SEND_M2_RSP,
54e0e9324cSopenharmony_ci    WFD_SOURCE_PLAY_SEND_M3_REQ, // GET_PARAMETER
55e0e9324cSopenharmony_ci    WFD_SOURCE_PLAY_RECV_M3_RSP,
56e0e9324cSopenharmony_ci    WFD_SOURCE_PLAY_SEND_M4_REQ, // SET_PARAMETER
57e0e9324cSopenharmony_ci    WFD_SOURCE_PLAY_RECV_M4_RSP,
58e0e9324cSopenharmony_ci    WFD_SOURCE_PLAY_SEND_M5_REQ, // SET_PARAMETER wfd_trigger_method: SETUP
59e0e9324cSopenharmony_ci    WFD_SOURCE_PLAY_RECV_M5_RSP,
60e0e9324cSopenharmony_ci    WFD_SOURCE_PLAY_RECV_M6_REQ, // SETUP
61e0e9324cSopenharmony_ci    WFD_SOURCE_PLAY_SEND_M6_RSP,
62e0e9324cSopenharmony_ci    WFD_SOURCE_PLAY_RECV_M7_REQ, // PLAY
63e0e9324cSopenharmony_ci    WFD_SOURCE_PLAY_SEND_M7_RSP,
64e0e9324cSopenharmony_ci    WFD_SOURCE_PLAY_RECV_M8_REQ, // TEARDOWN
65e0e9324cSopenharmony_ci    WFD_SOURCE_PLAY_SEND_M8_RSP,
66e0e9324cSopenharmony_ci    // scene2  P2P_START_DISCOVERY
67e0e9324cSopenharmony_ci    P2P_START_DISCOVERY = 1,
68e0e9324cSopenharmony_ci    P2P_DEVICE_FOUND,
69e0e9324cSopenharmony_ci    // scene P2P_CONNECT_DEVICE
70e0e9324cSopenharmony_ci    P2P_CONNECT_DEVICE = 1,
71e0e9324cSopenharmony_ci
72e0e9324cSopenharmony_ci    // scene P2P_DISCONNECT_DEVICE
73e0e9324cSopenharmony_ci    P2P_DISCONNECT_DEVICE = 1,
74e0e9324cSopenharmony_ci
75e0e9324cSopenharmony_ci    WFD_SOURCE_SCENE_REMOVE_DEVICE,
76e0e9324cSopenharmony_ci    WFD_SOUCE_SCENE_STOP_DISCOVERY,
77e0e9324cSopenharmony_ci};
78e0e9324cSopenharmony_ci
79e0e9324cSopenharmony_cienum class BlzErrorCode : int32_t {
80e0e9324cSopenharmony_ci    ERROR_NONE = 0,
81e0e9324cSopenharmony_ci    ERROR_FAIL,
82e0e9324cSopenharmony_ci};
83e0e9324cSopenharmony_ci
84e0e9324cSopenharmony_ciclass SharingHiSysEvent {
85e0e9324cSopenharmony_cipublic:
86e0e9324cSopenharmony_ci    using Ptr = std::shared_ptr<SharingHiSysEvent>;
87e0e9324cSopenharmony_ci    explicit SharingHiSysEvent(BIZSceneType scene, std::string callPkg);
88e0e9324cSopenharmony_ci    ~SharingHiSysEvent();
89e0e9324cSopenharmony_ci    void ReportStart(std::string funcName, BIZSceneStage stage);
90e0e9324cSopenharmony_ci    void ReportEnd(std::string funcName, BIZSceneStage stage, BlzErrorCode error = BlzErrorCode::ERROR_NONE);
91e0e9324cSopenharmony_ci    void Report(std::string funcName, BIZSceneStage stage, StageResType resType = StageResType::STAGE_RES_SUCCESS,
92e0e9324cSopenharmony_ci                std::string peerMac = "");
93e0e9324cSopenharmony_ci    void SetCallPkg(const std::string callPkg);
94e0e9324cSopenharmony_ci    void SetLocalMac(const std::string mac);
95e0e9324cSopenharmony_ci    void SetPeerMac(const std::string mac);
96e0e9324cSopenharmony_ci    void ChangeScene(BIZSceneType scene);
97e0e9324cSopenharmony_ci    int32_t GetScene() const;
98e0e9324cSopenharmony_ci
99e0e9324cSopenharmony_ciprivate:
100e0e9324cSopenharmony_ci    int32_t bizScene_ = 0;
101e0e9324cSopenharmony_ci    std::string toCallPkg_ = "";
102e0e9324cSopenharmony_ci    std::string localMac_ = "";
103e0e9324cSopenharmony_ci    std::string peerMac_ = "";
104e0e9324cSopenharmony_ci    BIZSceneStage lastStage_;
105e0e9324cSopenharmony_ci    bool sceneDisposed = false;
106e0e9324cSopenharmony_ci};
107e0e9324cSopenharmony_ci
108e0e9324cSopenharmony_ci} // namespace Sharing
109e0e9324cSopenharmony_ci} // namespace OHOS
110e0e9324cSopenharmony_ci#endif