1 /* 2 * Copyright (c) 2021 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 DEVSL_DISPATCHER_H 17 #define DEVSL_DISPATCHER_H 18 19 #include <map> 20 #include <memory> 21 #include <mutex> 22 #include <string> 23 #include <vector> 24 #include "dev_slinfo_mgr.h" 25 #include "device/device_manager_agent.h" 26 27 namespace OHOS { 28 namespace Storage { 29 namespace DistributedFile { 30 class DevslDispatcher final { 31 public: 32 DevslDispatcher() = delete; 33 ~DevslDispatcher() = delete; 34 static int Start(); 35 static void Stop(); 36 static void DevslGottonCallback(DEVSLQueryParams *queryParams, int32_t result, uint32_t levelInfo); 37 static uint32_t DevslGetRegister(const std::string &cid, std::weak_ptr<KernelTalker>); 38 private: 39 static DEVSLQueryParams MakeDevslQueryParams(const std::string &cid); 40 static void DevslGottonCallbackAsync(const std::string udid, uint32_t devsl); 41 static std::map<std::string, std::vector<std::weak_ptr<KernelTalker>>> talkersMap_; 42 static std::map<std::string, std::string> idMap_; 43 static std::mutex mutex; 44 }; 45 } // namespace DistributedFile 46 } // namespace Storage 47 } // namespace OHOS 48 #endif // DSL_DISPATCHER_H