mirror of
https://gitee.com/openharmony/global_i18n
synced 2024-11-23 07:00:13 +00:00
remove query settings
Signed-off-by: LY <liuyong235@huawei.com>
This commit is contained in:
parent
a4d7696583
commit
b8ceac2188
@ -57,14 +57,12 @@
|
||||
"bundle_framework",
|
||||
"common_event_service",
|
||||
"c_utils",
|
||||
"data_share",
|
||||
"eventhandler",
|
||||
"hilog",
|
||||
"init",
|
||||
"ipc",
|
||||
"napi",
|
||||
"preferences",
|
||||
"relational_store",
|
||||
"resource_management",
|
||||
"safwk",
|
||||
"samgr"
|
||||
|
@ -112,7 +112,6 @@ ohos_shared_library("intl_util") {
|
||||
"src/phone_number_matched.cpp",
|
||||
"src/phone_number_rule.cpp",
|
||||
"src/plural_rules.cpp",
|
||||
"src/query_settings.cpp",
|
||||
"src/regex_rule.cpp",
|
||||
"src/relative_time_format.cpp",
|
||||
"src/rules_engine.cpp",
|
||||
|
@ -24,7 +24,6 @@
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
#include "configuration.h"
|
||||
#include <common_event_data.h>
|
||||
#include "iremote_object.h"
|
||||
#endif
|
||||
#include "i18n_types.h"
|
||||
|
||||
@ -101,7 +100,6 @@ public:
|
||||
static bool IsValidLanguage(const std::string &language);
|
||||
static bool IsValidRegion(const std::string ®ion);
|
||||
static bool IsValidTag(const std::string &tag);
|
||||
static bool queryWithProxy;
|
||||
|
||||
private:
|
||||
static void Split(const std::string &src, const std::string &sep, std::vector<std::string> &dest);
|
||||
@ -112,7 +110,6 @@ private:
|
||||
static const char *LANGUAGE_KEY;
|
||||
static const char *LOCALE_KEY;
|
||||
static const char *HOUR_KEY;
|
||||
static const char *TIME_FORMAT;
|
||||
static const char *DEFAULT_LOCALE_KEY;
|
||||
static const char *DEFAULT_LANGUAGE_KEY;
|
||||
static const char *DEFAULT_REGION_KEY;
|
||||
|
@ -1,42 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except", "in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* 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.
|
||||
*/
|
||||
#ifndef OHOS_GLOBAL_I18N_QUERY_SETTINGS_H
|
||||
#define OHOS_GLOBAL_I18N_QUERY_SETTINGS_H
|
||||
|
||||
#include <string>
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
#include "iremote_object.h"
|
||||
#endif
|
||||
|
||||
namespace OHOS {
|
||||
namespace Global {
|
||||
namespace I18n {
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
using I18nQuery = bool (*)(const std::string&, std::string&, sptr<IRemoteObject>);
|
||||
#endif
|
||||
|
||||
class QuerySettings {
|
||||
private:
|
||||
static const char *QUERY_WITH_PROXY;
|
||||
static const char *LIB_PATH;
|
||||
public:
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
static bool SettingsQuery(const std::string& key, std::string& value, sptr<IRemoteObject> &proxy);
|
||||
#endif
|
||||
};
|
||||
} // namespace I18n
|
||||
} // namespace Global
|
||||
} // namespace OHOS
|
||||
#endif
|
@ -31,7 +31,6 @@
|
||||
#include "locid.h"
|
||||
#include "ohos/init_data.h"
|
||||
#include "parameter.h"
|
||||
#include "query_settings.h"
|
||||
#include "securec.h"
|
||||
#include "string_ex.h"
|
||||
#include "ucase.h"
|
||||
@ -54,7 +53,6 @@ static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, 0xD001E00, "Loc
|
||||
const char *LocaleConfig::LANGUAGE_KEY = "persist.global.language";
|
||||
const char *LocaleConfig::LOCALE_KEY = "persist.global.locale";
|
||||
const char *LocaleConfig::HOUR_KEY = "persist.global.is24Hour";
|
||||
const char *LocaleConfig::TIME_FORMAT = "settings.date.time_format";
|
||||
const char *LocaleConfig::DEFAULT_LOCALE_KEY = "const.global.locale";
|
||||
const char *LocaleConfig::DEFAULT_LANGUAGE_KEY = "const.global.language";
|
||||
const char *LocaleConfig::DEFAULT_REGION_KEY = "const.global.region";
|
||||
@ -85,7 +83,6 @@ const char *LocaleConfig::secondRootTag = "lang";
|
||||
const char *LocaleConfig::rootRegion = "regions";
|
||||
const char *LocaleConfig::secondRootRegion = "region";
|
||||
const char *LocaleConfig::NUMBER_SYSTEM_KEY = "-nu-";
|
||||
bool LocaleConfig::queryWithProxy = true;
|
||||
unordered_set<string> LocaleConfig::supportedLocales;
|
||||
unordered_set<string> LocaleConfig::supportLocales;
|
||||
unordered_set<string> LocaleConfig::supportedRegions;
|
||||
@ -984,32 +981,6 @@ bool LocaleConfig::Is24HourClock()
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
bool LocaleConfig::Is24HourClock(sptr<IRemoteObject> &proxy)
|
||||
{
|
||||
std::string is24HourValue;
|
||||
std::string is24HourSystem = ReadSystemParameter(HOUR_KEY, CONFIG_LEN);
|
||||
std::string is24Hour;
|
||||
if (QuerySettings::SettingsQuery(TIME_FORMAT, is24HourValue, proxy)) {
|
||||
is24Hour = (is24HourValue == "24") ? "true" : "false";
|
||||
if (is24HourSystem != is24Hour) {
|
||||
if (SetParameter(HOUR_KEY, is24Hour.data()) != 0) {
|
||||
HiLog::Error(LABEL, "LocaleConfig::Set parameter failed.");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
is24Hour = is24HourSystem.c_str();
|
||||
}
|
||||
if (is24Hour.empty()) {
|
||||
return false;
|
||||
}
|
||||
if (is24Hour.compare("true") == 0) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
bool LocaleConfig::GetUsingLocalDigit()
|
||||
{
|
||||
std::string locale = GetSystemLocale();
|
||||
|
@ -1,51 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except", "in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* 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.
|
||||
*/
|
||||
#include <dlfcn.h>
|
||||
#include <filesystem>
|
||||
#include "hilog/log.h"
|
||||
#include "query_settings.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Global {
|
||||
namespace I18n {
|
||||
const char* QuerySettings::LIB_PATH = "libzone_util.z.so";
|
||||
const char* QuerySettings::QUERY_WITH_PROXY = "QueryWithProxy";
|
||||
|
||||
static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, 0xD001E00, "QuerySettings" };
|
||||
using namespace OHOS::HiviewDFX;
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
bool QuerySettings::SettingsQuery(const std::string& key, std::string& value, sptr<IRemoteObject>& proxy)
|
||||
{
|
||||
if (proxy == nullptr) {
|
||||
HiLog::Error(LABEL, "QuerySettings::SettingsQuery proxy==nullptr.");
|
||||
return false;
|
||||
}
|
||||
void* handle = dlopen(QuerySettings::LIB_PATH, RTLD_LAZY);
|
||||
if (handle == nullptr) {
|
||||
HiLog::Error(LABEL, "Query failed, handle is nullptr.");
|
||||
return false;
|
||||
}
|
||||
I18nQuery query = reinterpret_cast<I18nQuery>(dlsym(handle, QuerySettings::QUERY_WITH_PROXY));
|
||||
bool result = query(key, value, proxy);
|
||||
if (handle != nullptr) {
|
||||
dlclose(handle);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
} // namespace I18n
|
||||
} // namespace Global
|
||||
} // namespace OHOS
|
@ -30,8 +30,6 @@ ohos_unittest("intl_test") {
|
||||
"//base/global/i18n/frameworks/intl/include",
|
||||
"//base/global/i18n/frameworks/intl/test/unittest/mock/include",
|
||||
"//base/global/i18n/interfaces/native/inner_api/preferred_language/include",
|
||||
"//base/global/i18n/interfaces/native/inner_api/zone/include",
|
||||
"//base/global/i18n/services/include",
|
||||
"//third_party/icu/icu4c/source/common",
|
||||
"//third_party/icu/icu4c/source/common/unicode",
|
||||
"//third_party/icu/icu4c/source/i18n",
|
||||
@ -40,24 +38,16 @@ ohos_unittest("intl_test") {
|
||||
"//third_party/protobuf/src",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"ability_base:configuration",
|
||||
"c_utils:utils",
|
||||
"init:libbegetutil",
|
||||
"samgr:samgr_proxy",
|
||||
]
|
||||
external_deps = [ "init:libbegetutil" ]
|
||||
|
||||
deps = [
|
||||
"//base/global/i18n/frameworks/intl:build_module",
|
||||
"//base/global/i18n/services:i18n_sa_client",
|
||||
"//third_party/googletest:gtest_main",
|
||||
"//third_party/icu/icu4c:shared_icui18n",
|
||||
"//third_party/icu/icu4c:shared_icuuc",
|
||||
"//third_party/libphonenumber/cpp:phonenumber_standard",
|
||||
"//third_party/libpng:libpng",
|
||||
]
|
||||
|
||||
defines = [ "SUPPORT_GRAPHICS" ]
|
||||
}
|
||||
|
||||
group("unittest") {
|
||||
|
@ -18,13 +18,11 @@
|
||||
#include "i18n_break_iterator.h"
|
||||
#include "i18n_calendar.h"
|
||||
#include "i18n_normalizer.h"
|
||||
#include "i18n_service_ability_load_manager.h"
|
||||
#include "i18n_timezone_mock.h"
|
||||
#include "locale_config.h"
|
||||
#include "measure_data.h"
|
||||
#include "phone_number_format_mock.h"
|
||||
#include "preferred_language.h"
|
||||
#include "query_settings.h"
|
||||
|
||||
using namespace OHOS::Global::I18n;
|
||||
using testing::ext::TestSize;
|
||||
@ -1198,20 +1196,6 @@ HWTEST_F(I18nTest, I18nFuncTest046, TestSize.Level1)
|
||||
EXPECT_EQ(res[1][3], 17);
|
||||
EXPECT_EQ(res[1][4], 34);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: I18nFuncTest047
|
||||
* @tc.desc: Test I18n QuerySettings
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(I18nTest, I18nFuncTest047, TestSize.Level1)
|
||||
{
|
||||
const std::string key = "settings.date.time_format";
|
||||
std::string valueQuery;
|
||||
sptr<IRemoteObject> proxy = I18nServiceAbilityLoadManager::GetInstance()->GetI18nServiceAbility(1602);
|
||||
bool flagQuery = QuerySettings::SettingsQuery(key, valueQuery, proxy);
|
||||
EXPECT_EQ(flagQuery, true);
|
||||
}
|
||||
} // namespace I18n
|
||||
} // namespace Global
|
||||
} // namespace OHOS
|
@ -65,7 +65,6 @@ int I18nFuncTest043(void);
|
||||
int I18nFuncTest044(void);
|
||||
int I18nFuncTest045(void);
|
||||
int I18nFuncTest046(void);
|
||||
int I18nFuncTest047(void);
|
||||
} // namespace I18n
|
||||
} // namespace Global
|
||||
} // namespace OHOS
|
||||
|
@ -16,14 +16,7 @@ import("//build/ohos.gni")
|
||||
config("zone_util_public_configs") {
|
||||
include_dirs = [
|
||||
"//base/global/i18n/frameworks/intl/include",
|
||||
"//base/global/i18n/frameworks/zone/include",
|
||||
"//base/global/i18n/interfaces/native/inner_api/zone/include",
|
||||
"//base/global/i18n/services/include",
|
||||
"//foundation/ability/ability_runtime/interfaces/inner_api/dataobs_manager/include",
|
||||
"//foundation/distributeddatamgr/data_share/interfaces/inner_api/common/include",
|
||||
"//foundation/distributeddatamgr/data_share/interfaces/inner_api/consumer/include",
|
||||
"//foundation/distributeddatamgr/data_share/interfaces/inner_api/provider/include",
|
||||
"//foundation/distributeddatamgr/relational_store/interfaces/inner_api/rdb/include",
|
||||
"//third_party/icu/icu4c/source",
|
||||
"//third_party/icu/icu4c/source/common",
|
||||
"//third_party/icu/icu4c/source/common/unicode",
|
||||
@ -38,17 +31,13 @@ config("zone_util_public_configs") {
|
||||
|
||||
ohos_shared_library("zone_util") {
|
||||
public_configs = [ ":zone_util_public_configs" ]
|
||||
sources = [
|
||||
"src/i18n_datashare_helper.cpp",
|
||||
"src/zone_util.cpp",
|
||||
]
|
||||
sources = [ "src/zone_util.cpp" ]
|
||||
cflags_cc = [
|
||||
"-Wall",
|
||||
"-fPIC",
|
||||
]
|
||||
deps = [
|
||||
"//base/global/i18n/frameworks/intl:intl_util",
|
||||
"//base/global/i18n/services:i18n_sa_client",
|
||||
"//third_party/icu/icu4c:ohos_icudat",
|
||||
"//third_party/icu/icu4c:shared_icui18n",
|
||||
"//third_party/icu/icu4c:shared_icuuc",
|
||||
@ -56,16 +45,7 @@ ohos_shared_library("zone_util") {
|
||||
"//third_party/libpng:libpng",
|
||||
"//third_party/libxml2:xml2",
|
||||
]
|
||||
external_deps = [
|
||||
"ability_base:zuri",
|
||||
"ability_runtime:dataobs_manager",
|
||||
"c_utils:utils",
|
||||
"data_share:datashare_common",
|
||||
"data_share:datashare_consumer",
|
||||
"hilog:libhilog",
|
||||
"relational_store:native_rdb",
|
||||
"samgr:samgr_proxy",
|
||||
]
|
||||
external_deps = [ "hilog:libhilog" ]
|
||||
subsystem_name = "global"
|
||||
part_name = "i18n"
|
||||
}
|
||||
|
@ -1,35 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* 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.
|
||||
*/
|
||||
#ifndef GLOBAL_I18N_DATASHARE_HELPER_H
|
||||
#define GLOBAL_I18N_DATASHARE_HELPER_H
|
||||
|
||||
#include <string>
|
||||
#include "datashare_helper.h"
|
||||
#include "datashare_predicates.h"
|
||||
#include "datashare_result_set.h"
|
||||
#include "i18n_service_ability_load_manager.h"
|
||||
#include "system_ability_definition.h"
|
||||
#include "rdb_errno.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Global {
|
||||
namespace I18n {
|
||||
extern "C" __attribute__((used)) bool QueryWithProxy(const std::string& key,
|
||||
std::string& value, sptr<IRemoteObject> &proxy);
|
||||
__attribute__((used)) static Uri AssembleUri(const std::string& key);
|
||||
} // namespace I18n
|
||||
} // namespace Global
|
||||
} // namespace OHOS
|
||||
#endif
|
@ -1,73 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* 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.
|
||||
*/
|
||||
#include "hilog/log.h"
|
||||
#include "i18n_datashare_helper.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Global {
|
||||
namespace I18n {
|
||||
static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, 0xD001E00, "I18nDataShareHelper" };
|
||||
using namespace OHOS::HiviewDFX;
|
||||
|
||||
const std::string SETTINGS_DATASHARE_URI =
|
||||
"datashare:///com.ohos.settingsdata/entry/settingsdata/SETTINGSDATA?Proxy=true";
|
||||
const std::string SETTINGS_DATA_EXT_URI = "datashare:///com.ohos.settingsdata.DataAbility";
|
||||
const std::string SETTINGS_DATA_COLUMN_KEYWORD = "KEYWORD";
|
||||
const std::string SETTINGS_DATA_COLUMN_VALUE = "VALUE";
|
||||
|
||||
bool QueryWithProxy(const std::string& key, std::string& value, sptr<IRemoteObject> &proxy)
|
||||
{
|
||||
std::shared_ptr<DataShare::DataShareHelper> dataShareHelper =
|
||||
DataShare::DataShareHelper::Creator(proxy, SETTINGS_DATASHARE_URI, SETTINGS_DATA_EXT_URI);
|
||||
std::vector<std::string> columns = {SETTINGS_DATA_COLUMN_VALUE};
|
||||
DataShare::DataSharePredicates predicates;
|
||||
predicates.EqualTo(SETTINGS_DATA_COLUMN_KEYWORD, key);
|
||||
Uri uri(AssembleUri(key));
|
||||
if (dataShareHelper == nullptr) {
|
||||
HiLog::Error(LABEL, "QueryWithProxy Query failed, dataShareHelper is nullptr.");
|
||||
return false;
|
||||
}
|
||||
auto result = dataShareHelper->Query(uri, predicates, columns);
|
||||
int32_t count;
|
||||
if (result == nullptr) {
|
||||
HiLog::Error(LABEL, "QueryWithProxy Query failed, result is nullptr.");
|
||||
return false;
|
||||
}
|
||||
result->GetRowCount(count);
|
||||
if (count == 0) {
|
||||
HiLog::Error(LABEL, "QueryWithProxy Query failed, count is zero.");
|
||||
return false;
|
||||
}
|
||||
const int32_t INDEX = 0;
|
||||
result->GoToRow(INDEX);
|
||||
int32_t ret = result->GetString(INDEX, value);
|
||||
HiLog::Info(LABEL, "QueryWithProxy Query GetString %{public}s.", value.c_str());
|
||||
if (ret != NativeRdb::E_OK) {
|
||||
HiLog::Error(LABEL, "QueryWithProxy Query failed, GetString Failed.");
|
||||
return false;
|
||||
}
|
||||
result->Close();
|
||||
dataShareHelper->Release();
|
||||
return true;
|
||||
}
|
||||
|
||||
Uri AssembleUri(const std::string& key)
|
||||
{
|
||||
Uri uri(SETTINGS_DATASHARE_URI + "&key=" + key);
|
||||
return uri;
|
||||
}
|
||||
} // namespace I18n
|
||||
} // namespace Global
|
||||
} // namespace OHOS
|
@ -46,11 +46,8 @@ ohos_unittest("zone_util_test") {
|
||||
]
|
||||
deps = [
|
||||
"//base/global/i18n/frameworks/zone:zone_util",
|
||||
"//base/global/i18n/services:i18n_sa_client",
|
||||
"//third_party/libphonenumber/cpp:phonenumber_standard",
|
||||
"//third_party/libxml2:xml2",
|
||||
]
|
||||
external_deps = [
|
||||
"c_utils:utils",
|
||||
"samgr:samgr_proxy",
|
||||
]
|
||||
external_deps = [ "c_utils:utils" ]
|
||||
}
|
||||
|
@ -14,8 +14,6 @@
|
||||
*/
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include "i18n_datashare_helper.h"
|
||||
#include "i18n_service_ability_load_manager.h"
|
||||
#include "zone_util.h"
|
||||
|
||||
using namespace OHOS::Global::I18n;
|
||||
@ -287,20 +285,6 @@ HWTEST_F(ZoneUtilTest, ZoneUtilFuncTest011, TestSize.Level1)
|
||||
EXPECT_EQ(result5.timezoneId, "Asia/Nicosia");
|
||||
EXPECT_EQ(result5.quality, 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: ZoneUtilFuncTest012
|
||||
* @tc.desc: Test i18n_datashare_helper Query
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(ZoneUtilTest, ZoneUtilFuncTest012, TestSize.Level1)
|
||||
{
|
||||
const char* key = "settings.date.time_format";
|
||||
sptr<IRemoteObject> proxy = I18nServiceAbilityLoadManager::GetInstance()->GetI18nServiceAbility(I18N_SA_ID);
|
||||
std::string valueQuery;
|
||||
bool flagQuery = QueryWithProxy(key, valueQuery, proxy);
|
||||
EXPECT_EQ(flagQuery, true);
|
||||
}
|
||||
} // namespace I18n
|
||||
} // namespace Global
|
||||
} // namespace OHOS
|
@ -30,7 +30,6 @@ int ZoneUtilFuncTest008(void);
|
||||
int ZoneUtilFuncTest009(void);
|
||||
int ZoneUtilFuncTest0010(void);
|
||||
int ZoneUtilFuncTest0011(void);
|
||||
int ZoneUtilFuncTest0012(void);
|
||||
} // namespace I18n
|
||||
} // namespace Global
|
||||
} // namespace OHOS
|
||||
|
Loading…
Reference in New Issue
Block a user