Add test for non-GC'd parcel.
Test: hidl_test_java
Bug: 36088202
Change-Id: I9ac3771b9571ea63a00005d178ca0d82ef60263d
(cherry picked from commit 2e4d670350c58bb62ef1d86bcba271faf2e12633)
diff --git a/test/java_test/src/com/android/commands/hidl_test_java/HidlTestJava.java b/test/java_test/src/com/android/commands/hidl_test_java/HidlTestJava.java
index 4864371..dbdbb04 100644
--- a/test/java_test/src/com/android/commands/hidl_test_java/HidlTestJava.java
+++ b/test/java_test/src/com/android/commands/hidl_test_java/HidlTestJava.java
@@ -791,6 +791,25 @@
Expect(proxy.toString(), IBaz.kInterfaceName + "@Proxy");
}
+ {
+ // Ensure that native parcel is cleared even if the corresponding
+ // Java object isn't GC'd.
+ ArrayList<Integer> data4K = new ArrayList<>(1024);
+ for (int i = 0; i < 1024; i++) {
+ data4K.add(i);
+ }
+
+ for (int i = 0; i < 1024; i++) {
+ // If they are not properly cleaned up, these calls will put 4MB of data in
+ // kernel binder buffer, and will fail.
+ try {
+ proxy.mapThisVector(data4K);
+ } catch (RemoteException ex) {
+ throw new RuntimeException("Failed at call #" + Integer.toString(i), ex);
+ }
+ }
+ }
+
// --- DEATH RECIPIENT TESTING ---
// This must always be done last, since it will kill the native server process
HidlDeathRecipient recipient1 = new HidlDeathRecipient();