• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/platform/linux/preloaded_nanoapps.h"
18 
19 #include "chre/core/event_loop_manager.h"
20 #include "chre/platform/fatal_error.h"
21 #include "chre/util/macros.h"
22 #include "chre/util/unique_ptr.h"
23 
24 namespace chre {
25 
loadPreloadedNanoapps()26 void loadPreloadedNanoapps() {
27   struct PreloadedNanoappDescriptor {
28     const char *filename;
29     UniquePtr<Nanoapp> nanoapp;
30   };
31 
32   // The list of nanoapps to be loaded from the filesystem of the device.
33   // TODO: allow these to be overridden by target-specific build configuration
34   static PreloadedNanoappDescriptor preloadedNanoapps[] = {
35     { "activity.so", MakeUnique<Nanoapp>() },
36   };
37 
38   EventLoop& eventLoop = EventLoopManagerSingleton::get()->getEventLoop();
39   for (size_t i = 0; i < ARRAY_SIZE(preloadedNanoapps); i++) {
40     if (preloadedNanoapps[i].nanoapp.isNull()) {
41       FATAL_ERROR("Couldn't allocate memory for preloaded nanoapp");
42     } else {
43       preloadedNanoapps[i].nanoapp->loadFromFile(preloadedNanoapps[i].filename);
44       eventLoop.startNanoapp(preloadedNanoapps[i].nanoapp);
45     }
46   }
47 }
48 
49 }  // namespace chre
50