RuntimeException on unknown transaction

Previously, a call to a non-existing method was silently ignored when
the default implementation was not set for the interface. Now, it
triggers a RuntimeException in the client side. Note that the exception
is thrown only when the interface is versioned. For unversioned
interfaces which have been available to apps, this would be a non-compat
change.

Bug: 167632276
Test: aidl_unittest, aidl_integration_test
Change-Id: I58ac249e85a67a2b0671d66ef208eeb81588641d
diff --git a/generate_java_binder.cpp b/generate_java_binder.cpp
index b9c7674..4d9d708 100644
--- a/generate_java_binder.cpp
+++ b/generate_java_binder.cpp
@@ -662,22 +662,41 @@
   auto _status = std::make_shared<Variable>("boolean", "_status");
   tryStatement->statements->Add(std::make_shared<VariableDeclaration>(_status, call));
 
-  // If the transaction returns false, which means UNKNOWN_TRANSACTION, fall
-  // back to the local method in the default impl, if set before.
+  // If the transaction returns false, which means UNKNOWN_TRANSACTION, fall back to the local
+  // method in the default impl, if set before. Otherwise, throw a RuntimeException if the interface
+  // is versioned. We can't throw the exception for unversioned interface because that would be an
+  // app breaking change.
   vector<string> arg_names;
   for (const auto& arg : method.GetArguments()) {
     arg_names.emplace_back(arg->GetName());
   }
   bool has_return_type = method.GetType().GetName() != "void";
-  tryStatement->statements->Add(std::make_shared<LiteralStatement>(
-      android::base::StringPrintf(has_return_type ? "if (!_status && getDefaultImpl() != null) {\n"
-                                                    "  return getDefaultImpl().%s(%s);\n"
-                                                    "}\n"
-                                                  : "if (!_status && getDefaultImpl() != null) {\n"
-                                                    "  getDefaultImpl().%s(%s);\n"
-                                                    "  return;\n"
-                                                    "}\n",
-                                  method.GetName().c_str(), Join(arg_names, ", ").c_str())));
+
+  auto checkDefaultImpl = std::make_shared<IfStatement>();
+  checkDefaultImpl->expression = std::make_shared<LiteralExpression>("getDefaultImpl() != null");
+  if (has_return_type) {
+    checkDefaultImpl->statements->Add(std::make_shared<LiteralStatement>(
+        android::base::StringPrintf("return getDefaultImpl().%s(%s);\n", method.GetName().c_str(),
+                                    Join(arg_names, ", ").c_str())));
+  } else {
+    checkDefaultImpl->statements->Add(std::make_shared<LiteralStatement>(
+        android::base::StringPrintf("getDefaultImpl().%s(%s);\n", method.GetName().c_str(),
+                                    Join(arg_names, ", ").c_str())));
+    checkDefaultImpl->statements->Add(std::make_shared<LiteralStatement>("return;\n"));
+  }
+  if (options.Version() > 0) {
+    checkDefaultImpl->elseif = std::make_shared<IfStatement>();
+    checkDefaultImpl->elseif->statements->Add(
+        std::make_shared<LiteralStatement>(android::base::StringPrintf(
+            "throw new RuntimeException(\"Method %s is unimplemented.\");\n",
+            method.GetName().c_str())));
+  }
+
+  auto checkTransactionError = std::make_shared<IfStatement>();
+  checkTransactionError->expression = std::make_shared<LiteralExpression>("!_status");
+  checkTransactionError->statements->Add(checkDefaultImpl);
+
+  tryStatement->statements->Add(checkTransactionError);
 
   // throw back exceptions.
   if (_reply) {
diff --git a/tests/java_app/src/android/aidl/tests/TestVersionedInterface.java b/tests/java_app/src/android/aidl/tests/TestVersionedInterface.java
index b14504b..06b14a7 100644
--- a/tests/java_app/src/android/aidl/tests/TestVersionedInterface.java
+++ b/tests/java_app/src/android/aidl/tests/TestVersionedInterface.java
@@ -16,21 +16,22 @@
 
 package android.aidl.tests;
 
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.assertThat;
 import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
 
-import androidx.test.core.app.ApplicationProvider;
 import android.aidl.versioned.tests.IFooInterface;
 import android.os.IBinder;
 import android.os.RemoteException;
 import android.os.ServiceManager;
-
+import androidx.test.core.app.ApplicationProvider;
 import org.junit.Before;
+import org.junit.Rule;
 import org.junit.Test;
-import org.junit.runners.JUnit4;
+import org.junit.rules.ExpectedException;
 import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
 
 @RunWith(JUnit4.class)
 public class TestVersionedInterface {
@@ -53,4 +54,14 @@
     public void testGetInterfaceHash() throws RemoteException {
         assertThat(service.getInterfaceHash(), is("fcd4f9c806cbc8af3694d569fd1de1ecc8cf7d22"));
     }
+
+    @Rule public ExpectedException expectedException = ExpectedException.none();
+
+    @Test
+    public void testUnimplementedMethodTriggersException() throws RemoteException {
+      expectedException.expect(RuntimeException.class);
+      expectedException.expectMessage("Method bar is unimplemented.");
+
+      service.bar();
+    }
 }
diff --git a/tests/test_data_example_interface.cpp b/tests/test_data_example_interface.cpp
index 6448dd3..a1c3498 100644
--- a/tests/test_data_example_interface.cpp
+++ b/tests/test_data_example_interface.cpp
@@ -340,8 +340,10 @@
         try {
           _data.writeInterfaceToken(DESCRIPTOR);
           boolean _status = mRemote.transact(Stub.TRANSACTION_isEnabled, _data, _reply, 0);
-          if (!_status && getDefaultImpl() != null) {
-            return getDefaultImpl().isEnabled();
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              return getDefaultImpl().isEnabled();
+            }
           }
           _reply.readException();
           _result = (0!=_reply.readInt());
@@ -360,8 +362,10 @@
         try {
           _data.writeInterfaceToken(DESCRIPTOR);
           boolean _status = mRemote.transact(Stub.TRANSACTION_getState, _data, _reply, 0);
-          if (!_status && getDefaultImpl() != null) {
-            return getDefaultImpl().getState();
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              return getDefaultImpl().getState();
+            }
           }
           _reply.readException();
           _result = _reply.readInt();
@@ -380,8 +384,10 @@
         try {
           _data.writeInterfaceToken(DESCRIPTOR);
           boolean _status = mRemote.transact(Stub.TRANSACTION_getAddress, _data, _reply, 0);
-          if (!_status && getDefaultImpl() != null) {
-            return getDefaultImpl().getAddress();
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              return getDefaultImpl().getAddress();
+            }
           }
           _reply.readException();
           _result = _reply.readString();
@@ -401,8 +407,10 @@
         try {
           _data.writeInterfaceToken(DESCRIPTOR);
           boolean _status = mRemote.transact(Stub.TRANSACTION_getParcelables, _data, _reply, 0);
-          if (!_status && getDefaultImpl() != null) {
-            return getDefaultImpl().getParcelables();
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              return getDefaultImpl().getParcelables();
+            }
           }
           _reply.readException();
           _result = _reply.createTypedArray(android.foo.ExampleParcelable.CREATOR);
@@ -425,8 +433,10 @@
           _data.writeInt(mode);
           _data.writeInt(duration);
           boolean _status = mRemote.transact(Stub.TRANSACTION_setScanMode, _data, _reply, 0);
-          if (!_status && getDefaultImpl() != null) {
-            return getDefaultImpl().setScanMode(mode, duration);
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              return getDefaultImpl().setScanMode(mode, duration);
+            }
           }
           _reply.readException();
           _result = (0!=_reply.readInt());
@@ -447,9 +457,11 @@
           _data.writeInterfaceToken(DESCRIPTOR);
           _data.writeStrongBinder((((foo!=null))?(foo.asBinder()):(null)));
           boolean _status = mRemote.transact(Stub.TRANSACTION_registerBinder, _data, _reply, 0);
-          if (!_status && getDefaultImpl() != null) {
-            getDefaultImpl().registerBinder(foo);
-            return;
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              getDefaultImpl().registerBinder(foo);
+              return;
+            }
           }
           _reply.readException();
         }
@@ -466,8 +478,10 @@
         try {
           _data.writeInterfaceToken(DESCRIPTOR);
           boolean _status = mRemote.transact(Stub.TRANSACTION_getRecursiveBinder, _data, _reply, 0);
-          if (!_status && getDefaultImpl() != null) {
-            return getDefaultImpl().getRecursiveBinder();
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              return getDefaultImpl().getRecursiveBinder();
+            }
           }
           _reply.readException();
           _result = android.test.IExampleInterface.Stub.asInterface(_reply.readStrongBinder());
@@ -487,8 +501,10 @@
           _data.writeInterfaceToken(DESCRIPTOR);
           _data.writeStrongBinder((((arg!=null))?(arg.asBinder()):(null)));
           boolean _status = mRemote.transact(Stub.TRANSACTION_takesAnInterface, _data, _reply, 0);
-          if (!_status && getDefaultImpl() != null) {
-            return getDefaultImpl().takesAnInterface(arg);
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              return getDefaultImpl().takesAnInterface(arg);
+            }
           }
           _reply.readException();
           _result = _reply.readInt();
@@ -521,8 +537,10 @@
             _data.writeInt(0);
           }
           boolean _status = mRemote.transact(Stub.TRANSACTION_takesAParcelable, _data, _reply, 0);
-          if (!_status && getDefaultImpl() != null) {
-            return getDefaultImpl().takesAParcelable(arg, arg2);
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              return getDefaultImpl().takesAParcelable(arg, arg2);
+            }
           }
           _reply.readException();
           _result = _reply.readInt();
@@ -860,8 +878,10 @@
         try {
           _data.writeInterfaceToken(DESCRIPTOR);
           boolean _status = mRemote.transact(Stub.TRANSACTION_isEnabled, _data, _reply, 0);
-          if (!_status && getDefaultImpl() != null) {
-            return getDefaultImpl().isEnabled();
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              return getDefaultImpl().isEnabled();
+            }
           }
           _reply.readException();
           _result = (0!=_reply.readInt());
@@ -880,8 +900,10 @@
         try {
           _data.writeInterfaceToken(DESCRIPTOR);
           boolean _status = mRemote.transact(Stub.TRANSACTION_getState, _data, _reply, 0);
-          if (!_status && getDefaultImpl() != null) {
-            return getDefaultImpl().getState();
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              return getDefaultImpl().getState();
+            }
           }
           _reply.readException();
           _result = _reply.readInt();
@@ -900,8 +922,10 @@
         try {
           _data.writeInterfaceToken(DESCRIPTOR);
           boolean _status = mRemote.transact(Stub.TRANSACTION_getAddress, _data, _reply, 0);
-          if (!_status && getDefaultImpl() != null) {
-            return getDefaultImpl().getAddress();
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              return getDefaultImpl().getAddress();
+            }
           }
           _reply.readException();
           _result = _reply.readString();
@@ -921,8 +945,10 @@
         try {
           _data.writeInterfaceToken(DESCRIPTOR);
           boolean _status = mRemote.transact(Stub.TRANSACTION_getParcelables, _data, _reply, 0);
-          if (!_status && getDefaultImpl() != null) {
-            return getDefaultImpl().getParcelables();
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              return getDefaultImpl().getParcelables();
+            }
           }
           _reply.readException();
           _result = _reply.createTypedArray(android.foo.ExampleParcelable.CREATOR);
@@ -945,8 +971,10 @@
           _data.writeInt(mode);
           _data.writeInt(duration);
           boolean _status = mRemote.transact(Stub.TRANSACTION_setScanMode, _data, _reply, 0);
-          if (!_status && getDefaultImpl() != null) {
-            return getDefaultImpl().setScanMode(mode, duration);
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              return getDefaultImpl().setScanMode(mode, duration);
+            }
           }
           _reply.readException();
           _result = (0!=_reply.readInt());
@@ -967,9 +995,11 @@
           _data.writeInterfaceToken(DESCRIPTOR);
           _data.writeStrongBinder((((foo!=null))?(foo.asBinder()):(null)));
           boolean _status = mRemote.transact(Stub.TRANSACTION_registerBinder, _data, _reply, 0);
-          if (!_status && getDefaultImpl() != null) {
-            getDefaultImpl().registerBinder(foo);
-            return;
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              getDefaultImpl().registerBinder(foo);
+              return;
+            }
           }
           _reply.readException();
         }
@@ -986,8 +1016,10 @@
         try {
           _data.writeInterfaceToken(DESCRIPTOR);
           boolean _status = mRemote.transact(Stub.TRANSACTION_getRecursiveBinder, _data, _reply, 0);
-          if (!_status && getDefaultImpl() != null) {
-            return getDefaultImpl().getRecursiveBinder();
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              return getDefaultImpl().getRecursiveBinder();
+            }
           }
           _reply.readException();
           _result = android.test.IExampleInterface.Stub.asInterface(_reply.readStrongBinder());
@@ -1007,8 +1039,10 @@
           _data.writeInterfaceToken(DESCRIPTOR);
           _data.writeStrongBinder((((arg!=null))?(arg.asBinder()):(null)));
           boolean _status = mRemote.transact(Stub.TRANSACTION_takesAnInterface, _data, _reply, 0);
-          if (!_status && getDefaultImpl() != null) {
-            return getDefaultImpl().takesAnInterface(arg);
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              return getDefaultImpl().takesAnInterface(arg);
+            }
           }
           _reply.readException();
           _result = _reply.readInt();
@@ -1041,8 +1075,10 @@
             _data.writeInt(0);
           }
           boolean _status = mRemote.transact(Stub.TRANSACTION_takesAParcelable, _data, _reply, 0);
-          if (!_status && getDefaultImpl() != null) {
-            return getDefaultImpl().takesAParcelable(arg, arg2);
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              return getDefaultImpl().takesAParcelable(arg, arg2);
+            }
           }
           _reply.readException();
           _result = _reply.readInt();
@@ -1383,8 +1419,10 @@
           android.os.Trace.traceBegin(android.os.Trace.TRACE_TAG_AIDL, "AIDL::java::IExampleInterface::isEnabled::client");
           _data.writeInterfaceToken(DESCRIPTOR);
           boolean _status = mRemote.transact(Stub.TRANSACTION_isEnabled, _data, _reply, 0);
-          if (!_status && getDefaultImpl() != null) {
-            return getDefaultImpl().isEnabled();
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              return getDefaultImpl().isEnabled();
+            }
           }
           _reply.readException();
           _result = (0!=_reply.readInt());
@@ -1405,8 +1443,10 @@
           android.os.Trace.traceBegin(android.os.Trace.TRACE_TAG_AIDL, "AIDL::java::IExampleInterface::getState::client");
           _data.writeInterfaceToken(DESCRIPTOR);
           boolean _status = mRemote.transact(Stub.TRANSACTION_getState, _data, _reply, 0);
-          if (!_status && getDefaultImpl() != null) {
-            return getDefaultImpl().getState();
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              return getDefaultImpl().getState();
+            }
           }
           _reply.readException();
           _result = _reply.readInt();
@@ -1427,8 +1467,10 @@
           android.os.Trace.traceBegin(android.os.Trace.TRACE_TAG_AIDL, "AIDL::java::IExampleInterface::getAddress::client");
           _data.writeInterfaceToken(DESCRIPTOR);
           boolean _status = mRemote.transact(Stub.TRANSACTION_getAddress, _data, _reply, 0);
-          if (!_status && getDefaultImpl() != null) {
-            return getDefaultImpl().getAddress();
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              return getDefaultImpl().getAddress();
+            }
           }
           _reply.readException();
           _result = _reply.readString();
@@ -1450,8 +1492,10 @@
           android.os.Trace.traceBegin(android.os.Trace.TRACE_TAG_AIDL, "AIDL::java::IExampleInterface::getParcelables::client");
           _data.writeInterfaceToken(DESCRIPTOR);
           boolean _status = mRemote.transact(Stub.TRANSACTION_getParcelables, _data, _reply, 0);
-          if (!_status && getDefaultImpl() != null) {
-            return getDefaultImpl().getParcelables();
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              return getDefaultImpl().getParcelables();
+            }
           }
           _reply.readException();
           _result = _reply.createTypedArray(android.foo.ExampleParcelable.CREATOR);
@@ -1476,8 +1520,10 @@
           _data.writeInt(mode);
           _data.writeInt(duration);
           boolean _status = mRemote.transact(Stub.TRANSACTION_setScanMode, _data, _reply, 0);
-          if (!_status && getDefaultImpl() != null) {
-            return getDefaultImpl().setScanMode(mode, duration);
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              return getDefaultImpl().setScanMode(mode, duration);
+            }
           }
           _reply.readException();
           _result = (0!=_reply.readInt());
@@ -1500,9 +1546,11 @@
           _data.writeInterfaceToken(DESCRIPTOR);
           _data.writeStrongBinder((((foo!=null))?(foo.asBinder()):(null)));
           boolean _status = mRemote.transact(Stub.TRANSACTION_registerBinder, _data, _reply, 0);
-          if (!_status && getDefaultImpl() != null) {
-            getDefaultImpl().registerBinder(foo);
-            return;
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              getDefaultImpl().registerBinder(foo);
+              return;
+            }
           }
           _reply.readException();
         }
@@ -1521,8 +1569,10 @@
           android.os.Trace.traceBegin(android.os.Trace.TRACE_TAG_AIDL, "AIDL::java::IExampleInterface::getRecursiveBinder::client");
           _data.writeInterfaceToken(DESCRIPTOR);
           boolean _status = mRemote.transact(Stub.TRANSACTION_getRecursiveBinder, _data, _reply, 0);
-          if (!_status && getDefaultImpl() != null) {
-            return getDefaultImpl().getRecursiveBinder();
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              return getDefaultImpl().getRecursiveBinder();
+            }
           }
           _reply.readException();
           _result = android.test.IExampleInterface.Stub.asInterface(_reply.readStrongBinder());
@@ -1544,8 +1594,10 @@
           _data.writeInterfaceToken(DESCRIPTOR);
           _data.writeStrongBinder((((arg!=null))?(arg.asBinder()):(null)));
           boolean _status = mRemote.transact(Stub.TRANSACTION_takesAnInterface, _data, _reply, 0);
-          if (!_status && getDefaultImpl() != null) {
-            return getDefaultImpl().takesAnInterface(arg);
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              return getDefaultImpl().takesAnInterface(arg);
+            }
           }
           _reply.readException();
           _result = _reply.readInt();
@@ -1580,8 +1632,10 @@
             _data.writeInt(0);
           }
           boolean _status = mRemote.transact(Stub.TRANSACTION_takesAParcelable, _data, _reply, 0);
-          if (!_status && getDefaultImpl() != null) {
-            return getDefaultImpl().takesAParcelable(arg, arg2);
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              return getDefaultImpl().takesAParcelable(arg, arg2);
+            }
           }
           _reply.readException();
           _result = _reply.readInt();
@@ -1814,8 +1868,10 @@
         try {
           _data.writeInterfaceToken(DESCRIPTOR);
           boolean _status = mRemote.transact(Stub.TRANSACTION_isEnabled, _data, _reply, 0);
-          if (!_status && getDefaultImpl() != null) {
-            return getDefaultImpl().isEnabled();
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              return getDefaultImpl().isEnabled();
+            }
           }
           _reply.readException();
           _result = (0!=_reply.readInt());
@@ -1836,8 +1892,10 @@
           _data.writeInt(a);
           _data.writeInt(b);
           boolean _status = mRemote.transact(Stub.TRANSACTION_getState, _data, _reply, 0);
-          if (!_status && getDefaultImpl() != null) {
-            return getDefaultImpl().getState(a, b);
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              return getDefaultImpl().getState(a, b);
+            }
           }
           _reply.readException();
           _result = _reply.readInt();
@@ -1856,8 +1914,10 @@
         try {
           _data.writeInterfaceToken(DESCRIPTOR);
           boolean _status = mRemote.transact(Stub.TRANSACTION_getAddress, _data, _reply, 0);
-          if (!_status && getDefaultImpl() != null) {
-            return getDefaultImpl().getAddress();
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              return getDefaultImpl().getAddress();
+            }
           }
           _reply.readException();
           _result = _reply.readString();
@@ -1877,8 +1937,10 @@
         try {
           _data.writeInterfaceToken(DESCRIPTOR);
           boolean _status = mRemote.transact(Stub.TRANSACTION_getParcelables, _data, _reply, 0);
-          if (!_status && getDefaultImpl() != null) {
-            return getDefaultImpl().getParcelables();
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              return getDefaultImpl().getParcelables();
+            }
           }
           _reply.readException();
           _result = _reply.createTypedArray(android.foo.ExampleParcelable.CREATOR);
@@ -1901,8 +1963,10 @@
           _data.writeInt(mode);
           _data.writeInt(duration);
           boolean _status = mRemote.transact(Stub.TRANSACTION_setScanMode, _data, _reply, 0);
-          if (!_status && getDefaultImpl() != null) {
-            return getDefaultImpl().setScanMode(mode, duration);
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              return getDefaultImpl().setScanMode(mode, duration);
+            }
           }
           _reply.readException();
           _result = (0!=_reply.readInt());
@@ -1923,9 +1987,11 @@
           _data.writeInterfaceToken(DESCRIPTOR);
           _data.writeStrongBinder((((foo!=null))?(foo.asBinder()):(null)));
           boolean _status = mRemote.transact(Stub.TRANSACTION_registerBinder, _data, _reply, 0);
-          if (!_status && getDefaultImpl() != null) {
-            getDefaultImpl().registerBinder(foo);
-            return;
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              getDefaultImpl().registerBinder(foo);
+              return;
+            }
           }
           _reply.readException();
         }
@@ -1942,8 +2008,10 @@
         try {
           _data.writeInterfaceToken(DESCRIPTOR);
           boolean _status = mRemote.transact(Stub.TRANSACTION_getRecursiveBinder, _data, _reply, 0);
-          if (!_status && getDefaultImpl() != null) {
-            return getDefaultImpl().getRecursiveBinder();
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              return getDefaultImpl().getRecursiveBinder();
+            }
           }
           _reply.readException();
           _result = android.test.IExampleInterface.Stub.asInterface(_reply.readStrongBinder());
@@ -1963,8 +2031,10 @@
           _data.writeInterfaceToken(DESCRIPTOR);
           _data.writeStrongBinder((((arg!=null))?(arg.asBinder()):(null)));
           boolean _status = mRemote.transact(Stub.TRANSACTION_takesAnInterface, _data, _reply, 0);
-          if (!_status && getDefaultImpl() != null) {
-            return getDefaultImpl().takesAnInterface(arg);
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              return getDefaultImpl().takesAnInterface(arg);
+            }
           }
           _reply.readException();
           _result = _reply.readInt();
@@ -1997,8 +2067,10 @@
             _data.writeInt(0);
           }
           boolean _status = mRemote.transact(Stub.TRANSACTION_takesAParcelable, _data, _reply, 0);
-          if (!_status && getDefaultImpl() != null) {
-            return getDefaultImpl().takesAParcelable(arg, arg2);
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              return getDefaultImpl().takesAParcelable(arg, arg2);
+            }
           }
           _reply.readException();
           _result = _reply.readInt();
@@ -2340,8 +2412,13 @@
         try {
           _data.writeInterfaceToken(DESCRIPTOR);
           boolean _status = mRemote.transact(Stub.TRANSACTION_isEnabled, _data, _reply, 0);
-          if (!_status && getDefaultImpl() != null) {
-            return getDefaultImpl().isEnabled();
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              return getDefaultImpl().isEnabled();
+            }
+            else {
+              throw new RuntimeException("Method isEnabled is unimplemented.");
+            }
           }
           _reply.readException();
           _result = (0!=_reply.readInt());
@@ -2362,8 +2439,13 @@
           _data.writeInt(a);
           _data.writeInt(b);
           boolean _status = mRemote.transact(Stub.TRANSACTION_getState, _data, _reply, 0);
-          if (!_status && getDefaultImpl() != null) {
-            return getDefaultImpl().getState(a, b);
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              return getDefaultImpl().getState(a, b);
+            }
+            else {
+              throw new RuntimeException("Method getState is unimplemented.");
+            }
           }
           _reply.readException();
           _result = _reply.readInt();
@@ -2382,8 +2464,13 @@
         try {
           _data.writeInterfaceToken(DESCRIPTOR);
           boolean _status = mRemote.transact(Stub.TRANSACTION_getAddress, _data, _reply, 0);
-          if (!_status && getDefaultImpl() != null) {
-            return getDefaultImpl().getAddress();
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              return getDefaultImpl().getAddress();
+            }
+            else {
+              throw new RuntimeException("Method getAddress is unimplemented.");
+            }
           }
           _reply.readException();
           _result = _reply.readString();
@@ -2403,8 +2490,13 @@
         try {
           _data.writeInterfaceToken(DESCRIPTOR);
           boolean _status = mRemote.transact(Stub.TRANSACTION_getParcelables, _data, _reply, 0);
-          if (!_status && getDefaultImpl() != null) {
-            return getDefaultImpl().getParcelables();
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              return getDefaultImpl().getParcelables();
+            }
+            else {
+              throw new RuntimeException("Method getParcelables is unimplemented.");
+            }
           }
           _reply.readException();
           _result = _reply.createTypedArray(android.foo.ExampleParcelable.CREATOR);
@@ -2427,8 +2519,13 @@
           _data.writeInt(mode);
           _data.writeInt(duration);
           boolean _status = mRemote.transact(Stub.TRANSACTION_setScanMode, _data, _reply, 0);
-          if (!_status && getDefaultImpl() != null) {
-            return getDefaultImpl().setScanMode(mode, duration);
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              return getDefaultImpl().setScanMode(mode, duration);
+            }
+            else {
+              throw new RuntimeException("Method setScanMode is unimplemented.");
+            }
           }
           _reply.readException();
           _result = (0!=_reply.readInt());
@@ -2449,9 +2546,14 @@
           _data.writeInterfaceToken(DESCRIPTOR);
           _data.writeStrongBinder((((foo!=null))?(foo.asBinder()):(null)));
           boolean _status = mRemote.transact(Stub.TRANSACTION_registerBinder, _data, _reply, 0);
-          if (!_status && getDefaultImpl() != null) {
-            getDefaultImpl().registerBinder(foo);
-            return;
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              getDefaultImpl().registerBinder(foo);
+              return;
+            }
+            else {
+              throw new RuntimeException("Method registerBinder is unimplemented.");
+            }
           }
           _reply.readException();
         }
@@ -2468,8 +2570,13 @@
         try {
           _data.writeInterfaceToken(DESCRIPTOR);
           boolean _status = mRemote.transact(Stub.TRANSACTION_getRecursiveBinder, _data, _reply, 0);
-          if (!_status && getDefaultImpl() != null) {
-            return getDefaultImpl().getRecursiveBinder();
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              return getDefaultImpl().getRecursiveBinder();
+            }
+            else {
+              throw new RuntimeException("Method getRecursiveBinder is unimplemented.");
+            }
           }
           _reply.readException();
           _result = android.test.IExampleInterface.Stub.asInterface(_reply.readStrongBinder());
@@ -2489,8 +2596,13 @@
           _data.writeInterfaceToken(DESCRIPTOR);
           _data.writeStrongBinder((((arg!=null))?(arg.asBinder()):(null)));
           boolean _status = mRemote.transact(Stub.TRANSACTION_takesAnInterface, _data, _reply, 0);
-          if (!_status && getDefaultImpl() != null) {
-            return getDefaultImpl().takesAnInterface(arg);
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              return getDefaultImpl().takesAnInterface(arg);
+            }
+            else {
+              throw new RuntimeException("Method takesAnInterface is unimplemented.");
+            }
           }
           _reply.readException();
           _result = _reply.readInt();
@@ -2523,8 +2635,13 @@
             _data.writeInt(0);
           }
           boolean _status = mRemote.transact(Stub.TRANSACTION_takesAParcelable, _data, _reply, 0);
-          if (!_status && getDefaultImpl() != null) {
-            return getDefaultImpl().takesAParcelable(arg, arg2);
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              return getDefaultImpl().takesAParcelable(arg, arg2);
+            }
+            else {
+              throw new RuntimeException("Method takesAParcelable is unimplemented.");
+            }
           }
           _reply.readException();
           _result = _reply.readInt();