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 #include "datashare_stub.h"
17 
18 #include <cinttypes>
19 
20 #include "data_ability_observer_interface.h"
21 #include "datashare_itypes_utils.h"
22 #include "datashare_log.h"
23 #include "ipc_skeleton.h"
24 #include "ipc_types.h"
25 #include "ishared_result_set.h"
26 #include "datashare_operation_statement.h"
27 #include "unistd.h"
28 #include "string_ex.h"
29 
30 using namespace OHOS::DistributedShare::DataShare;
31 
32 namespace OHOS {
33 namespace DataShare {
34 constexpr int DEFAULT_NUMBER = -1;
35 constexpr int PERMISSION_ERROR_NUMBER = -2;
DataShareStub()36 DataShareStub::DataShareStub()
37 {
38     stubFuncMap_[static_cast<uint32_t>(IDataShareInterfaceCode::CMD_GET_FILE_TYPES)] = &DataShareStub::CmdGetFileTypes;
39     stubFuncMap_[static_cast<uint32_t>(IDataShareInterfaceCode::CMD_OPEN_FILE)] = &DataShareStub::CmdOpenFile;
40     stubFuncMap_[static_cast<uint32_t>(IDataShareInterfaceCode::CMD_OPEN_RAW_FILE)] = &DataShareStub::CmdOpenRawFile;
41     stubFuncMap_[static_cast<uint32_t>(IDataShareInterfaceCode::CMD_INSERT)] = &DataShareStub::CmdInsert;
42     stubFuncMap_[static_cast<uint32_t>(IDataShareInterfaceCode::CMD_UPDATE)] = &DataShareStub::CmdUpdate;
43     stubFuncMap_[static_cast<uint32_t>(IDataShareInterfaceCode::CMD_DELETE)] = &DataShareStub::CmdDelete;
44     stubFuncMap_[static_cast<uint32_t>(IDataShareInterfaceCode::CMD_QUERY)] = &DataShareStub::CmdQuery;
45     stubFuncMap_[static_cast<uint32_t>(IDataShareInterfaceCode::CMD_GET_TYPE)] = &DataShareStub::CmdGetType;
46     stubFuncMap_[static_cast<uint32_t>(IDataShareInterfaceCode::CMD_BATCH_INSERT)] = &DataShareStub::CmdBatchInsert;
47     stubFuncMap_[static_cast<uint32_t>(IDataShareInterfaceCode::CMD_REGISTER_OBSERVER)] =
48         &DataShareStub::CmdRegisterObserver;
49     stubFuncMap_[static_cast<uint32_t>(IDataShareInterfaceCode::CMD_UNREGISTER_OBSERVER)] =
50         &DataShareStub::CmdUnregisterObserver;
51     stubFuncMap_[static_cast<uint32_t>(IDataShareInterfaceCode::CMD_NOTIFY_CHANGE)] = &DataShareStub::CmdNotifyChange;
52     stubFuncMap_[static_cast<uint32_t>(IDataShareInterfaceCode::CMD_NORMALIZE_URI)] = &DataShareStub::CmdNormalizeUri;
53     stubFuncMap_[static_cast<uint32_t>(IDataShareInterfaceCode::CMD_DENORMALIZE_URI)] =
54         &DataShareStub::CmdDenormalizeUri;
55     stubFuncMap_[static_cast<uint32_t>(IDataShareInterfaceCode::CMD_EXECUTE_BATCH)] = &DataShareStub::CmdExecuteBatch;
56     stubFuncMap_[static_cast<uint32_t>(IDataShareInterfaceCode::CMD_INSERT_EXT)] = &DataShareStub::CmdInsertExt;
57     stubFuncMap_[static_cast<uint32_t>(IDataShareInterfaceCode::CMD_BATCH_UPDATE)] = &DataShareStub::CmdBatchUpdate;
58     stubFuncMap_[static_cast<uint32_t>(IDataShareInterfaceCode::CMD_INSERT_EX)] = &DataShareStub::CmdInsertEx;
59     stubFuncMap_[static_cast<uint32_t>(IDataShareInterfaceCode::CMD_UPDATE_EX)] = &DataShareStub::CmdUpdateEx;
60     stubFuncMap_[static_cast<uint32_t>(IDataShareInterfaceCode::CMD_DELETE_EX)] = &DataShareStub::CmdDeleteEx;
61 }
62 
~DataShareStub()63 DataShareStub::~DataShareStub()
64 {
65     stubFuncMap_.clear();
66 }
67 
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)68 int DataShareStub::OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply,
69     MessageOption& option)
70 {
71     std::u16string descriptor = DataShareStub::GetDescriptor();
72     std::u16string remoteDescriptor = data.ReadInterfaceToken();
73     if (descriptor != remoteDescriptor) {
74         LOG_INFO("local descriptor is not equal to remote, localDescriptor = %{public}s, remoteDescriptor = %{public}s",
75             Str16ToStr8(descriptor).c_str(), Str16ToStr8(remoteDescriptor).c_str());
76         return ERR_INVALID_STATE;
77     }
78 
79     const auto &itFunc = stubFuncMap_.find(code);
80     if (itFunc != stubFuncMap_.end()) {
81         auto start = std::chrono::steady_clock::now();
82         auto ret = (this->*(itFunc->second))(data, reply);
83         auto finish = std::chrono::steady_clock::now();
84         auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(finish - start);
85         if (duration >= TIME_THRESHOLD) {
86             auto callingPid = IPCSkeleton::GetCallingPid();
87             int64_t milliseconds = duration.count();
88             LOG_ERROR("extension time over, code:%{public}u callingPid:%{public}d, cost:%{public}" PRIi64 "ms",
89                 code, callingPid, milliseconds);
90         }
91         return ret;
92     }
93 
94     LOG_DEBUG("remote request unhandled: %{public}d", code);
95     return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
96 }
97 
CmdGetFileTypes(MessageParcel & data,MessageParcel & reply)98 ErrCode DataShareStub::CmdGetFileTypes(MessageParcel &data, MessageParcel &reply)
99 {
100     Uri uri("");
101     std::string mimeTypeFilter;
102     if (!ITypesUtil::Unmarshal(data, uri, mimeTypeFilter)) {
103         LOG_ERROR("Unmarshalling value is nullptr");
104         return ERR_INVALID_VALUE;
105     }
106     if (mimeTypeFilter.empty()) {
107         LOG_ERROR("mimeTypeFilter is nullptr");
108         return ERR_INVALID_VALUE;
109     }
110     std::vector<std::string> types = GetFileTypes(uri, mimeTypeFilter);
111     if (!ITypesUtil::Marshal(reply, types)) {
112         LOG_ERROR("Marshal value is nullptr");
113         return ERR_INVALID_VALUE;
114     }
115     return E_OK;
116 }
117 
CmdOpenFile(MessageParcel & data,MessageParcel & reply)118 ErrCode DataShareStub::CmdOpenFile(MessageParcel &data, MessageParcel &reply)
119 {
120     Uri uri("");
121     std::string mode;
122     if (!ITypesUtil::Unmarshal(data, uri, mode)) {
123         LOG_ERROR("Unmarshalling value is nullptr");
124         return ERR_INVALID_VALUE;
125     }
126     if (mode.empty()) {
127         LOG_ERROR("mode is nullptr");
128         return ERR_INVALID_VALUE;
129     }
130     int fd = OpenFile(uri, mode);
131     if (fd < 0) {
132         return ERR_INVALID_DATA;
133     }
134     if (!reply.WriteFileDescriptor(fd)) {
135         LOG_ERROR("fail to WriteFileDescriptor fd");
136         close(fd);
137         return ERR_INVALID_VALUE;
138     }
139     close(fd);
140     return E_OK;
141 }
142 
CmdOpenRawFile(MessageParcel & data,MessageParcel & reply)143 ErrCode DataShareStub::CmdOpenRawFile(MessageParcel &data, MessageParcel &reply)
144 {
145     Uri uri("");
146     std::string mode;
147     if (!ITypesUtil::Unmarshal(data, uri, mode)) {
148         LOG_ERROR("Unmarshalling value is nullptr");
149         return ERR_INVALID_VALUE;
150     }
151     int fd = OpenRawFile(uri, mode);
152     if (!ITypesUtil::Marshal(reply, fd)) {
153         LOG_ERROR("Marshal value is nullptr");
154         return ERR_INVALID_VALUE;
155     }
156     return E_OK;
157 }
158 
CmdInsert(MessageParcel & data,MessageParcel & reply)159 ErrCode DataShareStub::CmdInsert(MessageParcel &data, MessageParcel &reply)
160 {
161     Uri uri("");
162     DataShareValuesBucket value;
163     if (!ITypesUtil::Unmarshal(data, uri, value)) {
164         LOG_ERROR("Unmarshalling value is nullptr");
165         return ERR_INVALID_VALUE;
166     }
167     int index = Insert(uri, value);
168     if (index == DEFAULT_NUMBER) {
169         LOG_ERROR("Insert inner error");
170         return ERR_INVALID_VALUE;
171     } else if (index == PERMISSION_ERROR_NUMBER) {
172         LOG_ERROR("Insert permission error");
173         return ERR_PERMISSION_DENIED;
174     }
175     if (!reply.WriteInt32(index)) {
176         LOG_ERROR("fail to WriteInt32 index");
177         return ERR_INVALID_VALUE;
178     }
179     return E_OK;
180 }
181 
CmdUpdate(MessageParcel & data,MessageParcel & reply)182 ErrCode DataShareStub::CmdUpdate(MessageParcel &data, MessageParcel &reply)
183 {
184     Uri uri("");
185     DataSharePredicates predicates;
186     DataShareValuesBucket value;
187     if (!ITypesUtil::Unmarshal(data, uri, predicates, value)) {
188         LOG_ERROR("Unmarshalling predicates is nullptr");
189         return ERR_INVALID_VALUE;
190     }
191     int index = Update(uri, predicates, value);
192     if (index == DEFAULT_NUMBER) {
193         LOG_ERROR("Update inner error");
194         return ERR_INVALID_VALUE;
195     } else if (index == PERMISSION_ERROR_NUMBER) {
196         LOG_ERROR("Update permission error");
197         return ERR_PERMISSION_DENIED;
198     }
199     if (!reply.WriteInt32(index)) {
200         LOG_ERROR("fail to WriteInt32 index");
201         return ERR_INVALID_VALUE;
202     }
203     return E_OK;
204 }
205 
CmdBatchUpdate(OHOS::MessageParcel & data,OHOS::MessageParcel & reply)206 ErrCode DataShareStub::CmdBatchUpdate(OHOS::MessageParcel &data, OHOS::MessageParcel &reply)
207 {
208     UpdateOperations updateOperations;
209     if (!ITypesUtil::Unmarshal(data, updateOperations)) {
210         LOG_ERROR("Unmarshalling updateOperations is nullptr");
211         return ERR_INVALID_VALUE;
212     }
213     std::vector<BatchUpdateResult> results;
214     int ret = BatchUpdate(updateOperations, results);
215     if (ret != E_OK) {
216         LOG_ERROR("BatchUpdate inner error, ret is %{public}d.", ret);
217         return ret;
218     }
219     if (!ITypesUtil::Marshal(reply, results)) {
220         LOG_ERROR("marshalling updateOperations is failed");
221         return ERR_INVALID_VALUE;
222     }
223     return E_OK;
224 }
225 
CmdDelete(MessageParcel & data,MessageParcel & reply)226 ErrCode DataShareStub::CmdDelete(MessageParcel &data, MessageParcel &reply)
227 {
228     Uri uri("");
229     DataSharePredicates predicates;
230     if (!ITypesUtil::Unmarshal(data, uri, predicates)) {
231         LOG_ERROR("Unmarshalling predicates is nullptr");
232         return ERR_INVALID_VALUE;
233     }
234     int index = Delete(uri, predicates);
235     if (index == DEFAULT_NUMBER) {
236         LOG_ERROR("Delete inner error");
237         return ERR_INVALID_VALUE;
238     } else if (index == PERMISSION_ERROR_NUMBER) {
239         LOG_ERROR("Delete permission error");
240         return ERR_PERMISSION_DENIED;
241     }
242     if (!reply.WriteInt32(index)) {
243         LOG_ERROR("fail to WriteInt32 index");
244         return ERR_INVALID_VALUE;
245     }
246     return E_OK;
247 }
248 
CmdInsertEx(MessageParcel & data,MessageParcel & reply)249 ErrCode DataShareStub::CmdInsertEx(MessageParcel &data, MessageParcel &reply)
250 {
251     Uri uri("");
252     DataShareValuesBucket value;
253     if (!ITypesUtil::Unmarshal(data, uri, value)) {
254         LOG_ERROR("Unmarshalling value is nullptr");
255         return E_UNMARSHAL_ERROR;
256     }
257 
258     auto [errCode, result] = InsertEx(uri, value);
259     if (errCode == DEFAULT_NUMBER) {
260         LOG_ERROR("Insert inner error");
261         return ERR_INVALID_VALUE;
262     } else if (errCode == PERMISSION_ERROR_NUMBER) {
263         LOG_ERROR("Insert permission error");
264         return ERR_PERMISSION_DENIED;
265     }
266 
267     if (!ITypesUtil::Marshal(reply, errCode, result)) {
268         LOG_ERROR("Marshal value is nullptr");
269         return E_MARSHAL_ERROR;
270     }
271     return E_OK;
272 }
273 
CmdUpdateEx(MessageParcel & data,MessageParcel & reply)274 ErrCode DataShareStub::CmdUpdateEx(MessageParcel &data, MessageParcel &reply)
275 {
276     Uri uri("");
277     DataSharePredicates predicates;
278     DataShareValuesBucket value;
279     if (!ITypesUtil::Unmarshal(data, uri, predicates, value)) {
280         LOG_ERROR("Unmarshalling predicates is nullptr");
281         return E_UNMARSHAL_ERROR;
282     }
283 
284     auto [errCode, result] = UpdateEx(uri, predicates, value);
285     if (errCode == DEFAULT_NUMBER) {
286         LOG_ERROR("Update inner error");
287         return ERR_INVALID_VALUE;
288     } else if (errCode == PERMISSION_ERROR_NUMBER) {
289         LOG_ERROR("Update permission error");
290         return ERR_PERMISSION_DENIED;
291     }
292 
293     if (!ITypesUtil::Marshal(reply, errCode, result)) {
294         LOG_ERROR("Marshal value is nullptr");
295         return E_MARSHAL_ERROR;
296     }
297     return E_OK;
298 }
299 
CmdDeleteEx(MessageParcel & data,MessageParcel & reply)300 ErrCode DataShareStub::CmdDeleteEx(MessageParcel &data, MessageParcel &reply)
301 {
302     Uri uri("");
303     DataSharePredicates predicates;
304     if (!ITypesUtil::Unmarshal(data, uri, predicates)) {
305         LOG_ERROR("Unmarshalling predicates is nullptr");
306         return E_UNMARSHAL_ERROR;
307     }
308     auto [errCode, result] = DeleteEx(uri, predicates);
309     if (errCode == DEFAULT_NUMBER) {
310         LOG_ERROR("Delete inner error");
311         return ERR_INVALID_VALUE;
312     } else if (errCode == PERMISSION_ERROR_NUMBER) {
313         LOG_ERROR("Delete permission error");
314         return ERR_PERMISSION_DENIED;
315     }
316     if (!ITypesUtil::Marshal(reply, errCode, result)) {
317         LOG_ERROR("Marshal value is nullptr");
318         return E_MARSHAL_ERROR;
319     }
320     return E_OK;
321 }
322 
CmdQuery(MessageParcel & data,MessageParcel & reply)323 ErrCode DataShareStub::CmdQuery(MessageParcel &data, MessageParcel &reply)
324 {
325     Uri uri("");
326     DataSharePredicates predicates;
327     std::vector<std::string> columns;
328     if (!ITypesUtil::Unmarshal(data, uri, predicates, columns)) {
329         LOG_ERROR("Unmarshalling predicates is nullptr");
330         return ERR_INVALID_VALUE;
331     }
332     DatashareBusinessError businessError;
333     auto resultSet = Query(uri, predicates, columns, businessError);
334     auto result = ISharedResultSet::WriteToParcel(std::move(resultSet), reply);
335     reply.WriteInt32(businessError.GetCode());
336     reply.WriteString(businessError.GetMessage());
337     if (result == nullptr) {
338         LOG_ERROR("!resultSet->Marshalling(reply)");
339         return ERR_INVALID_VALUE;
340     }
341     return E_OK;
342 }
343 
CmdGetType(MessageParcel & data,MessageParcel & reply)344 ErrCode DataShareStub::CmdGetType(MessageParcel &data, MessageParcel &reply)
345 {
346     Uri uri("");
347     if (!ITypesUtil::Unmarshal(data, uri)) {
348         LOG_ERROR("Unmarshalling predicates is nullptr");
349         return ERR_INVALID_VALUE;
350     }
351     std::string type = GetType(uri);
352     if (!reply.WriteString(type)) {
353         LOG_ERROR("fail to WriteString type");
354         return ERR_INVALID_VALUE;
355     }
356     return E_OK;
357 }
358 
CmdBatchInsert(MessageParcel & data,MessageParcel & reply)359 ErrCode DataShareStub::CmdBatchInsert(MessageParcel &data, MessageParcel &reply)
360 {
361     Uri uri("");
362     std::vector<DataShareValuesBucket> values;
363     if (!ITypesUtil::Unmarshal(data, uri, values)) {
364         LOG_ERROR("Unmarshalling predicates is nullptr");
365         return ERR_INVALID_VALUE;
366     }
367 
368     int ret = BatchInsert(uri, values);
369     if (ret == DEFAULT_NUMBER) {
370         LOG_ERROR("BatchInsert inner error");
371         return ERR_INVALID_VALUE;
372     } else if (ret == PERMISSION_ERROR_NUMBER) {
373         LOG_ERROR("BatchInsert permission error");
374         return ERR_PERMISSION_DENIED;
375     }
376     if (!reply.WriteInt32(ret)) {
377         LOG_ERROR("fail to WriteInt32 ret");
378         return ERR_INVALID_VALUE;
379     }
380     return E_OK;
381 }
382 
CmdRegisterObserver(MessageParcel & data,MessageParcel & reply)383 ErrCode DataShareStub::CmdRegisterObserver(MessageParcel &data, MessageParcel &reply)
384 {
385     Uri uri("");
386     sptr<IRemoteObject> observer;
387     if (!ITypesUtil::Unmarshal(data, uri, observer)) {
388         LOG_ERROR("Unmarshalling predicates is nullptr");
389         return ERR_INVALID_VALUE;
390     }
391     auto obServer = iface_cast<AAFwk::IDataAbilityObserver>(observer);
392     if (obServer == nullptr) {
393         LOG_ERROR("obServer is nullptr");
394         return ERR_INVALID_VALUE;
395     }
396 
397     bool ret = RegisterObserver(uri, obServer);
398     if (!reply.WriteInt32(ret)) {
399         LOG_ERROR("fail to WriteInt32 ret");
400         return ERR_INVALID_VALUE;
401     }
402     return E_OK;
403 }
404 
CmdUnregisterObserver(MessageParcel & data,MessageParcel & reply)405 ErrCode DataShareStub::CmdUnregisterObserver(MessageParcel &data, MessageParcel &reply)
406 {
407     Uri uri("");
408     sptr<IRemoteObject> observer;
409     if (!ITypesUtil::Unmarshal(data, uri, observer)) {
410         LOG_ERROR("Unmarshalling predicates is nullptr");
411         return ERR_INVALID_VALUE;
412     }
413     auto obServer = iface_cast<AAFwk::IDataAbilityObserver>(observer);
414     if (obServer == nullptr) {
415         LOG_ERROR("obServer is nullptr");
416         return ERR_INVALID_VALUE;
417     }
418 
419     bool ret = UnregisterObserver(uri, obServer);
420     if (!reply.WriteInt32(ret)) {
421         LOG_ERROR("fail to WriteInt32 ret");
422         return ERR_INVALID_VALUE;
423     }
424     return E_OK;
425 }
426 
CmdNotifyChange(MessageParcel & data,MessageParcel & reply)427 ErrCode DataShareStub::CmdNotifyChange(MessageParcel &data, MessageParcel &reply)
428 {
429     Uri uri("");
430     if (!ITypesUtil::Unmarshal(data, uri)) {
431         LOG_ERROR("Unmarshalling predicates is nullptr");
432         return ERR_INVALID_VALUE;
433     }
434 
435     bool ret = NotifyChange(uri);
436     if (!reply.WriteInt32(ret)) {
437         LOG_ERROR("fail to WriteInt32 ret");
438         return ERR_INVALID_VALUE;
439     }
440     return E_OK;
441 }
442 
CmdNormalizeUri(MessageParcel & data,MessageParcel & reply)443 ErrCode DataShareStub::CmdNormalizeUri(MessageParcel &data, MessageParcel &reply)
444 {
445     Uri uri("");
446     if (!ITypesUtil::Unmarshal(data, uri)) {
447         LOG_ERROR("Unmarshalling predicates is nullptr");
448         return ERR_INVALID_VALUE;
449     }
450     auto ret = NormalizeUri(uri);
451     if (!ITypesUtil::Marshal(reply, ret)) {
452         LOG_ERROR("Write to message parcel failed!");
453         return ERR_INVALID_VALUE;
454     }
455     return E_OK;
456 }
457 
CmdDenormalizeUri(MessageParcel & data,MessageParcel & reply)458 ErrCode DataShareStub::CmdDenormalizeUri(MessageParcel &data, MessageParcel &reply)
459 {
460     Uri uri("");
461     if (!ITypesUtil::Unmarshal(data, uri)) {
462         LOG_ERROR("Unmarshalling predicates is nullptr");
463         return ERR_INVALID_VALUE;
464     }
465 
466     auto ret = DenormalizeUri(uri);
467     if (!ITypesUtil::Marshal(reply, ret)) {
468         LOG_ERROR("Write to message parcel failed!");
469         return ERR_INVALID_VALUE;
470     }
471     return E_OK;
472 }
473 
CmdExecuteBatch(MessageParcel & data,MessageParcel & reply)474 ErrCode DataShareStub::CmdExecuteBatch(MessageParcel &data, MessageParcel &reply)
475 {
476     std::vector<OperationStatement> statements;
477     ExecResultSet result;
478     if (!ITypesUtil::Unmarshal(data, statements)) {
479         LOG_ERROR("Unmarshalling OperationStatement failed");
480         return ERR_INVALID_VALUE;
481     }
482     auto ret = ExecuteBatch(statements, result);
483     if (ret == DEFAULT_NUMBER) {
484         LOG_ERROR("ExecuteBatch error");
485         return ERR_INVALID_VALUE;
486     }
487     if (!ITypesUtil::Marshal(reply, result)) {
488         LOG_ERROR("fail to write result");
489         return ERR_INVALID_VALUE;
490     }
491     return E_OK;
492 }
493 
CmdInsertExt(MessageParcel & data,MessageParcel & reply)494 ErrCode DataShareStub::CmdInsertExt(MessageParcel &data, MessageParcel &reply)
495 {
496     Uri uri("");
497     DataShareValuesBucket value;
498     if (!ITypesUtil::Unmarshal(data, uri, value)) {
499         LOG_ERROR("Unmarshalling value is nullptr");
500         return ERR_INVALID_VALUE;
501     }
502     std::string result;
503     int index = InsertExt(uri, value, result);
504     if (index == DEFAULT_NUMBER) {
505         LOG_ERROR("Insert inner error");
506         return ERR_INVALID_VALUE;
507     }
508     if (!ITypesUtil::Marshal(reply, index, result)) {
509         LOG_ERROR("fail to write result");
510         return ERR_INVALID_VALUE;
511     }
512     return E_OK;
513 }
514 
ExecuteBatch(const std::vector<OperationStatement> & statements,ExecResultSet & result)515 int DataShareStub::ExecuteBatch(const std::vector<OperationStatement> &statements, ExecResultSet &result)
516 {
517     return 0;
518 }
519 
InsertExt(const Uri & uri,const DataShareValuesBucket & value,std::string & result)520 int DataShareStub::InsertExt(const Uri &uri, const DataShareValuesBucket &value, std::string &result)
521 {
522     return 0;
523 }
524 
BatchUpdate(const UpdateOperations & operations,std::vector<BatchUpdateResult> & results)525 int DataShareStub::BatchUpdate(const UpdateOperations &operations, std::vector<BatchUpdateResult> &results)
526 {
527     return 0;
528 }
InsertEx(const Uri & uri,const DataShareValuesBucket & value)529 std::pair<int32_t, int32_t> DataShareStub::InsertEx(const Uri &uri, const DataShareValuesBucket &value)
530 {
531     return std::make_pair(0, 0);
532 }
UpdateEx(const Uri & uri,const DataSharePredicates & predicates,const DataShareValuesBucket & value)533 std::pair<int32_t, int32_t> DataShareStub::UpdateEx(const Uri &uri, const DataSharePredicates &predicates,
534     const DataShareValuesBucket &value)
535 {
536     return std::make_pair(0, 0);
537 }
DeleteEx(const Uri & uri,const DataSharePredicates & predicates)538 std::pair<int32_t, int32_t> DataShareStub::DeleteEx(const Uri &uri, const DataSharePredicates &predicates)
539 {
540     return std::make_pair(0, 0);
541 }
542 
543 } // namespace DataShare
544 } // namespace OHOS