Remove u_strCompareIter and uloc_acceptLanguageFromHTTP from NDK headers

It does not cause any compat problems because the functions are not
the NDK stub described in .map.txt. Also, there were no new release
after adding the NDK headers, and no app can use them today.

It was accidentally added into the headers due to a bug in the
code generation script.

Bug: 160350521
Test: m droid cts
Change-Id: I53d8984df6ce20578ccabb4572ab0f3586125d27
diff --git a/libicu/ndk_headers/unicode/uiter.h b/libicu/ndk_headers/unicode/uiter.h
deleted file mode 100644
index b8b6c3b..0000000
--- a/libicu/ndk_headers/unicode/uiter.h
+++ /dev/null
@@ -1,503 +0,0 @@
-// © 2016 and later: Unicode, Inc. and others.
-// License & terms of use: http://www.unicode.org/copyright.html
-/*
-*******************************************************************************
-*
-*   Copyright (C) 2002-2011 International Business Machines
-*   Corporation and others.  All Rights Reserved.
-*
-*******************************************************************************
-*   file name:  uiter.h
-*   encoding:   UTF-8
-*   tab size:   8 (not used)
-*   indentation:4
-*
-*   created on: 2002jan18
-*   created by: Markus W. Scherer
-*/
-
-#ifndef __UITER_H__
-#define __UITER_H__
-
-/**
- * \file
- * \brief C API: Unicode Character Iteration
- *
- * @see UCharIterator
- */
-
-#include "unicode/utypes.h"
-
-#if U_SHOW_CPLUSPLUS_API
-    U_NAMESPACE_BEGIN
-
-    class CharacterIterator;
-    class Replaceable;
-
-    U_NAMESPACE_END
-#endif
-
-U_CDECL_BEGIN
-
-struct UCharIterator;
-typedef struct UCharIterator UCharIterator; /**< C typedef for struct UCharIterator. @stable ICU 2.1 */
-
-/**
- * Origin constants for UCharIterator.getIndex() and UCharIterator.move().
- * @see UCharIteratorMove
- * @see UCharIterator
- * @stable ICU 2.1
- */
-typedef enum UCharIteratorOrigin {
-    UITER_START, UITER_CURRENT, UITER_LIMIT, UITER_ZERO, UITER_LENGTH
-} UCharIteratorOrigin;
-
-/** Constants for UCharIterator. @stable ICU 2.6 */
-enum {
-    /**
-     * Constant value that may be returned by UCharIteratorMove
-     * indicating that the final UTF-16 index is not known, but that the move succeeded.
-     * This can occur when moving relative to limit or length, or
-     * when moving relative to the current index after a setState()
-     * when the current UTF-16 index is not known.
-     *
-     * It would be very inefficient to have to count from the beginning of the text
-     * just to get the current/limit/length index after moving relative to it.
-     * The actual index can be determined with getIndex(UITER_CURRENT)
-     * which will count the UChars if necessary.
-     *
-     * @stable ICU 2.6
-     */
-    UITER_UNKNOWN_INDEX=-2
-};
-
-
-/**
- * Constant for UCharIterator getState() indicating an error or
- * an unknown state.
- * Returned by uiter_getState()/UCharIteratorGetState
- * when an error occurs.
- * Also, some UCharIterator implementations may not be able to return
- * a valid state for each position. This will be clearly documented
- * for each such iterator (none of the public ones here).
- *
- * @stable ICU 2.6
- */
-#define UITER_NO_STATE ((uint32_t)0xffffffff)
-
-/**
- * Function type declaration for UCharIterator.getIndex().
- *
- * Gets the current position, or the start or limit of the
- * iteration range.
- *
- * This function may perform slowly for UITER_CURRENT after setState() was called,
- * or for UITER_LENGTH, because an iterator implementation may have to count
- * UChars if the underlying storage is not UTF-16.
- *
- * @param iter the UCharIterator structure ("this pointer")
- * @param origin get the 0, start, limit, length, or current index
- * @return the requested index, or U_SENTINEL in an error condition
- *
- * @see UCharIteratorOrigin
- * @see UCharIterator
- * @stable ICU 2.1
- */
-typedef int32_t U_CALLCONV
-UCharIteratorGetIndex(UCharIterator *iter, UCharIteratorOrigin origin);
-
-/**
- * Function type declaration for UCharIterator.move().
- *
- * Use iter->move(iter, index, UITER_ZERO) like CharacterIterator::setIndex(index).
- *
- * Moves the current position relative to the start or limit of the
- * iteration range, or relative to the current position itself.
- * The movement is expressed in numbers of code units forward
- * or backward by specifying a positive or negative delta.
- * Out of bounds movement will be pinned to the start or limit.
- *
- * This function may perform slowly for moving relative to UITER_LENGTH
- * because an iterator implementation may have to count the rest of the
- * UChars if the native storage is not UTF-16.
- *
- * When moving relative to the limit or length, or
- * relative to the current position after setState() was called,
- * move() may return UITER_UNKNOWN_INDEX (-2) to avoid an inefficient
- * determination of the actual UTF-16 index.
- * The actual index can be determined with getIndex(UITER_CURRENT)
- * which will count the UChars if necessary.
- * See UITER_UNKNOWN_INDEX for details.
- *
- * @param iter the UCharIterator structure ("this pointer")
- * @param delta can be positive, zero, or negative
- * @param origin move relative to the 0, start, limit, length, or current index
- * @return the new index, or U_SENTINEL on an error condition,
- *         or UITER_UNKNOWN_INDEX when the index is not known.
- *
- * @see UCharIteratorOrigin
- * @see UCharIterator
- * @see UITER_UNKNOWN_INDEX
- * @stable ICU 2.1
- */
-typedef int32_t U_CALLCONV
-UCharIteratorMove(UCharIterator *iter, int32_t delta, UCharIteratorOrigin origin);
-
-/**
- * Function type declaration for UCharIterator.hasNext().
- *
- * Check if current() and next() can still
- * return another code unit.
- *
- * @param iter the UCharIterator structure ("this pointer")
- * @return boolean value for whether current() and next() can still return another code unit
- *
- * @see UCharIterator
- * @stable ICU 2.1
- */
-typedef UBool U_CALLCONV
-UCharIteratorHasNext(UCharIterator *iter);
-
-/**
- * Function type declaration for UCharIterator.hasPrevious().
- *
- * Check if previous() can still return another code unit.
- *
- * @param iter the UCharIterator structure ("this pointer")
- * @return boolean value for whether previous() can still return another code unit
- *
- * @see UCharIterator
- * @stable ICU 2.1
- */
-typedef UBool U_CALLCONV
-UCharIteratorHasPrevious(UCharIterator *iter);
- 
-/**
- * Function type declaration for UCharIterator.current().
- *
- * Return the code unit at the current position,
- * or U_SENTINEL if there is none (index is at the limit).
- *
- * @param iter the UCharIterator structure ("this pointer")
- * @return the current code unit
- *
- * @see UCharIterator
- * @stable ICU 2.1
- */
-typedef UChar32 U_CALLCONV
-UCharIteratorCurrent(UCharIterator *iter);
-
-/**
- * Function type declaration for UCharIterator.next().
- *
- * Return the code unit at the current index and increment
- * the index (post-increment, like s[i++]),
- * or return U_SENTINEL if there is none (index is at the limit).
- *
- * @param iter the UCharIterator structure ("this pointer")
- * @return the current code unit (and post-increment the current index)
- *
- * @see UCharIterator
- * @stable ICU 2.1
- */
-typedef UChar32 U_CALLCONV
-UCharIteratorNext(UCharIterator *iter);
-
-/**
- * Function type declaration for UCharIterator.previous().
- *
- * Decrement the index and return the code unit from there
- * (pre-decrement, like s[--i]),
- * or return U_SENTINEL if there is none (index is at the start).
- *
- * @param iter the UCharIterator structure ("this pointer")
- * @return the previous code unit (after pre-decrementing the current index)
- *
- * @see UCharIterator
- * @stable ICU 2.1
- */
-typedef UChar32 U_CALLCONV
-UCharIteratorPrevious(UCharIterator *iter);
-
-/**
- * Function type declaration for UCharIterator.reservedFn().
- * Reserved for future use.
- *
- * @param iter the UCharIterator structure ("this pointer")
- * @param something some integer argument
- * @return some integer
- *
- * @see UCharIterator
- * @stable ICU 2.1
- */
-typedef int32_t U_CALLCONV
-UCharIteratorReserved(UCharIterator *iter, int32_t something);
-
-/**
- * Function type declaration for UCharIterator.getState().
- *
- * Get the "state" of the iterator in the form of a single 32-bit word.
- * It is recommended that the state value be calculated to be as small as
- * is feasible. For strings with limited lengths, fewer than 32 bits may
- * be sufficient.
- *
- * This is used together with setState()/UCharIteratorSetState
- * to save and restore the iterator position more efficiently than with
- * getIndex()/move().
- *
- * The iterator state is defined as a uint32_t value because it is designed
- * for use in ucol_nextSortKeyPart() which provides 32 bits to store the state
- * of the character iterator.
- *
- * With some UCharIterator implementations (e.g., UTF-8),
- * getting and setting the UTF-16 index with existing functions
- * (getIndex(UITER_CURRENT) followed by move(pos, UITER_ZERO)) is possible but
- * relatively slow because the iterator has to "walk" from a known index
- * to the requested one.
- * This takes more time the farther it needs to go.
- *
- * An opaque state value allows an iterator implementation to provide
- * an internal index (UTF-8: the source byte array index) for
- * fast, constant-time restoration.
- *
- * After calling setState(), a getIndex(UITER_CURRENT) may be slow because
- * the UTF-16 index may not be restored as well, but the iterator can deliver
- * the correct text contents and move relative to the current position
- * without performance degradation.
- *
- * Some UCharIterator implementations may not be able to return
- * a valid state for each position, in which case they return UITER_NO_STATE instead.
- * This will be clearly documented for each such iterator (none of the public ones here).
- *
- * @param iter the UCharIterator structure ("this pointer")
- * @return the state word
- *
- * @see UCharIterator
- * @see UCharIteratorSetState
- * @see UITER_NO_STATE
- * @stable ICU 2.6
- */
-typedef uint32_t U_CALLCONV
-UCharIteratorGetState(const UCharIterator *iter);
-
-/**
- * Function type declaration for UCharIterator.setState().
- *
- * Restore the "state" of the iterator using a state word from a getState() call.
- * The iterator object need not be the same one as for which getState() was called,
- * but it must be of the same type (set up using the same uiter_setXYZ function)
- * and it must iterate over the same string
- * (binary identical regardless of memory address).
- * For more about the state word see UCharIteratorGetState.
- *
- * After calling setState(), a getIndex(UITER_CURRENT) may be slow because
- * the UTF-16 index may not be restored as well, but the iterator can deliver
- * the correct text contents and move relative to the current position
- * without performance degradation.
- *
- * @param iter the UCharIterator structure ("this pointer")
- * @param state the state word from a getState() call
- *              on a same-type, same-string iterator
- * @param pErrorCode Must be a valid pointer to an error code value,
- *                   which must not indicate a failure before the function call.
- *
- * @see UCharIterator
- * @see UCharIteratorGetState
- * @stable ICU 2.6
- */
-typedef void U_CALLCONV
-UCharIteratorSetState(UCharIterator *iter, uint32_t state, UErrorCode *pErrorCode);
-
-
-/**
- * C API for code unit iteration.
- * This can be used as a C wrapper around
- * CharacterIterator, Replaceable, or implemented using simple strings, etc.
- *
- * There are two roles for using UCharIterator:
- *
- * A "provider" sets the necessary function pointers and controls the "protected"
- * fields of the UCharIterator structure. A "provider" passes a UCharIterator
- * into C APIs that need a UCharIterator as an abstract, flexible string interface.
- *
- * Implementations of such C APIs are "callers" of UCharIterator functions;
- * they only use the "public" function pointers and never access the "protected"
- * fields directly.
- *
- * The current() and next() functions only check the current index against the
- * limit, and previous() only checks the current index against the start,
- * to see if the iterator already reached the end of the iteration range.
- *
- * The assumption - in all iterators - is that the index is moved via the API,
- * which means it won't go out of bounds, or the index is modified by
- * user code that knows enough about the iterator implementation to set valid
- * index values.
- *
- * UCharIterator functions return code unit values 0..0xffff,
- * or U_SENTINEL if the iteration bounds are reached.
- *
- * @stable ICU 2.1
- */
-struct UCharIterator {
-    /**
-     * (protected) Pointer to string or wrapped object or similar.
-     * Not used by caller.
-     * @stable ICU 2.1
-     */
-    const void *context;
-
-    /**
-     * (protected) Length of string or similar.
-     * Not used by caller.
-     * @stable ICU 2.1
-     */
-    int32_t length;
-
-    /**
-     * (protected) Start index or similar.
-     * Not used by caller.
-     * @stable ICU 2.1
-     */
-    int32_t start;
-
-    /**
-     * (protected) Current index or similar.
-     * Not used by caller.
-     * @stable ICU 2.1
-     */
-    int32_t index;
-
-    /**
-     * (protected) Limit index or similar.
-     * Not used by caller.
-     * @stable ICU 2.1
-     */
-    int32_t limit;
-
-    /**
-     * (protected) Used by UTF-8 iterators and possibly others.
-     * @stable ICU 2.1
-     */
-    int32_t reservedField;
-
-    /**
-     * (public) Returns the current position or the
-     * start or limit index of the iteration range.
-     *
-     * @see UCharIteratorGetIndex
-     * @stable ICU 2.1
-     */
-    UCharIteratorGetIndex *getIndex;
-
-    /**
-     * (public) Moves the current position relative to the start or limit of the
-     * iteration range, or relative to the current position itself.
-     * The movement is expressed in numbers of code units forward
-     * or backward by specifying a positive or negative delta.
-     *
-     * @see UCharIteratorMove
-     * @stable ICU 2.1
-     */
-    UCharIteratorMove *move;
-
-    /**
-     * (public) Check if current() and next() can still
-     * return another code unit.
-     *
-     * @see UCharIteratorHasNext
-     * @stable ICU 2.1
-     */
-    UCharIteratorHasNext *hasNext;
-
-    /**
-     * (public) Check if previous() can still return another code unit.
-     *
-     * @see UCharIteratorHasPrevious
-     * @stable ICU 2.1
-     */
-    UCharIteratorHasPrevious *hasPrevious;
-
-    /**
-     * (public) Return the code unit at the current position,
-     * or U_SENTINEL if there is none (index is at the limit).
-     *
-     * @see UCharIteratorCurrent
-     * @stable ICU 2.1
-     */
-    UCharIteratorCurrent *current;
-
-    /**
-     * (public) Return the code unit at the current index and increment
-     * the index (post-increment, like s[i++]),
-     * or return U_SENTINEL if there is none (index is at the limit).
-     *
-     * @see UCharIteratorNext
-     * @stable ICU 2.1
-     */
-    UCharIteratorNext *next;
-
-    /**
-     * (public) Decrement the index and return the code unit from there
-     * (pre-decrement, like s[--i]),
-     * or return U_SENTINEL if there is none (index is at the start).
-     *
-     * @see UCharIteratorPrevious
-     * @stable ICU 2.1
-     */
-    UCharIteratorPrevious *previous;
-
-    /**
-     * (public) Reserved for future use. Currently NULL.
-     *
-     * @see UCharIteratorReserved
-     * @stable ICU 2.1
-     */
-    UCharIteratorReserved *reservedFn;
-
-    /**
-     * (public) Return the state of the iterator, to be restored later with setState().
-     * This function pointer is NULL if the iterator does not implement it.
-     *
-     * @see UCharIteratorGet
-     * @stable ICU 2.6
-     */
-    UCharIteratorGetState *getState;
-
-    /**
-     * (public) Restore the iterator state from the state word from a call
-     * to getState().
-     * This function pointer is NULL if the iterator does not implement it.
-     *
-     * @see UCharIteratorSet
-     * @stable ICU 2.6
-     */
-    UCharIteratorSetState *setState;
-};
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-#if U_SHOW_CPLUSPLUS_API
-
-
-
-
-
-#endif
-
-U_CDECL_END
-
-#endif
diff --git a/libicu/ndk_headers/unicode/uloc.h b/libicu/ndk_headers/unicode/uloc.h
index 0848b2b..32e27ea 100644
--- a/libicu/ndk_headers/unicode/uloc.h
+++ b/libicu/ndk_headers/unicode/uloc.h
@@ -1099,28 +1099,7 @@
 } UAcceptResult;
 
 
-#if !defined(__ANDROID__) || __ANDROID_API__ >= 31
 
-/**
- * Based on a HTTP header from a web browser and a list of available locales,
- * determine an acceptable locale for the user.
- * @param result - buffer to accept the result locale
- * @param resultAvailable the size of the result buffer.
- * @param outResult - An out parameter that contains the fallback status
- * @param httpAcceptLanguage - "Accept-Language:" header as per HTTP.
- * @param availableLocales - list of available locales to match
- * @param status Error status, may be BUFFER_OVERFLOW_ERROR
- * @return length needed for the locale.
- * @stable ICU 3.2
- */
-U_STABLE int32_t U_EXPORT2
-uloc_acceptLanguageFromHTTP(char *result, int32_t resultAvailable,
-                            UAcceptResult *outResult,
-                            const char *httpAcceptLanguage,
-                            UEnumeration* availableLocales,
-                            UErrorCode *status) __INTRODUCED_IN(31);
-
-#endif // !defined(__ANDROID__) || __ANDROID_API__ >= 31
 
 #if !defined(__ANDROID__) || __ANDROID_API__ >= 31
 
diff --git a/libicu/ndk_headers/unicode/ustring.h b/libicu/ndk_headers/unicode/ustring.h
index 6357232..560ebe0 100644
--- a/libicu/ndk_headers/unicode/ustring.h
+++ b/libicu/ndk_headers/unicode/ustring.h
@@ -20,7 +20,6 @@
 
 #include "unicode/utypes.h"
 #include "unicode/putil.h"
-#include "unicode/uiter.h"
 
 /**
  * \def UBRK_TYPEDEF_UBREAK_ITERATOR
@@ -554,32 +553,7 @@
 
 #endif // !defined(__ANDROID__) || __ANDROID_API__ >= 31
 
-#if !defined(__ANDROID__) || __ANDROID_API__ >= 31
 
-/**
- * Compare two Unicode strings (binary order)
- * as presented by UCharIterator objects.
- * Works otherwise just like u_strCompare().
- *
- * Both iterators are reset to their start positions.
- * When the function returns, it is undefined where the iterators
- * have stopped.
- *
- * @param iter1 First source string iterator.
- * @param iter2 Second source string iterator.
- * @param codePointOrder Choose between code unit order (FALSE)
- *                       and code point order (TRUE).
- *
- * @return <0 or 0 or >0 as usual for string comparisons
- *
- * @see u_strCompare
- *
- * @stable ICU 2.6
- */
-U_STABLE int32_t U_EXPORT2
-u_strCompareIter(UCharIterator *iter1, UCharIterator *iter2, UBool codePointOrder) __INTRODUCED_IN(31);
-
-#endif // !defined(__ANDROID__) || __ANDROID_API__ >= 31
 
 #if !defined(__ANDROID__) || __ANDROID_API__ >= 31
 
diff --git a/tools/icu4c_srcgen/doc_patches/apply_patches.sh b/tools/icu4c_srcgen/doc_patches/apply_patches.sh
index 0d12c4c..7108c60 100755
--- a/tools/icu4c_srcgen/doc_patches/apply_patches.sh
+++ b/tools/icu4c_srcgen/doc_patches/apply_patches.sh
@@ -19,4 +19,6 @@
 source $(dirname $BASH_SOURCE)/common.sh
 
 cd ${ICU_DIR}
-find ${PATCHES_DIR} -name '*.patch' -type f -exec patch -p0 -s -i '{}' \;
+if [ -d "${PATCHES_DIR}" ]; then
+  find ${PATCHES_DIR} -name '*.patch' -type f -exec patch -p0 -s -i '{}' \;
+fi
diff --git a/tools/icu4c_srcgen/doc_patches/create_patches.sh b/tools/icu4c_srcgen/doc_patches/create_patches.sh
index 6d2482a..e40d64d 100755
--- a/tools/icu4c_srcgen/doc_patches/create_patches.sh
+++ b/tools/icu4c_srcgen/doc_patches/create_patches.sh
@@ -25,7 +25,7 @@
 # Create libicu/ copy without patches
 cd ${ICU_DIR}
 git checkout -- ${LIBICU_DIR}
-if [ -d "$DIR" ]; then
+if [ -d "${PATCHES_DIR}" ]; then
   rm -r ${PATCHES_DIR} 2> /dev/null
 fi
 cd ${SRCGEN_DIR}
diff --git a/tools/icu4c_srcgen/doc_patches/patches/unicode/uloc.h.patch b/tools/icu4c_srcgen/doc_patches/patches/unicode/uloc.h.patch
index 3d8b1f9..b2438e3 100644
--- a/tools/icu4c_srcgen/doc_patches/patches/unicode/uloc.h.patch
+++ b/tools/icu4c_srcgen/doc_patches/patches/unicode/uloc.h.patch
@@ -1,5 +1,5 @@
---- libicu/ndk_headers/unicode/uloc.h	2020-09-23 17:46:50.130053357 +0100
-+++ libicu/ndk_headers/unicode/uloc.h	2020-09-23 17:46:50.230054109 +0100
+--- libicu/ndk_headers/unicode/uloc.h	2020-11-20 20:54:36.898730971 +0000
++++ libicu/ndk_headers/unicode/uloc.h	2020-11-20 20:54:37.010731778 +0000
 @@ -368,6 +368,9 @@
   *   and unchanged even when uloc_setDefault() is called.
   *   The returned storage is owned by ICU, and must not be altered or deleted
diff --git a/tools/icu4c_srcgen/doc_patches/patches/unicode/ulocdata.h.patch b/tools/icu4c_srcgen/doc_patches/patches/unicode/ulocdata.h.patch
index 2ef9bde..c771dcb 100644
--- a/tools/icu4c_srcgen/doc_patches/patches/unicode/ulocdata.h.patch
+++ b/tools/icu4c_srcgen/doc_patches/patches/unicode/ulocdata.h.patch
@@ -1,12 +1,8 @@
---- 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__
+--- libicu/ndk_headers/unicode/ulocdata.h	2020-11-20 20:54:36.910731058 +0000
++++ libicu/ndk_headers/unicode/ulocdata.h	2020-11-20 20:54:37.042732009 +0000
+@@ -21,87 +21,11 @@
  
--#include "unicode/ures.h"
  #include "unicode/uloc.h"
--#include "unicode/uset.h"
  
 -#if U_SHOW_CPLUSPLUS_API
 -#include "unicode/localpointer.h"
@@ -92,7 +88,7 @@
  
  
  
-@@ -113,22 +35,6 @@
+@@ -111,22 +35,6 @@
  
  
  
diff --git a/tools/icu4c_srcgen/generate_ndk.py b/tools/icu4c_srcgen/generate_ndk.py
index cbdc1d7..30e560c 100755
--- a/tools/icu4c_srcgen/generate_ndk.py
+++ b/tools/icu4c_srcgen/generate_ndk.py
@@ -64,7 +64,7 @@
     """Return a regex in string to capture the C function declarations in the decl_names list"""
     tag = "|".join(decl_names)
     return r"(" + DOC_BLOCK_COMMENT + STABLE_MACRO + r"[^(]*(?=" + tag + r")(" + tag + ")" \
-           + TILL_CLOSE_PARENTHESIS +");$"
+           + r"\("+ TILL_CLOSE_PARENTHESIS +");$"
 
 def get_replacement_adding_api_level_macro(api_level):
     """Return the replacement string adding the NDK C macro
@@ -80,8 +80,8 @@
     and output to the dst_path """
     allowlist_regex_string = get_allowlisted_regex_string(decl_names)
     allowlist_decl_regex = re.compile('^' + allowlist_regex_string, re.MULTILINE)
-    secrete_allowlist_decl_regex = re.compile('^' + SECRET_PROCESSING_TOKEN
-                                              + allowlist_regex_string, re.MULTILINE)
+    secret_allowlist_decl_regex = re.compile('^' + SECRET_PROCESSING_TOKEN
+                                             + allowlist_regex_string, re.MULTILINE)
     with open(src_path, "r") as file:
         src = file.read()
 
@@ -94,11 +94,31 @@
     # Remove all other stable declarations not in the allowlist
     modified = REGEX_STABLE_FUNCTION_DECLARATION.sub('', modified)
     # Insert C macro and annotation to indicate the API level to each functions in the allowlist
-    modified = secrete_allowlist_decl_regex.sub(
+    modified = secret_allowlist_decl_regex.sub(
         get_replacement_adding_api_level_macro(31), modified)
 
     with open(dst_path, "w") as out:
         out.write(modified)
+def remove_ignored_includes(file_path, include_list):
+    """
+    Remove the included header, i.e. #include lines, listed in include_list from the file_path
+    header.
+    """
+
+    # Do nothing if the list is empty
+    if not include_list:
+        return
+
+    tag = "|".join(include_list)
+
+    with open(file_path, "r") as file:
+        content = file.read()
+
+    regex = re.compile(r"^#include \"unicode\/(" + tag + ")\"\n", re.MULTILINE)
+    content = regex.sub('', content)
+
+    with open(file_path, "w") as out:
+        out.write(content)
 
 def copy_header_only_files():
     """Copy required header only files"""
@@ -171,7 +191,8 @@
         out.write(modified)
 
 IGNORED_INCLUDE_DEPENDENCY = {
-    "ulocdata.h" : [ "ures.h", "uset.h", ],
+    "ulocdata.h": ["ures.h", "uset.h", ],
+    "ustring.h": ["uiter.h", ],
 }
 
 def main():
@@ -212,6 +233,9 @@
         basename = os.path.basename(src_path)
         dst_path = os.path.join(headers_folder, basename)
         modify_func_declarations(src_path, dst_path, header_to_function_names[basename])
+        # Remove #include lines from the header files.
+        if basename in IGNORED_INCLUDE_DEPENDENCY:
+            remove_ignored_includes(dst_path, IGNORED_INCLUDE_DEPENDENCY[basename])
 
     copy_header_only_files()