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 DISTRIBUTEDDATASERVICE_OBJECT_SERVICE_H 17 #define DISTRIBUTEDDATASERVICE_OBJECT_SERVICE_H 18 19 #include "feature/static_acts.h" 20 #include "metadata/store_meta_data.h" 21 #include "object_manager.h" 22 #include "object_service_stub.h" 23 #include "visibility.h" 24 25 namespace OHOS::DistributedObject { 26 class ObjectServiceImpl : public ObjectServiceStub { 27 public: 28 using Handler = std::function<void(int, std::map<std::string, std::vector<std::string>> &)>; 29 ObjectServiceImpl(); 30 virtual ~ObjectServiceImpl(); 31 int32_t ObjectStoreSave(const std::string &bundleName, const std::string &sessionId, 32 const std::string &deviceId, const std::map<std::string, std::vector<uint8_t>> &data, 33 sptr<IRemoteObject> callback) override; 34 int32_t ObjectStoreRetrieve( 35 const std::string &bundleName, const std::string &sessionId, sptr<IRemoteObject> callback) override; 36 int32_t ObjectStoreRevokeSave(const std::string &bundleName, const std::string &sessionId, 37 sptr<IRemoteObject> callback) override; 38 int32_t RegisterDataObserver(const std::string &bundleName, const std::string &sessionId, 39 sptr<IRemoteObject> callback) override; 40 int32_t UnregisterDataChangeObserver(const std::string &bundleName, const std::string &sessionId) override; 41 int32_t RegisterProgressObserver(const std::string &bundleName, const std::string &sessionId, 42 sptr<IRemoteObject> callback) override; 43 int32_t UnregisterProgressObserver(const std::string &bundleName, const std::string &sessionId) override; 44 int32_t DeleteSnapshot(const std::string &bundleName, const std::string &sessionId) override; 45 int32_t IsBundleNameEqualTokenId( 46 const std::string &bundleName, const std::string &sessionId, const uint32_t &tokenId); 47 int32_t ResolveAutoLaunch(const std::string &identifier, DistributedDB::AutoLaunchParam ¶m) override; 48 int32_t OnAppExit(pid_t uid, pid_t pid, uint32_t tokenId, const std::string &appId) override; 49 int32_t OnInitialize() override; 50 int32_t OnUserChange(uint32_t code, const std::string &user, const std::string &account) override; 51 int32_t OnBind(const BindInfo &bindInfo) override; 52 void DumpObjectServiceInfo(int fd, std::map<std::string, std::vector<std::string>> ¶ms); 53 int32_t OnAssetChanged(const std::string &bundleName, const std::string &sessionId, 54 const std::string &deviceId, const ObjectStore::Asset &assetValue) override; 55 int32_t BindAssetStore(const std::string &bundleName, const std::string &sessionId, 56 ObjectStore::Asset &asset, ObjectStore::AssetBindInfo &bindInfo) override; 57 int32_t IsContinue(bool &result) override; 58 private: 59 using StaticActs = DistributedData::StaticActs; 60 class ObjectStatic : public StaticActs { 61 public: ~ObjectStatic()62 ~ObjectStatic() override {}; 63 int32_t OnAppUninstall(const std::string &bundleName, int32_t user, int32_t index) override; 64 }; 65 class Factory { 66 public: 67 Factory(); 68 ~Factory(); 69 private: 70 std::shared_ptr<ObjectStatic> staticActs_; 71 }; 72 void RegisterObjectServiceInfo(); 73 void RegisterHandler(); 74 int32_t SaveMetaData(StoreMetaData& saveMeta); 75 void UpdateMetaData(); 76 77 static Factory factory_; 78 std::shared_ptr<ExecutorPool> executors_; 79 static constexpr int64_t WAIT_ACCOUNT_SERVICE = 5; 80 }; 81 } // namespace OHOS::DistributedObject 82 #endif 83