1 /* 2 * Copyright (C) 2016 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.h" 18 #include "chre/core/event_loop.h" 19 #include "chre/core/event_loop_manager.h" 20 #include "chre/core/init.h" 21 #include "chre/core/nanoapp.h" 22 #include "chre/platform/context.h" 23 #include "chre/platform/log.h" 24 #include "chre/platform/static_nanoapps.h" 25 #include "chre/platform/system_timer.h" 26 #include "chre/util/time.h" 27 28 #include <csignal> 29 30 using chre::Milliseconds; 31 32 namespace { 33 signalHandler(int sig)34extern "C" void signalHandler(int sig) { 35 (void) sig; 36 LOGI("Stop request received"); 37 chre::getCurrentEventLoop()->stop(); 38 } 39 40 } 41 main()42int main() { 43 chre::init(); 44 45 // Construct the event loop and register the signal handler. 46 chre::EventLoop& eventLoop = *chre::getCurrentEventLoop(); 47 std::signal(SIGINT, signalHandler); 48 49 // Load any static nanoapps and start the event loop. 50 chre::loadStaticNanoapps(&eventLoop); 51 eventLoop.run(); 52 53 chre::deinit(); 54 return 0; 55 } 56