• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-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_DM_SERVICE_H
17 #define OHOS_DM_SERVICE_H
18 
19 #include <string>
20 #include <memory>
21 #if defined(__LITEOS_M__)
22 #include "dm_mutex.h"
23 #else
24 #include <mutex>
25 #endif
26 
27 #include "advertise_manager.h"
28 #include "discovery_manager.h"
29 #include "pin_holder.h"
30 #include "device_manager_service_listener.h"
31 #include "idevice_manager_service_impl.h"
32 #include "hichain_listener.h"
33 #include "i_dm_check_api_white_list.h"
34 #include "i_dm_service_impl_ext_resident.h"
35 #include "i_dm_device_risk_detect.h"
36 #if !(defined(__LITEOS_M__) || defined(LITE_DEVICE))
37 #include "dm_account_common_event.h"
38 #include "dm_datashare_common_event.h"
39 #include "dm_package_common_event.h"
40 #include "dm_screen_common_event.h"
41 #include "relationship_sync_mgr.h"
42 #include "local_service_info.h"
43 #if defined(SUPPORT_BLUETOOTH) || defined(SUPPORT_WIFI)
44 #include "dm_publish_common_event.h"
45 #endif // SUPPORT_BLUETOOTH SUPPORT_WIFI
46 #endif
47 
48 namespace OHOS {
49 namespace DistributedHardware {
50 class DeviceManagerService {
51 DM_DECLARE_SINGLE_INSTANCE_BASE(DeviceManagerService);
52 public:
DeviceManagerService()53     DeviceManagerService() {}
54 
55     ~DeviceManagerService();
56 
57     int32_t Init();
58 
59     int32_t InitSoftbusListener();
60 
61     void InitHichainListener();
62 
63     void StartDetectDeviceRisk();
64 
65     void DelAllRelateShip();
66 
67     DM_EXPORT void RegisterCallerAppId(const std::string &pkgName);
68 
69     DM_EXPORT void UnRegisterCallerAppId(const std::string &pkgName);
70 
71     void UninitSoftbusListener();
72 
73     int32_t InitDMServiceListener();
74 
75     DM_EXPORT void UninitDMServiceListener();
76 
77     int32_t GetTrustedDeviceList(const std::string &pkgName, const std::string &extra,
78                                  std::vector<DmDeviceInfo> &deviceList);
79 
80     int32_t ShiftLNNGear(const std::string &pkgName, const std::string &callerId, bool isRefresh, bool isWakeUp);
81 
82     int32_t GetLocalDeviceInfo(DmDeviceInfo &info);
83 
84     int32_t GetDeviceInfo(const std::string &networkId, DmDeviceInfo &info);
85 
86     int32_t GetUdidByNetworkId(const std::string &pkgName, const std::string &netWorkId, std::string &udid);
87 
88     int32_t GetUuidByNetworkId(const std::string &pkgName, const std::string &netWorkId, std::string &uuid);
89 
90     int32_t PublishDeviceDiscovery(const std::string &pkgName, const DmPublishInfo &publishInfo);
91 
92     int32_t UnPublishDeviceDiscovery(const std::string &pkgName, int32_t publishId);
93 
94     int32_t AuthenticateDevice(const std::string &pkgName, int32_t authType, const std::string &deviceId,
95                                const std::string &extra);
96 
97     int32_t UnAuthenticateDevice(const std::string &pkgName, const std::string &networkId);
98 
99     int32_t StopAuthenticateDevice(const std::string &pkgName);
100 
101     int32_t BindDevice(const std::string &pkgName, int32_t authType, const std::string &deviceId,
102         const std::string &bindParam);
103 
104     int32_t UnBindDeviceParseExtra(const std::string &pkgName, const std::string &udidHash,
105         const std::string &extra);
106 
107     int32_t UnBindDevice(const std::string &pkgName, const std::string &udidHash);
108 
109     int32_t UnBindDevice(const std::string &pkgName, const std::string &udidHash, const std::string &extra);
110 
111     int32_t ValidateUnBindDeviceParams(const std::string &pkgName, const std::string &udidHash);
112 
113     int32_t ValidateUnBindDeviceParams(const std::string &pkgName, const std::string &udidHash,
114         const std::string &extra);
115 
116     int32_t SetUserOperation(std::string &pkgName, int32_t action, const std::string &params);
117 
118     void HandleDeviceStatusChange(DmDeviceState devState, DmDeviceInfo &devInfo);
119 
120     int OnSessionOpened(int sessionId, int result);
121 
122     void OnSessionClosed(int sessionId);
123 
124     void OnBytesReceived(int sessionId, const void *data, unsigned int dataLen);
125 
126     int OnPinHolderSessionOpened(int sessionId, int result);
127 
128     void OnPinHolderSessionClosed(int sessionId);
129 
130     void OnPinHolderBytesReceived(int sessionId, const void *data, unsigned int dataLen);
131 
132     int32_t DmHiDumper(const std::vector<std::string>& args, std::string &result);
133 
134     int32_t RequestCredential(const std::string &reqJsonStr, std::string &returnJsonStr);
135 
136     int32_t ImportCredential(const std::string &pkgName, const std::string &credentialInfo);
137 
138     int32_t DeleteCredential(const std::string &pkgName, const std::string &deleteInfo);
139 
140     int32_t MineRequestCredential(const std::string &pkgName, std::string &returnJsonStr);
141 
142     int32_t CheckCredential(const std::string &pkgName, const std::string &reqJsonStr,
143         std::string &returnJsonStr);
144 
145     int32_t ImportCredential(const std::string &pkgName, const std::string &reqJsonStr,
146         std::string &returnJsonStr);
147 
148     int32_t DeleteCredential(const std::string &pkgName, const std::string &reqJsonStr,
149         std::string &returnJsonStr);
150 
151     int32_t RegisterCredentialCallback(const std::string &pkgName);
152 
153     int32_t UnRegisterCredentialCallback(const std::string &pkgName);
154 
155     int32_t NotifyEvent(const std::string &pkgName, const int32_t eventId, const std::string &event);
156 
157     int32_t CheckApiPermission(int32_t permissionLevel);
158 
159     void LoadHardwareFwkService();
160 
161     int32_t GetEncryptedUuidByNetworkId(const std::string &pkgName, const std::string &networkId, std::string &uuid);
162 
163     int32_t GenerateEncryptedUuid(const std::string &pkgName, const std::string &uuid, const std::string &appId,
164         std::string &encryptedUuid);
165 
166     int32_t GetNetworkTypeByNetworkId(const std::string &pkgName, const std::string &netWorkId, int32_t &networkType);
167     int32_t RegisterUiStateCallback(const std::string &pkgName);
168     int32_t UnRegisterUiStateCallback(const std::string &pkgName);
169     int32_t ImportAuthCode(const std::string &pkgName, const std::string &authCode);
170     int32_t ExportAuthCode(std::string &authCode);
171 
172     int32_t RegisterPinHolderCallback(const std::string &pkgName);
173     int32_t CreatePinHolder(const std::string &pkgName, const PeerTargetId &targetId,
174         DmPinType pinType, const std::string &payload);
175     int32_t DestroyPinHolder(const std::string &pkgName, const PeerTargetId &targetId,
176         DmPinType pinType, const std::string &payload);
177 
178     // The following interfaces are provided since OpenHarmony 4.1 Version.
179     int32_t StartDiscovering(const std::string &pkgName, const std::map<std::string, std::string> &discoverParam,
180         const std::map<std::string, std::string> &filterOptions);
181 
182     int32_t StopDiscovering(const std::string &pkgName, const std::map<std::string, std::string> &discoverParam);
183 
184     int32_t EnableDiscoveryListener(const std::string &pkgName, const std::map<std::string, std::string> &discoverParam,
185         const std::map<std::string, std::string> &filterOptions);
186 
187     int32_t DisableDiscoveryListener(const std::string &pkgName, const std::map<std::string, std::string> &extraParam);
188 
189     int32_t StartAdvertising(const std::string &pkgName, const std::map<std::string, std::string> &advertiseParam);
190 
191     int32_t StopAdvertising(const std::string &pkgName, const std::map<std::string, std::string> &advertiseParam);
192 
193     int32_t BindTarget(const std::string &pkgName, const PeerTargetId &targetId,
194         const std::map<std::string, std::string> &bindParam);
195 
196     int32_t UnbindTarget(const std::string &pkgName, const PeerTargetId &targetId,
197         const std::map<std::string, std::string> &unbindParam);
198 
199     int32_t DpAclAdd(const std::string &udid);
200 
201     int32_t GetDeviceSecurityLevel(const std::string &pkgName, const std::string &networkId, int32_t &networkType);
202     int32_t IsSameAccount(const std::string &networkId);
203     int32_t InitAccountInfo();
204     int32_t InitScreenLockEvent();
205     bool CheckAccessControl(const DmAccessCaller &caller, const DmAccessCallee &callee);
206     bool CheckIsSameAccount(const DmAccessCaller &caller, const DmAccessCallee &callee);
207     void HandleDeviceNotTrust(const std::string &msg);
208 #if !(defined(__LITEOS_M__) || defined(LITE_DEVICE))
209     void HandleCredentialDeleted(const char *credId, const char *credInfo);
210     void HandleDeviceTrustedChange(const std::string &msg);
211     bool ParseRelationShipChangeType(const RelationShipChangeMsg &relationShipMsg);
212     void HandleUserIdCheckSumChange(const std::string &msg);
213     void HandleUserStop(int32_t stopUserId, const std::string &stopEventUdid);
214     void HandleUserStop(int32_t stopUserId, const std::string &stopEventUdid,
215         const std::vector<std::string> &acceptEventUdids);
216     std::set<std::pair<std::string, std::string>> GetProxyInfosByParseExtra(const std::string &pkgName,
217         const std::string &extra, std::vector<std::pair<int64_t, int64_t>> &agentToProxyVec);
218 #endif
219     int32_t SetDnPolicy(const std::string &pkgName, std::map<std::string, std::string> &policy);
220     void ClearDiscoveryCache(const ProcessInfo &processInfo);
221     void HandleDeviceScreenStatusChange(DmDeviceInfo &devInfo);
222     int32_t GetDeviceScreenStatus(const std::string &pkgName, const std::string &networkId,
223         int32_t &screenStatus);
224     void SubscribePackageCommonEvent();
225     int32_t GetNetworkIdByUdid(const std::string &pkgName, const std::string &udid, std::string &networkId);
226     void HandleCredentialAuthStatus(const std::string &deviceList, uint16_t deviceTypeId, int32_t errcode);
227     int32_t SyncLocalAclListProcess(const DevUserInfo &localDevUserInfo,
228         const DevUserInfo &remoteDevUserInfo, std::string remoteAclList);
229     int32_t GetAclListHash(const DevUserInfo &localDevUserInfo,
230         const DevUserInfo &remoteDevUserInfo, std::string &aclList);
231     void ProcessSyncUserIds(const std::vector<uint32_t> &foregroundUserIds,
232         const std::vector<uint32_t> &backgroundUserIds, const std::string &remoteUdid);
233 
234     void ProcessUninstApp(int32_t userId, int32_t tokenId);
235     void ProcessUnBindApp(int32_t userId, int32_t tokenId, const std::string &extra, const std::string &udid);
236 
237     int32_t SetLocalDisplayNameToSoftbus(const std::string &displayName);
238     void RemoveNotifyRecord(const ProcessInfo &processInfo);
239     int32_t RegDevStateCallbackToService(const std::string &pkgName);
240     int32_t GetTrustedDeviceList(const std::string &pkgName, std::vector<DmDeviceInfo> &deviceList);
241     void HandleDeviceUnBind(const char *peerUdid, const GroupInformation &groupInfo);
242     int32_t GetAnonyLocalUdid(const std::string &pkgName, std::string &anonyUdid);
243     int32_t GetAllTrustedDeviceList(const std::string &pkgName, const std::string &extra,
244         std::vector<DmDeviceInfo> &deviceList);
245     int32_t RegisterAuthenticationType(const std::string &pkgName,
246         const std::map<std::string, std::string> &authParam);
247     int32_t GetDeviceProfileInfoList(const std::string &pkgName, DmDeviceProfileInfoFilterOptions &filterOptions);
248     int32_t GetDeviceIconInfo(const std::string &pkgName, DmDeviceIconInfoFilterOptions &filterOptions);
249     int32_t PutDeviceProfileInfoList(const std::string &pkgName,
250         std::vector<DmDeviceProfileInfo> &deviceProfileInfoList);
251     int32_t GetLocalDisplayDeviceName(const std::string &pkgName, int32_t maxNameLength, std::string &displayName);
252     int32_t SetLocalDeviceName(const std::string &pkgName, const std::string &deviceName);
253     int32_t SetRemoteDeviceName(const std::string &pkgName, const std::string &deviceId, const std::string &deviceName);
254     std::vector<std::string> GetDeviceNamePrefixs();
255     int32_t RestoreLocalDeviceName(const std::string &pkgName);
256     int32_t RegisterLocalServiceInfo(const DMLocalServiceInfo &serviceInfo);
257     int32_t UnRegisterLocalServiceInfo(const std::string &bundleName, int32_t pinExchangeType);
258     int32_t UpdateLocalServiceInfo(const DMLocalServiceInfo &serviceInfo);
259     int32_t GetLocalServiceInfoByBundleNameAndPinExchangeType(const std::string &bundleName, int32_t pinExchangeType,
260         DMLocalServiceInfo &serviceInfo);
261     void ClearPublishIdCache(const std::string &pkgName);
262     bool IsPC();
263     int32_t GetDeviceNetworkIdList(const std::string &pkgName, const NetworkIdQueryFilter &queryFilter,
264         std::vector<std::string> &networkIds);
265     void ProcessSyncAccountLogout(const std::string &accountId, const std::string &peerUdid, int32_t userId);
266     int32_t OpenAuthSessionWithPara(const std::string &deviceId, int32_t actionId, bool isEnable160m);
267     int32_t UnRegisterPinHolderCallback(const std::string &pkgName);
268     void ProcessReceiveRspAppUninstall(const std::string &remoteUdid);
269     void ProcessReceiveRspAppUnbind(const std::string &remoteUdid);
270     void ProcessCommonUserStatusEvent(const std::vector<uint32_t> &foregroundUserIds,
271         const std::vector<uint32_t> &backgroundUserIds, const std::string &remoteUdid);
272     int32_t GetLocalDeviceName(std::string &deviceName);
273     int32_t GetLocalDeviceNameOld(std::string &deviceName);
274     bool CheckSrcAccessControl(const DmAccessCaller &caller, const DmAccessCallee &callee);
275     bool CheckSinkAccessControl(const DmAccessCaller &caller, const DmAccessCallee &callee);
276     bool CheckSrcIsSameAccount(const DmAccessCaller &caller, const DmAccessCallee &callee);
277     bool CheckSinkIsSameAccount(const DmAccessCaller &caller, const DmAccessCallee &callee);
278 private:
279     bool IsDMServiceImplReady();
280     bool IsDMImplSoLoaded();
281     bool IsDMServiceAdapterSoLoaded();
282     bool IsDMServiceAdapterResidentLoad();
283     bool IsDMDeviceRiskDetectSoLoaded();
284     bool IsMsgEmptyAndDMServiceImplReady(const std::string &msg);
285     void UnloadDMServiceImplSo();
286     void UnloadDMServiceAdapterResident();
287     void UnloadDMDeviceRiskDetect();
288     void SendUnBindBroadCast(const std::vector<std::string> &peerUdids, int32_t userId, uint64_t tokenId,
289         int32_t bindLevel);
290     void SendUnBindBroadCast(const std::vector<std::string> &peerUdids, int32_t userId, uint64_t tokenId,
291         int32_t bindLevel, uint64_t peerTokenId);
292     void SendDeviceUnBindBroadCast(const std::vector<std::string> &peerUdids, int32_t userId);
293     void SendAppUnBindBroadCast(const std::vector<std::string> &peerUdids, int32_t userId, uint64_t tokenId);
294     int32_t CalculateBroadCastDelayTime();
295     void SendAppUnBindBroadCast(const std::vector<std::string> &peerUdids, int32_t userId,
296         uint64_t tokenId, uint64_t peerTokenId);
297     void SendAppUnInstallBroadCast(const std::vector<std::string> &peerUdids, int32_t userId,
298         uint64_t tokenId);
299     void SendServiceUnBindBroadCast(const std::vector<std::string> &peerUdids, int32_t userId, uint64_t tokenId);
300     void SendAccountLogoutBroadCast(const std::vector<std::string> &peerUdids, const std::string &accountId,
301         const std::string &accountName, int32_t userId);
302     /**
303      * @brief send local foreground or background userids by broadcast
304      *
305      * @param peerUdids the broadcast target device udid list
306      * @param foregroundUserIds local foreground userids
307      * @param backgroundUserIds local background userids
308      */
309     void SendUserIdsBroadCast(const std::vector<std::string> &peerUdids,
310         const std::vector<int32_t> &foregroundUserIds, const std::vector<int32_t> &backgroundUserIds,
311         bool isNeedResponse);
312     void SendUserRemovedBroadCast(const std::vector<std::string> &peerUdids, int32_t userId);
313     /**
314      * @brief parse dsoftbus checksum msg
315      *
316      * @param msg checksum msg
317      * @param networkId remote device networkid
318      * @param discoveryType remote device link type, wifi or ble/br
319      * @return int32_t 0 for success
320      */
321     int32_t ParseCheckSumMsg(const std::string &msg, std::string &networkId, uint32_t &discoveryType, bool &isChange);
322     void ProcessCheckSumByWifi(std::string networkId, std::vector<int32_t> foregroundUserIds,
323         std::vector<int32_t> backgroundUserIds);
324     void ProcessCheckSumByBT(std::string networkId, std::vector<int32_t> foregroundUserIds,
325         std::vector<int32_t> backgroundUserIds);
326     void AddHmlInfoToBindParam(int32_t actionId, std::string &bindParam);
327 
328 #if !(defined(__LITEOS_M__) || defined(LITE_DEVICE))
329     void SubscribeAccountCommonEvent();
330     void SendShareTypeUnBindBroadCast(const char *credId, const int32_t localUserId,
331         const std::vector<std::string> &peerUdids);
332     DM_EXPORT void AccountCommonEventCallback(const std::string commonEventType,
333         int32_t currentUserId, int32_t beforeUserId);
334     void SubscribeScreenLockEvent();
335     void ScreenCommonEventCallback(std::string commonEventType);
336     DM_EXPORT void ConvertUdidHashToAnoyDeviceId(DmDeviceInfo &deviceInfo);
337     DM_EXPORT int32_t ConvertUdidHashToAnoyDeviceId(const std::string &udidHash,
338         std::string &anoyDeviceId);
339     DM_EXPORT int32_t GetUdidHashByAnoyDeviceId(const std::string &anoyDeviceId,
340         std::string &udidHash);
341     void HandleAccountLogout(int32_t userId, const std::string &accountId, const std::string &accountName);
342     void HandleUserRemoved(int32_t removedUserId);
343     void HandleUserIdsBroadCast(const std::vector<UserIdInfo> &remoteUserIdInfos,
344         const std::string &remoteUdid, bool isNeedResponse);
345     void HandleShareUnbindBroadCast(const int32_t userId, const std::string &credId);
346     bool InitDPLocalServiceInfo(const DMLocalServiceInfo &serviceInfo,
347         DistributedDeviceProfile::LocalServiceInfo &dpLocalServiceItem);
348     void InitServiceInfo(const DistributedDeviceProfile::LocalServiceInfo &dpLocalServiceItem,
349         DMLocalServiceInfo &serviceInfo);
350     void InitServiceInfos(const std::vector<DistributedDeviceProfile::LocalServiceInfo> &dpLocalServiceItems,
351         std::vector<DMLocalServiceInfo> &serviceInfos);
352 
353     void NotifyRemoteUninstallApp(int32_t userId, int32_t tokenId);
354     void NotifyRemoteUninstallAppByWifi(int32_t userId, int32_t tokenId,
355         const std::map<std::string, std::string> &wifiDevices);
356     int32_t SendUninstAppByWifi(int32_t userId, int32_t tokenId, const std::string &networkId);
357 
358     void GetNotifyRemoteUnBindAppWay(int32_t userId, int32_t tokenId,
359         std::map<std::string, std::string> &wifiDevices, bool &isBleWay);
360     void NotifyRemoteUnBindAppByWifi(int32_t userId, int32_t tokenId, std::string extra,
361         const std::map<std::string, std::string> &wifiDevices);
362     int32_t SendUnBindAppByWifi(int32_t userId, int32_t tokenId, std::string extra,
363         const std::string &networkId, const std::string &udid);
364 
365     void UpdateAclAndDeleteGroup(const std::string &localUdid, const std::vector<std::string> &deviceVec,
366         const std::vector<int32_t> &foregroundUserIds, const std::vector<int32_t> &backgroundUserIds);
367     void HandleUserSwitchedEvent(int32_t currentUserId, int32_t beforeUserId);
368     void HandleUserStopEvent(int32_t stopUserId);
369     void DivideNotifyMethod(const std::vector<std::string> &peerUdids, std::vector<std::string> &bleUdids,
370         std::map<std::string, std::string> &wifiDevices);
371     void NotifyRemoteLocalUserStop(const std::string &localUdid,
372         const std::vector<std::string> &peerUdids, int32_t stopUserId);
373     void SendUserStopBroadCast(const std::vector<std::string> &peerUdids, int32_t stopUserId);
374     void HandleUserStopBroadCast(int32_t stopUserId, const std::string &remoteUdid);
375     void NotifyRemoteLocalUserStopByWifi(const std::string &localUdid,
376         const std::map<std::string, std::string> &wifiDevices, int32_t stopUserId);
377 
378     void HandleAccountCommonEvent(const std::string commonEventType);
379     bool IsUserStatusChanged(std::vector<int32_t> foregroundUserVec, std::vector<int32_t> backgroundUserVec);
380     void NotifyRemoteAccountCommonEvent(const std::string commonEventType, const std::string &localUdid,
381         const std::vector<std::string> &peerUdids, const std::vector<int32_t> &foregroundUserIds,
382         const std::vector<int32_t> &backgroundUserIds);
383     void NotifyRemoteAccountCommonEventByWifi(const std::string &localUdid,
384         const std::map<std::string, std::string> &wifiDevices, const std::vector<int32_t> &foregroundUserIds,
385         const std::vector<int32_t> &backgroundUserIds);
386     int32_t SendAccountCommonEventByWifi(const std::string &networkId,
387         const std::vector<int32_t> &foregroundUserIds, const std::vector<int32_t> &backgroundUserIds);
388     void HandleCommonEventTimeout(const std::string &localUdid, const std::vector<int32_t> &foregroundUserIds,
389         const std::vector<int32_t> &backgroundUserIds, const std::string &udid);
390     void UpdateAcl(const std::string &localUdid, const std::vector<std::string> &peerUdids,
391         const std::vector<int32_t> &foregroundUserIds, const std::vector<int32_t> &backgroundUserIds);
392     void HandleCommonEventBroadCast(const std::vector<UserIdInfo> &remoteUserIdInfos,
393         const std::string &remoteUdid, bool isNeedResponse);
394     void SendCommonEventBroadCast(const std::vector<std::string> &peerUdids,
395         const std::vector<int32_t> &foregroundUserIds, const std::vector<int32_t> &backgroundUserIds,
396         bool isNeedResponse);
397     void HandleUserSwitchEventCallback(const std::string &commonEventType, int32_t currentUserId, int32_t beforeUserId);
398     void GetHoOsTypeUdids(std::vector<std::string> &peerUdids);
399     void DeleteHoDevice(const std::vector<int32_t> &foreGroundUserIds, const std::vector<int32_t> &backGroundUserIds);
400     void HandleAccountLogoutEventCallback(const std::string &commonEventType, int32_t currentUserId,
401         int32_t beforeUserId);
402 
403 #if defined(SUPPORT_BLUETOOTH) || defined(SUPPORT_WIFI)
404     void SubscribePublishCommonEvent();
405     void QueryDependsSwitchState();
406 #endif // SUPPORT_BLUETOOTH  SUPPORT_WIFI
407     DM_EXPORT void SubscribeDataShareCommonEvent();
408 #endif
409     void HandleNetworkConnected(int32_t networkStatus);
410     void NotifyRemoteLocalLogout(const std::vector<std::string> &peerUdids,
411         const std::string &accountIdHash, const std::string &accountName, int32_t userId);
412 #if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) && !defined(DEVICE_MANAGER_COMMON_FLAG)
413     bool IsCallerInWhiteList();
414     bool IsDMAdapterCheckApiWhiteListLoaded();
415 #endif
416     bool GetAccessUdidByNetworkId(const std::string &srcNetWorkId, std::string &srcUdid,
417         const std::string &sinkNetWorkId, std::string &sinkUdid);
418     void GetLocalUserIdFromDataBase(std::vector<int32_t> &foregroundUsers, std::vector<int32_t> &backgroundUsers);
419     void PutLocalUserIdToDataBase(const std::vector<int32_t> &foregroundUsers,
420         const std::vector<int32_t> &backgroundUsers);
421 
422 private:
423     bool isImplsoLoaded_ = false;
424     bool isAdapterResidentSoLoaded_ = false;
425     bool isDeviceRiskDetectSoLoaded_ = false;
426     void *residentSoHandle_ = nullptr;
427     void *deviceRiskDetectSoHandle_ = nullptr;
428     std::mutex isImplLoadLock_;
429     std::mutex isAdapterResidentLoadLock_;
430     std::mutex isDeviceRiskDetectSoLoadLock_;
431     std::mutex detectLock_;
432     std::mutex hichainListenerLock_;
433     std::mutex userVecLock_;
434     std::shared_ptr<AdvertiseManager> advertiseMgr_;
435     std::shared_ptr<DiscoveryManager> discoveryMgr_;
436     std::shared_ptr<SoftbusListener> softbusListener_;
437     std::shared_ptr<HichainListener> hichainListener_;
438     std::shared_ptr<DeviceManagerServiceListener> listener_;
439     std::shared_ptr<IDeviceManagerServiceImpl> dmServiceImpl_;
440     std::shared_ptr<IDMServiceImplExtResident> dmServiceImplExtResident_;
441     std::shared_ptr<IDMDeviceRiskDetect> dmDeviceRiskDetect_;
442     std::string localDeviceId_;
443     std::shared_ptr<PinHolder> pinHolder_;
444 #if !(defined(__LITEOS_M__) || defined(LITE_DEVICE))
445     std::shared_ptr<DmAccountCommonEventManager> accountCommonEventManager_;
446     std::shared_ptr<DmPackageCommonEventManager> packageCommonEventManager_;
447     std::shared_ptr<DmScreenCommonEventManager> screenCommonEventManager_;
448     std::vector<int32_t> foregroundUserVec_;
449     std::vector<int32_t> backgroundUserVec_;
450     std::mutex broadCastLock_;
451     int64_t SendLastBroadCastTime_ = 0;
452     int64_t lastDelayTime_ = 0;
453 #if defined(SUPPORT_BLUETOOTH) || defined(SUPPORT_WIFI)
454     std::shared_ptr<DmPublishCommonEventManager> publshCommonEventManager_;
455 #endif // SUPPORT_BLUETOOTH  SUPPORT_WIFI
456     DM_EXPORT std::shared_ptr<DmDataShareCommonEventManager> dataShareCommonEventManager_;
457 #endif
458     std::string localNetWorkId_ = "";
459     std::shared_ptr<DmTimer> timer_;
460 #if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) && !defined(DEVICE_MANAGER_COMMON_FLAG)
461     bool isAdapterCheckApiWhiteListSoLoaded_ = false;
462     void *checkApiWhiteListSoHandle_ = nullptr;
463     std::mutex isAdapterCheckApiWhiteListLoadedLock_;
464     std::shared_ptr<IDMCheckApiWhiteList> dmCheckApiWhiteList_;
465 #endif
466 };
467 } // namespace DistributedHardware
468 } // namespace OHOS
469 #endif // OHOS_DM_SERVICE_H
470