1 /* 2 * Copyright (c) 2021-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_ADAPTER_COMMON_CPP_ACE_APPLICATION_INFO_H 17 #define FOUNDATION_ACE_ADAPTER_COMMON_CPP_ACE_APPLICATION_INFO_H 18 19 #include <map> 20 #include <memory> 21 #include <string> 22 #include <vector> 23 24 #include "resource_manager.h" 25 26 #include "base/utils/noncopyable.h" 27 #include "core/common/ace_application_info.h" 28 29 namespace OHOS::Ace::Platform { 30 31 class ACE_FORCE_EXPORT AceApplicationInfoImpl : public AceApplicationInfo { 32 public: 33 AceApplicationInfoImpl(); 34 ~AceApplicationInfoImpl() override; 35 36 static AceApplicationInfoImpl& GetInstance(); 37 38 void SetLocale(const std::string& language, const std::string& countryOrRegion, const std::string& script, 39 const std::string& keywordsAndValues) override; 40 void ChangeLocale(const std::string& language, const std::string& countryOrRegion) override; 41 42 bool GetBundleInfo(const std::string& packageName, AceBundleInfo& bundleInfo) override; 43 GetLifeTime()44 double GetLifeTime() const override 45 { 46 return 0.0; 47 } 48 std::string GetJsEngineParam(const std::string& key) const override; 49 50 void SetJsEngineParam(const std::string& key, const std::string& value); 51 SetResourceManager(std::shared_ptr<Global::Resource::ResourceManager> & resourceManager)52 void SetResourceManager(std::shared_ptr<Global::Resource::ResourceManager>& resourceManager) 53 { 54 resourceManager_ = resourceManager; 55 } 56 SetDebug(bool isDebugVersion,bool needDebugBreakpoint)57 void SetDebug(bool isDebugVersion, bool needDebugBreakpoint) override 58 { 59 AceApplicationInfoImpl::GetInstance().isDebugVersion_ = isDebugVersion; 60 AceApplicationInfoImpl::GetInstance().needDebugBreakpoint_ = needDebugBreakpoint; 61 } 62 63 private: 64 std::map<std::string, std::string> jsEngineParams_; 65 std::shared_ptr<Global::Resource::ResourceManager> resourceManager_; 66 }; 67 } // namespace OHOS::Ace::Platform 68 69 #endif // FOUNDATION_ACE_ADAPTER_COMMON_CPP_ACE_APPLICATION_INFO_H 70