114cf0368Sopenharmony_ci/* 214cf0368Sopenharmony_ci * Copyright (c) 2022 Huawei Device Co., Ltd. 314cf0368Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 414cf0368Sopenharmony_ci * you may not use this file except in compliance with the License. 514cf0368Sopenharmony_ci * You may obtain a copy of the License at 614cf0368Sopenharmony_ci * 714cf0368Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 814cf0368Sopenharmony_ci * 914cf0368Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 1014cf0368Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 1114cf0368Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1214cf0368Sopenharmony_ci * See the License for the specific language governing permissions and 1314cf0368Sopenharmony_ci * limitations under the License. 1414cf0368Sopenharmony_ci */ 1514cf0368Sopenharmony_ci 1614cf0368Sopenharmony_ci#ifndef UDMF_SERVICE_CLIENT_H 1714cf0368Sopenharmony_ci#define UDMF_SERVICE_CLIENT_H 1814cf0368Sopenharmony_ci 1914cf0368Sopenharmony_ci#include <mutex> 2014cf0368Sopenharmony_ci#include <string> 2114cf0368Sopenharmony_ci 2214cf0368Sopenharmony_ci#include "ikvstore_data_service.h" 2314cf0368Sopenharmony_ci#include "iremote_object.h" 2414cf0368Sopenharmony_ci#include "udmf_service.h" 2514cf0368Sopenharmony_ci#include "udmf_service_proxy.h" 2614cf0368Sopenharmony_ci 2714cf0368Sopenharmony_cinamespace OHOS { 2814cf0368Sopenharmony_cinamespace UDMF { 2914cf0368Sopenharmony_ciclass UdmfServiceClient final : public UdmfService { 3014cf0368Sopenharmony_cipublic: 3114cf0368Sopenharmony_ci explicit UdmfServiceClient(const sptr<UdmfServiceProxy> &proxy); 3214cf0368Sopenharmony_ci ~UdmfServiceClient() override = default; 3314cf0368Sopenharmony_ci static std::shared_ptr<UdmfServiceClient> GetInstance(); 3414cf0368Sopenharmony_ci 3514cf0368Sopenharmony_ci int32_t SetData(CustomOption &option, UnifiedData &unifiedData, std::string &key) override; 3614cf0368Sopenharmony_ci int32_t GetData(const QueryOption &query, UnifiedData &unifiedData) override; 3714cf0368Sopenharmony_ci int32_t GetBatchData(const QueryOption &query, std::vector<UnifiedData> &unifiedDataSet) override; 3814cf0368Sopenharmony_ci int32_t UpdateData(const QueryOption &query, UnifiedData &unifiedData) override; 3914cf0368Sopenharmony_ci int32_t DeleteData(const QueryOption &query, std::vector<UnifiedData> &unifiedDataSet) override; 4014cf0368Sopenharmony_ci int32_t GetSummary(const QueryOption &query, Summary &summary) override; 4114cf0368Sopenharmony_ci int32_t AddPrivilege(const QueryOption &query, Privilege &privilege) override; 4214cf0368Sopenharmony_ci int32_t Sync(const QueryOption &query, const std::vector<std::string> &devices) override; 4314cf0368Sopenharmony_ci int32_t IsRemoteData(const QueryOption &query, bool &result) override; 4414cf0368Sopenharmony_ci int32_t SetAppShareOption(const std::string &intention, int32_t shareOption) override; 4514cf0368Sopenharmony_ci int32_t GetAppShareOption(const std::string &intention, int32_t &shareOption) override; 4614cf0368Sopenharmony_ci int32_t RemoveAppShareOption(const std::string &intention) override; 4714cf0368Sopenharmony_ci int32_t ObtainAsynProcess(AsyncProcessInfo& processInfo) override; 4814cf0368Sopenharmony_ci int32_t ClearAsynProcess() override; 4914cf0368Sopenharmony_ci 5014cf0368Sopenharmony_ciprivate: 5114cf0368Sopenharmony_ci class ServiceDeathRecipient : public IRemoteObject::DeathRecipient { 5214cf0368Sopenharmony_ci public: 5314cf0368Sopenharmony_ci ServiceDeathRecipient(); 5414cf0368Sopenharmony_ci virtual ~ServiceDeathRecipient(); 5514cf0368Sopenharmony_ci 5614cf0368Sopenharmony_ci void OnRemoteDied(const wptr<IRemoteObject> &remote) override; 5714cf0368Sopenharmony_ci }; 5814cf0368Sopenharmony_ci 5914cf0368Sopenharmony_ci static std::shared_ptr<UdmfServiceClient> instance_; 6014cf0368Sopenharmony_ci static std::mutex mutex_; 6114cf0368Sopenharmony_ci static sptr<DistributedKv::IKvStoreDataService> kvDataServiceProxy_; 6214cf0368Sopenharmony_ci static sptr<DistributedKv::IKvStoreDataService> GetDistributedKvDataService(); 6314cf0368Sopenharmony_ci sptr<UdmfServiceProxy> udmfProxy_; 6414cf0368Sopenharmony_ci}; 6514cf0368Sopenharmony_ci} // namespace UDMF 6614cf0368Sopenharmony_ci} // namespace OHOS 6714cf0368Sopenharmony_ci#endif // UDMF_SERVICE_CLIENT_H