Merge "HwBinder: Clean up code, add logging"
am: 28ed91161d
Change-Id: Ie7d511812c6dc419ca793c28a4cee1150a90bd66
This commit is contained in:
@@ -35,6 +35,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 <nativehelper/ScopedUtfChars.h>
|
||||||
#include <vintf/parse_string.h>
|
#include <vintf/parse_string.h>
|
||||||
#include <utils/misc.h>
|
#include <utils/misc.h>
|
||||||
|
|
||||||
@@ -261,14 +262,9 @@ static void JHwBinder_native_registerService(
|
|||||||
JNIEnv *env,
|
JNIEnv *env,
|
||||||
jobject thiz,
|
jobject thiz,
|
||||||
jstring serviceNameObj) {
|
jstring serviceNameObj) {
|
||||||
if (serviceNameObj == NULL) {
|
ScopedUtfChars str(env, serviceNameObj);
|
||||||
jniThrowException(env, "java/lang/NullPointerException", NULL);
|
if (str.c_str() == nullptr) {
|
||||||
return;
|
return; // NPE will be pending.
|
||||||
}
|
|
||||||
|
|
||||||
const char *serviceName = env->GetStringUTFChars(serviceNameObj, NULL);
|
|
||||||
if (serviceName == NULL) {
|
|
||||||
return; // XXX exception already pending?
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sp<hardware::IBinder> binder = JHwBinder::GetNativeBinder(env, thiz);
|
sp<hardware::IBinder> binder = JHwBinder::GetNativeBinder(env, thiz);
|
||||||
@@ -284,15 +280,12 @@ static void JHwBinder_native_registerService(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Return<bool> ret = manager->add(serviceName, base);
|
Return<bool> ret = manager->add(str.c_str(), base);
|
||||||
|
|
||||||
env->ReleaseStringUTFChars(serviceNameObj, serviceName);
|
|
||||||
serviceName = NULL;
|
|
||||||
|
|
||||||
bool ok = ret.isOk() && ret;
|
bool ok = ret.isOk() && ret;
|
||||||
|
|
||||||
if (ok) {
|
if (ok) {
|
||||||
LOG(INFO) << "Starting thread pool.";
|
LOG(INFO) << "HwBinder: Starting thread pool for " << str.c_str();
|
||||||
::android::hardware::ProcessState::self()->startThreadPool();
|
::android::hardware::ProcessState::self()->startThreadPool();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -308,28 +301,23 @@ static jobject JHwBinder_native_getService(
|
|||||||
using ::android::hidl::base::V1_0::IBase;
|
using ::android::hidl::base::V1_0::IBase;
|
||||||
using ::android::hardware::details::getRawServiceInternal;
|
using ::android::hardware::details::getRawServiceInternal;
|
||||||
|
|
||||||
if (ifaceNameObj == NULL) {
|
std::string ifaceName;
|
||||||
jniThrowException(env, "java/lang/NullPointerException", NULL);
|
{
|
||||||
return NULL;
|
ScopedUtfChars str(env, ifaceNameObj);
|
||||||
}
|
if (str.c_str() == nullptr) {
|
||||||
if (serviceNameObj == NULL) {
|
return nullptr; // NPE will be pending.
|
||||||
jniThrowException(env, "java/lang/NullPointerException", NULL);
|
}
|
||||||
return NULL;
|
ifaceName = str.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *ifaceNameCStr = env->GetStringUTFChars(ifaceNameObj, NULL);
|
std::string serviceName;
|
||||||
if (ifaceNameCStr == NULL) {
|
{
|
||||||
return NULL; // XXX exception already pending?
|
ScopedUtfChars str(env, serviceNameObj);
|
||||||
|
if (str.c_str() == nullptr) {
|
||||||
|
return nullptr; // NPE will be pending.
|
||||||
|
}
|
||||||
|
serviceName = str.c_str();
|
||||||
}
|
}
|
||||||
std::string ifaceName(ifaceNameCStr);
|
|
||||||
env->ReleaseStringUTFChars(ifaceNameObj, ifaceNameCStr);
|
|
||||||
|
|
||||||
const char *serviceNameCStr = env->GetStringUTFChars(serviceNameObj, NULL);
|
|
||||||
if (serviceNameCStr == NULL) {
|
|
||||||
return NULL; // XXX exception already pending?
|
|
||||||
}
|
|
||||||
std::string serviceName(serviceNameCStr);
|
|
||||||
env->ReleaseStringUTFChars(serviceNameObj, serviceNameCStr);
|
|
||||||
|
|
||||||
// TODO(b/67981006): true /* retry */
|
// TODO(b/67981006): true /* retry */
|
||||||
sp<IBase> ret = getRawServiceInternal(ifaceName, serviceName, false /* retry */, false /* getStub */);
|
sp<IBase> ret = getRawServiceInternal(ifaceName, serviceName, false /* retry */, false /* getStub */);
|
||||||
@@ -340,7 +328,7 @@ static jobject JHwBinder_native_getService(
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG(INFO) << "Starting thread pool.";
|
LOG(INFO) << "HwBinder: Starting thread pool for " << serviceName << "::" << ifaceName;
|
||||||
::android::hardware::ProcessState::self()->startThreadPool();
|
::android::hardware::ProcessState::self()->startThreadPool();
|
||||||
|
|
||||||
return JHwRemoteBinder::NewObject(env, service);
|
return JHwRemoteBinder::NewObject(env, service);
|
||||||
|
|||||||
Reference in New Issue
Block a user