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 OHOS_DISTRIBUTED_RADAR_H 17 #define OHOS_DISTRIBUTED_RADAR_H 18 19 #include <cstdint> 20 #include <chrono> 21 #include <string> 22 #include <vector> 23 24 #include "dtbschedmgr_log.h" 25 #include "single_instance.h" 26 27 namespace OHOS { 28 namespace DistributedSchedule { 29 const std::string ORG_PKG_NAME = "ohos.distributedschedule"; 30 const std::string APPLICATION_CONTINUE_BEHAVIOR = "APPLICATION_CONTINUE_BEHAVIOR"; 31 const std::string ABILITY_MANAGER_SERVICE = "ohos.abilitymanagerservice"; 32 const std::string INIT = "init"; 33 const std::string NORMAL = "normal"; 34 const std::string MULTIMODE = "multimode"; 35 const std::string DEVICEONLINE = "deviceonline"; 36 const std::string FOCUSED = "focused"; 37 const std::string UNFOCUSED = "unfocused"; 38 const std::string BMS_PKG_NAME = "foundation_bms"; 39 const std::string DBMS_PKG_NAME = "d_bms"; 40 const std::string DSOFTBUS_PKG_NAME = "dsoftbus"; 41 const std::string ORG_PKG = "ORG_PKG"; 42 const std::string FUNC = "FUNC"; 43 const std::string BIZ_SCENE = "BIZ_SCENE"; 44 const std::string BIZ_STAGE = "BIZ_STAGE"; 45 const std::string STAGE_RES = "STAGE_RES"; 46 const std::string BIZ_STATE = "BIZ_STATE"; 47 const std::string TO_CALL_PKG = "TO_CALL_PKG"; 48 const std::string HOST_PKG = "HOST_PKG"; 49 const std::string ERROR_CODE = "ERROR_CODE"; 50 const std::string PEER_UDID = "PEER_UDID"; 51 const std::string APP_CALLEE = "APP_CALLEE"; 52 const std::string APP_CALLER = "APP_CALLER"; 53 const std::string LOCAL_APP_VERSION = "LOCAL_APP_VERSION"; 54 const std::string PEER_APP_VERSION = "PEER_APP_VERSION"; 55 constexpr char APP_CONTINUE_DOMAIN[] = "APP_CONTINUE"; 56 constexpr int32_t ANONYM_MIN_LENGTH = 10; 57 constexpr int32_t SUBSTR_UDID_LENGTH = 5; 58 enum class BizScene : int32_t { 59 DMS_INIT = 1, 60 /*2 not our scene*/ 61 NORMAL_MULTIMODE_FOCUSED = 3, 62 CHANGE_STATE_FOCUSED = 4, 63 NORMAL_UNFOCUSED = 5, 64 MULTIMODE_UNFOCUSED = 6, 65 CHANGE_STATE_UNFOCUSED = 7, 66 RECV_FOCUSED = 8, 67 RECV_UNFOCUSED = 9, 68 CLICK_ICON = 10, 69 SAVE_DATA = 11, 70 }; 71 72 enum class StageRes : int32_t { 73 STAGE_IDLE = 0, 74 STAGE_SUCC = 1, 75 STAGE_FAIL = 2, 76 STAGE_CANCEL = 3, 77 STAGE_UNKNOW = 4, 78 }; 79 80 enum class BizState : int32_t { 81 BIZ_STATE_START = 1, 82 BIZ_STATE_END = 2, 83 }; 84 85 enum class DmsInit : int32_t { 86 REGISTER_ABILITY_FOCUSED = 1, 87 REGISTER_SOFTBUS_CALLBACK = 2, 88 }; 89 90 enum class NormalOrMultimodeFocused : int32_t { 91 DMS_FOCUSED = 1, 92 GET_BMS_ACCESSTOKENID = 2, 93 SOFTBUS_SENDEVENT = 3, 94 }; 95 96 enum class ChangeStateFocused : int32_t { 97 SET_STATE = 1, 98 GET_BMS_ACCESSTOKENID = 2, 99 SOFTBUS_SENDEVENT = 3, 100 }; 101 102 enum class NormalUnfocused : int32_t { 103 DMS_UNFOCUSED = 1, 104 GET_BMS_ACCESSTOKENID = 2, 105 SOFTBUS_SENDEVENT = 3, 106 }; 107 108 enum class MultimodeUnfocused : int32_t { 109 RECORD_TIME = 1, 110 GET_BMS_ACCESSTOKENID = 2, 111 SOFTBUS_SENDEVENT = 3, 112 }; 113 114 enum class ChangeStateUnfocused : int32_t { 115 SET_STATE = 1, 116 GET_BMS_ACCESSTOKENID = 2, 117 SOFTBUS_SENDEVENT = 3, 118 }; 119 120 enum class RecvFocused : int32_t { 121 RECV_FOCUSED = 1, 122 GET_DBMS_BUNDLENAME = 2, 123 NOTIFY_DOCK_FOCUSED = 3, 124 }; 125 126 enum class RecvUnfocused : int32_t { 127 RECV_UNFOCUSED = 1, 128 GET_DBMS_BUNDLENAME = 2, 129 NOTIFY_DOCK_UNFOCUSED = 3, 130 }; 131 132 enum class ClickIcon : int32_t { 133 DMS_CONTINUE = 4, 134 DMS_STARTABILITY = 5, 135 DMS_RECV_OVER = 10, 136 }; 137 138 enum class SaveData : int32_t { 139 DMS_CONTINUE = 1, 140 DMS_REMOTE_WANT = 5, 141 }; 142 143 enum class Module : int32_t { 144 DMS_CONTINUE = 0, 145 }; 146 147 class DmsRadar { 148 DECLARE_SINGLE_INSTANCE(DmsRadar); 149 public: 150 bool RegisterSoftbusCallbackRes(const std::string& func, int32_t errCode); 151 bool RegisterFocusedRes(const std::string& func, int32_t errCode); 152 bool DmsFocused(const std::string& func, std::string focusMode); 153 bool NormalFocusedGetAccessTokenIdRes(const std::string& func, int32_t errCode); 154 bool NormalFocusedSendEventRes(const std::string& func, int32_t errCode); 155 bool SetFocusedState(const std::string& func); 156 bool ChangeStateFocusedGetAccessTokenIdRes(const std::string& func, int32_t errCode); 157 bool ChangeStateFocusedSendEventRes(const std::string& func, int32_t errCode); 158 bool DmsUnfocused(const std::string& func); 159 bool NormalUnfocusedGetAccessTokenIdRes(const std::string& func, int32_t errCode); 160 bool NormalUnfocusedSendEventRes(const std::string& func, int32_t errCode); 161 bool RecordTime(const std::string& func); 162 bool MultimodeUnfocusedGetAccessTokenIdRes(const std::string& func, int32_t errCode); 163 bool MultimodeUnfocusedSendEventRes(const std::string& func, int32_t errCode); 164 bool SetUnfocusedState(const std::string& func); 165 bool ChangeStateUnfocusedGetAccessTokenIdRes(const std::string& func, int32_t errCode); 166 bool ChangeStateUnfocusedSendEventRes(const std::string& func, int32_t errCode); 167 bool RecvFocused(const std::string& func); 168 bool FocusedGetBundleName(const std::string& func, int32_t errCode); 169 bool NotifyDockFocused(const std::string& func, int32_t errCode); 170 bool RecvUnfocused(const std::string& func); 171 bool UnfocusedGetBundleName(const std::string& func, int32_t errCode); 172 bool NotifyDockUnfocused(const std::string& func, int32_t errCode); 173 bool ClickIconDmsContinue(const std::string& func, int32_t errCode, std::string peerDeviceId, 174 const std::string& srcBundleName, const std::string& dstBundleName); 175 bool ClickIconDmsStartAbility(const std::string& func, int32_t errCode); 176 bool ClickIconDmsRecvOver(const std::string& func, int32_t errCode); 177 bool SaveDataDmsContinue(const std::string& func, int32_t errCode); 178 bool SaveDataDmsRemoteWant(const std::string& func, int32_t errCode); 179 std::string GetAnonyUdid(std::string udid); 180 }; 181 } // namespace DistributedSchedule 182 } // namespace OHOS 183 #endif // OHOS_DISTRIBUTED_RADAR_H