Reject "out ParcelFileDescriptor" parameters

Out(not inout) parameters should be known how to create it. But in Java,
ParcelFileDescriptor is not default constructible and there's no way to
construct it from nothing.

Instead of rejecting it only in Java, we reject it in every backend for
future compatibility.

Bug: 181194872
Test: aidl_unittests
Change-Id: I93637bb6f5bbbd9f4c3119c0baa8ba4042fc2305
diff --git a/aidl_unittest.cpp b/aidl_unittest.cpp
index 2d33bbb..9b1258e 100644
--- a/aidl_unittest.cpp
+++ b/aidl_unittest.cpp
@@ -213,7 +213,7 @@
 }
 
 TEST_P(AidlTest, RejectsOutParametersInOnewayInterface) {
-  const string oneway_interface = "package a; oneway interface IBar { void f(out int bar); }";
+  const string oneway_interface = "package a; oneway interface IBar { void f(out int[] bar); }";
   const string expected_stderr =
       "ERROR: a/IBar.aidl:1.40-42: oneway method 'f' cannot have out parameters\n";
   CaptureStderr();
@@ -222,7 +222,7 @@
 }
 
 TEST_P(AidlTest, RejectsOutParametersInOnewayMethod) {
-  const string oneway_method = "package a; interface IBar { oneway void f(out int bar); }";
+  const string oneway_method = "package a; interface IBar { oneway void f(out int[] bar); }";
   const string expected_stderr =
       "ERROR: a/IBar.aidl:1.40-42: oneway method 'f' cannot have out parameters\n";
   CaptureStderr();
@@ -2770,6 +2770,31 @@
   EXPECT_EQ(outputs, io_delegate_.OutputFiles());
 }
 
+TEST_P(AidlTest, RejectsOutputParcelFileDescriptor) {
+  Options options = Options::From("aidl p/IFoo.aidl -I . --lang=" + to_string(GetLanguage()));
+  CaptureStderr();
+  io_delegate_.SetFileContents("p/IFoo.aidl",
+                               "package p;"
+                               "interface IFoo{"
+                               "  void foo(out ParcelFileDescriptor fd);"
+                               "}");
+  EXPECT_EQ(1, ::android::aidl::compile_aidl(options, io_delegate_));
+  EXPECT_THAT(GetCapturedStderr(), HasSubstr("can't be an out parameter"));
+}
+
+TEST_P(AidlTest, RejectsArgumentDirectionNotSpecified) {
+  Options options = Options::From("aidl p/IFoo.aidl -I . --lang=" + to_string(GetLanguage()));
+  CaptureStderr();
+  io_delegate_.SetFileContents("p/IFoo.aidl",
+                               "package p;"
+                               "interface IFoo{"
+                               "  void foo(ParcelFileDescriptor fd);"
+                               "}");
+  EXPECT_EQ(1, ::android::aidl::compile_aidl(options, io_delegate_));
+  EXPECT_THAT(GetCapturedStderr(),
+              HasSubstr("ParcelFileDescriptor can be an in or inout parameter."));
+}
+
 TEST_F(AidlTest, ManualIds) {
   Options options = Options::From("aidl --lang=java -o out IFoo.aidl");
   io_delegate_.SetFileContents("IFoo.aidl",