1 /* 2 * Copyright (C) 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 NOTIFICATION_DISTRIBUTED_DEVICE_MANAGER_H 17 #define NOTIFICATION_DISTRIBUTED_DEVICE_MANAGER_H 18 19 #include "device_manager_callback.h" 20 21 namespace OHOS { 22 namespace Notification { 23 using namespace DistributedHardware; 24 25 class DmsInitCallback : public DmInitCallback { 26 public: 27 void OnRemoteDied() override; 28 }; 29 30 class DmsStateCallback : public DeviceStateCallback { 31 public: 32 void OnDeviceOnline(const DmDeviceInfo &deviceInfo) override; 33 void OnDeviceOffline(const DmDeviceInfo &deviceInfo) override; 34 void OnDeviceChanged(const DmDeviceInfo &deviceInfo) override; 35 void OnDeviceReady(const DmDeviceInfo &deviceInfo) override; 36 }; 37 38 class DistributedDeviceManager { 39 public: 40 void InitTrustList(); 41 bool RegisterDms(bool forceInit); 42 static DistributedDeviceManager& GetInstance(); 43 private: 44 std::atomic<bool> hasInit = false; 45 std::shared_ptr<DmsInitCallback> initCallback_; 46 std::shared_ptr<DmsStateCallback> stateCallback_; 47 }; 48 49 } 50 } 51 #endif // NOTIFICATION_DISTRIBUTED_DEVICE_MANAGER_H 52