• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2025 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_IMPL_UTILS_H
17 #define OHOS_DISTRIBUTED_HARDWARE_IMPL_UTILS_H
18 
19 #include <unordered_map>
20 
21 #include "device_type.h"
22 #include "constants.h"
23 
24 namespace OHOS {
25 namespace DistributedHardware {
26 enum class TaskType : int32_t {
27     UNKNOWN = 0,
28     ENABLE = 1,
29     DISABLE = 2,
30     ON_LINE = 3,
31     OFF_LINE = 4,
32     META_ENABLE = 5,
33     META_DISABLE = 6
34 };
35 
36 enum class TaskStep : int32_t {
37     DO_ENABLE = 1,
38     DO_DISABLE = 2,
39     SYNC_ONLINE_INFO = 3,
40     REGISTER_ONLINE_DISTRIBUTED_HARDWARE = 4,
41     UNREGISTER_OFFLINE_DISTRIBUTED_HARDWARE = 5,
42     CLEAR_OFFLINE_INFO = 6,
43     WAIT_UNREGISTGER_COMPLETE = 7,
44     META_ENABLE_TASK = 8,
45     META_DISABLE_TASK = 9,
46     DO_MODEM_META_ENABLE = 10,
47     DO_MODEM_META_DISABLE = 11
48 };
49 
50 enum class TaskState : int32_t {
51     INIT = 0,
52     RUNNING = 1,
53     SUCCESS = 2,
54     FAIL = 3
55 };
56 
57 struct CompVersion {
58     std::string name;
59     DHType dhType;
60     std::string handlerVersion;
61     std::string sourceVersion;
62     std::string sinkVersion;
63     bool haveFeature;
64     std::vector<std::string> sourceFeatureFilters;
65     std::vector<std::string> sinkSupportedFeatures;
66 };
67 
68 struct DHVersion {
69     std::string uuid;
70     std::string dhVersion;
71     std::unordered_map<DHType, CompVersion> compVersions;
72 };
73 
74 struct TaskParam {
75     // remote device networkid
76     std::string networkId;
77     // remote device uuid
78     std::string uuid;
79     // remote device udid
80     std::string udid;
81     // remote device dhid
82     std::string dhId;
83     // remote device dh type
84     DHType dhType{ DHType::UNKNOWN };
85     // effect sink
86     bool effectSink{ false };
87     // effect source
88     bool effectSource{ false };
89     // enable or disable calling uid
90     int32_t callingUid{ 0 };
91     // enable or disable calling pid
92     int32_t callingPid{ 0 };
93 };
94 
95 struct TaskDump {
96     std::string id;
97     TaskType taskType;
98     TaskParam taskParm;
99     TaskState taskState;
100     std::vector<TaskStep> taskSteps;
101 };
102 } // namespace DistributedHardware
103 } // namespace OHOS
104 #endif
105