Merge "Test the new 'explicit GC' policy in StrictMode."
diff --git a/tests/tests/os/src/android/os/cts/StrictModeTest.java b/tests/tests/os/src/android/os/cts/StrictModeTest.java
index 21730c6..58c8fb1 100644
--- a/tests/tests/os/src/android/os/cts/StrictModeTest.java
+++ b/tests/tests/os/src/android/os/cts/StrictModeTest.java
@@ -305,6 +305,17 @@
         });
     }
 
+    public void testExplicitGc() throws Exception {
+        StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
+                .detectExplicitGc()
+                .penaltyLog()
+                .build());
+
+        assertViolation("StrictModeExplicitGcViolation", () -> {
+            Runtime.getRuntime().gc();
+        });
+    }
+
     private static void assertViolation(String expected, ThrowingRunnable r) throws Exception {
         final LinkedBlockingQueue<String> violations = new LinkedBlockingQueue<>();
         StrictMode.setViolationListener(new ViolationListener() {