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 BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_DEVICE_DATA_H 17 #define BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_DEVICE_DATA_H 18 19 #include <string> 20 #include "socket.h" 21 #include "ans_log_wrapper.h" 22 #include "dm_device_info.h" 23 #include <unordered_set> 24 25 namespace OHOS { 26 namespace Notification { 27 28 constexpr char const ANS_SOCKET_CMD[] = "notification_service.cmd"; 29 constexpr char const ANS_SOCKET_MSG[] = "notification_service.content"; 30 constexpr char const ANS_SOCKET_PKG[] = "ohos.distributed_notification"; 31 const int32_t CURRENT_VERSION = 1000; 32 const int32_t DEFAULT_ICON_WITHE = 60; 33 const int32_t DEFAULT_ICON_HEIGHT = 60; 34 35 enum DeviceState { 36 STATE_INIT = 0, 37 STATE_SYNC, 38 STATE_ONLINE, 39 STATE_OFFLINE, 40 STATE_IDEL, 41 }; 42 43 struct DistributedDeviceInfo { DistributedDeviceInfoDistributedDeviceInfo44 DistributedDeviceInfo() {} DistributedDeviceInfoDistributedDeviceInfo45 DistributedDeviceInfo(uint16_t deviceType, std::string deviceId) 46 : deviceType_(deviceType), deviceId_(deviceId) {} DistributedDeviceInfoDistributedDeviceInfo47 DistributedDeviceInfo(uint16_t deviceType, std::string deviceId, std::string networkId) 48 : deviceType_(deviceType), deviceId_(deviceId), networkId_(networkId) {} IsPadOrPcDistributedDeviceInfo49 bool IsPadOrPc() const 50 { 51 if (deviceType_ != DistributedHardware::DmDeviceType::DEVICE_TYPE_PAD && 52 deviceType_ != DistributedHardware::DmDeviceType::DEVICE_TYPE_2IN1 && 53 deviceType_ != DistributedHardware::DmDeviceType::DEVICE_TYPE_PC) { 54 return false; 55 } 56 return true; 57 } 58 bool deviceUsage = false; 59 bool liveViewSync = false; 60 bool iconSync = false; 61 bool installedBundlesSync = false; 62 uint16_t deviceType_; 63 int32_t peerState_ = DeviceState::STATE_INIT; 64 int32_t socketId_ = -1; 65 int32_t connectedTry_ = 0; 66 std::string udid_; 67 std::string deviceId_; 68 std::string networkId_; 69 }; 70 71 struct ConnectedSocketInfo { 72 int32_t socketId_; 73 std::string networkId_; 74 std::string peerName_; 75 std::string pkgName_; 76 TransDataType dataType_; 77 }; 78 } 79 } 80 #endif // BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_DEVICE_DATA_H 81