HIDL Java: DeadObjectException
Allow HIDL to throw DeadObjectException (which extends RemoteException) like AIDL in order to distinguish this error. There is a slight risk of API breakage here because someone could be guarding against DeadObjectException already for AIDL code and ignoring all HIDL exceptions within that scope. In this case, HIDL code which previously did not trigger the DeadObjectException could trigger that code path. However, mixing AIDL and HIDL like this would already be considered extremely unsafe. Fixes: 160169016 Test: hidl_test_java Change-Id: I259070bbba5cabb52cf7cf5a11cb5d5c21abeff8
This commit is contained in:
@@ -122,10 +122,18 @@ void signalExceptionForError(JNIEnv *env, status_t err, bool canThrowRemoteExcep
|
||||
std::stringstream ss;
|
||||
ss << "HwBinder Error: (" << err << ")";
|
||||
|
||||
jniThrowException(
|
||||
env,
|
||||
canThrowRemoteException ? "android/os/RemoteException" : "java/lang/RuntimeException",
|
||||
ss.str().c_str());
|
||||
const char* exception = nullptr;
|
||||
if (canThrowRemoteException) {
|
||||
if (err == DEAD_OBJECT) {
|
||||
exception = "android/os/DeadObjectException";
|
||||
} else {
|
||||
exception = "android/os/RemoteException";
|
||||
}
|
||||
} else {
|
||||
exception = "java/lang/RuntimeException";
|
||||
}
|
||||
|
||||
jniThrowException(env, exception, ss.str().c_str());
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user