1 /*
2  * Copyright (c) 2021-2023 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:
31     AceDataAbility();
32     virtual ~AceDataAbility() = default;
33 
34     void OnStart(const OHOS::AAFwk::Want& want, sptr<AAFwk::SessionInfo> sessionInfo = nullptr) override;
35     void OnStop() override;
36 
37     int32_t Insert(const Uri& uri, const NativeRdb::ValuesBucket& value) override;
38     std::shared_ptr<NativeRdb::AbsSharedResultSet> Query(
39         const Uri& uri, const std::vector<std::string>& columns,
40         const NativeRdb::DataAbilityPredicates& predicates) override;
41     int32_t Update(const Uri& uri, const NativeRdb::ValuesBucket& value,
42         const NativeRdb::DataAbilityPredicates& predicates) override;
43     int32_t Delete(const Uri& uri, const NativeRdb::DataAbilityPredicates& predicates) override;
44 
45     int32_t BatchInsert(const Uri& uri, const std::vector<NativeRdb::ValuesBucket>& values) override;
46     std::string GetType(const Uri& uri) override;
47     std::vector<std::string> GetFileTypes(const Uri& uri, const std::string& mimeTypeFilter) override;
48     int32_t OpenFile(const Uri& uri, const std::string& mode) override;
49     int32_t OpenRawFile(const Uri& uri, const std::string& mode) override;
50     Uri NormalizeUri(const Uri& uri) override;
51     Uri DenormalizeUri(const Uri& uri) override;
52     std::shared_ptr<AppExecFwk::PacMap> Call(
53         const Uri& uri, const std::string& method, const std::string& arg, const AppExecFwk::PacMap& pacMap) override;
54 
55 private:
56     int32_t abilityId_;
57 
58     static const std::string START_PARAMS_KEY;
59     static const std::string URI;
60 };
61 
62 } // namespace OHOS::Ace
63 
64 #endif // FOUNDATION_ACE_ACE_ENGINE_ADAPTER_OHOS_CPP_ACE_DATA_ABILITY_H
65