1 /*
2  * Copyright (c) 2021-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_HARDWARE_DEVICE_TYPE_H
17 #define OHOS_DISTRIBUTED_HARDWARE_DEVICE_TYPE_H
18 
19 #include <string>
20 #include <unordered_map>
21 
22 namespace OHOS {
23 namespace DistributedHardware {
24 enum class DHType : uint32_t {
25     UNKNOWN = 0x0,            // unknown device
26     CAMERA = 0x01,            // Camera
27     AUDIO = 0x02,             // Mic
28     SCREEN = 0x08,            // Display
29     GPS = 0x10,               // GPS
30     INPUT = 0x20,             // Key board
31     HFP = 0x40,               // HFP External device
32     A2D = 0x80,               // A2DP External device
33     VIRMODEM_AUDIO = 0x100,     // Cellular call AUDIO
34     MODEM = 0X200, // Distributed Modem
35     MAX_DH = 0x80000000
36 };
37 
38 enum class DHSubtype : uint32_t {
39     CAMERA = 0x01,            // Camera
40     SCREEN = 0x08,            // Display
41     INPUT = 0x20,             // Key board
42     AUDIO_MIC = 0x400,        // AUDIO Mic
43     AUDIO_SPEAKER = 0x800     // AUDIO Speaker
44 };
45 
46 const std::unordered_map<DHType, std::string> DHTypeStrMap = {
47     { DHType::CAMERA, "CAMERA" },
48     { DHType::AUDIO, "AUDIO" },
49     { DHType::SCREEN, "SCREEN" },
50     { DHType::GPS, "GPS" },
51     { DHType::INPUT, "INPUT" },
52     { DHType::HFP, "HFP" },
53     { DHType::A2D, "A2D" },
54     { DHType::VIRMODEM_AUDIO, "VIRMODEM_AUDIO" },
55     { DHType::MODEM, "MODEM" },
56 };
57 
58 struct DeviceInfo {
59     // device networkid
60     std::string networkId;
61     // device uuid
62     std::string uuid;
63     // device id for uuid hash
64     std::string deviceId;
65     // device udid
66     std::string udid;
67     // udid hash as the absolute id even if the device resetting
68     std::string udidHash;
69     // device name
70     std::string deviceName;
71     // device type
72     uint16_t deviceType;
73 
DeviceInfoDeviceInfo74     explicit DeviceInfo(std::string networkId, std::string uuid, std::string deviceId,
75         std::string udid, std::string udidHash, std::string deviceName,
76         uint16_t deviceType) : networkId(networkId), uuid(uuid), deviceId(deviceId),
77         udid(udid), udidHash(udidHash), deviceName(deviceName), deviceType(deviceType) {}
78 };
79 
80 /* The key is DHType, the value is the prefix of DHId */
81 const std::unordered_map<DHType, std::string> DHTypePrefixMap = {
82     {DHType::CAMERA, "Camera"},
83     {DHType::SCREEN, "Screen"},
84     {DHType::INPUT, "Input"},
85 };
86 } // namespace DistributedHardware
87 } // namespace OHOS
88 #endif
89