• 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     EXIT_DFWK = 7
35 };
36 
37 enum class TaskStep : int32_t {
38     DO_ENABLE = 1,
39     DO_DISABLE = 2,
40     SYNC_ONLINE_INFO = 3,
41     REGISTER_ONLINE_DISTRIBUTED_HARDWARE = 4,
42     UNREGISTER_OFFLINE_DISTRIBUTED_HARDWARE = 5,
43     CLEAR_OFFLINE_INFO = 6,
44     WAIT_UNREGISTGER_COMPLETE = 7,
45     META_ENABLE_TASK = 8,
46     META_DISABLE_TASK = 9,
47     DO_MODEM_META_ENABLE = 10,
48     DO_MODEM_META_DISABLE = 11,
49     ENABLE_SINK = 12,
50     DISABLE_SINK = 13
51 };
52 
53 enum class TaskState : int32_t {
54     INIT = 0,
55     RUNNING = 1,
56     SUCCESS = 2,
57     FAIL = 3
58 };
59 
60 struct CompVersion {
61     std::string name;
62     DHType dhType;
63     std::string handlerVersion;
64     std::string sourceVersion;
65     std::string sinkVersion;
66     bool haveFeature;
67     std::vector<std::string> sourceFeatureFilters;
68     std::vector<std::string> sinkSupportedFeatures;
69 };
70 
71 struct DHVersion {
72     std::string uuid;
73     std::string dhVersion;
74     std::unordered_map<DHType, CompVersion> compVersions;
75 };
76 
77 struct TaskParam {
78     // remote device networkid
79     std::string networkId;
80     // remote device uuid
81     std::string uuid;
82     // remote device udid
83     std::string udid;
84     // remote device dhid
85     std::string dhId;
86     // remote device dh type
87     DHType dhType{ DHType::UNKNOWN };
88     // effect sink
89     bool effectSink{ false };
90     // effect source
91     bool effectSource{ false };
92     // enable or disable calling uid
93     int32_t callingUid{ 0 };
94     // enable or disable calling pid
95     int32_t callingPid{ 0 };
96 };
97 
98 struct TaskDump {
99     std::string id;
100     TaskType taskType;
101     TaskParam taskParm;
102     TaskState taskState;
103     std::vector<TaskStep> taskSteps;
104 };
105 } // namespace DistributedHardware
106 } // namespace OHOS
107 #endif
108