Enable StrictMode checks for explicit garbageCollection from T.

This disallows calls to runtime.gc() in the new version of Android.
Explicit GC calls are blocking and can thus cause runtime overhead.
They used to be performed as a pattern in order to avoid GC_FOR_ALLOC.
However, that was only the case for Dalvik, that is now discouraged for
ART.

Bug: 3400644
Test: m
Test: atest StrictModeTest
Change-Id: I12cee0af955a708b6bf5a3a0c21cddc7f6a19185
diff --git a/tests/tests/os/src/android/os/cts/StrictModeTest.java b/tests/tests/os/src/android/os/cts/StrictModeTest.java
index 3e2bce4..8ff06af 100644
--- a/tests/tests/os/src/android/os/cts/StrictModeTest.java
+++ b/tests/tests/os/src/android/os/cts/StrictModeTest.java
@@ -81,6 +81,8 @@
 import androidx.test.rule.ServiceTestRule;
 import androidx.test.runner.AndroidJUnit4;
 
+import com.android.compatibility.common.util.ApiTest;
+
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -563,6 +565,16 @@
     }
 
     @Test
+    @ApiTest(apis={"StrictMode.VmPolicy.Builder#permitExplicitGc"})
+    public void testPermitExplicitGc() throws Exception {
+        StrictMode.setThreadPolicy(
+                new StrictMode.ThreadPolicy.Builder().permitExplicitGc().penaltyLog().build());
+
+        assertNoViolation(() -> Runtime.getRuntime().gc());
+    }
+
+    @Test
+    @ApiTest(apis={"StrictMode.VmPolicy.Builder#detectUnbufferedIo"})
     public void testUnbufferedIoGZipInput() throws Exception {
         StrictMode.setThreadPolicy(
                 new StrictMode.ThreadPolicy.Builder().detectUnbufferedIo().penaltyLog().build());