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