1 /* 2 * Copyright (c) 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 #include "bundle_resource_param.h" 17 18 #include "app_log_wrapper.h" 19 #include "parameter.h" 20 21 namespace OHOS { 22 namespace AppExecFwk { 23 namespace { 24 const int32_t MAX_LEN = 128; 25 const std::string SYSTEM_LANGUAGE = "persist.global.locale"; 26 const std::string DEFAULT_LANGUAGE = "zh-Hans"; 27 const std::string DEFAULT_COLOR_MODE_LIGHT = "light"; 28 } 29 GetSystemLanguage()30std::string BundleResourceParam::GetSystemLanguage() 31 { 32 std::string language = GetSystemParam(SYSTEM_LANGUAGE); 33 return language.empty() ? DEFAULT_LANGUAGE : language; 34 } 35 GetSystemColorMode()36std::string BundleResourceParam::GetSystemColorMode() 37 { 38 // no need to process colorMode 39 return DEFAULT_COLOR_MODE_LIGHT; 40 } 41 GetSystemParam(const std::string & key)42std::string BundleResourceParam::GetSystemParam(const std::string &key) 43 { 44 char value[MAX_LEN] = {0}; 45 int32_t ret = GetParameter(key.c_str(), "", value, MAX_LEN); 46 if (ret <= 0) { 47 APP_LOGE("GetParameter:%{public}s failed", key.c_str()); 48 return ""; 49 } 50 return std::string(value); 51 } 52 } // AppExecFwk 53 } // OHOS 54