• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2023 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 DISTRIBUTED_INPUT_SOURCE_MANAGER_SERVICE_H
17 #define DISTRIBUTED_INPUT_SOURCE_MANAGER_SERVICE_H
18 
19 #include <cstring>
20 #include <mutex>
21 #include <set>
22 
23 #include <unistd.h>
24 #include <sys/types.h>
25 
26 #include "event_handler.h"
27 #include "ipublisher_listener.h"
28 #include "publisher_listener_stub.h"
29 #include "singleton.h"
30 #include "system_ability.h"
31 #include "system_ability_status_change_stub.h"
32 
33 #include "constants_dinput.h"
34 #include "dinput_context.h"
35 #include "dinput_source_trans_callback.h"
36 #include "distributed_input_node_manager.h"
37 #include "distributed_input_source_event_handler.h"
38 #include "distributed_input_source_sa_cli_mgr.h"
39 #include "distributed_input_source_stub.h"
40 #include "dinput_state.h"
41 
42 namespace OHOS {
43 namespace DistributedHardware {
44 namespace DistributedInput {
45 using EventRunner = OHOS::AppExecFwk::EventRunner;
46 using EventHandler = OHOS::AppExecFwk::EventHandler;
47 enum class ServiceSourceRunningState { STATE_NOT_START, STATE_RUNNING };
48 const uint32_t DINPUT_SOURCE_MANAGER_RIGISTER_MSG = 1;
49 const uint32_t DINPUT_SOURCE_MANAGER_UNRIGISTER_MSG = 2;
50 const uint32_t DINPUT_SOURCE_MANAGER_PREPARE_MSG = 3;
51 const uint32_t DINPUT_SOURCE_MANAGER_UNPREPARE_MSG = 4;
52 const uint32_t DINPUT_SOURCE_MANAGER_START_MSG = 5;
53 const uint32_t DINPUT_SOURCE_MANAGER_STOP_MSG = 6;
54 const uint32_t DINPUT_SOURCE_MANAGER_START_DHID_MSG = 7;
55 const uint32_t DINPUT_SOURCE_MANAGER_STOP_DHID_MSG = 8;
56 const uint32_t DINPUT_SOURCE_MANAGER_RECEIVE_DATA_MSG = 9;
57 const uint32_t DINPUT_SOURCE_MANAGER_STARTSERVER_MSG = 10;
58 const uint32_t DINPUT_SOURCE_MANAGER_KEY_STATE_MSG = 11;
59 
60 const uint32_t DINPUT_SOURCE_MANAGER_RELAY_PREPARE_RESULT_TO_ORIGIN   = 12;
61 const uint32_t DINPUT_SOURCE_MANAGER_RELAY_UNPREPARE_RESULT_TO_ORIGIN = 13;
62 const uint32_t DINPUT_SOURCE_MANAGER_RELAY_PREPARE_RESULT_MMI   = 14;
63 const uint32_t DINPUT_SOURCE_MANAGER_RELAY_UNPREPARE_RESULT_MMI = 15;
64 const uint32_t DINPUT_SOURCE_MANAGER_RELAY_STARTDHID_RESULT_MMI = 16;
65 const uint32_t DINPUT_SOURCE_MANAGER_RELAY_STOPDHID_RESULT_MMI  = 17;
66 const uint32_t DINPUT_SOURCE_MANAGER_RELAY_STARTTYPE_RESULT_MMI = 18;
67 const uint32_t DINPUT_SOURCE_MANAGER_RELAY_STOPTYPE_RESULT_MMI  = 19;
68 
69 const std::string INPUT_SOURCEMANAGER_KEY_SESSIONID = "sessionId";
70 const std::string INPUT_SOURCEMANAGER_KEY_DEVID = "deviceId";
71 const std::string INPUT_SOURCEMANAGER_KEY_HWID = "hardwareId";
72 const std::string INPUT_SOURCEMANAGER_KEY_ITP = "inputTypes";
73 const std::string INPUT_SOURCEMANAGER_KEY_DHID = "dhids";
74 const std::string INPUT_SOURCEMANAGER_KEY_TYPE = "type";
75 const std::string INPUT_SOURCEMANAGER_KEY_CODE = "code";
76 const std::string INPUT_SOURCEMANAGER_KEY_VALUE = "value";
77 const std::string INPUT_SOURCEMANAGER_KEY_RESULT = "result";
78 const std::string INPUT_SOURCEMANAGER_KEY_WHITELIST = "whitelist";
79 const std::string INPUT_SOURCEMANAGER_KEY_SRC_DEVID = "srcId";
80 const std::string INPUT_SOURCEMANAGER_KEY_SINK_DEVID = "sinkId";
81 
82 const uint32_t DINPUT_SOURCE_SWITCH_OFF = 0;
83 const uint32_t DINPUT_SOURCE_SWITCH_ON = 1;
84 const uint32_t DINPUT_SOURCE_WRITE_EVENT_SIZE = 1;
85 
86 // Node Info that registerd by remote node
87 typedef struct BeRegNodeInfo {
88     // source node network id
89     std::string srcId;
90     // sink node dh id
91     std::string dhId;
92     // node desc on sink node
93     std::string nodeDesc;
94 
95     bool operator==(const BeRegNodeInfo &node)
96     {
97         return (srcId == node.srcId) && (dhId == node.dhId) && (nodeDesc == node.nodeDesc);
98     }
99 
100     bool operator<(const BeRegNodeInfo &node) const
101     {
102         return (srcId + dhId + nodeDesc).compare(node.srcId + node.dhId + node.nodeDesc) < 0;
103     }
104 } BeRegNodeInfo;
105 
106 class DistributedInputSourceManager : public SystemAbility, public DistributedInputSourceStub {
107     DECLARE_SYSTEM_ABILITY(DistributedInputSourceManager)
108 
109 typedef struct InputDeviceId {
110     std::string devId;
111     std::string dhId;
112     std::string nodeDesc;
113 
114     bool operator==(const InputDeviceId &inputId)
115     {
116         return (devId == inputId.devId) && (dhId == inputId.dhId) && (nodeDesc == inputId.nodeDesc);
117     }
118 } InputDeviceId;
119 
120 public:
121     DistributedInputSourceManager(int32_t saId, bool runOnCreate);
122     ~DistributedInputSourceManager() override;
123 
124     void OnStart() override;
125 
126     void OnStop() override;
127 
128     int32_t Init() override;
129 
130     int32_t Release() override;
131 
132     int32_t RegisterDistributedHardware(const std::string &devId, const std::string &dhId,
133         const std::string &parameters, sptr<IRegisterDInputCallback> callback) override;
134 
135     int32_t UnregisterDistributedHardware(const std::string &devId, const std::string &dhId,
136         sptr<IUnregisterDInputCallback> callback) override;
137 
138     int32_t PrepareRemoteInput(const std::string &deviceId, sptr<IPrepareDInputCallback> callback) override;
139 
140     int32_t UnprepareRemoteInput(const std::string &deviceId, sptr<IUnprepareDInputCallback> callback) override;
141 
142     int32_t StartRemoteInput(
143         const std::string &deviceId, const uint32_t &inputTypes, sptr<IStartDInputCallback> callback) override;
144 
145     int32_t StopRemoteInput(
146         const std::string &deviceId, const uint32_t &inputTypes, sptr<IStopDInputCallback> callback) override;
147 
148     int32_t StartRemoteInput(const std::string &srcId, const std::string &sinkId, const uint32_t &inputTypes,
149         sptr<IStartDInputCallback> callback) override;
150 
151     int32_t StopRemoteInput(const std::string &srcId, const std::string &sinkId, const uint32_t &inputTypes,
152         sptr<IStopDInputCallback> callback) override;
153 
154     int32_t PrepareRemoteInput(const std::string &srcId, const std::string &sinkId,
155         sptr<IPrepareDInputCallback> callback) override;
156 
157     int32_t UnprepareRemoteInput(const std::string &srcId, const std::string &sinkId,
158         sptr<IUnprepareDInputCallback> callback) override;
159 
160     int32_t StartRemoteInput(const std::string &sinkId, const std::vector<std::string> &dhIds,
161         sptr<IStartStopDInputsCallback> callback) override;
162 
163     int32_t StopRemoteInput(const std::string &sinkId, const std::vector<std::string> &dhIds,
164         sptr<IStartStopDInputsCallback> callback) override;
165 
166     int32_t StartRemoteInput(const std::string &srcId, const std::string &sinkId,
167         const std::vector<std::string> &dhIds, sptr<IStartStopDInputsCallback> callback) override;
168 
169     int32_t StopRemoteInput(const std::string &srcId, const std::string &sinkId,
170         const std::vector<std::string> &dhIds, sptr<IStartStopDInputsCallback> callback) override;
171 
172     int32_t RegisterAddWhiteListCallback(sptr<IAddWhiteListInfosCallback> addWhiteListCallback) override;
173     int32_t RegisterDelWhiteListCallback(sptr<IDelWhiteListInfosCallback> delWhiteListCallback) override;
174     int32_t RegisterInputNodeListener(sptr<InputNodeListener> listener) override;
175     int32_t UnregisterInputNodeListener(sptr<InputNodeListener> listener) override;
176 
177     int32_t SyncNodeInfoRemoteInput(const std::string &userDevId, const std::string &dhId,
178         const std::string &nodeDesc) override;
179     int32_t RegisterSimulationEventListener(sptr<ISimulationEventListener> listener) override;
180     int32_t UnregisterSimulationEventListener(sptr<ISimulationEventListener> listener) override;
181     bool CheckRegisterParam(const std::string &devId, const std::string &dhId,
182         const std::string &parameters, sptr<IRegisterDInputCallback> callback);
183     bool CheckUnregisterParam(const std::string &devId, const std::string &dhId,
184         sptr<IUnregisterDInputCallback> callback);
185     int32_t Dump(int32_t fd, const std::vector<std::u16string> &args) override;
186 
187     class DInputSourceListener : public DInputSourceTransCallback {
188     public:
189         explicit DInputSourceListener(DistributedInputSourceManager *manager);
190         virtual ~DInputSourceListener();
191         void OnResponseRegisterDistributedHardware(const std::string deviceId, const std::string dhId,
192             bool result) override;
193         void OnResponsePrepareRemoteInput(const std::string deviceId, bool result, const std::string &object) override;
194         void OnResponseUnprepareRemoteInput(const std::string deviceId, bool result) override;
195         void OnResponseStartRemoteInput(const std::string deviceId, const uint32_t inputTypes, bool result) override;
196         void OnResponseStopRemoteInput(const std::string deviceId, const uint32_t inputTypes, bool result) override;
197         void OnResponseStartRemoteInputDhid(const std::string deviceId, const std::string &dhids, bool result) override;
198         void OnResponseStopRemoteInputDhid(const std::string deviceId, const std::string &dhids, bool result) override;
199         void OnResponseKeyState(const std::string deviceId, const std::string &dhid, const uint32_t type,
200             const uint32_t code, const uint32_t value) override;
201         void OnReceivedEventRemoteInput(const std::string deviceId, const std::string &event) override;
202         void OnResponseRelayPrepareRemoteInput(int32_t sessionId, const std::string &deviceId, bool result,
203             const std::string &object) override;
204         void OnResponseRelayUnprepareRemoteInput(int32_t sessionId, const std::string &deviceId, bool result) override;
205 
206         void OnReceiveRelayPrepareResult(int32_t status, const std::string &srcId, const std::string &sinkId) override;
207         void OnReceiveRelayUnprepareResult(int32_t status, const std::string &srcId,
208             const std::string &sinkId) override;
209         void OnReceiveRelayStartDhidResult(int32_t status, const std::string &srcId, const std::string &sinkId,
210             const std::string &dhids) override;
211         void OnReceiveRelayStopDhidResult(int32_t status, const std::string &srcId, const std::string &sinkId,
212             const std::string &dhids) override;
213         void OnReceiveRelayStartTypeResult(int32_t status, const std::string &srcId, const std::string &sinkId,
214             uint32_t inputTypes) override;
215         void OnReceiveRelayStopTypeResult(int32_t status, const std::string &srcId, const std::string &sinkId,
216             uint32_t inputTypes) override;
217         void RecordEventLog(int64_t when, int32_t type, int32_t code, int32_t value, const std::string &path);
218 
219     private:
220         DistributedInputSourceManager *sourceManagerObj_;
221     };
222 
223     class DInputSourceManagerEventHandler : public AppExecFwk::EventHandler {
224     public:
225         DInputSourceManagerEventHandler(const std::shared_ptr<AppExecFwk::EventRunner> &runner,
226             DistributedInputSourceManager *manager);
227         ~DInputSourceManagerEventHandler() override;
228 
229         void ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event) override;
230     private:
231         void NotifyRegisterCallback(const AppExecFwk::InnerEvent::Pointer &event);
232         void NotifyUnregisterCallback(const AppExecFwk::InnerEvent::Pointer &event);
233         void NotifyPrepareCallback(const AppExecFwk::InnerEvent::Pointer &event);
234         void NotifyUnprepareCallback(const AppExecFwk::InnerEvent::Pointer &event);
235         void NotifyStartCallback(const AppExecFwk::InnerEvent::Pointer &event);
236         void NotifyStopCallback(const AppExecFwk::InnerEvent::Pointer &event);
237         void NotifyStartDhidCallback(const AppExecFwk::InnerEvent::Pointer &event);
238         void NotifyStopDhidCallback(const AppExecFwk::InnerEvent::Pointer &event);
239         void NotifyKeyStateCallback(const AppExecFwk::InnerEvent::Pointer &event);
240         void NotifyStartServerCallback(const AppExecFwk::InnerEvent::Pointer &event);
241         void NotifyRelayPrepareCallback(const AppExecFwk::InnerEvent::Pointer &event);
242         void NotifyRelayUnprepareCallback(const AppExecFwk::InnerEvent::Pointer &event);
243         void NotifyRelayStartDhidCallback(const AppExecFwk::InnerEvent::Pointer &event);
244         void NotifyRelayStopDhidCallback(const AppExecFwk::InnerEvent::Pointer &event);
245         void NotifyRelayStartTypeCallback(const AppExecFwk::InnerEvent::Pointer &event);
246         void NotifyRelayStopTypeCallback(const AppExecFwk::InnerEvent::Pointer &event);
247         void NotifyRelayPrepareRemoteInput(const AppExecFwk::InnerEvent::Pointer &event);
248         void NotifyRelayUnprepareRemoteInput(const AppExecFwk::InnerEvent::Pointer &event);
249 
250         using SourceEventFunc = void (DInputSourceManagerEventHandler::*)(
251             const AppExecFwk::InnerEvent::Pointer &event);
252         std::map<int32_t, SourceEventFunc> eventFuncMap_;
253         DistributedInputSourceManager *sourceManagerObj_;
254     };
255 
256     class StartDScreenListener : public PublisherListenerStub {
257     public:
258         StartDScreenListener();
259         ~StartDScreenListener() override;
260         void OnMessage(const DHTopic topic, const std::string &message) override;
261 
262     private:
263         int32_t ParseMessage(const std::string &message, std::string &sinkDevId, SrcScreenInfo &srcScreenInfo);
264         int32_t UpdateSrcScreenInfoCache(const SrcScreenInfo &tmpInfo);
265     };
266 
267     class StopDScreenListener : public PublisherListenerStub {
268     public:
269         StopDScreenListener();
270         ~StopDScreenListener() override;
271         void OnMessage(const DHTopic topic, const std::string &message) override;
272 
273     private:
274         int32_t ParseMessage(const std::string &message, std::string &sinkDevId, uint64_t &sourceWinId);
275     };
276 
277     class DeviceOfflineListener : public PublisherListenerStub {
278     public:
279         explicit DeviceOfflineListener(DistributedInputSourceManager *srcManagerContext);
280         ~DeviceOfflineListener() override;
281 
282         void OnMessage(const DHTopic topic, const std::string &message) override;
283 
284     private:
285         void DeleteNodeInfoAndNotify(const std::string &offlineDevId);
286 
287     private:
288         DistributedInputSourceManager *sourceManagerContext_;
289     };
290 
291     class DScreenSourceSvrRecipient : public IRemoteObject::DeathRecipient {
292     public:
293         DScreenSourceSvrRecipient(const std::string &srcDevId, const std::string &sinkDevId, const uint64_t srcWinId);
294         ~DScreenSourceSvrRecipient() override;
295         void OnRemoteDied(const wptr<IRemoteObject> &remote) override;
296 
297     private:
298         std::string srcDevId_;
299         std::string sinkDevId_;
300         uint64_t srcWinId_;
301     };
302 
GetCallbackEventHandler()303     std::shared_ptr<DInputSourceManagerEventHandler> GetCallbackEventHandler()
304     {
305         return callBackHandler_;
306     };
307 
308 public:
309     void RunRegisterCallback(const std::string &devId, const std::string &dhId, const int32_t &status);
310     void RunUnregisterCallback(const std::string &devId, const std::string &dhId, const int32_t &status);
311     void RunPrepareCallback(const std::string &devId, const int32_t &status, const std::string &object);
312     void RunUnprepareCallback(const std::string &devId, const int32_t &status);
313     void RunStartCallback(const std::string &devId, const uint32_t &inputTypes, const int32_t &status);
314     void RunStopCallback(const std::string &devId, const uint32_t &inputTypes, const int32_t &status);
315 
316     void RunStartDhidCallback(const std::string &sinkId, const std::string &dhIds, const int32_t &status);
317     void RunStopDhidCallback(const std::string &sinkId, const std::string &dhIds, const int32_t &status);
318     void RunKeyStateCallback(const std::string &sinkId, const std::string &dhId, const uint32_t type,
319         const uint32_t code, const uint32_t value);
320     void RunWhiteListCallback(const std::string &devId, const std::string &object);
321 
322     DInputServerType GetStartTransFlag();
323     void SetStartTransFlag(const DInputServerType flag);
324     std::vector<InputDeviceId> GetInputDeviceId();
325     void RemoveInputDeviceId(const std::string deviceId, const std::string dhId);
326     void SetDeviceMapValue(const std::string deviceId, int32_t value);
327     bool GetDeviceMapAllDevSwitchOff();
328     int32_t CheckDeviceIsExists(const std::string &devId, const std::string &dhId,
329         const InputDeviceId &inputDeviceId, std::vector<InputDeviceId>::iterator &it);
330     int32_t DeleteInputDeviceNodeInfo(const std::string &devId, const std::string &dhId,
331         const std::vector<InputDeviceId>::iterator &it);
332     int32_t UnregCallbackNotify(const std::string &devId, const std::string &dhId);
333     void SetInputTypesMap(const std::string deviceId, uint32_t value);
334     uint32_t GetInputTypesMap(const std::string deviceId);
335     uint32_t GetAllInputTypesMap();
336 
337 private:
338     struct DInputClientRegistInfo {
339         std::string devId;
340         std::string dhId;
341         sptr<IRegisterDInputCallback> callback = nullptr;
342     };
343 
344     struct DInputClientUnregistInfo {
345         std::string devId;
346         std::string dhId;
347         sptr<IUnregisterDInputCallback> callback = nullptr;
348     };
349 
350     struct DInputClientPrepareInfo {
351         std::string devId;
352         sptr<IPrepareDInputCallback> preCallback = nullptr;
353 
DInputClientPrepareInfoDInputClientPrepareInfo354         DInputClientPrepareInfo(std::string deviceId, sptr<IPrepareDInputCallback> prepareCallback)
355             : devId(deviceId), preCallback(prepareCallback) {}
356     };
357 
358     struct DInputClientUnprepareInfo {
359         std::string devId;
360         sptr<IUnprepareDInputCallback> unpreCallback = nullptr;
361     };
362 
363     struct DInputClientStartInfo {
364         std::string devId;
365         uint32_t inputTypes;
366         sptr<IStartDInputCallback> callback = nullptr;
DInputClientStartInfoDInputClientStartInfo367         DInputClientStartInfo(std::string deviceId, uint32_t types, sptr<IStartDInputCallback> cb)
368             : devId(deviceId), inputTypes(types), callback(cb) {}
369     };
370 
371     struct DInputClientStopInfo {
372         std::string devId;
373         uint32_t inputTypes;
374         sptr<IStopDInputCallback> callback = nullptr;
DInputClientStopInfoDInputClientStopInfo375         DInputClientStopInfo(std::string deviceId, uint32_t types, sptr<IStopDInputCallback> cb)
376             : devId(deviceId), inputTypes(types), callback(cb) {}
377     };
378     // add new prepare/start function
379     struct DInputClientRelayPrepareInfo {
380         std::string srcId;
381         std::string sinkId;
382         sptr<IPrepareDInputCallback> preCallback = nullptr;
383 
DInputClientRelayPrepareInfoDInputClientRelayPrepareInfo384         DInputClientRelayPrepareInfo(std::string sourceId, std::string sinkid,
385             sptr<IPrepareDInputCallback> prepareCallback)
386             : srcId(sourceId), sinkId(sinkid), preCallback(prepareCallback) {}
387     };
388     struct DInputClientRelayUnprepareInfo {
389         std::string srcId;
390         std::string sinkId;
391         sptr<IUnprepareDInputCallback> unpreCallback = nullptr;
DInputClientRelayUnprepareInfoDInputClientRelayUnprepareInfo392         DInputClientRelayUnprepareInfo(std::string sourceId, std::string sinkid,
393             sptr<IUnprepareDInputCallback> unprepareCallback)
394             : srcId(sourceId), sinkId(sinkid), unpreCallback(unprepareCallback) {}
395     };
396 
397     struct DInputClientStartDhidInfo {
398         std::string srcId;
399         std::string sinkId;
400         std::vector<std::string> dhIds;
401         sptr<IStartStopDInputsCallback> callback = nullptr;
402     };
403     struct DInputClientStopDhidInfo {
404         std::string srcId;
405         std::string sinkId;
406         std::vector<std::string> dhIds;
407         sptr<IStartStopDInputsCallback> callback = nullptr;
408     };
409 
410     struct DInputClientStartTypeInfo {
411         std::string srcId;
412         std::string sinkId;
413         uint32_t inputTypes;
414         sptr<IStartDInputCallback> callback = nullptr;
DInputClientStartTypeInfoDInputClientStartTypeInfo415         DInputClientStartTypeInfo(std::string sourceId, std::string sinkid, uint32_t types,
416             sptr<IStartDInputCallback> cb) : srcId(sourceId), sinkId(sinkid), inputTypes(types), callback(cb) {}
417     };
418     struct DInputClientStopTypeInfo {
419         std::string srcId;
420         std::string sinkId;
421         uint32_t inputTypes;
422         sptr<IStopDInputCallback> callback = nullptr;
DInputClientStopTypeInfoDInputClientStopTypeInfo423         DInputClientStopTypeInfo(std::string sourceId, std::string sinkid, uint32_t types,
424             sptr<IStopDInputCallback> cb) : srcId(sourceId), sinkId(sinkid), inputTypes(types), callback(cb) {}
425     };
426 
427     ServiceSourceRunningState serviceRunningState_ = ServiceSourceRunningState::STATE_NOT_START;
428     DInputServerType isStartTrans_ = DInputServerType::NULL_SERVER_TYPE;
429     std::shared_ptr<DistributedInputSourceManager::DInputSourceListener> statuslistener_;
430 
431     std::vector<DInputClientRegistInfo> regCallbacks_;
432     std::vector<DInputClientUnregistInfo> unregCallbacks_;
433     std::vector<DInputClientPrepareInfo> preCallbacks_;
434     std::vector<DInputClientUnprepareInfo> unpreCallbacks_;
435     std::vector<DInputClientStartInfo> staCallbacks_;
436     std::vector<DInputClientStopInfo> stpCallbacks_;
437 
438     std::vector<DInputClientStartDhidInfo> staStringCallbacks_;
439     std::vector<DInputClientStopDhidInfo> stpStringCallbacks_;
440 
441     std::vector<DInputClientRelayPrepareInfo> relayPreCallbacks_;
442     std::vector<DInputClientRelayUnprepareInfo> relayUnpreCallbacks_;
443     std::vector<DInputClientStartDhidInfo> relayStaDhidCallbacks_;
444     std::vector<DInputClientStopDhidInfo> relayStpDhidCallbacks_;
445     std::vector<DInputClientStartTypeInfo> relayStaTypeCallbacks_;
446     std::vector<DInputClientStopTypeInfo> relayStpTypeCallbacks_;
447 
448     std::set<sptr<IAddWhiteListInfosCallback>> addWhiteListCallbacks_;
449     std::set<sptr<IDelWhiteListInfosCallback>> delWhiteListCallbacks_;
450     std::set<sptr<ISimulationEventListener>> simulationEventCallbacks_;
451 
452     std::map<std::string, int32_t> DeviceMap_;
453     std::map<std::string, uint32_t> InputTypesMap_;
454     std::shared_ptr<AppExecFwk::EventRunner> runner_;
455     std::shared_ptr<DistributedInputSourceEventHandler> handler_;
456     std::shared_ptr<DInputSourceManagerEventHandler> callBackHandler_;
457     std::vector<InputDeviceId> inputDevice_;
458     bool InitAuto();
459     void handleStartServerCallback(const std::string &devId);
460     std::mutex mutex_;
461     std::mutex operationMutex_;
462     sptr<StartDScreenListener> startDScreenListener_ = nullptr;
463     sptr<StopDScreenListener> stopDScreenListener_ = nullptr;
464     sptr<DeviceOfflineListener> deviceOfflineListener_ = nullptr;
465 
466     std::mutex valMutex_;
467     std::mutex syncNodeInfoMutex_;
468     std::map<std::string, std::set<BeRegNodeInfo>> syncNodeInfoMap_;
469 
470     void RunRelayPrepareCallback(const std::string &srcId, const std::string &sinkId, const int32_t &status);
471     void RunRelayUnprepareCallback(const std::string &srcId, const std::string &sinkId, const int32_t &status);
472     void RunRelayStartDhidCallback(const std::string &srcId, const std::string &sinkId, const int32_t &status,
473         const std::string &dhids);
474     void RunRelayStopDhidCallback(const std::string &srcId, const std::string &sinkId, const int32_t &status,
475         const std::string &dhids);
476     void RunRelayStartTypeCallback(const std::string &srcId, const std::string &sinkId, const int32_t &status,
477         uint32_t inputTypes);
478     void RunRelayStopTypeCallback(const std::string &srcId, const std::string &sinkId, const int32_t &status,
479         uint32_t inputTypes);
480 
481     int32_t RelayStartRemoteInputByType(const std::string &srcId, const std::string &sinkId, const uint32_t &inputTypes,
482         sptr<IStartDInputCallback> callback);
483     int32_t RelayStopRemoteInputByType(const std::string &srcId, const std::string &sinkId, const uint32_t &inputTypes,
484         sptr<IStopDInputCallback> callback);
485     int32_t RelayPrepareRemoteInput(const std::string &srcId, const std::string &sinkId,
486         sptr<IPrepareDInputCallback> callback);
487     int32_t RelayUnprepareRemoteInput(const std::string &srcId, const std::string &sinkId,
488         sptr<IUnprepareDInputCallback> callback);
489     int32_t RelayStartRemoteInputByDhid(const std::string &srcId, const std::string &sinkId,
490         const std::vector<std::string> &dhIds, sptr<IStartStopDInputsCallback> callback);
491     int32_t RelayStopRemoteInputByDhid(const std::string &srcId, const std::string &sinkId,
492         const std::vector<std::string> &dhIds, sptr<IStartStopDInputsCallback> callback);
493     bool IsStringDataSame(const std::vector<std::string> &oldDhIds, std::vector<std::string> newDhIds);
494     void DeleteNodeInfoAndNotify(const std::string &offlineDevId);
495     void SendExistVirNodeInfos(sptr<InputNodeListener> listener);
496     std::set<BeRegNodeInfo> GetSyncNodeInfo(const std::string &devId);
497     void UpdateSyncNodeInfo(const std::string &devId, const std::string &dhId, const std::string &nodeDesc);
498     void DeleteSyncNodeInfo(const std::string &devId);
499     void UnregisterDHFwkPublisher();
500 };
501 } // namespace DistributedInput
502 } // namespace DistributedHardware
503 } // namespace OHOS
504 
505 #endif // DISTRIBUTED_INPUT_SOURCE_MANAGER_SERVICE_H
506