[automerger skipped] Merge "DO NOT MERGE Use explicitly opened file with O_WRONLY in test_sendfile_errno" into pie-cts-dev am: 9db3eee3c9 -s ours am: 17d4498ffd -s ours am: 5dccb3f8e3 -s ours am: 05dd7da2ad -s ours am: fac2da6b63 -s ours am: c42854858a -s ours am: 098e0e7d00 -s ours am: 4620dfbb00 -s ours am: 40cb904bef -s ours

am skip reason: subject contains skip directive

Original change: https://android-review.googlesource.com/c/platform/libcore/+/2241795

Change-Id: I43f693f7673d31d352bb66567f55ce2a273e203d
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/JavaLibrary.bp b/JavaLibrary.bp
index f070571..da7aace 100644
--- a/JavaLibrary.bp
+++ b/JavaLibrary.bp
@@ -531,6 +531,8 @@
     srcs: ["support/src/test/java/**/*.java"],
 
     sdk_version: "core_platform",
+    // Make sure that this will be added to the sdk snapshot for S.
+    min_sdk_version: "S",
     libs: ["junit"],
     static_libs: [
         "bouncycastle-unbundled",
@@ -1120,4 +1122,6 @@
         ":api_surface_annotation_files",
     ],
     sdk_version: "core_current",
+    // Make sure that this will be added to the sdk snapshot for S.
+    min_sdk_version: "S",
 }
diff --git a/dalvik/src/main/java/dalvik/system/ZygoteHooks.java b/dalvik/src/main/java/dalvik/system/ZygoteHooks.java
index bfe1945..296e18d 100644
--- a/dalvik/src/main/java/dalvik/system/ZygoteHooks.java
+++ b/dalvik/src/main/java/dalvik/system/ZygoteHooks.java
@@ -192,7 +192,9 @@
 
         // Enable memory-mapped coverage if JaCoCo is in the boot classpath. system_server is
         // skipped due to being persistent and having its own coverage writing mechanism.
-        if (!isSystemServer && enableMemoryMappedDataMethod != null) {
+        // Child zygote processes are also skipped so that file descriptors are not kept open
+        // when the child zygote process forks again.
+        if (!isSystemServer && !isChildZygote && enableMemoryMappedDataMethod != null) {
           try {
             enableMemoryMappedDataMethod.invoke(null);
           } catch (ReflectiveOperationException e) {
diff --git a/expectations/Android.bp b/expectations/Android.bp
index 2aadab9..6a61227 100644
--- a/expectations/Android.bp
+++ b/expectations/Android.bp
@@ -35,6 +35,8 @@
     visibility: expectations_visibility,
     java_resources: ["knownfailures.txt"],
     sdk_version: "core_current",
+    // Make sure that this will be added to the sdk snapshot for S.
+    min_sdk_version: "S",
 }
 
 java_library {
@@ -42,4 +44,6 @@
     visibility: expectations_visibility,
     java_resources: ["virtualdeviceknownfailures.txt"],
     sdk_version: "core_current",
+    // Make sure that this will be added to the sdk snapshot for S.
+    min_sdk_version: "S",
 }
diff --git a/luni/src/test/java/libcore/java/util/TimeZoneTest.java b/luni/src/test/java/libcore/java/util/TimeZoneTest.java
index 145c2d1..f871da1 100644
--- a/luni/src/test/java/libcore/java/util/TimeZoneTest.java
+++ b/luni/src/test/java/libcore/java/util/TimeZoneTest.java
@@ -108,7 +108,10 @@
     public void testGetDisplayNameShort_nonHourOffsets() {
         TimeZone iranTz = TimeZone.getTimeZone("Asia/Tehran");
         assertEquals("GMT+03:30", iranTz.getDisplayName(false, TimeZone.SHORT, Locale.UK));
-        assertEquals("GMT+04:30", iranTz.getDisplayName(true, TimeZone.SHORT, Locale.UK));
+
+        TimeZone chathamTz = TimeZone.getTimeZone("Pacific/Chatham");
+        assertEquals("GMT+12:45", chathamTz.getDisplayName(false, TimeZone.SHORT, Locale.UK));
+        assertEquals("GMT+13:45", chathamTz.getDisplayName(true, TimeZone.SHORT, Locale.UK));
     }
 
     public void testPreHistoricOffsets() throws Exception {
diff --git a/luni/src/test/java/libcore/javax/net/ServerSocketFactoryTest.java b/luni/src/test/java/libcore/javax/net/ServerSocketFactoryTest.java
index bf544b1..2643d26 100644
--- a/luni/src/test/java/libcore/javax/net/ServerSocketFactoryTest.java
+++ b/luni/src/test/java/libcore/javax/net/ServerSocketFactoryTest.java
@@ -122,7 +122,10 @@
          * We've observed that Linux always adds 3 to the user-specified
          * backlog.
          */
-        assertTrue(peak >= specifiedBacklog && peak <= (specifiedBacklog + 3) * 1.5);
+        int maxBacklog = (int) ((specifiedBacklog + 3) * 1.5);
+        assertTrue(String.format("Backlog = %d, but expected between %d and %d.",
+                peak, specifiedBacklog, maxBacklog),
+            peak >= specifiedBacklog && peak <= maxBacklog);
     }
 
     private void transfer(InputStream in, ByteArrayOutputStream out) throws IOException {
diff --git a/ojluni/src/main/java/java/util/concurrent/FutureTask.java b/ojluni/src/main/java/java/util/concurrent/FutureTask.java
index e913ef3..4263944 100644
--- a/ojluni/src/main/java/java/util/concurrent/FutureTask.java
+++ b/ojluni/src/main/java/java/util/concurrent/FutureTask.java
@@ -507,10 +507,15 @@
             status = "[Cancelled]";
             break;
         default:
+            // BEGIN Android-changed: recursion risk building string (b/241297967)
+            /*
             final Callable<?> callable = this.callable;
             status = (callable == null)
                 ? "[Not completed]"
                 : "[Not completed, task = " + callable + "]";
+            */
+            status = "[Not completed]";
+            // END Android-changed: recursion risk building string (b/241297967)
         }
         return super.toString() + status;
     }