1 /* 2 * Copyright (c) 2024 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 COOPERATE_HISYSEVENT_H 17 #define COOPERATE_HISYSEVENT_H 18 19 #include <map> 20 #include <string> 21 22 #include "devicestatus_define.h" 23 #include "hisysevent.h" 24 25 namespace OHOS { 26 namespace Msdp { 27 namespace DeviceStatus { 28 enum CooperateType : int32_t { 29 ENABLE_SUCC = 0, 30 ENABLE_FAIL = 1, 31 DISABLE_SUCC = 2, 32 DISABLE_FAIL = 3, 33 LOCAL_ACTIVATE_SUCC = 4, 34 LOCAL_ACTIVATE_FAIL = 5, 35 REMOTE_ACTIVATE_SUCC = 6, 36 REMOTE_ACTIVATE_FAIL = 7, 37 LOCAL_DEACTIVATE_SUCC = 8, 38 LOCAL_DEACTIVATE_FAIL = 9, 39 REMOTE_DEACTIVATE_SUCC = 10, 40 REMOTE_DEACTIVATE_FAIL = 11, 41 OPENSESSION_SUCC = 12, 42 OPENSESSION_FAIL = 13, 43 UPDATESTATE_SUCC = 14, 44 START_SUCC = 15, 45 START_FAIL = 16, 46 STOP_SUCC = 17, 47 STOP_FAIL = 18, 48 }; 49 enum CooperateState : size_t { 50 COOPERATE_STATE_FREE = 0, 51 COOPERATE_STATE_OUT, 52 COOPERATE_STATE_IN, 53 N_COOPERATE_STATES, 54 }; 55 56 class CooperateDFX { 57 public: 58 59 static int32_t WriteEnable(OHOS::HiviewDFX::HiSysEvent::EventType type); 60 static int32_t WriteDisable(OHOS::HiviewDFX::HiSysEvent::EventType type); 61 static int32_t WriteLocalStart(OHOS::HiviewDFX::HiSysEvent::EventType type); 62 static int32_t WriteLocalStop(OHOS::HiviewDFX::HiSysEvent::EventType type); 63 static int32_t WriteRemoteStart(OHOS::HiviewDFX::HiSysEvent::EventType type); 64 static int32_t WriteRemoteStop(OHOS::HiviewDFX::HiSysEvent::EventType type); 65 static int32_t WriteOpenSession(OHOS::HiviewDFX::HiSysEvent::EventType type); 66 static int32_t WriteStart(OHOS::HiviewDFX::HiSysEvent::EventType type); 67 static int32_t WriteStop(OHOS::HiviewDFX::HiSysEvent::EventType type); 68 static int32_t WriteCooperateState(CooperateState curState); 69 template<typename... Types> 70 static int32_t WriteInputFunc(const CooperateType &cooperateType, 71 OHOS::HiviewDFX::HiSysEvent::EventType eventType, Types... paras); 72 73 private: 74 static std::map<CooperateState, std::string> CooperateState_; 75 static std::map<CooperateType, std::pair<std::string, std::string>> serialStr_; 76 }; 77 } // namespace DeviceStatus 78 } // namespace Msdp 79 } // namespace OHOS 80 #endif // COOPERATE_HISYSEVENT_H 81