1eace7efcSopenharmony_ci/* 2eace7efcSopenharmony_ci * Copyright (c) 2021-2023 Huawei Device Co., Ltd. 3eace7efcSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4eace7efcSopenharmony_ci * you may not use this file except in compliance with the License. 5eace7efcSopenharmony_ci * You may obtain a copy of the License at 6eace7efcSopenharmony_ci * 7eace7efcSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8eace7efcSopenharmony_ci * 9eace7efcSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10eace7efcSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11eace7efcSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12eace7efcSopenharmony_ci * See the License for the specific language governing permissions and 13eace7efcSopenharmony_ci * limitations under the License. 14eace7efcSopenharmony_ci */ 15eace7efcSopenharmony_ci 16eace7efcSopenharmony_ci#ifndef OHOS_ABILITY_RUNTIME_DATAOBS_MGR_PROXY_H 17eace7efcSopenharmony_ci#define OHOS_ABILITY_RUNTIME_DATAOBS_MGR_PROXY_H 18eace7efcSopenharmony_ci 19eace7efcSopenharmony_ci#include "dataobs_mgr_interface.h" 20eace7efcSopenharmony_ci#include "iremote_proxy.h" 21eace7efcSopenharmony_ci#include "dataobs_mgr_errors.h" 22eace7efcSopenharmony_ci 23eace7efcSopenharmony_cinamespace OHOS { 24eace7efcSopenharmony_cinamespace AAFwk { 25eace7efcSopenharmony_ci/** 26eace7efcSopenharmony_ci * @class DataObsManagerProxy 27eace7efcSopenharmony_ci * DataObsManagerProxy. 28eace7efcSopenharmony_ci */ 29eace7efcSopenharmony_ciclass DataObsManagerProxy : public IRemoteProxy<IDataObsMgr> { 30eace7efcSopenharmony_cipublic: 31eace7efcSopenharmony_ci explicit DataObsManagerProxy(const sptr<IRemoteObject> &impl) : IRemoteProxy<IDataObsMgr>(impl) 32eace7efcSopenharmony_ci {} 33eace7efcSopenharmony_ci 34eace7efcSopenharmony_ci virtual ~DataObsManagerProxy() 35eace7efcSopenharmony_ci {} 36eace7efcSopenharmony_ci 37eace7efcSopenharmony_ci /** 38eace7efcSopenharmony_ci * Registers an observer to DataObsMgr specified by the given Uri. 39eace7efcSopenharmony_ci * 40eace7efcSopenharmony_ci * @param uri, Indicates the path of the data to operate. 41eace7efcSopenharmony_ci * @param dataObserver, Indicates the IDataAbilityObserver object. 42eace7efcSopenharmony_ci * 43eace7efcSopenharmony_ci * @return Returns ERR_OK on success, others on failure. 44eace7efcSopenharmony_ci */ 45eace7efcSopenharmony_ci 46eace7efcSopenharmony_ci virtual int RegisterObserver(const Uri &uri, sptr<IDataAbilityObserver> dataObserver) override; 47eace7efcSopenharmony_ci 48eace7efcSopenharmony_ci /** 49eace7efcSopenharmony_ci * Deregisters an observer used for DataObsMgr specified by the given Uri. 50eace7efcSopenharmony_ci * 51eace7efcSopenharmony_ci * @param uri, Indicates the path of the data to operate. 52eace7efcSopenharmony_ci * @param dataObserver, Indicates the IDataAbilityObserver object. 53eace7efcSopenharmony_ci * 54eace7efcSopenharmony_ci * @return Returns ERR_OK on success, others on failure. 55eace7efcSopenharmony_ci */ 56eace7efcSopenharmony_ci virtual int UnregisterObserver(const Uri &uri, sptr<IDataAbilityObserver> dataObserver) override; 57eace7efcSopenharmony_ci 58eace7efcSopenharmony_ci /** 59eace7efcSopenharmony_ci * Notifies the registered observers of a change to the data resource specified by Uri. 60eace7efcSopenharmony_ci * 61eace7efcSopenharmony_ci * @param uri, Indicates the path of the data to operate. 62eace7efcSopenharmony_ci * 63eace7efcSopenharmony_ci * @return Returns ERR_OK on success, others on failure. 64eace7efcSopenharmony_ci */ 65eace7efcSopenharmony_ci virtual int NotifyChange(const Uri &uri) override; 66eace7efcSopenharmony_ci 67eace7efcSopenharmony_ci /** 68eace7efcSopenharmony_ci * Registers an observer to DataObsMgr specified by the given Uri. 69eace7efcSopenharmony_ci * 70eace7efcSopenharmony_ci * @param uri, Indicates the path of the data to operate. 71eace7efcSopenharmony_ci * @param dataObserver, Indicates the IDataAbilityObserver object. 72eace7efcSopenharmony_ci * @param isDescendants, Indicates the Whether to note the change of descendants. 73eace7efcSopenharmony_ci * 74eace7efcSopenharmony_ci * @return Returns SUCCESS on success, others on failure. 75eace7efcSopenharmony_ci */ 76eace7efcSopenharmony_ci virtual Status RegisterObserverExt(const Uri &uri, sptr<IDataAbilityObserver> dataObserver, 77eace7efcSopenharmony_ci bool isDescendants) override; 78eace7efcSopenharmony_ci 79eace7efcSopenharmony_ci /** 80eace7efcSopenharmony_ci * Deregisters an observer used for DataObsMgr specified by the given Uri. 81eace7efcSopenharmony_ci * 82eace7efcSopenharmony_ci * @param uri, Indicates the path of the data to operate. 83eace7efcSopenharmony_ci * @param dataObserver, Indicates the IDataAbilityObserver object. 84eace7efcSopenharmony_ci * 85eace7efcSopenharmony_ci * @return Returns SUCCESS on success, others on failure. 86eace7efcSopenharmony_ci */ 87eace7efcSopenharmony_ci virtual Status UnregisterObserverExt(const Uri &uri, sptr<IDataAbilityObserver> dataObserver) override; 88eace7efcSopenharmony_ci 89eace7efcSopenharmony_ci /** 90eace7efcSopenharmony_ci * Deregisters dataObserver used for DataObsMgr specified 91eace7efcSopenharmony_ci * 92eace7efcSopenharmony_ci * @param dataObserver, Indicates the IDataAbilityObserver object. 93eace7efcSopenharmony_ci * 94eace7efcSopenharmony_ci * @return Returns SUCCESS on success, others on failure. 95eace7efcSopenharmony_ci */ 96eace7efcSopenharmony_ci virtual Status UnregisterObserverExt(sptr<IDataAbilityObserver> dataObserver) override; 97eace7efcSopenharmony_ci 98eace7efcSopenharmony_ci /** 99eace7efcSopenharmony_ci * Notifies the registered observers of a change to the data resource specified by Uris. 100eace7efcSopenharmony_ci * 101eace7efcSopenharmony_ci * @param changeInfo Indicates the info of the data to operate. 102eace7efcSopenharmony_ci * 103eace7efcSopenharmony_ci * @return Returns SUCCESS on success, others on failure. 104eace7efcSopenharmony_ci */ 105eace7efcSopenharmony_ci virtual Status NotifyChangeExt(const ChangeInfo &changeInfo) override; 106eace7efcSopenharmony_ci 107eace7efcSopenharmony_ciprivate: 108eace7efcSopenharmony_ci bool WriteInterfaceToken(MessageParcel &data); 109eace7efcSopenharmony_ci bool WriteParam(MessageParcel &data, const Uri &uri, sptr<IDataAbilityObserver> dataObserver); 110eace7efcSopenharmony_ci int SendTransactCmd(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option); 111eace7efcSopenharmony_ci 112eace7efcSopenharmony_ciprivate: 113eace7efcSopenharmony_ci static inline BrokerDelegator<DataObsManagerProxy> delegator_; 114eace7efcSopenharmony_ci}; 115eace7efcSopenharmony_ci} // namespace AAFwk 116eace7efcSopenharmony_ci} // namespace OHOS 117eace7efcSopenharmony_ci#endif // OHOS_ABILITY_RUNTIME_DATAOBS_MGR_PROXY_H 118