aidl: support RPC in Java

In Java, when need to make a transaction on an RPC binder object, the
Parcel needs to be in a different format. This adds a build option to
enable RPC to work (by attaching the binder to a parcel, the correct
format can be used). In the future, we could enable this by default
on all AIDL interfaces which are built against a new enough API version
(b/175819535).

Bug: 175814583
Test: atest aidl_integration_test, manual
Change-Id: Ia5234e58d0f1731ddb7bb577c4e193a81779e6ec
diff --git a/Android.bp b/Android.bp
index fdf3d32..59c4a62 100644
--- a/Android.bp
+++ b/Android.bp
@@ -561,6 +561,7 @@
         java: {
             platform_apis: true,
             srcs_available: true,
+            gen_rpc: true,
         },
         rust: {
             enabled: true,
diff --git a/build/aidl_gen_rule.go b/build/aidl_gen_rule.go
index 3df3173..af50979 100644
--- a/build/aidl_gen_rule.go
+++ b/build/aidl_gen_rule.go
@@ -71,6 +71,7 @@
 	BaseName              string
 	GenLog                bool
 	Version               string
+	GenRpc                bool
 	GenTrace              bool
 	Unstable              *bool
 	Visibility            []string
@@ -177,6 +178,9 @@
 		}
 		optionalFlags = append(optionalFlags, "--hash "+hash)
 	}
+	if g.properties.GenRpc {
+		optionalFlags = append(optionalFlags, "--rpc")
+	}
 	if g.properties.GenTrace {
 		optionalFlags = append(optionalFlags, "-t")
 	}
diff --git a/build/aidl_interface.go b/build/aidl_interface.go
index 1aad7c8..3d7912d 100644
--- a/build/aidl_interface.go
+++ b/build/aidl_interface.go
@@ -373,6 +373,9 @@
 			// Whether to compile against platform APIs instead of
 			// an SDK.
 			Platform_apis *bool
+			// Whether RPC features are enabled (requires API level 32)
+			// TODO(b/175819535): enable this automatically?
+			Gen_rpc *bool
 		}
 		// Backend of the compiler generating code for C++ clients using
 		// libbinder (unstable C++ interface)
diff --git a/build/aidl_interface_backends.go b/build/aidl_interface_backends.go
index 5881258..0bb360f 100644
--- a/build/aidl_interface_backends.go
+++ b/build/aidl_interface_backends.go
@@ -230,6 +230,7 @@
 		Lang:                  langJava,
 		BaseName:              i.ModuleBase.Name(),
 		Version:               i.versionForAidlGenRule(version),
+		GenRpc:                proptools.Bool(i.properties.Backend.Java.Gen_rpc),
 		GenTrace:              proptools.Bool(i.properties.Gen_trace),
 		Unstable:              i.properties.Unstable,
 		Visibility:            srcsVisibility(mctx, langJava),
diff --git a/generate_java_binder.cpp b/generate_java_binder.cpp
index 04887fc..7a738cd 100644
--- a/generate_java_binder.cpp
+++ b/generate_java_binder.cpp
@@ -615,8 +615,13 @@
   proxy->statements->Add(std::make_shared<VariableDeclaration>(
       _data, std::make_shared<MethodCall>("android.os.Parcel", "obtain")));
 
+  if (options.GenRpc()) {
+    proxy->statements->Add(
+        std::make_shared<LiteralStatement>("_data.markForBinder(asBinder());\n"));
+  }
+
   if (iface.IsSensitiveData()) {
-    proxy->statements->Add(std::make_shared<LiteralStatement>("_data.markSensitive();"));
+    proxy->statements->Add(std::make_shared<LiteralStatement>("_data.markSensitive();\n"));
   }
 
   std::shared_ptr<Variable> _reply = nullptr;
@@ -875,8 +880,11 @@
            << "android.os.RemoteException {\n"
            << "  if (mCachedVersion == -1) {\n"
            << "    android.os.Parcel data = android.os.Parcel.obtain();\n"
-           << "    android.os.Parcel reply = android.os.Parcel.obtain();\n"
-           << "    try {\n"
+           << "    android.os.Parcel reply = android.os.Parcel.obtain();\n";
+      if (options.GenRpc()) {
+        code << "    data.markForBinder(asBinder());\n";
+      }
+      code << "    try {\n"
            << "      data.writeInterfaceToken(DESCRIPTOR);\n"
            << "      boolean _status = mRemote.transact(Stub." << transactCodeName << ", "
            << "data, reply, 0);\n"
@@ -904,8 +912,11 @@
            << "android.os.RemoteException {\n"
            << "  if (\"-1\".equals(mCachedHash)) {\n"
            << "    android.os.Parcel data = android.os.Parcel.obtain();\n"
-           << "    android.os.Parcel reply = android.os.Parcel.obtain();\n"
-           << "    try {\n"
+           << "    android.os.Parcel reply = android.os.Parcel.obtain();\n";
+      if (options.GenRpc()) {
+        code << "    data.markForBinder(asBinder());\n";
+      }
+      code << "    try {\n"
            << "      data.writeInterfaceToken(DESCRIPTOR);\n"
            << "      boolean _status = mRemote.transact(Stub." << transactCodeName << ", "
            << "data, reply, 0);\n"
diff --git a/options.cpp b/options.cpp
index f756e70..36c4471 100644
--- a/options.cpp
+++ b/options.cpp
@@ -105,6 +105,8 @@
        << "          Trigger fail when trying to compile a parcelable." << endl
        << "  --ninja" << endl
        << "          Generate dependency file in a format ninja understands." << endl
+       << "  --rpc" << endl
+       << "          (for Java) whether to generate support for RPC transactions." << endl
        << "  --structured" << endl
        << "          Whether this interface is defined exclusively in AIDL." << endl
        << "          It is therefore a candidate for stabilization." << endl
@@ -225,6 +227,7 @@
         {"out", required_argument, 0, 'o'},
         {"header_out", required_argument, 0, 'h'},
         {"ninja", no_argument, 0, 'n'},
+        {"rpc", no_argument, 0, 'r'},
         {"stability", required_argument, 0, 'Y'},
         {"structured", no_argument, 0, 'S'},
         {"trace", no_argument, 0, 't'},
@@ -332,6 +335,9 @@
         }
         break;
       }
+      case 'r':
+        gen_rpc_ = true;
+        break;
       case 't':
         gen_traces_ = true;
         break;
diff --git a/options.h b/options.h
index 70c82a6..3c4490f 100644
--- a/options.h
+++ b/options.h
@@ -120,6 +120,8 @@
 
   bool AutoDepFile() const { return auto_dep_file_; }
 
+  bool GenRpc() const { return gen_rpc_; }
+
   bool GenTraces() const { return gen_traces_; }
 
   bool GenTransactionNames() const { return gen_transaction_names_; }
@@ -177,6 +179,7 @@
   set<string> import_dirs_;
   vector<string> preprocessed_files_;
   string dependency_file_;
+  bool gen_rpc_ = false;
   bool gen_traces_ = false;
   bool gen_transaction_names_ = false;
   bool dependency_file_ninja_ = false;
diff --git a/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/INamedCallback.java b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/INamedCallback.java
index aa427ae..a1e8aa7 100644
--- a/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/INamedCallback.java
+++ b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/INamedCallback.java
@@ -91,6 +91,7 @@
       @Override public java.lang.String GetName() throws android.os.RemoteException
       {
         android.os.Parcel _data = android.os.Parcel.obtain();
+        _data.markForBinder(asBinder());
         android.os.Parcel _reply = android.os.Parcel.obtain();
         java.lang.String _result;
         try {
diff --git a/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/INewName.java b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/INewName.java
index e556b65..66d4748 100644
--- a/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/INewName.java
+++ b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/INewName.java
@@ -91,6 +91,7 @@
       @Override public java.lang.String RealName() throws android.os.RemoteException
       {
         android.os.Parcel _data = android.os.Parcel.obtain();
+        _data.markForBinder(asBinder());
         android.os.Parcel _reply = android.os.Parcel.obtain();
         java.lang.String _result;
         try {
diff --git a/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/IOldName.java b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/IOldName.java
index 109b6ec..c2ae904 100644
--- a/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/IOldName.java
+++ b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/IOldName.java
@@ -91,6 +91,7 @@
       @Override public java.lang.String RealName() throws android.os.RemoteException
       {
         android.os.Parcel _data = android.os.Parcel.obtain();
+        _data.markForBinder(asBinder());
         android.os.Parcel _reply = android.os.Parcel.obtain();
         java.lang.String _result;
         try {
diff --git a/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/ITestService.java b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/ITestService.java
index 8a8eafd..895e07e 100644
--- a/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/ITestService.java
+++ b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/ITestService.java
@@ -946,7 +946,9 @@
       @Override public int UnimplementedMethod(int arg) throws android.os.RemoteException
       {
         android.os.Parcel _data = android.os.Parcel.obtain();
-        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        _data.markForBinder(asBinder());
+        _data.markSensitive();
+        android.os.Parcel _reply = android.os.Parcel.obtain();
         int _result;
         try {
           _data.writeInterfaceToken(DESCRIPTOR);
@@ -973,7 +975,9 @@
       @Override public void Deprecated() throws android.os.RemoteException
       {
         android.os.Parcel _data = android.os.Parcel.obtain();
-        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        _data.markForBinder(asBinder());
+        _data.markSensitive();
+        android.os.Parcel _reply = android.os.Parcel.obtain();
         try {
           _data.writeInterfaceToken(DESCRIPTOR);
           boolean _status = mRemote.transact(Stub.TRANSACTION_Deprecated, _data, _reply, android.os.IBinder.FLAG_CLEAR_BUF);
@@ -993,7 +997,9 @@
       @Override public void TestOneway() throws android.os.RemoteException
       {
         android.os.Parcel _data = android.os.Parcel.obtain();
-        _data.markSensitive();try {
+        _data.markForBinder(asBinder());
+        _data.markSensitive();
+        try {
           _data.writeInterfaceToken(DESCRIPTOR);
           boolean _status = mRemote.transact(Stub.TRANSACTION_TestOneway, _data, null, android.os.IBinder.FLAG_ONEWAY | android.os.IBinder.FLAG_CLEAR_BUF);
           if (!_status) {
@@ -1011,7 +1017,9 @@
       @Override public boolean RepeatBoolean(boolean token) throws android.os.RemoteException
       {
         android.os.Parcel _data = android.os.Parcel.obtain();
-        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        _data.markForBinder(asBinder());
+        _data.markSensitive();
+        android.os.Parcel _reply = android.os.Parcel.obtain();
         boolean _result;
         try {
           _data.writeInterfaceToken(DESCRIPTOR);
@@ -1034,7 +1042,9 @@
       @Override public byte RepeatByte(byte token) throws android.os.RemoteException
       {
         android.os.Parcel _data = android.os.Parcel.obtain();
-        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        _data.markForBinder(asBinder());
+        _data.markSensitive();
+        android.os.Parcel _reply = android.os.Parcel.obtain();
         byte _result;
         try {
           _data.writeInterfaceToken(DESCRIPTOR);
@@ -1057,7 +1067,9 @@
       @Override public char RepeatChar(char token) throws android.os.RemoteException
       {
         android.os.Parcel _data = android.os.Parcel.obtain();
-        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        _data.markForBinder(asBinder());
+        _data.markSensitive();
+        android.os.Parcel _reply = android.os.Parcel.obtain();
         char _result;
         try {
           _data.writeInterfaceToken(DESCRIPTOR);
@@ -1080,7 +1092,9 @@
       @Override public int RepeatInt(int token) throws android.os.RemoteException
       {
         android.os.Parcel _data = android.os.Parcel.obtain();
-        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        _data.markForBinder(asBinder());
+        _data.markSensitive();
+        android.os.Parcel _reply = android.os.Parcel.obtain();
         int _result;
         try {
           _data.writeInterfaceToken(DESCRIPTOR);
@@ -1103,7 +1117,9 @@
       @Override public long RepeatLong(long token) throws android.os.RemoteException
       {
         android.os.Parcel _data = android.os.Parcel.obtain();
-        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        _data.markForBinder(asBinder());
+        _data.markSensitive();
+        android.os.Parcel _reply = android.os.Parcel.obtain();
         long _result;
         try {
           _data.writeInterfaceToken(DESCRIPTOR);
@@ -1126,7 +1142,9 @@
       @Override public float RepeatFloat(float token) throws android.os.RemoteException
       {
         android.os.Parcel _data = android.os.Parcel.obtain();
-        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        _data.markForBinder(asBinder());
+        _data.markSensitive();
+        android.os.Parcel _reply = android.os.Parcel.obtain();
         float _result;
         try {
           _data.writeInterfaceToken(DESCRIPTOR);
@@ -1149,7 +1167,9 @@
       @Override public double RepeatDouble(double token) throws android.os.RemoteException
       {
         android.os.Parcel _data = android.os.Parcel.obtain();
-        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        _data.markForBinder(asBinder());
+        _data.markSensitive();
+        android.os.Parcel _reply = android.os.Parcel.obtain();
         double _result;
         try {
           _data.writeInterfaceToken(DESCRIPTOR);
@@ -1172,7 +1192,9 @@
       @Override public java.lang.String RepeatString(java.lang.String token) throws android.os.RemoteException
       {
         android.os.Parcel _data = android.os.Parcel.obtain();
-        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        _data.markForBinder(asBinder());
+        _data.markSensitive();
+        android.os.Parcel _reply = android.os.Parcel.obtain();
         java.lang.String _result;
         try {
           _data.writeInterfaceToken(DESCRIPTOR);
@@ -1195,7 +1217,9 @@
       @Override public byte RepeatByteEnum(byte token) throws android.os.RemoteException
       {
         android.os.Parcel _data = android.os.Parcel.obtain();
-        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        _data.markForBinder(asBinder());
+        _data.markSensitive();
+        android.os.Parcel _reply = android.os.Parcel.obtain();
         byte _result;
         try {
           _data.writeInterfaceToken(DESCRIPTOR);
@@ -1218,7 +1242,9 @@
       @Override public int RepeatIntEnum(int token) throws android.os.RemoteException
       {
         android.os.Parcel _data = android.os.Parcel.obtain();
-        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        _data.markForBinder(asBinder());
+        _data.markSensitive();
+        android.os.Parcel _reply = android.os.Parcel.obtain();
         int _result;
         try {
           _data.writeInterfaceToken(DESCRIPTOR);
@@ -1241,7 +1267,9 @@
       @Override public long RepeatLongEnum(long token) throws android.os.RemoteException
       {
         android.os.Parcel _data = android.os.Parcel.obtain();
-        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        _data.markForBinder(asBinder());
+        _data.markSensitive();
+        android.os.Parcel _reply = android.os.Parcel.obtain();
         long _result;
         try {
           _data.writeInterfaceToken(DESCRIPTOR);
@@ -1265,7 +1293,9 @@
       @Override public boolean[] ReverseBoolean(boolean[] input, boolean[] repeated) throws android.os.RemoteException
       {
         android.os.Parcel _data = android.os.Parcel.obtain();
-        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        _data.markForBinder(asBinder());
+        _data.markSensitive();
+        android.os.Parcel _reply = android.os.Parcel.obtain();
         boolean[] _result;
         try {
           _data.writeInterfaceToken(DESCRIPTOR);
@@ -1295,7 +1325,9 @@
       @Override public byte[] ReverseByte(byte[] input, byte[] repeated) throws android.os.RemoteException
       {
         android.os.Parcel _data = android.os.Parcel.obtain();
-        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        _data.markForBinder(asBinder());
+        _data.markSensitive();
+        android.os.Parcel _reply = android.os.Parcel.obtain();
         byte[] _result;
         try {
           _data.writeInterfaceToken(DESCRIPTOR);
@@ -1325,7 +1357,9 @@
       @Override public char[] ReverseChar(char[] input, char[] repeated) throws android.os.RemoteException
       {
         android.os.Parcel _data = android.os.Parcel.obtain();
-        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        _data.markForBinder(asBinder());
+        _data.markSensitive();
+        android.os.Parcel _reply = android.os.Parcel.obtain();
         char[] _result;
         try {
           _data.writeInterfaceToken(DESCRIPTOR);
@@ -1355,7 +1389,9 @@
       @Override public int[] ReverseInt(int[] input, int[] repeated) throws android.os.RemoteException
       {
         android.os.Parcel _data = android.os.Parcel.obtain();
-        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        _data.markForBinder(asBinder());
+        _data.markSensitive();
+        android.os.Parcel _reply = android.os.Parcel.obtain();
         int[] _result;
         try {
           _data.writeInterfaceToken(DESCRIPTOR);
@@ -1385,7 +1421,9 @@
       @Override public long[] ReverseLong(long[] input, long[] repeated) throws android.os.RemoteException
       {
         android.os.Parcel _data = android.os.Parcel.obtain();
-        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        _data.markForBinder(asBinder());
+        _data.markSensitive();
+        android.os.Parcel _reply = android.os.Parcel.obtain();
         long[] _result;
         try {
           _data.writeInterfaceToken(DESCRIPTOR);
@@ -1415,7 +1453,9 @@
       @Override public float[] ReverseFloat(float[] input, float[] repeated) throws android.os.RemoteException
       {
         android.os.Parcel _data = android.os.Parcel.obtain();
-        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        _data.markForBinder(asBinder());
+        _data.markSensitive();
+        android.os.Parcel _reply = android.os.Parcel.obtain();
         float[] _result;
         try {
           _data.writeInterfaceToken(DESCRIPTOR);
@@ -1445,7 +1485,9 @@
       @Override public double[] ReverseDouble(double[] input, double[] repeated) throws android.os.RemoteException
       {
         android.os.Parcel _data = android.os.Parcel.obtain();
-        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        _data.markForBinder(asBinder());
+        _data.markSensitive();
+        android.os.Parcel _reply = android.os.Parcel.obtain();
         double[] _result;
         try {
           _data.writeInterfaceToken(DESCRIPTOR);
@@ -1475,7 +1517,9 @@
       @Override public java.lang.String[] ReverseString(java.lang.String[] input, java.lang.String[] repeated) throws android.os.RemoteException
       {
         android.os.Parcel _data = android.os.Parcel.obtain();
-        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        _data.markForBinder(asBinder());
+        _data.markSensitive();
+        android.os.Parcel _reply = android.os.Parcel.obtain();
         java.lang.String[] _result;
         try {
           _data.writeInterfaceToken(DESCRIPTOR);
@@ -1505,7 +1549,9 @@
       @Override public byte[] ReverseByteEnum(byte[] input, byte[] repeated) throws android.os.RemoteException
       {
         android.os.Parcel _data = android.os.Parcel.obtain();
-        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        _data.markForBinder(asBinder());
+        _data.markSensitive();
+        android.os.Parcel _reply = android.os.Parcel.obtain();
         byte[] _result;
         try {
           _data.writeInterfaceToken(DESCRIPTOR);
@@ -1535,7 +1581,9 @@
       @Override public int[] ReverseIntEnum(int[] input, int[] repeated) throws android.os.RemoteException
       {
         android.os.Parcel _data = android.os.Parcel.obtain();
-        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        _data.markForBinder(asBinder());
+        _data.markSensitive();
+        android.os.Parcel _reply = android.os.Parcel.obtain();
         int[] _result;
         try {
           _data.writeInterfaceToken(DESCRIPTOR);
@@ -1565,7 +1613,9 @@
       @Override public long[] ReverseLongEnum(long[] input, long[] repeated) throws android.os.RemoteException
       {
         android.os.Parcel _data = android.os.Parcel.obtain();
-        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        _data.markForBinder(asBinder());
+        _data.markSensitive();
+        android.os.Parcel _reply = android.os.Parcel.obtain();
         long[] _result;
         try {
           _data.writeInterfaceToken(DESCRIPTOR);
@@ -1596,7 +1646,9 @@
       @Override public android.aidl.tests.INamedCallback GetOtherTestService(java.lang.String name) throws android.os.RemoteException
       {
         android.os.Parcel _data = android.os.Parcel.obtain();
-        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        _data.markForBinder(asBinder());
+        _data.markSensitive();
+        android.os.Parcel _reply = android.os.Parcel.obtain();
         android.aidl.tests.INamedCallback _result;
         try {
           _data.writeInterfaceToken(DESCRIPTOR);
@@ -1619,7 +1671,9 @@
       @Override public boolean VerifyName(android.aidl.tests.INamedCallback service, java.lang.String name) throws android.os.RemoteException
       {
         android.os.Parcel _data = android.os.Parcel.obtain();
-        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        _data.markForBinder(asBinder());
+        _data.markSensitive();
+        android.os.Parcel _reply = android.os.Parcel.obtain();
         boolean _result;
         try {
           _data.writeInterfaceToken(DESCRIPTOR);
@@ -1644,7 +1698,9 @@
       @Override public java.util.List<java.lang.String> ReverseStringList(java.util.List<java.lang.String> input, java.util.List<java.lang.String> repeated) throws android.os.RemoteException
       {
         android.os.Parcel _data = android.os.Parcel.obtain();
-        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        _data.markForBinder(asBinder());
+        _data.markSensitive();
+        android.os.Parcel _reply = android.os.Parcel.obtain();
         java.util.List<java.lang.String> _result;
         try {
           _data.writeInterfaceToken(DESCRIPTOR);
@@ -1668,7 +1724,9 @@
       @Override public android.os.ParcelFileDescriptor RepeatParcelFileDescriptor(android.os.ParcelFileDescriptor read) throws android.os.RemoteException
       {
         android.os.Parcel _data = android.os.Parcel.obtain();
-        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        _data.markForBinder(asBinder());
+        _data.markSensitive();
+        android.os.Parcel _reply = android.os.Parcel.obtain();
         android.os.ParcelFileDescriptor _result;
         try {
           _data.writeInterfaceToken(DESCRIPTOR);
@@ -1702,7 +1760,9 @@
       @Override public android.os.ParcelFileDescriptor[] ReverseParcelFileDescriptorArray(android.os.ParcelFileDescriptor[] input, android.os.ParcelFileDescriptor[] repeated) throws android.os.RemoteException
       {
         android.os.Parcel _data = android.os.Parcel.obtain();
-        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        _data.markForBinder(asBinder());
+        _data.markSensitive();
+        android.os.Parcel _reply = android.os.Parcel.obtain();
         android.os.ParcelFileDescriptor[] _result;
         try {
           _data.writeInterfaceToken(DESCRIPTOR);
@@ -1733,7 +1793,9 @@
       @Override public void ThrowServiceException(int code) throws android.os.RemoteException
       {
         android.os.Parcel _data = android.os.Parcel.obtain();
-        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        _data.markForBinder(asBinder());
+        _data.markSensitive();
+        android.os.Parcel _reply = android.os.Parcel.obtain();
         try {
           _data.writeInterfaceToken(DESCRIPTOR);
           _data.writeInt(code);
@@ -1755,7 +1817,9 @@
       @Override public int[] RepeatNullableIntArray(int[] input) throws android.os.RemoteException
       {
         android.os.Parcel _data = android.os.Parcel.obtain();
-        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        _data.markForBinder(asBinder());
+        _data.markSensitive();
+        android.os.Parcel _reply = android.os.Parcel.obtain();
         int[] _result;
         try {
           _data.writeInterfaceToken(DESCRIPTOR);
@@ -1778,7 +1842,9 @@
       @Override public byte[] RepeatNullableByteEnumArray(byte[] input) throws android.os.RemoteException
       {
         android.os.Parcel _data = android.os.Parcel.obtain();
-        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        _data.markForBinder(asBinder());
+        _data.markSensitive();
+        android.os.Parcel _reply = android.os.Parcel.obtain();
         byte[] _result;
         try {
           _data.writeInterfaceToken(DESCRIPTOR);
@@ -1801,7 +1867,9 @@
       @Override public int[] RepeatNullableIntEnumArray(int[] input) throws android.os.RemoteException
       {
         android.os.Parcel _data = android.os.Parcel.obtain();
-        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        _data.markForBinder(asBinder());
+        _data.markSensitive();
+        android.os.Parcel _reply = android.os.Parcel.obtain();
         int[] _result;
         try {
           _data.writeInterfaceToken(DESCRIPTOR);
@@ -1824,7 +1892,9 @@
       @Override public long[] RepeatNullableLongEnumArray(long[] input) throws android.os.RemoteException
       {
         android.os.Parcel _data = android.os.Parcel.obtain();
-        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        _data.markForBinder(asBinder());
+        _data.markSensitive();
+        android.os.Parcel _reply = android.os.Parcel.obtain();
         long[] _result;
         try {
           _data.writeInterfaceToken(DESCRIPTOR);
@@ -1847,7 +1917,9 @@
       @Override public java.lang.String RepeatNullableString(java.lang.String input) throws android.os.RemoteException
       {
         android.os.Parcel _data = android.os.Parcel.obtain();
-        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        _data.markForBinder(asBinder());
+        _data.markSensitive();
+        android.os.Parcel _reply = android.os.Parcel.obtain();
         java.lang.String _result;
         try {
           _data.writeInterfaceToken(DESCRIPTOR);
@@ -1870,7 +1942,9 @@
       @Override public java.util.List<java.lang.String> RepeatNullableStringList(java.util.List<java.lang.String> input) throws android.os.RemoteException
       {
         android.os.Parcel _data = android.os.Parcel.obtain();
-        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        _data.markForBinder(asBinder());
+        _data.markSensitive();
+        android.os.Parcel _reply = android.os.Parcel.obtain();
         java.util.List<java.lang.String> _result;
         try {
           _data.writeInterfaceToken(DESCRIPTOR);
@@ -1893,7 +1967,9 @@
       @Override public android.aidl.tests.StructuredParcelable RepeatNullableParcelable(android.aidl.tests.StructuredParcelable input) throws android.os.RemoteException
       {
         android.os.Parcel _data = android.os.Parcel.obtain();
-        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        _data.markForBinder(asBinder());
+        _data.markSensitive();
+        android.os.Parcel _reply = android.os.Parcel.obtain();
         android.aidl.tests.StructuredParcelable _result;
         try {
           _data.writeInterfaceToken(DESCRIPTOR);
@@ -1927,7 +2003,9 @@
       @Override public void TakesAnIBinder(android.os.IBinder input) throws android.os.RemoteException
       {
         android.os.Parcel _data = android.os.Parcel.obtain();
-        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        _data.markForBinder(asBinder());
+        _data.markSensitive();
+        android.os.Parcel _reply = android.os.Parcel.obtain();
         try {
           _data.writeInterfaceToken(DESCRIPTOR);
           _data.writeStrongBinder(input);
@@ -1948,7 +2026,9 @@
       @Override public void TakesANullableIBinder(android.os.IBinder input) throws android.os.RemoteException
       {
         android.os.Parcel _data = android.os.Parcel.obtain();
-        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        _data.markForBinder(asBinder());
+        _data.markSensitive();
+        android.os.Parcel _reply = android.os.Parcel.obtain();
         try {
           _data.writeInterfaceToken(DESCRIPTOR);
           _data.writeStrongBinder(input);
@@ -1970,7 +2050,9 @@
       @Override public java.lang.String RepeatUtf8CppString(java.lang.String token) throws android.os.RemoteException
       {
         android.os.Parcel _data = android.os.Parcel.obtain();
-        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        _data.markForBinder(asBinder());
+        _data.markSensitive();
+        android.os.Parcel _reply = android.os.Parcel.obtain();
         java.lang.String _result;
         try {
           _data.writeInterfaceToken(DESCRIPTOR);
@@ -1993,7 +2075,9 @@
       @Override public java.lang.String RepeatNullableUtf8CppString(java.lang.String token) throws android.os.RemoteException
       {
         android.os.Parcel _data = android.os.Parcel.obtain();
-        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        _data.markForBinder(asBinder());
+        _data.markSensitive();
+        android.os.Parcel _reply = android.os.Parcel.obtain();
         java.lang.String _result;
         try {
           _data.writeInterfaceToken(DESCRIPTOR);
@@ -2016,7 +2100,9 @@
       @Override public java.lang.String[] ReverseUtf8CppString(java.lang.String[] input, java.lang.String[] repeated) throws android.os.RemoteException
       {
         android.os.Parcel _data = android.os.Parcel.obtain();
-        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        _data.markForBinder(asBinder());
+        _data.markSensitive();
+        android.os.Parcel _reply = android.os.Parcel.obtain();
         java.lang.String[] _result;
         try {
           _data.writeInterfaceToken(DESCRIPTOR);
@@ -2046,7 +2132,9 @@
       @Override public java.lang.String[] ReverseNullableUtf8CppString(java.lang.String[] input, java.lang.String[] repeated) throws android.os.RemoteException
       {
         android.os.Parcel _data = android.os.Parcel.obtain();
-        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        _data.markForBinder(asBinder());
+        _data.markSensitive();
+        android.os.Parcel _reply = android.os.Parcel.obtain();
         java.lang.String[] _result;
         try {
           _data.writeInterfaceToken(DESCRIPTOR);
@@ -2076,7 +2164,9 @@
       @Override public java.util.List<java.lang.String> ReverseUtf8CppStringList(java.util.List<java.lang.String> input, java.util.List<java.lang.String> repeated) throws android.os.RemoteException
       {
         android.os.Parcel _data = android.os.Parcel.obtain();
-        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        _data.markForBinder(asBinder());
+        _data.markSensitive();
+        android.os.Parcel _reply = android.os.Parcel.obtain();
         java.util.List<java.lang.String> _result;
         try {
           _data.writeInterfaceToken(DESCRIPTOR);
@@ -2100,7 +2190,9 @@
       @Override public android.aidl.tests.INamedCallback GetCallback(boolean return_null) throws android.os.RemoteException
       {
         android.os.Parcel _data = android.os.Parcel.obtain();
-        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        _data.markForBinder(asBinder());
+        _data.markSensitive();
+        android.os.Parcel _reply = android.os.Parcel.obtain();
         android.aidl.tests.INamedCallback _result;
         try {
           _data.writeInterfaceToken(DESCRIPTOR);
@@ -2125,7 +2217,9 @@
       @Override public void FillOutStructuredParcelable(android.aidl.tests.StructuredParcelable parcel) throws android.os.RemoteException
       {
         android.os.Parcel _data = android.os.Parcel.obtain();
-        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        _data.markForBinder(asBinder());
+        _data.markSensitive();
+        android.os.Parcel _reply = android.os.Parcel.obtain();
         try {
           _data.writeInterfaceToken(DESCRIPTOR);
           if ((parcel!=null)) {
@@ -2155,7 +2249,9 @@
       @Override public android.aidl.tests.RecursiveList ReverseList(android.aidl.tests.RecursiveList list) throws android.os.RemoteException
       {
         android.os.Parcel _data = android.os.Parcel.obtain();
-        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        _data.markForBinder(asBinder());
+        _data.markSensitive();
+        android.os.Parcel _reply = android.os.Parcel.obtain();
         android.aidl.tests.RecursiveList _result;
         try {
           _data.writeInterfaceToken(DESCRIPTOR);
@@ -2189,7 +2285,9 @@
       @Override public android.aidl.tests.IOldName GetOldNameInterface() throws android.os.RemoteException
       {
         android.os.Parcel _data = android.os.Parcel.obtain();
-        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        _data.markForBinder(asBinder());
+        _data.markSensitive();
+        android.os.Parcel _reply = android.os.Parcel.obtain();
         android.aidl.tests.IOldName _result;
         try {
           _data.writeInterfaceToken(DESCRIPTOR);
@@ -2211,7 +2309,9 @@
       @Override public android.aidl.tests.INewName GetNewNameInterface() throws android.os.RemoteException
       {
         android.os.Parcel _data = android.os.Parcel.obtain();
-        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        _data.markForBinder(asBinder());
+        _data.markSensitive();
+        android.os.Parcel _reply = android.os.Parcel.obtain();
         android.aidl.tests.INewName _result;
         try {
           _data.writeInterfaceToken(DESCRIPTOR);
@@ -2234,7 +2334,9 @@
       @Override public android.os.IBinder GetCppJavaTests() throws android.os.RemoteException
       {
         android.os.Parcel _data = android.os.Parcel.obtain();
-        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        _data.markForBinder(asBinder());
+        _data.markSensitive();
+        android.os.Parcel _reply = android.os.Parcel.obtain();
         android.os.IBinder _result;
         try {
           _data.writeInterfaceToken(DESCRIPTOR);
@@ -2256,7 +2358,9 @@
       @Override public byte getBackendType() throws android.os.RemoteException
       {
         android.os.Parcel _data = android.os.Parcel.obtain();
-        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        _data.markForBinder(asBinder());
+        _data.markSensitive();
+        android.os.Parcel _reply = android.os.Parcel.obtain();
         byte _result;
         try {
           _data.writeInterfaceToken(DESCRIPTOR);