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 #ifndef FOUNDATION_ACE_ACE_ENGINE_ADAPTER_OHOS_CPP_DATA_ABILITY_HELPER_STANDARD_H 17 #define FOUNDATION_ACE_ACE_ENGINE_ADAPTER_OHOS_CPP_DATA_ABILITY_HELPER_STANDARD_H 18 19 #include "base/resource/data_ability_helper.h" 20 21 #include "pixel_map.h" 22 23 namespace OHOS::AppExecFwk { 24 class DataAbilityHelper; 25 class Context; 26 } 27 28 namespace OHOS::AbilityRuntime { 29 class Context; 30 } 31 32 namespace OHOS::DataShare { 33 class DataShareHelper; 34 } 35 36 namespace OHOS { 37 class Uri; 38 } 39 40 namespace OHOS::Ace { 41 42 class DataAbilityHelperStandard : public DataAbilityHelper { 43 DECLARE_ACE_TYPE(DataAbilityHelperStandard, DataAbilityHelper) 44 45 public: 46 DataAbilityHelperStandard(const std::shared_ptr<OHOS::AppExecFwk::Context>& context, 47 const std::shared_ptr<OHOS::AbilityRuntime::Context>& runtimeContext, bool useStageModel); 48 ~DataAbilityHelperStandard() override = default; 49 50 int32_t OpenFile(const std::string& uriStr, const std::string& mode) override; 51 void* QueryThumbnailResFromDataAbility(const std::string& uri) override; 52 53 private: 54 int32_t OpenFileWithDataAbility(const std::string& uriStr, const std::string& mode); 55 int32_t OpenFileWithDataShare(const std::string& uriStr, const std::string& mode); 56 57 bool useStageModel_ = false; 58 std::shared_ptr<DataShare::DataShareHelper> dataShareHelper_; 59 std::shared_ptr<AppExecFwk::DataAbilityHelper> dataAbilityHelper_; 60 std::weak_ptr<OHOS::AbilityRuntime::Context> runtimeContext_; 61 std::weak_ptr<OHOS::AppExecFwk::Context> context_; 62 }; 63 64 } // namespace OHOS::Ace 65 66 #endif // FOUNDATION_ACE_ACE_ENGINE_ADAPTER_OHOS_CPP_DATA_ABILITY_HELPER_STANDARD_H 67