1 /* 2 * Copyright (c) 2021 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_ABILITY_RUNTIME_DATAOBS_MGR_PROXY_H 17 #define OHOS_ABILITY_RUNTIME_DATAOBS_MGR_PROXY_H 18 19 #include "dataobs_mgr_interface.h" 20 #include "iremote_proxy.h" 21 22 namespace OHOS { 23 namespace AAFwk { 24 /** 25 * @class DataObsManagerProxy 26 * DataObsManagerProxy. 27 */ 28 class DataObsManagerProxy : public IRemoteProxy<IDataObsMgr> { 29 public: DataObsManagerProxy(const sptr<IRemoteObject> & impl)30 explicit DataObsManagerProxy(const sptr<IRemoteObject> &impl) : IRemoteProxy<IDataObsMgr>(impl) 31 {} 32 ~DataObsManagerProxy()33 virtual ~DataObsManagerProxy() 34 {} 35 36 /** 37 * Registers an observer to DataObsMgr specified by the given Uri. 38 * 39 * @param uri, Indicates the path of the data to operate. 40 * @param dataObserver, Indicates the IDataAbilityObserver object. 41 * 42 * @return Returns ERR_OK on success, others on failure. 43 */ 44 45 virtual int RegisterObserver(const Uri &uri, const sptr<IDataAbilityObserver> &dataObserver); 46 47 /** 48 * Deregisters an observer used for DataObsMgr specified by the given Uri. 49 * 50 * @param uri, Indicates the path of the data to operate. 51 * @param dataObserver, Indicates the IDataAbilityObserver object. 52 * 53 * @return Returns ERR_OK on success, others on failure. 54 */ 55 virtual int UnregisterObserver(const Uri &uri, const sptr<IDataAbilityObserver> &dataObserver); 56 57 /** 58 * Notifies the registered observers of a change to the data resource specified by Uri. 59 * 60 * @param uri, Indicates the path of the data to operate. 61 * 62 * @return Returns ERR_OK on success, others on failure. 63 */ 64 virtual int NotifyChange(const Uri &uri); 65 66 private: 67 bool WriteInterfaceToken(MessageParcel &data); 68 69 private: 70 static inline BrokerDelegator<DataObsManagerProxy> delegator_; 71 }; 72 } // namespace AAFwk 73 } // namespace OHOS 74 #endif // OHOS_ABILITY_RUNTIME_DATAOBS_MGR_PROXY_H 75