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 FOUNDATION_ACE_ACE_ENGINE_ADAPTER_OHOS_CPP_ACE_DATA_ABILITY_H 17 #define FOUNDATION_ACE_ACE_ENGINE_ADAPTER_OHOS_CPP_ACE_DATA_ABILITY_H 18 19 #include <string> 20 #include <vector> 21 22 #include "ability.h" 23 #include "ability_loader.h" 24 #include "iremote_object.h" 25 #include "want.h" 26 27 namespace OHOS::Ace { 28 29 class AceDataAbility final : public OHOS::AppExecFwk::Ability { 30 public: AceDataAbility()31 AceDataAbility() 32 { 33 abilityId_ = instanceId_; 34 instanceId_++; 35 } 36 virtual ~AceDataAbility() = default; 37 38 void OnStart(const OHOS::AAFwk::Want& want) override; 39 void OnStop() override; 40 41 int32_t Insert(const Uri& uri, const NativeRdb::ValuesBucket& value) override; 42 std::shared_ptr<NativeRdb::AbsSharedResultSet> Query( 43 const Uri& uri, const std::vector<std::string>& columns, 44 const NativeRdb::DataAbilityPredicates& predicates) override; 45 int32_t Update(const Uri& uri, const NativeRdb::ValuesBucket& value, 46 const NativeRdb::DataAbilityPredicates& predicates) override; 47 int32_t Delete(const Uri& uri, const NativeRdb::DataAbilityPredicates& predicates) override; 48 49 int32_t BatchInsert(const Uri& uri, const std::vector<NativeRdb::ValuesBucket>& values) override; 50 std::string GetType(const Uri& uri) override; 51 std::vector<std::string> GetFileTypes(const Uri& uri, const std::string& mimeTypeFilter) override; 52 int32_t OpenFile(const Uri& uri, const std::string& mode) override; 53 int32_t OpenRawFile(const Uri& uri, const std::string& mode) override; 54 Uri NormalizeUri(const Uri& uri) override; 55 Uri DenormalizeUri(const Uri& uri) override; 56 std::shared_ptr<AppExecFwk::PacMap> Call( 57 const Uri& uri, const std::string& method, const std::string& arg, const AppExecFwk::PacMap& pacMap) override; 58 59 private: 60 int32_t abilityId_ = 200000; 61 62 static int32_t instanceId_; 63 static const std::string START_PARAMS_KEY; 64 static const std::string URI; 65 }; 66 67 } // namespace OHOS::Ace 68 69 #endif // FOUNDATION_ACE_ACE_ENGINE_ADAPTER_OHOS_CPP_ACE_DATA_ABILITY_H 70