2 * Copyright (C) 2016 Simon Fels <morphis@gravedo.de>
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3, as published
6 * by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranties of
10 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11 * PURPOSE. See the GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program. If not, see <http://www.gnu.org/licenses/>.
18 #include "android/service/daemon.h"
19 #include "android/service/host_connector.h"
20 #include "android/service/platform_service.h"
22 #include "core/posix/signal.h"
28 #include <binder/IPCThreadState.h>
29 #include <binder/ProcessState.h>
30 #include <binder/IServiceManager.h>
40 auto trap = core::posix::trap_signals_for_process({core::posix::Signal::sig_term,
41 core::posix::Signal::sig_int});
42 trap->signal_raised().connect([trap](const core::posix::Signal&) {
46 auto host_connector = std::make_shared<HostConnector>();
47 host_connector->start();
49 android::defaultServiceManager()->addService(
50 android::String16(android::PlatformService::service_name()),
51 new android::PlatformService(host_connector->platform_api_stub()));
53 android::ProcessState::self()->startThreadPool();
57 android::IPCThreadState::self()->joinThreadPool();