1 /* 2 * Copyright (c) 2021-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 #ifndef CALLLOG_ABILITY_H 17 #define CALLLOG_ABILITY_H 18 19 #include "abs_shared_result_set.h" 20 #include "datashare_ext_ability.h" 21 #include "datashare_values_bucket.h" 22 #include "telephony_permission.h" 23 #include "want.h" 24 25 #include "calllog_database.h" 26 27 namespace OHOS { 28 namespace AbilityRuntime { 29 class CallLogAbility : public DataShare::DataShareExtAbility { 30 public: 31 CallLogAbility(); 32 virtual ~CallLogAbility() override; 33 static CallLogAbility* Create(); 34 sptr<IRemoteObject> OnConnect(const AAFwk::Want &want) override; 35 virtual int Insert(const Uri &uri, const DataShare::DataShareValuesBucket &value) override; 36 virtual int BatchInsert(const Uri &uri, const std::vector<DataShare::DataShareValuesBucket> &values) override; 37 virtual void OnStart(const Want &want) override; 38 virtual int Update(const Uri &uri, const DataShare::DataSharePredicates &predicates, 39 const DataShare::DataShareValuesBucket &value) override; 40 virtual int Delete(const Uri &uri, const DataShare::DataSharePredicates &predicates) override; 41 virtual std::shared_ptr<DataShare::DataShareResultSet> Query(const Uri &uri, 42 const DataShare::DataSharePredicates &predicates, std::vector<std::string> &columns, 43 DataShare::DatashareBusinessError &businessError) override; 44 45 private: 46 static std::shared_ptr<Contacts::CallLogDataBase> callLogDataBase_; 47 static std::map<std::string, int> uriValueMap_; 48 int UriParse(Uri &uri); 49 int InsertExecute(const Uri &uri, const OHOS::NativeRdb::ValuesBucket &value); 50 void DataBaseNotifyChange(int code, Uri uri); 51 bool IsBeginTransactionOK(int code, std::mutex &mutex); 52 bool IsCommitOk(int code, std::mutex &mutex); 53 }; 54 } // namespace AbilityRuntime 55 } // namespace OHOS 56 57 #endif // CALLLOG_ABILITY_H 58