• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifdef MEDIA_LIBRARY_EXISTS
22 #include "media_library_manager.h"
23 #endif
24 
25 #include "pixel_map.h"
26 #include "datashare_result_set.h"
27 
28 namespace OHOS::AppExecFwk {
29 class DataAbilityHelper;
30 class Context;
31 } // namespace OHOS::AppExecFwk
32 
33 namespace OHOS::AbilityRuntime {
34 class Context;
35 }
36 
37 namespace OHOS::DataShare {
38 class DataShareHelper;
39 }
40 
41 namespace OHOS {
42 class Uri;
43 }
44 
45 namespace OHOS::Ace {
46 
47 class ACE_FORCE_EXPORT DataAbilityHelperStandard : public DataAbilityHelper {
48     DECLARE_ACE_TYPE(DataAbilityHelperStandard, DataAbilityHelper)
49 
50 public:
51     DataAbilityHelperStandard(const std::shared_ptr<OHOS::AppExecFwk::Context>& context,
52         const std::shared_ptr<OHOS::AbilityRuntime::Context>& runtimeContext, bool useStageModel);
53     ~DataAbilityHelperStandard() override = default;
54 
55     int32_t OpenFile(const std::string& uriStr, const std::string& mode) override;
56     void* QueryThumbnailResFromDataAbility(const std::string& uri) override;
57     int32_t ReadMovingPhotoVideo(const std::string &uri) override;
58     std::string GetMovingPhotoImageUri(const std::string& uri) override;
59     int64_t GetMovingPhotoDateModified(const std::string& uri) override;
60     int64_t GetMovingPhotoCoverPosition(const std::string& columnName, const std::string& value,
61         std::vector<std::string>& columns) override;
62     std::string GetMovingPhotoImagePath(const std::string& uri) override;
63 
64 private:
65     int32_t OpenFileWithDataAbility(const std::string& uriStr, const std::string& mode);
66     int32_t OpenFileWithDataShare(const std::string& uriStr, const std::string& mode);
67 
68     bool useStageModel_ = false;
69     std::shared_ptr<DataShare::DataShareHelper> dataShareHelper_;
70     std::shared_ptr<AppExecFwk::DataAbilityHelper> dataAbilityHelper_;
71     std::weak_ptr<OHOS::AbilityRuntime::Context> runtimeContext_;
72     std::weak_ptr<OHOS::AppExecFwk::Context> context_;
73 #ifdef MEDIA_LIBRARY_EXISTS
74     OHOS::Media::MediaLibraryManager mgr_;
75 #endif
76 };
77 
78 } // namespace OHOS::Ace
79 
80 #endif // FOUNDATION_ACE_ACE_ENGINE_ADAPTER_OHOS_CPP_DATA_ABILITY_HELPER_STANDARD_H
81