1 /* 2 * Copyright (c) 2022 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 OBJECT_CLIENT_ADAPTOR_H 17 #define OBJECT_CLIENT_ADAPTOR_H 18 19 #include "object_service_proxy.h" 20 #include "iobject_service.h" 21 22 namespace OHOS::ObjectStore { 23 class ObjectStoreDataServiceProxy; 24 class ClientAdaptor { 25 public: 26 static sptr<OHOS::DistributedObject::IObjectService> GetObjectService(); 27 static uint32_t RegisterClientDeathListener(const std::string &appId, sptr<IRemoteObject> remoteObject); 28 private: 29 static constexpr int32_t DISTRIBUTED_KV_DATA_SERVICE_ABILITY_ID = 1301; 30 static constexpr int32_t GET_SA_RETRY_TIMES = 3; 31 static constexpr int32_t RETRY_INTERVAL = 1; 32 static std::shared_ptr<ObjectStoreDataServiceProxy> distributedDataMgr_; 33 static std::shared_ptr<ObjectStoreDataServiceProxy> GetDistributedDataManager(); 34 }; 35 36 class ObjectStoreDataServiceProxy : public IRemoteProxy<DistributedObject::IKvStoreDataService> { 37 public: 38 explicit ObjectStoreDataServiceProxy(const sptr<IRemoteObject> &impl); 39 ~ObjectStoreDataServiceProxy() = default; 40 sptr<IRemoteObject> GetFeatureInterface(const std::string &name) override; 41 uint32_t RegisterClientDeathObserver(const std::string &appId, sptr<IRemoteObject> observer) override; 42 }; 43 } // namespace OHOS::ObjectStore 44 45 #endif // OBJECT_CLIENT_ADAPTOR_H 46