Merge "Add configureRpcThreadpool to java interface"

am: d8dab11547

Change-Id: I958ef6fc2d667a691e39e9fadd07303085a499f9
This commit is contained in:
Timur Iskhakov
2017-07-13 19:21:42 +00:00
committed by android-build-merger
2 changed files with 22 additions and 0 deletions

View File

@@ -51,6 +51,11 @@ public abstract class HwBinder implements IHwBinder {
String serviceName)
throws RemoteException, NoSuchElementException;
public static native final void configureRpcThreadpool(
long maxThreads, boolean callerWillJoin);
public static native final void joinRpcThreadpool();
// Returns address of the "freeFunction".
private static native final long native_init();

View File

@@ -42,6 +42,8 @@
using android::AndroidRuntime;
using android::hardware::hidl_vec;
using android::hardware::hidl_string;
using android::hardware::IPCThreadState;
using android::hardware::ProcessState;
template<typename T>
using Return = android::hardware::Return<T>;
@@ -395,6 +397,15 @@ static jobject JHwBinder_native_getService(
return JHwRemoteBinder::NewObject(env, service);
}
void JHwBinder_native_configureRpcThreadpool(jlong maxThreads, jboolean callerWillJoin) {
CHECK(maxThreads > 0);
ProcessState::self()->setThreadPoolConfiguration(maxThreads, callerWillJoin /*callerJoinsPool*/);
}
void JHwBinder_native_joinRpcThreadpool() {
IPCThreadState::self()->joinThreadPool();
}
static JNINativeMethod gMethods[] = {
{ "native_init", "()J", (void *)JHwBinder_native_init },
{ "native_setup", "()V", (void *)JHwBinder_native_setup },
@@ -408,6 +419,12 @@ static JNINativeMethod gMethods[] = {
{ "getService", "(Ljava/lang/String;Ljava/lang/String;)L" PACKAGE_PATH "/IHwBinder;",
(void *)JHwBinder_native_getService },
{ "configureRpcThreadpool", "(JZ)V",
(void *)JHwBinder_native_configureRpcThreadpool },
{ "joinRpcThreadpool", "()V",
(void *)JHwBinder_native_joinRpcThreadpool },
};
namespace android {