Merge "Add maxTargetSdk restriction to unused APIs."
diff --git a/android_icu4j/api/intra/current.txt b/android_icu4j/api/intra/current.txt
index b1e7dfe..a9c4793 100644
--- a/android_icu4j/api/intra/current.txt
+++ b/android_icu4j/api/intra/current.txt
@@ -1,25 +1,11 @@
// Signature format: 2.0
package android.icu.text {
- public class CurrencyMetaInfo {
- method public java.util.List<java.lang.String> currencies(android.icu.text.CurrencyMetaInfo.CurrencyFilter);
- method public static android.icu.text.CurrencyMetaInfo getInstance();
- }
-
- public static final class CurrencyMetaInfo.CurrencyFilter {
- method public static android.icu.text.CurrencyMetaInfo.CurrencyFilter onRegion(String);
- method public android.icu.text.CurrencyMetaInfo.CurrencyFilter withDate(java.util.Date);
- }
-
public class DateFormatSymbols implements java.lang.Cloneable java.io.Serializable {
ctor @Deprecated public DateFormatSymbols(android.icu.util.ULocale, String);
method public String[] getNarrowEras();
}
- public class DateTimePatternGenerator implements java.lang.Cloneable android.icu.util.Freezable<android.icu.text.DateTimePatternGenerator> {
- method @Deprecated public static android.icu.text.DateTimePatternGenerator getFrozenInstance(android.icu.util.ULocale);
- }
-
public class DecimalFormat extends android.icu.text.NumberFormat {
method public void setParseJavaCompatible(boolean);
}
@@ -185,7 +171,6 @@
public class Icu4cMetadata {
method public static String getCldrVersion();
method public static String getIcuVersion();
- method public static String getTzdbVersion();
method public static String getUnicodeVersion();
}
diff --git a/android_icu4j/libcore_bridge/src/java/com/android/icu/util/Icu4cMetadata.java b/android_icu4j/libcore_bridge/src/java/com/android/icu/util/Icu4cMetadata.java
index 0a7d45a..412c4e1 100644
--- a/android_icu4j/libcore_bridge/src/java/com/android/icu/util/Icu4cMetadata.java
+++ b/android_icu4j/libcore_bridge/src/java/com/android/icu/util/Icu4cMetadata.java
@@ -19,7 +19,6 @@
public class Icu4cMetadata {
/** Returns the TZData version as reported by ICU4C. */
- @libcore.api.IntraCoreApi
public static native String getTzdbVersion();
/**
diff --git a/android_icu4j/src/main/java/android/icu/text/CurrencyMetaInfo.java b/android_icu4j/src/main/java/android/icu/text/CurrencyMetaInfo.java
index 2f5d16e..f8aaedc 100644
--- a/android_icu4j/src/main/java/android/icu/text/CurrencyMetaInfo.java
+++ b/android_icu4j/src/main/java/android/icu/text/CurrencyMetaInfo.java
@@ -31,7 +31,6 @@
*
* @hide Only a subset of ICU is exposed in Android
*/
-@libcore.api.IntraCoreApi
public class CurrencyMetaInfo {
private static final CurrencyMetaInfo impl;
private static final boolean hasData;
@@ -40,7 +39,6 @@
* Returns the unique instance of the currency meta info.
* @return the meta info
*/
- @libcore.api.IntraCoreApi
public static CurrencyMetaInfo getInstance() {
return impl;
}
@@ -79,7 +77,6 @@
* A filter used to select which currency info is returned.
* @hide Only a subset of ICU is exposed in Android
*/
- @libcore.api.IntraCoreApi
public static final class CurrencyFilter {
/**
* The region to filter on. If null, accepts any region.
@@ -144,7 +141,6 @@
* @return a filter
* @see #withRegion(String)
*/
- @libcore.api.IntraCoreApi
public static CurrencyFilter onRegion(String region) {
return ALL.withRegion(region);
}
@@ -239,7 +235,6 @@
* @return the filter
* @see #onDate(Date)
*/
- @libcore.api.IntraCoreApi
public CurrencyFilter withDate(Date date) {
return new CurrencyFilter(this.region, this.currency, date.getTime(), date.getTime(), this.tenderOnly);
}
@@ -483,7 +478,6 @@
* returns all currencies for which information is available.
* @return the matching currency codes
*/
- @libcore.api.IntraCoreApi
public List<String> currencies(CurrencyFilter filter) {
return Collections.emptyList();
}
diff --git a/android_icu4j/src/main/java/android/icu/text/DateTimePatternGenerator.java b/android_icu4j/src/main/java/android/icu/text/DateTimePatternGenerator.java
index 294a7cb..6ad49c2 100644
--- a/android_icu4j/src/main/java/android/icu/text/DateTimePatternGenerator.java
+++ b/android_icu4j/src/main/java/android/icu/text/DateTimePatternGenerator.java
@@ -112,7 +112,6 @@
* @hide original deprecated declaration
* @hide draft / provisional / internal are hidden on Android
*/
- @libcore.api.IntraCoreApi
@Deprecated
public static DateTimePatternGenerator getFrozenInstance(ULocale uLocale) {
String localeKey = uLocale.toString();
diff --git a/libandroidicuinit/IcuRegistration.cpp b/libandroidicuinit/IcuRegistration.cpp
index e671f35..195318d 100644
--- a/libandroidicuinit/IcuRegistration.cpp
+++ b/libandroidicuinit/IcuRegistration.cpp
@@ -21,11 +21,44 @@
#include <sys/types.h>
#include <errno.h>
#include <fcntl.h>
+#include <string.h>
#include <unistd.h>
#include <unicode/udata.h>
#include <unicode/utypes.h>
+#ifndef __ANDROID__
+static int PriorityToLevel(char priority) {
+ // Priority is just the array index of priority in kPriorities.
+ static const char* kPriorities = "VDIWEF";
+ static const int kLogSuppress = sizeof(kPriorities);
+ const char* matching_priority = strchr(kPriorities, toupper(priority));
+ return (matching_priority != nullptr) ? matching_priority - kPriorities : kLogSuppress;
+}
+
+static int GetHostLogLevel() {
+ const char* log_tags = getenv("ANDROID_LOG_TAGS");
+ if (log_tags == nullptr) {
+ return 0;
+ }
+ // Find the wildcard prefix if present in ANDROID_LOG_TAGS.
+ static constexpr const char kLogWildcardPrefix[] = "*:";
+ static constexpr size_t kLogWildcardPrefixLength = sizeof(kLogWildcardPrefix) - 1;
+ const char* wildcard_start = strstr(log_tags, kLogWildcardPrefix);
+ if (wildcard_start == nullptr) {
+ return 0;
+ }
+ // Priority is based on the character after the wildcard prefix.
+ char priority = *(wildcard_start + kLogWildcardPrefixLength);
+ return PriorityToLevel(priority);
+}
+
+bool AIcuHostShouldLog(char priority) {
+ static int g_LogLevel = GetHostLogLevel();
+ return PriorityToLevel(priority) >= g_LogLevel;
+}
+#endif // __ANDROID__
+
namespace androidicuinit {
namespace impl {
@@ -72,6 +105,12 @@
#endif
#endif // #ifndef __ANDROID__
+// http://b/171371690 Avoid dependency on liblog and libbase on host
+#ifdef __ANDROID__
+ typedef android::base::unique_fd aicu_unique_fd;
+#else
+ typedef simple_unique_fd aicu_unique_fd;
+#endif
// Map in ICU data at the path, returning null to print error if it failed.
std::unique_ptr<IcuDataMap> IcuDataMap::Create(const std::string& path) {
@@ -91,14 +130,7 @@
bool IcuDataMap::TryMap() {
// Open the file and get its length.
- #ifdef __ANDROID__
- #define UNIQUE_FD android::base::unique_fd
- #else
- // http://b/171371690 Avoid dependency on liblog and libbase on host
- #define UNIQUE_FD simple_unique_fd
- #endif
- UNIQUE_FD fd(TEMP_FAILURE_RETRY(open(path_.c_str(), O_RDONLY)));
- #undef UNIQUE_FD
+ aicu_unique_fd fd(TEMP_FAILURE_RETRY(open(path_.c_str(), O_RDONLY)));
if (fd.get() == -1) {
AICU_LOGE("Couldn't open '%s': %s", path_.c_str(), strerror(errno));
diff --git a/libandroidicuinit/IcuRegistration.h b/libandroidicuinit/IcuRegistration.h
index 83cd4e1..ded6f5b 100644
--- a/libandroidicuinit/IcuRegistration.h
+++ b/libandroidicuinit/IcuRegistration.h
@@ -33,10 +33,35 @@
// http://b/171371690 Avoid dependency on liblog and libbase on host for
// downstream unbundled branches. In this case, liblog and libbase are not
// very useful on host and we just try to avoid it here in our best effort.
- #define AICU_LOGE(...) fprintf(stderr, __VA_ARGS__)
- #define AICU_LOGW(...) fprintf(stderr, __VA_ARGS__)
- #define AICU_LOGD(...) fprintf(stderr, __VA_ARGS__)
- #define AICU_LOGV(...) fprintf(stderr, __VA_ARGS__)
+
+ // Check if a host should log a message.
+ //
+ // This method checks the priority argument against the wildcard level set
+ // in the ANDROID_LOG_TAGS environment variable. The priority specified
+ // corresponds to the standard Android set:
+ //
+ // V - verbose D - debug
+ // I - info W - warn
+ // E - error F - fatal
+ //
+ // If the ANDROID_LOG_TAGS variable is not set then this method returns true.
+ // Otherwise, the priority is compared to the level in ANDROID_LOG_TAGS.
+ //
+ // Example: if ANDROID_LOG_TAGS has the value "*:W" then this method will
+ // return true if the priority is warn or above.
+ bool AIcuHostShouldLog(char priority);
+
+ #define AICU_LOG_PRINTLN(priority, ...) \
+ do { \
+ if (AIcuHostShouldLog(priority)) { \
+ fprintf(stderr, __VA_ARGS__); \
+ fputc('\n', stderr); \
+ } \
+ } while (0)
+ #define AICU_LOGE(...) AICU_LOG_PRINTLN('E', __VA_ARGS__)
+ #define AICU_LOGW(...) AICU_LOG_PRINTLN('W', __VA_ARGS__)
+ #define AICU_LOGD(...) AICU_LOG_PRINTLN('D', __VA_ARGS__)
+ #define AICU_LOGV(...) AICU_LOG_PRINTLN('V', __VA_ARGS__)
#ifndef CHECK
#define CHECK(cond) \
if (!(cond)) { \
diff --git a/libicu/cts_headers/unicode/urename.h b/libicu/cts_headers/unicode/urename.h
index c0172e3..a68944c 100644
--- a/libicu/cts_headers/unicode/urename.h
+++ b/libicu/cts_headers/unicode/urename.h
@@ -1103,7 +1103,7 @@
// #define uloc_toUnicodeLocaleKey U_ICU_ENTRY_POINT_RENAME(uloc_toUnicodeLocaleKey)
// #define uloc_toUnicodeLocaleType U_ICU_ENTRY_POINT_RENAME(uloc_toUnicodeLocaleType)
#define ulocdata_close U_ICU_ENTRY_POINT_RENAME(ulocdata_close)
-#define ulocdata_getCLDRVersion U_ICU_ENTRY_POINT_RENAME(ulocdata_getCLDRVersion)
+// #define ulocdata_getCLDRVersion U_ICU_ENTRY_POINT_RENAME(ulocdata_getCLDRVersion)
#define ulocdata_getDelimiter U_ICU_ENTRY_POINT_RENAME(ulocdata_getDelimiter)
#define ulocdata_getExemplarSet U_ICU_ENTRY_POINT_RENAME(ulocdata_getExemplarSet)
#define ulocdata_getLocaleDisplayPattern U_ICU_ENTRY_POINT_RENAME(ulocdata_getLocaleDisplayPattern)
diff --git a/libicu/libicu.map.txt b/libicu/libicu.map.txt
index 12f30b6..3098a69 100644
--- a/libicu/libicu.map.txt
+++ b/libicu/libicu.map.txt
@@ -160,6 +160,7 @@
uloc_toLegacyType;
uloc_toUnicodeLocaleKey;
uloc_toUnicodeLocaleType;
+ ulocdata_getCLDRVersion;
local:
*;
};
\ No newline at end of file
diff --git a/libicu/ndk_headers/unicode/ulocdata.h b/libicu/ndk_headers/unicode/ulocdata.h
new file mode 100644
index 0000000..3015c11
--- /dev/null
+++ b/libicu/ndk_headers/unicode/ulocdata.h
@@ -0,0 +1,60 @@
+// © 2016 and later: Unicode, Inc. and others.
+// License & terms of use: http://www.unicode.org/copyright.html
+/*
+******************************************************************************
+* *
+* Copyright (C) 2003-2015, International Business Machines *
+* Corporation and others. All Rights Reserved. *
+* *
+******************************************************************************
+* file name: ulocdata.h
+* encoding: UTF-8
+* tab size: 8 (not used)
+* indentation:4
+*
+* created on: 2003Oct21
+* created by: Ram Viswanadha
+*/
+
+#ifndef __ULOCDATA_H__
+#define __ULOCDATA_H__
+
+#include "unicode/uloc.h"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+#if !defined(__ANDROID__) || __ANDROID_API__ >= 31
+
+/**
+ * Return the current CLDR version used by the library.
+ * @param versionArray fillin that will recieve the version number
+ * @param status error code - could be U_MISSING_RESOURCE_ERROR if the version was not found.
+ * @stable ICU 4.2
+ */
+U_STABLE void U_EXPORT2
+ulocdata_getCLDRVersion(UVersionInfo versionArray, UErrorCode *status) __INTRODUCED_IN(31);
+
+#endif // !defined(__ANDROID__) || __ANDROID_API__ >= 31
+
+
+
+
+
+#endif
diff --git a/libicu/src/shim.cpp b/libicu/src/shim.cpp
index 6ad9643..b36b487 100644
--- a/libicu/src/shim.cpp
+++ b/libicu/src/shim.cpp
@@ -5,6 +5,7 @@
#include <unicode/uchar.h>
#include <unicode/uloc.h>
+#include <unicode/ulocdata.h>
#include <unicode/ustring.h>
#include <unicode/utypes.h>
#include <unicode/uversion.h>
@@ -154,6 +155,7 @@
#undef uloc_toLegacyType
#undef uloc_toUnicodeLocaleKey
#undef uloc_toUnicodeLocaleType
+#undef ulocdata_getCLDRVersion
extern "C" {
void u_charAge(UChar32 c, UVersionInfo versionArray) {
@@ -588,4 +590,7 @@
const char * uloc_toUnicodeLocaleType(const char * keyword, const char * value) {
return U_ICU_ENTRY_POINT_RENAME(uloc_toUnicodeLocaleType)(keyword, value);
}
+void ulocdata_getCLDRVersion(UVersionInfo versionArray, UErrorCode * status) {
+ U_ICU_ENTRY_POINT_RENAME(ulocdata_getCLDRVersion)(versionArray, status);
+}
}
\ No newline at end of file
diff --git a/tools/icu4c_srcgen/doc_patches/patches/unicode/ulocdata.h.patch b/tools/icu4c_srcgen/doc_patches/patches/unicode/ulocdata.h.patch
new file mode 100644
index 0000000..2ef9bde
--- /dev/null
+++ b/tools/icu4c_srcgen/doc_patches/patches/unicode/ulocdata.h.patch
@@ -0,0 +1,117 @@
+--- libicu/ndk_headers/unicode/ulocdata.h 2020-10-27 17:40:16.875879610 +0000
++++ libicu/ndk_headers/unicode/ulocdata.h 2020-10-27 17:40:16.987880483 +0000
+@@ -19,91 +19,13 @@
+ #ifndef __ULOCDATA_H__
+ #define __ULOCDATA_H__
+
+-#include "unicode/ures.h"
+ #include "unicode/uloc.h"
+-#include "unicode/uset.h"
+
+-#if U_SHOW_CPLUSPLUS_API
+-#include "unicode/localpointer.h"
+-#endif // U_SHOW_CPLUSPLUS_API
+-
+-/**
+- * \file
+- * \brief C API: Provides access to locale data.
+- */
+-
+-/** Forward declaration of the ULocaleData structure. @stable ICU 3.6 */
+-struct ULocaleData;
+-
+-/** A locale data object. @stable ICU 3.6 */
+-typedef struct ULocaleData ULocaleData;
+-
+-
+-
+-/** The possible types of exemplar character sets.
+- * @stable ICU 3.4
+- */
+-typedef enum ULocaleDataExemplarSetType {
+- /** Basic set @stable ICU 3.4 */
+- ULOCDATA_ES_STANDARD=0,
+- /** Auxiliary set @stable ICU 3.4 */
+- ULOCDATA_ES_AUXILIARY=1,
+- /** Index Character set @stable ICU 4.8 */
+- ULOCDATA_ES_INDEX=2,
+- /** Punctuation set @stable ICU 51 */
+- ULOCDATA_ES_PUNCTUATION=3,
+-#ifndef U_HIDE_DEPRECATED_API
+- /**
+- * One more than the highest normal ULocaleDataExemplarSetType value.
+- * @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420.
+- */
+- ULOCDATA_ES_COUNT=4
+-#endif /* U_HIDE_DEPRECATED_API */
+-} ULocaleDataExemplarSetType;
+-
+-/** The possible types of delimiters.
+- * @stable ICU 3.4
+- */
+-typedef enum ULocaleDataDelimiterType {
+- /** Quotation start @stable ICU 3.4 */
+- ULOCDATA_QUOTATION_START = 0,
+- /** Quotation end @stable ICU 3.4 */
+- ULOCDATA_QUOTATION_END = 1,
+- /** Alternate quotation start @stable ICU 3.4 */
+- ULOCDATA_ALT_QUOTATION_START = 2,
+- /** Alternate quotation end @stable ICU 3.4 */
+- ULOCDATA_ALT_QUOTATION_END = 3,
+-#ifndef U_HIDE_DEPRECATED_API
+- /**
+- * One more than the highest normal ULocaleDataDelimiterType value.
+- * @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420.
+- */
+- ULOCDATA_DELIMITER_COUNT = 4
+-#endif /* U_HIDE_DEPRECATED_API */
+-} ULocaleDataDelimiterType;
+
+
+
+
+
+-#if U_SHOW_CPLUSPLUS_API
+-
+-U_NAMESPACE_BEGIN
+-
+-/**
+- * \class LocalULocaleDataPointer
+- * "Smart pointer" class, closes a ULocaleData via ulocdata_close().
+- * For most methods see the LocalPointerBase base class.
+- *
+- * @see LocalPointerBase
+- * @see LocalPointer
+- * @stable ICU 4.4
+- */
+-U_DEFINE_LOCAL_OPEN_POINTER(LocalULocaleDataPointer, ULocaleData, ulocdata_close);
+-
+-U_NAMESPACE_END
+-
+-#endif
+
+
+
+@@ -113,22 +35,6 @@
+
+
+
+-/**
+- * Enumeration for representing the measurement systems.
+- * @stable ICU 2.8
+- */
+-typedef enum UMeasurementSystem {
+- UMS_SI, /**< Measurement system specified by SI otherwise known as Metric system. @stable ICU 2.8 */
+- UMS_US, /**< Measurement system followed in the United States of America. @stable ICU 2.8 */
+- UMS_UK, /**< Mix of metric and imperial units used in Great Britain. @stable ICU 55 */
+-#ifndef U_HIDE_DEPRECATED_API
+- /**
+- * One more than the highest normal UMeasurementSystem value.
+- * @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420.
+- */
+- UMS_LIMIT
+-#endif /* U_HIDE_DEPRECATED_API */
+-} UMeasurementSystem;
+
+
+
diff --git a/tools/icu4c_srcgen/generate_ndk.py b/tools/icu4c_srcgen/generate_ndk.py
index 6254a2c..cbdc1d7 100755
--- a/tools/icu4c_srcgen/generate_ndk.py
+++ b/tools/icu4c_srcgen/generate_ndk.py
@@ -170,6 +170,9 @@
with open(urename_path, "w") as out:
out.write(modified)
+IGNORED_INCLUDE_DEPENDENCY = {
+ "ulocdata.h" : [ "ures.h", "uset.h", ],
+}
def main():
"""Parse the ICU4C headers and generate the shim libicu."""
@@ -179,6 +182,7 @@
decl_filters = [StableDeclarationFilter()]
decl_filters.append(AllowlistedDeclarationFilter(allowlisted_apis))
parser = DeclaredFunctionsParser(decl_filters, [])
+ parser.set_ignored_include_dependency(IGNORED_INCLUDE_DEPENDENCY)
parser.parse()
diff --git a/tools/icu4c_srcgen/genutil.py b/tools/icu4c_srcgen/genutil.py
index a459f23..d652ac2 100644
--- a/tools/icu4c_srcgen/genutil.py
+++ b/tools/icu4c_srcgen/genutil.py
@@ -158,6 +158,7 @@
self.decl_filters = decl_filters
self.allowlisted_decl_filters = allowlisted_decl_filter
self.va_functions_mapping = {}
+ self.ignored_include_dependency = {}
# properties to store the parsing result
self.all_headers = []
@@ -186,6 +187,13 @@
inserted as the 3rd argument."""
self.va_functions_mapping = mapping
+ def set_ignored_include_dependency(self, mapping):
+ """
+ A sample mapping is { "ulocdata.h" : [ "uloc.h", "ures.h" ] }.
+ The include dependencies will explicitly be ignored when producing header_paths_to_copy.
+ """
+ self.ignored_include_dependency = mapping
+
@property
def header_includes(self):
"""Return all headers declaring the functions returned in get_all_declared_functions.
@@ -304,10 +312,16 @@
self.all_header_paths_to_copy.add(header)
while file_queue:
file = file_queue.pop()
+ file_basename = os.path.basename(file)
if file in file_processed:
continue
file_processed.add(file)
for header in header_dependencies[file]:
+ header_basename = os.path.basename(header)
+ # Skip this header if this dependency is explicitly ignored
+ if file_basename in self.ignored_include_dependency and \
+ header_basename in self.ignored_include_dependency[file_basename]:
+ continue
if header in header_dependencies: # Do not care non-icu4c headers
self.all_header_paths_to_copy.add(header)
file_queue.appendleft(header)
diff --git a/tools/icu4c_srcgen/libicu_export.txt b/tools/icu4c_srcgen/libicu_export.txt
index 0f7dc34..fc3c773 100644
--- a/tools/icu4c_srcgen/libicu_export.txt
+++ b/tools/icu4c_srcgen/libicu_export.txt
@@ -125,6 +125,7 @@
u_totitle
u_toupper
u_versionToString
+ulocdata_getCLDRVersion
uloc_acceptLanguage
uloc_addLikelySubtags
uloc_canonicalize
diff --git a/tools/srcgen/intra-core-api.txt b/tools/srcgen/intra-core-api.txt
index 0d1e9ae..7e17fda 100644
--- a/tools/srcgen/intra-core-api.txt
+++ b/tools/srcgen/intra-core-api.txt
@@ -6,13 +6,8 @@
field:android.icu.util.DateTimeRule#STANDARD_TIME
field:android.icu.util.DateTimeRule#UTC_TIME
field:android.icu.util.DateTimeRule#WALL_TIME
-method:android.icu.text.CurrencyMetaInfo#getInstance()
-method:android.icu.text.CurrencyMetaInfo#currencies(CurrencyFilter)
-method:android.icu.text.CurrencyMetaInfo$CurrencyFilter#onRegion(String)
-method:android.icu.text.CurrencyMetaInfo$CurrencyFilter#withDate(Date)
method:android.icu.text.DateFormatSymbols#DateFormatSymbols(ULocale,String)
method:android.icu.text.DateFormatSymbols#getNarrowEras()
-method:android.icu.text.DateTimePatternGenerator#getFrozenInstance(ULocale)
method:android.icu.text.DecimalFormat#setParseJavaCompatible(boolean)
method:android.icu.text.IDNA#convertIDNToASCII(String,int)
method:android.icu.text.IDNA#convertIDNToUnicode(String,int)
@@ -44,8 +39,6 @@
method:android.icu.util.TimeZoneTransition#getTime()
method:android.icu.util.TimeZoneTransition#getTo()
method:android.icu.util.ULocale#getRegionForSupplementalData(ULocale,boolean)
-type:android.icu.text.CurrencyMetaInfo
-type:android.icu.text.CurrencyMetaInfo$CurrencyFilter
type:android.icu.text.TimeZoneNames$MatchInfo
type:android.icu.util.AnnualTimeZoneRule
type:android.icu.util.BasicTimeZone