Merge "Update for hidlized hwservicemanager."

This commit is contained in:
Treehugger Robot
2016-11-02 22:17:24 +00:00
committed by Gerrit Code Review
2 changed files with 29 additions and 18 deletions

View File

@@ -24,8 +24,9 @@
#include "android_os_HwRemoteBinder.h"
#include <JNIHelp.h>
#include <android/hidl/manager/1.0/IServiceManager.h>
#include <android_runtime/AndroidRuntime.h>
#include <hidl/IServiceManager.h>
#include <hidl/ServiceManagement.h>
#include <hidl/Status.h>
#include <hwbinder/ProcessState.h>
#include <nativehelper/ScopedLocalRef.h>
@@ -220,27 +221,31 @@ static void JHwBinder_native_registerService(
return; // XXX exception already pending?
}
const hardware::hidl_version kVersion =
hardware::make_hidl_version(versionMajor, versionMinor);
using android::hidl::manager::V1_0::IServiceManager;
const IServiceManager::Version kVersion {
.major = static_cast<uint16_t>(versionMajor),
.minor = static_cast<uint16_t>(versionMinor),
};
sp<hardware::IBinder> binder = JHwBinder::GetNativeContext(env, thiz);
status_t err = hardware::defaultServiceManager()->addService(
String16(
reinterpret_cast<const char16_t *>(serviceName),
env->GetStringLength(serviceNameObj)),
bool ok = hardware::defaultServiceManager()->add(
String8(String16(
reinterpret_cast<const char16_t *>(serviceName),
env->GetStringLength(serviceNameObj))).string(),
binder,
kVersion);
env->ReleaseStringCritical(serviceNameObj, serviceName);
serviceName = NULL;
if (err == OK) {
if (ok) {
LOG(INFO) << "Starting thread pool.";
::android::hardware::ProcessState::self()->startThreadPool();
}
signalExceptionForError(env, err);
signalExceptionForError(env, (ok ? OK : UNKNOWN_ERROR));
}
static jobject JHwBinder_native_getService(
@@ -268,8 +273,12 @@ static jobject JHwBinder_native_getService(
return NULL; // XXX exception already pending?
}
const hardware::hidl_version kVersion =
hardware::make_hidl_version(versionMajor, versionMinor);
using android::hidl::manager::V1_0::IServiceManager;
const IServiceManager::Version kVersion {
.major = static_cast<uint16_t>(versionMajor),
.minor = static_cast<uint16_t>(versionMinor),
};
LOG(INFO) << "looking for service '"
<< String8(String16(
@@ -277,12 +286,15 @@ static jobject JHwBinder_native_getService(
env->GetStringLength(serviceNameObj))).string()
<< "'";
sp<hardware::IBinder> service =
hardware::defaultServiceManager()->getService(
String16(
reinterpret_cast<const char16_t *>(serviceName),
env->GetStringLength(serviceNameObj)),
kVersion);
sp<hardware::IBinder> service;
hardware::defaultServiceManager()->get(
String8(String16(
reinterpret_cast<const char16_t *>(serviceName),
env->GetStringLength(serviceNameObj))).string(),
kVersion,
[&service](sp<hardware::IBinder> out) {
service = out;
});
env->ReleaseStringCritical(serviceNameObj, serviceName);
serviceName = NULL;

View File

@@ -24,7 +24,6 @@
#include <JNIHelp.h>
#include <android_runtime/AndroidRuntime.h>
#include <hidl/IServiceManager.h>
#include <hidl/Status.h>
#include <nativehelper/ScopedLocalRef.h>