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_AAFWK_DATAOBS_MANAGER_INTERFACE_H 17 #define OHOS_AAFWK_DATAOBS_MANAGER_INTERFACE_H 18 19 #include <vector> 20 21 #include <ipc_types.h> 22 #include <iremote_broker.h> 23 24 #include "data_ability_observer_interface.h" 25 #include "uri.h" 26 27 namespace OHOS { 28 namespace AAFwk { 29 using Uri = OHOS::Uri; 30 const std::string DATAOBS_MANAGER_SERVICE_NAME = "DataObsMgrService"; 31 /** 32 * @class IDataObsMgr 33 * IDataObsMgr interface is used to access dataobs manager services. 34 */ 35 class IDataObsMgr : public OHOS::IRemoteBroker { 36 public: 37 DECLARE_INTERFACE_DESCRIPTOR(u"ohos.aafwk.DataObsMgr") 38 39 /** 40 * Registers an observer to DataObsMgr specified by the given Uri. 41 * 42 * @param uri, Indicates the path of the data to operate. 43 * @param dataObserver, Indicates the IDataAbilityObserver object. 44 * 45 * @return Returns ERR_OK on success, others on failure. 46 */ 47 virtual int RegisterObserver(const Uri &uri, const sptr<IDataAbilityObserver> &dataObserver) = 0; 48 49 /** 50 * Deregisters an observer used for DataObsMgr specified by the given Uri. 51 * 52 * @param uri, Indicates the path of the data to operate. 53 * @param dataObserver, Indicates the IDataAbilityObserver object. 54 * 55 * @return Returns ERR_OK on success, others on failure. 56 */ 57 virtual int UnregisterObserver(const Uri &uri, const sptr<IDataAbilityObserver> &dataObserver) = 0; 58 59 /** 60 * Notifies the registered observers of a change to the data resource specified by Uri. 61 * 62 * @param uri, Indicates the path of the data to operate. 63 * 64 * @return Returns ERR_OK on success, others on failure. 65 */ 66 virtual int NotifyChange(const Uri &uri) = 0; 67 68 enum { 69 // ipc id 1-1000 for kit 70 // ipc id for RegisterObserver (1) 71 REGISTER_OBSERVER = 1, 72 73 // ipc id for UnregisterObserver (2) 74 UNREGISTER_OBSERVER, 75 76 // ipc id for NotifyChange (3) 77 NOTIFY_CHANGE, 78 }; 79 }; 80 } // namespace AAFwk 81 } // namespace OHOS 82 #endif // OHOS_AAFWK_DATAOBS_MANAGER_INTERFACE_H 83