未验证 提交 2d4618e4 编写于 作者: O openharmony_ci 提交者: Gitee

!188 解决对bundle_framework、ability_base、ipc、resmgr_standard的部件依赖

Merge pull request !188 from sunyaozu/master
......@@ -26,10 +26,7 @@ config("preferred_language_config") {
}
ohos_shared_library("preferred_language") {
public_configs = [ ":preferred_language_config" ]
include_dirs = [
"//base/global/resmgr_standard/frameworks/resmgr/include",
"include",
]
include_dirs = [ "include" ]
sources = [ "src/preferred_language.cpp" ]
cflags_cc = [
"-Wall",
......@@ -37,12 +34,7 @@ ohos_shared_library("preferred_language") {
]
deps = [ "//base/global/i18n_standard/frameworks/intl:intl_util" ]
external_deps = [
"ability_base:want",
"bundle_framework:appexecfwk_base",
"bundle_framework:appexecfwk_core",
"hiviewdfx_hilog_native:libhilog",
"ipc:ipc_core",
"resmgr_standard:global_resmgr",
"startup_l2:syspara",
]
subsystem_name = "global"
......
......@@ -12,11 +12,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <regex>
#include "bundle_mgr_client.h"
#include "hap_resource.h"
#include "hilog/log.h"
#include "ipc_skeleton.h"
#include "locale_config.h"
#include "locale_info.h"
#include "parameter.h"
......@@ -29,7 +24,6 @@ const char *PreferredLanguage::RESOURCE_PATH_HEAD = "/data/accounts/account_0/ap
const char *PreferredLanguage::RESOURCE_PATH_TAILOR = "/assets/entry/resources.index";
const char *PreferredLanguage::RESOURCE_PATH_SPLITOR = "/";
const char *PreferredLanguage::PREFERRED_LANGUAGES = "persist.sys.preferredLanguages";
static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, 0xD001E00, "LocaleConfig" };
bool PreferredLanguage::AddPreferredLanguageExist(std::vector<std::string> &preferredLanguageList, int languageIdx,
int index, const std::string& language)
......@@ -180,40 +174,6 @@ std::vector<std::string> PreferredLanguage::GetPreferredLanguageList()
return list;
}
std::set<std::string> PreferredLanguage::GetResources()
{
pid_t uid = OHOS::IPCSkeleton::GetCallingUid();
std::string bundleName = "";
OHOS::AppExecFwk::BundleMgrClient client;
bool status = client.GetBundleNameForUid(uid, bundleName);
if (!status) {
HiviewDFX::HiLog::Error(LABEL, "Failed to get bundleName");
}
const std::string resourcePath = RESOURCE_PATH_HEAD + bundleName + RESOURCE_PATH_SPLITOR + bundleName +
RESOURCE_PATH_TAILOR;
const OHOS::Global::Resource::HapResource *resource =
OHOS::Global::Resource::HapResource::LoadFromIndex(resourcePath.c_str(), nullptr);
const std::vector<std::string> qualifiers = resource->GetQualifiers();
std::set<std::string> result;
std::regex languagePattern("type:0.*str:([a-z]{2})");
std::regex countryPattern("type:1.*str:([A-Z]{2})");
for (size_t i = 0; i < qualifiers.size(); i++) {
std::smatch match;
bool found = regex_search(qualifiers[i], match, languagePattern);
if (!found) {
continue;
}
std::string locale = match.str(1);
found = regex_search(qualifiers[i], match, countryPattern);
if (found) {
locale += "-";
locale += match.str(1);
}
result.insert(locale);
}
return result;
}
bool PreferredLanguage::IsMatched(const std::string& preferred, const std::string& resource)
{
LocaleInfo preferredLocaleInfo(preferred);
......
......@@ -9,8 +9,8 @@
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# limitations under the License.
declare_args() {
i18n_standard_telephony_core_service_exists = false
i18n_standard_telephony_core_service_exists = true
}
......@@ -35,7 +35,6 @@ private:
const std::string& language);
static bool AddPreferredLanguageExist(std::vector<std::string> &preferredLangList, int languageIdx, int index,
const std::string& language);
static std::set<std::string> GetResources();
static bool IsMatched(const std::string& preferred, const std::string& resource);
static bool IsValidLanguage(const std::string &language);
static bool IsValidTag(const std::string &tag);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册