1 /* 2 * Copyright (c) 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 OHOS_STORAGE_DISTRIBUTED_FILE_DAEMON_PROXY_H 17 #define OHOS_STORAGE_DISTRIBUTED_FILE_DAEMON_PROXY_H 18 19 #include <cstdint> 20 21 #include "dm_device_info.h" 22 #include "ipc/i_daemon.h" 23 #include "iremote_proxy.h" 24 25 26 namespace OHOS { 27 namespace Storage { 28 namespace DistributedFile { 29 class DistributedFileDaemonProxy : public IRemoteProxy<IDaemon> { 30 public: DistributedFileDaemonProxy(const sptr<IRemoteObject> & impl)31 explicit DistributedFileDaemonProxy(const sptr<IRemoteObject> &impl) : IRemoteProxy<IDaemon>(impl) {} ~DistributedFileDaemonProxy()32 ~DistributedFileDaemonProxy() override {} 33 34 static sptr<IDaemon> GetInstance(); 35 static void InvaildInstance(); 36 37 int32_t OpenP2PConnection(const DistributedHardware::DmDeviceInfo &deviceInfo) override; 38 int32_t CloseP2PConnection(const DistributedHardware::DmDeviceInfo &deviceInfo) override; 39 40 private: 41 static inline std::mutex proxyMutex_; 42 static inline sptr<IDaemon> daemonProxy_; 43 static inline BrokerDelegator<DistributedFileDaemonProxy> delegator_; 44 }; 45 46 } // namespace DistributedFile 47 } // namespace Storage 48 } // namespace OHOS 49 #endif // OHOS_STORAGE_DISTRIBUTED_FILE_DAEMON_PROXY_H