DO NOT MERGE - Merge PPRL.190305.001 into master

Bug: 127812889
Change-Id: I0d2081468576af5285eec5fb38a12d8fe58634f8
diff --git a/android_icu4j/src/main/tests/android/icu/dev/test/translit/UnicodeMapTest.java b/android_icu4j/src/main/tests/android/icu/dev/test/translit/UnicodeMapTest.java
index 89e9d95..ba55ee9 100644
--- a/android_icu4j/src/main/tests/android/icu/dev/test/translit/UnicodeMapTest.java
+++ b/android_icu4j/src/main/tests/android/icu/dev/test/translit/UnicodeMapTest.java
@@ -346,33 +346,28 @@
         checkNext(map1, map2, LIMIT);
     }
 
+    private static final int SET_LIMIT = 0x10FFFF;
     private static final int propEnum = UProperty.GENERAL_CATEGORY;
 
     @Test
     public void TestUnicodeMapGeneralCategory() {
         logln("Setting General Category");
-        UnicodeMap<String> map1 = new UnicodeMap();
-        Map<Integer, String> map2 = new HashMap<Integer, String>();
-        //Map<Integer, String> map3 = new TreeMap<Integer, String>();
-        map1 = new UnicodeMap<String>();
-        map2 = new TreeMap<Integer,String>();
-        for (int cp = 0;;) {
+        // Android patch begin. b/79168307 Reduce the heap memory needed for the test
+        splitTestUnicodeMapGeneralCategory(0, SET_LIMIT / 2);
+        splitTestUnicodeMapGeneralCategory(SET_LIMIT / 2 + 1, SET_LIMIT);
+        // Android patch end. b/79168307 Reduce the heap memory needed for the test
+    }
+
+    // Android patch begin. b/79168307 Reduce the heap memory needed for the test
+    private void splitTestUnicodeMapGeneralCategory(int startCodePoint, int endCodePoint) {
+        UnicodeMap<String> map1 = new UnicodeMap<String>();
+        Map<Integer, String> map2 = new TreeMap<Integer,String>();
+        for (int cp = startCodePoint; cp <= endCodePoint; ++cp) {
               int enumValue = UCharacter.getIntPropertyValue(cp, propEnum);
               //if (enumValue <= 0) continue; // for smaller set
               String value = UCharacter.getPropertyValueName(propEnum,enumValue, UProperty.NameChoice.LONG);
               map1.put(cp, value);
               map2.put(cp, value);
-              cp++;
-              // Unicode is huge, skip over large parts of it.
-              if (cp == 0x08FF) {           // General Scripts Area.
-                  cp = 0xD700;              // Hangul Syllables Area.
-              } else if (cp == 0x100FF) {   // General Scripts Area.
-                  cp = 0x1F000;             // Symbols Area.
-              } else if (cp == 0x200FF) {   // CJK Unified Ideographs Extensions.
-                  cp = 0x10FF00;            // Supplementary Private Use Area-B.
-              } else if (cp == 0x10FFFF) {  // The end of Unicode.
-                  break;
-              }
         }
         checkNext(map1, map2, Integer.MAX_VALUE);
 
@@ -395,6 +390,7 @@
             }
         }
     }
+    // Android patch end. b/79168307 Reduce the heap memory needed for the test
 
     @Test
     public void TestAUnicodeMap2() {
diff --git a/icu4j/main/tests/translit/src/com/ibm/icu/dev/test/translit/UnicodeMapTest.java b/icu4j/main/tests/translit/src/com/ibm/icu/dev/test/translit/UnicodeMapTest.java
index 0038304..34346d1 100644
--- a/icu4j/main/tests/translit/src/com/ibm/icu/dev/test/translit/UnicodeMapTest.java
+++ b/icu4j/main/tests/translit/src/com/ibm/icu/dev/test/translit/UnicodeMapTest.java
@@ -343,33 +343,28 @@
         checkNext(map1, map2, LIMIT);
     }
 
+    private static final int SET_LIMIT = 0x10FFFF;
     private static final int propEnum = UProperty.GENERAL_CATEGORY;
 
     @Test
     public void TestUnicodeMapGeneralCategory() {
         logln("Setting General Category");
-        UnicodeMap<String> map1 = new UnicodeMap();
-        Map<Integer, String> map2 = new HashMap<Integer, String>();
-        //Map<Integer, String> map3 = new TreeMap<Integer, String>();
-        map1 = new UnicodeMap<String>();
-        map2 = new TreeMap<Integer,String>();
-        for (int cp = 0;;) {
+        // Android patch begin. b/79168307 Reduce the heap memory needed for the test
+        splitTestUnicodeMapGeneralCategory(0, SET_LIMIT / 2);
+        splitTestUnicodeMapGeneralCategory(SET_LIMIT / 2 + 1, SET_LIMIT);
+        // Android patch end. b/79168307 Reduce the heap memory needed for the test
+    }
+
+    // Android patch begin. b/79168307 Reduce the heap memory needed for the test
+    private void splitTestUnicodeMapGeneralCategory(int startCodePoint, int endCodePoint) {
+        UnicodeMap<String> map1 = new UnicodeMap<String>();
+        Map<Integer, String> map2 = new TreeMap<Integer,String>();
+        for (int cp = startCodePoint; cp <= endCodePoint; ++cp) {
               int enumValue = UCharacter.getIntPropertyValue(cp, propEnum);
               //if (enumValue <= 0) continue; // for smaller set
               String value = UCharacter.getPropertyValueName(propEnum,enumValue, UProperty.NameChoice.LONG);
               map1.put(cp, value);
               map2.put(cp, value);
-              cp++;
-              // Unicode is huge, skip over large parts of it.
-              if (cp == 0x08FF) {           // General Scripts Area.
-                  cp = 0xD700;              // Hangul Syllables Area.
-              } else if (cp == 0x100FF) {   // General Scripts Area.
-                  cp = 0x1F000;             // Symbols Area.
-              } else if (cp == 0x200FF) {   // CJK Unified Ideographs Extensions.
-                  cp = 0x10FF00;            // Supplementary Private Use Area-B.
-              } else if (cp == 0x10FFFF) {  // The end of Unicode.
-                  break;
-              }
         }
         checkNext(map1, map2, Integer.MAX_VALUE);
 
@@ -392,6 +387,7 @@
             }
         }
     }
+    // Android patch end. b/79168307 Reduce the heap memory needed for the test
 
     @Test
     public void TestAUnicodeMap2() {