init.cc revision 432a24e4167d9114e9c64cb094bdd32d5d2ba52c
1/*
2 * Copyright (C) 2017 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include "chre/core/event_loop_manager.h"
18#include "chre/core/init.h"
19#include "chre/core/static_nanoapps.h"
20#include "chre/platform/shared/platform_log.h"
21
22#include <csignal>
23#include <thread>
24
25using chre::EventLoopManagerSingleton;
26
27namespace {
28
29extern "C" void signalHandler(int sig) {
30  (void) sig;
31  LOGI("Stop request received");
32  EventLoopManagerSingleton::get()->getEventLoop().stop();
33}
34
35}
36
37int main(int argc, char **argv) {
38  // Initilize the system.
39  chre::init();
40
41  // Register a signal handler and start CHRE.
42  std::signal(SIGINT, signalHandler);
43  chre::loadStaticNanoapps();
44  EventLoopManagerSingleton::get()->getEventLoop().run();
45
46  chre::deinit();
47  return 0;
48}
49