Merge "android.os.HwBinder.getService() in Java respects VINTF." am: 01f374c635
am: 71e77c865b
am: 2e943c5379
Change-Id: Ibbf18bc51e146abef1ab211614a98ec59031b1b9
This commit is contained in:
@ -274,6 +274,7 @@ LOCAL_SHARED_LIBRARIES := \
|
|||||||
libhidlbase \
|
libhidlbase \
|
||||||
libhidltransport \
|
libhidltransport \
|
||||||
libhwbinder \
|
libhwbinder \
|
||||||
|
libvintf \
|
||||||
|
|
||||||
LOCAL_SHARED_LIBRARIES += \
|
LOCAL_SHARED_LIBRARIES += \
|
||||||
libhwui \
|
libhwui \
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
#include <hidl/HidlTransportSupport.h>
|
#include <hidl/HidlTransportSupport.h>
|
||||||
#include <hwbinder/ProcessState.h>
|
#include <hwbinder/ProcessState.h>
|
||||||
#include <nativehelper/ScopedLocalRef.h>
|
#include <nativehelper/ScopedLocalRef.h>
|
||||||
|
#include <vintf/parse_string.h>
|
||||||
|
|
||||||
#include "core_jni_helpers.h"
|
#include "core_jni_helpers.h"
|
||||||
|
|
||||||
@ -300,6 +301,8 @@ static jobject JHwBinder_native_getService(
|
|||||||
jstring ifaceNameObj,
|
jstring ifaceNameObj,
|
||||||
jstring serviceNameObj) {
|
jstring serviceNameObj) {
|
||||||
|
|
||||||
|
using ::android::vintf::operator<<;
|
||||||
|
|
||||||
if (ifaceNameObj == NULL) {
|
if (ifaceNameObj == NULL) {
|
||||||
jniThrowException(env, "java/lang/NullPointerException", NULL);
|
jniThrowException(env, "java/lang/NullPointerException", NULL);
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -317,27 +320,41 @@ static jobject JHwBinder_native_getService(
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *ifaceName = env->GetStringUTFChars(ifaceNameObj, NULL);
|
const char *ifaceNameCStr = env->GetStringUTFChars(ifaceNameObj, NULL);
|
||||||
if (ifaceName == NULL) {
|
if (ifaceNameCStr == NULL) {
|
||||||
return NULL; // XXX exception already pending?
|
return NULL; // XXX exception already pending?
|
||||||
}
|
}
|
||||||
const char *serviceName = env->GetStringUTFChars(serviceNameObj, NULL);
|
std::string ifaceName(ifaceNameCStr);
|
||||||
if (serviceName == NULL) {
|
env->ReleaseStringUTFChars(ifaceNameObj, ifaceNameCStr);
|
||||||
env->ReleaseStringUTFChars(ifaceNameObj, ifaceName);
|
::android::hardware::hidl_string ifaceNameHStr;
|
||||||
|
ifaceNameHStr.setToExternal(ifaceName.c_str(), ifaceName.size());
|
||||||
|
|
||||||
|
const char *serviceNameCStr = env->GetStringUTFChars(serviceNameObj, NULL);
|
||||||
|
if (serviceNameCStr == NULL) {
|
||||||
return NULL; // XXX exception already pending?
|
return NULL; // XXX exception already pending?
|
||||||
}
|
}
|
||||||
|
std::string serviceName(serviceNameCStr);
|
||||||
|
env->ReleaseStringUTFChars(serviceNameObj, serviceNameCStr);
|
||||||
|
::android::hardware::hidl_string serviceNameHStr;
|
||||||
|
serviceNameHStr.setToExternal(serviceName.c_str(), serviceName.size());
|
||||||
|
|
||||||
LOG(INFO) << "Looking for service "
|
LOG(INFO) << "Looking for service "
|
||||||
<< ifaceName
|
<< ifaceName
|
||||||
<< "/"
|
<< "/"
|
||||||
<< serviceName;
|
<< serviceName;
|
||||||
|
|
||||||
Return<sp<hidl::base::V1_0::IBase>> ret = manager->get(ifaceName, serviceName);
|
::android::vintf::Transport transport =
|
||||||
|
::android::hardware::getTransport(ifaceName);
|
||||||
|
if ( transport != ::android::vintf::Transport::EMPTY
|
||||||
|
&& transport != ::android::vintf::Transport::HWBINDER) {
|
||||||
|
LOG(ERROR) << "service " << ifaceName << " declares transport method "
|
||||||
|
<< transport << " but framework expects "
|
||||||
|
<< ::android::vintf::Transport::HWBINDER;
|
||||||
|
signalExceptionForError(env, UNKNOWN_ERROR, true /* canThrowRemoteException */);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
env->ReleaseStringUTFChars(ifaceNameObj, ifaceName);
|
Return<sp<hidl::base::V1_0::IBase>> ret = manager->get(ifaceNameHStr, serviceNameHStr);
|
||||||
ifaceName = NULL;
|
|
||||||
env->ReleaseStringUTFChars(serviceNameObj, serviceName);
|
|
||||||
serviceName = NULL;
|
|
||||||
|
|
||||||
if (!ret.isOk()) {
|
if (!ret.isOk()) {
|
||||||
signalExceptionForError(env, UNKNOWN_ERROR, true /* canThrowRemoteException */);
|
signalExceptionForError(env, UNKNOWN_ERROR, true /* canThrowRemoteException */);
|
||||||
|
Reference in New Issue
Block a user