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_INTERFACE_H 17 #define OHOS_ABILITY_RUNTIME_DATAOBS_MGR_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 "dataobs_mgr_errors.h" 26 #include "uri.h" 27 28 namespace OHOS { 29 namespace AAFwk { 30 using Uri = OHOS::Uri; 31 constexpr const char* DATAOBS_MANAGER_SERVICE_NAME = "DataObsMgrService"; 32 /** 33 * @class IDataObsMgr 34 * IDataObsMgr interface is used to access dataobs manager services. 35 */ 36 class IDataObsMgr : public OHOS::IRemoteBroker { 37 public: 38 DECLARE_INTERFACE_DESCRIPTOR(u"ohos.aafwk.DataObsMgr") 39 40 enum { 41 TRANS_HEAD, 42 REGISTER_OBSERVER = TRANS_HEAD, 43 UNREGISTER_OBSERVER, 44 NOTIFY_CHANGE, 45 REGISTER_OBSERVER_EXT, 46 UNREGISTER_OBSERVER_EXT, 47 UNREGISTER_OBSERVER_ALL_EXT, 48 NOTIFY_CHANGE_EXT, 49 NOTIFY_PROCESS, 50 TRANS_BUTT, 51 }; 52 /** 53 * Registers an observer to DataObsMgr specified by the given Uri. 54 * 55 * @param uri, Indicates the path of the data to operate. 56 * @param dataObserver, Indicates the IDataAbilityObserver object. 57 * 58 * @return Returns ERR_OK on success, others on failure. 59 */ 60 virtual int RegisterObserver(const Uri &uri, sptr<IDataAbilityObserver> dataObserver) = 0; 61 62 /** 63 * Deregisters an observer used for DataObsMgr specified by the given Uri. 64 * 65 * @param uri, Indicates the path of the data to operate. 66 * @param dataObserver, Indicates the IDataAbilityObserver object. 67 * 68 * @return Returns ERR_OK on success, others on failure. 69 */ 70 virtual int UnregisterObserver(const Uri &uri, sptr<IDataAbilityObserver> dataObserver) = 0; 71 72 /** 73 * Notifies the registered observers of a change to the data resource specified by Uri. 74 * 75 * @param uri, Indicates the path of the data to operate. 76 * 77 * @return Returns ERR_OK on success, others on failure. 78 */ 79 virtual int NotifyChange(const Uri &uri) = 0; 80 81 /** 82 * Registers an observer to DataObsMgr specified by the given Uri. 83 * 84 * @param uri, Indicates the path of the data to operate. 85 * @param dataObserver, Indicates the IDataAbilityObserver object. 86 * @param isDescendants, Indicates the Whether to note the change of descendants. 87 * 88 * @return Returns SUCCESS on success, others on failure. 89 */ 90 virtual Status RegisterObserverExt(const Uri &uri, sptr<IDataAbilityObserver> dataObserver, bool isDescendants) = 0; 91 92 /** 93 * Deregisters an observer used for DataObsMgr specified by the given Uri. 94 * 95 * @param uri, Indicates the path of the data to operate. 96 * @param dataObserver, Indicates the IDataAbilityObserver object. 97 * 98 * @return Returns SUCCESS on success, others on failure. 99 */ 100 virtual Status UnregisterObserverExt(const Uri &uri, sptr<IDataAbilityObserver> dataObserver) = 0; 101 102 /** 103 * Deregisters dataObserver used for DataObsMgr specified 104 * 105 * @param dataObserver, Indicates the IDataAbilityObserver object. 106 * 107 * @return Returns SUCCESS on success, others on failure. 108 */ 109 virtual Status UnregisterObserverExt(sptr<IDataAbilityObserver> dataObserver) = 0; 110 111 /** 112 * Notifies the registered observers of a change to the data resource specified by Uris. 113 * 114 * @param changeInfo Indicates the info of the data to operate. 115 * 116 * @return Returns SUCCESS on success, others on failure. 117 */ 118 virtual Status NotifyChangeExt(const ChangeInfo &changeInfo) = 0; 119 120 /** 121 * Notifies the process observer with the given progress key and cancel observer. 122 * 123 * @param key Identifies the progress of a specific task. 124 125 * @param observer Observer for monitoring the ongoing process. 126 * 127 * @return Returns SUCCESS on success, others on failure. 128 */ 129 virtual Status NotifyProcessObserver(const std::string &key, const sptr<IRemoteObject> &observer) = 0; 130 }; 131 } // namespace AAFwk 132 } // namespace OHOS 133 #endif // OHOS_ABILITY_RUNTIME_DATAOBS_MGR_INTERFACE_H 134