Use hwservicemanager getTransport.

libhidl no longer provides a getTransport function. Now, call into the
hwservicemanager which directly interfaces with libvintf.

Test: extensive, see Ia5d1eb41b057ab5d6800f6c3fd22658adecc4be7
Bug: 36377072

Merged-In: I8b0ca845251cd7cd156f3471cbd4b0ce17617be0
Change-Id: I8b0ca845251cd7cd156f3471cbd4b0ce17617be0
(cherry picked from commit f8202e464e)
This commit is contained in:
Steven Moreland
2017-04-06 09:28:32 -07:00
parent f19c52d20d
commit f7019c2e53

View File

@@ -276,7 +276,8 @@ static jobject JHwBinder_native_getService(
jstring ifaceNameObj,
jstring serviceNameObj) {
using ::android::vintf::operator<<;
using ::android::hidl::base::V1_0::IBase;
using ::android::hidl::manager::V1_0::IServiceManager;
if (ifaceNameObj == NULL) {
jniThrowException(env, "java/lang/NullPointerException", NULL);
@@ -318,13 +319,20 @@ static jobject JHwBinder_native_getService(
<< "/"
<< serviceName;
::android::vintf::Transport transport =
::android::hardware::getTransport(ifaceName, serviceName);
if ( transport != ::android::vintf::Transport::EMPTY
&& transport != ::android::vintf::Transport::HWBINDER) {
Return<IServiceManager::Transport> transportRet =
manager->getTransport(ifaceNameHStr, serviceNameHStr);
if (!transportRet.isOk()) {
signalExceptionForError(env, UNKNOWN_ERROR, true /* canThrowRemoteException */);
return NULL;
}
IServiceManager::Transport transport = transportRet;
if ( transport != IServiceManager::Transport::EMPTY
&& transport != IServiceManager::Transport::HWBINDER) {
LOG(ERROR) << "service " << ifaceName << " declares transport method "
<< transport << " but framework expects "
<< ::android::vintf::Transport::HWBINDER;
<< toString(transport) << " but framework expects hwbinder.";
signalExceptionForError(env, UNKNOWN_ERROR, true /* canThrowRemoteException */);
return NULL;
}