diff options
author | Casey Dahlin <sadmac@google.com> | 2016-01-07 16:13:57 -0800 |
---|---|---|
committer | Casey Dahlin <sadmac@google.com> | 2016-01-07 16:43:59 -0800 |
commit | fc465468a55047324dd5ecef9282ff41f3d8b542 (patch) | |
tree | a1fcaf4c75bdefb75e6471ad0f7a4fd16d844ccd /tests | |
parent | c13bf96817473143f17d9c6f7e7ca6b98d18b341 (diff) | |
download | android_system_tools_aidl-fc465468a55047324dd5ecef9282ff41f3d8b542.tar.gz android_system_tools_aidl-fc465468a55047324dd5ecef9282ff41f3d8b542.tar.bz2 android_system_tools_aidl-fc465468a55047324dd5ecef9282ff41f3d8b542.zip |
Move aidl_test_service Run function out of service class
This was discussed in relation to a previous CL. There was no reason for
this to be a method, and now it isn't.
Change-Id: I7fb975bdb74d6b94d6a1366209a8711b5fc98343
Test: Unit and integration tests pass
Bug: None
Diffstat (limited to 'tests')
-rw-r--r-- | tests/aidl_test_service.cpp | 62 |
1 files changed, 32 insertions, 30 deletions
diff --git a/tests/aidl_test_service.cpp b/tests/aidl_test_service.cpp index 8ae2a11..4cf4113 100644 --- a/tests/aidl_test_service.cpp +++ b/tests/aidl_test_service.cpp @@ -103,33 +103,6 @@ class NativeService : public BnTestService { NativeService() {} virtual ~NativeService() = default; - int Run(const android::sp<NativeService>& service) { - sp<Looper> looper(Looper::prepare(0 /* opts */)); - - int binder_fd = -1; - ProcessState::self()->setThreadPoolMaxThreadCount(0); - IPCThreadState::self()->disableBackgroundScheduling(true); - IPCThreadState::self()->setupPolling(&binder_fd); - ALOGI("Got binder FD %d", binder_fd); - if (binder_fd < 0) return -1; - - sp<BinderCallback> cb(new BinderCallback); - if (looper->addFd(binder_fd, Looper::POLL_CALLBACK, Looper::EVENT_INPUT, cb, - nullptr) != 1) { - ALOGE("Failed to add binder FD to Looper"); - return -1; - } - - defaultServiceManager()->addService(getInterfaceDescriptor(), service); - - ALOGI("Entering loop"); - while (true) { - const int result = looper->pollAll(-1 /* timeoutMillis */); - ALOGI("Looper returned %d", result); - } - return 0; - } - void LogRepeatedStringToken(const String16& token) { ALOGI("Repeating '%s' of length=%zu", android::String8(token).string(), token.size()); @@ -375,11 +348,40 @@ class NativeService : public BnTestService { }; } // namespace + +int Run() { + android::sp<android::generated::NativeService> service = + new android::generated::NativeService; + sp<Looper> looper(Looper::prepare(0 /* opts */)); + + int binder_fd = -1; + ProcessState::self()->setThreadPoolMaxThreadCount(0); + IPCThreadState::self()->disableBackgroundScheduling(true); + IPCThreadState::self()->setupPolling(&binder_fd); + ALOGI("Got binder FD %d", binder_fd); + if (binder_fd < 0) return -1; + + sp<BinderCallback> cb(new BinderCallback); + if (looper->addFd(binder_fd, Looper::POLL_CALLBACK, Looper::EVENT_INPUT, cb, + nullptr) != 1) { + ALOGE("Failed to add binder FD to Looper"); + return -1; + } + + defaultServiceManager()->addService(service->getInterfaceDescriptor(), + service); + + ALOGI("Entering loop"); + while (true) { + const int result = looper->pollAll(-1 /* timeoutMillis */); + ALOGI("Looper returned %d", result); + } + return 0; +} + } // namespace generated } // namespace android int main(int /* argc */, char* /* argv */ []) { - android::sp<android::generated::NativeService> service = - new android::generated::NativeService; - return service->Run(service); + return android::generated::Run(); } |