diff --git a/icu.gni b/icu.gni index 0203735b..8756c1be 100644 --- a/icu.gni +++ b/icu.gni @@ -15,4 +15,6 @@ declare_args() { icu_support_locales = true build_feature = "normal" icu_support_libbegetutil = true + distro_tzdata_dir = "\"/system/etc/tzdata_distro\"" + system_tzdata_dir = "\"/system/etc/icu_tzdata\"" } diff --git a/icu4c/BUILD.gn b/icu4c/BUILD.gn index df87ab14..cfada17c 100644 --- a/icu4c/BUILD.gn +++ b/icu4c/BUILD.gn @@ -539,6 +539,8 @@ ohos_shared_library("shared_icuuc") { "UPRV_BLOCK_MACRO_END=", "UCONFIG_USE_WINDOWS_LCID_MAPPING_API=0", "_REENTRANT", + "DISTRO_TZDATA_DIR=${distro_tzdata_dir}", + "SYSTEM_TZDATA_DIR=${system_tzdata_dir}", ] if (!is_mingw) { defines += [ "ICU_SUPPORT_DISTRO" ] diff --git a/icu4c/source/common/udata.cpp b/icu4c/source/common/udata.cpp index aa115877..91bd98d8 100644 --- a/icu4c/source/common/udata.cpp +++ b/icu4c/source/common/udata.cpp @@ -1308,16 +1308,29 @@ doOpenChoice(const char *path, const char *type, const char *name, /**** Time zone individual files override */ if (isICUData && isTimeZoneFile(name, type)) { +#ifdef DISTRO_TZDATA_DIR + const char* distroTzdataDir = DISTRO_TZDATA_DIR; + retVal = doLoadFromIndividualFiles(/* pkgName.data() */ "", distroTzdataDir, tocEntryPathSuffix, + /* path */ "", type, name, isAcceptable, context, &subErrorCode, pErrorCode); + if((retVal != NULL) || U_FAILURE(*pErrorCode)) { + return retVal; + } +#endif + +#ifdef SYSTEM_TZDATA_DIR + const char* systemTzdataDir = SYSTEM_TZDATA_DIR; + retVal = doLoadFromIndividualFiles(/* pkgName.data() */ "", systemTzdataDir, tocEntryPathSuffix, + /* path */ "", type, name, isAcceptable, context, &subErrorCode, pErrorCode); + if((retVal != NULL) || U_FAILURE(*pErrorCode)) { + return retVal; + } +#endif + const char *tzFilesDir = u_getTimeZoneFilesDirectory(pErrorCode); if (tzFilesDir[0] != 0) { #ifdef UDATA_DEBUG fprintf(stderr, "Trying Time Zone Files directory = %s\n", tzFilesDir); #endif - retVal = doLoadFromIndividualFiles(/* pkgName.data() */ "", tzFilesDir, tocEntryPathSuffix, - /* path */ "", type, name, isAcceptable, context, &subErrorCode, pErrorCode); - if((retVal != NULL) || U_FAILURE(*pErrorCode)) { - return retVal; - } retVal = doLoadFromCommonData(isICUData, "icu_tzdata", tzFilesDir, tocEntryPathSuffix, tocEntryName.data(), "icu_tzdata", type, name, isAcceptable, context, &subErrorCode, pErrorCode); diff --git a/icu4c/source/ohos/distro_tzdata_loader.cpp b/icu4c/source/ohos/distro_tzdata_loader.cpp index b275271b..28714602 100644 --- a/icu4c/source/ohos/distro_tzdata_loader.cpp +++ b/icu4c/source/ohos/distro_tzdata_loader.cpp @@ -22,20 +22,14 @@ namespace OHOS { namespace Global { namespace I18n { -const char *DistroTZDataLoader::ICU_TZDATA_PATH = "/system/etc/tzdata_distro/icu/icu_tzdata.dat"; -const char *DistroTZDataLoader::DISTRO_TZDATA_PATH = "/system/etc/tzdata_distro/icu"; +const char *DistroTZDataLoader::ICU_TZDATA_PATH = "/system/etc/tzdata_distro/icu_tzdata.dat"; +const char *DistroTZDataLoader::DISTRO_TZDATA_PATH = "/system/etc/tzdata_distro"; const char *DistroTZDataLoader::TZDATA_PATH = "/system/etc/icu_tzdata"; const char *DistroTZDataLoader::ICU_TIMEZONE_FILES_DIR = "ICU_TIMEZONE_FILES_DIR"; void DistroTZDataLoader::SetDistroTZDataPath() { #ifdef ICU_SUPPORT_DISTRO - // if distro_tzdata_path is exist, use distro tzdata first - if (CheckFileExist()) { - setenv(ICU_TIMEZONE_FILES_DIR, DISTRO_TZDATA_PATH, 1); - } else { - setenv(ICU_TIMEZONE_FILES_DIR, TZDATA_PATH, 1); - } #endif }