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 #ifndef CHRE_CORE_INIT_H_
18 #define CHRE_CORE_INIT_H_
19 
20 namespace chre {
21 
22 /**
23  * Performs initialization of CHRE. The CHRE is designed to be portable and as
24  * such the order of initialization must be as follows:
25  *
26  * 1) [optional] Perform platform initialization if needed.
27  * 2) [required] Perform CHRE initialization by invoking this function. All
28  *               platforms must invoke chre::init() prior to loading apps.
29  *
30  * When step 2) is performed, the platform must be ready for any and all
31  * platform-specific code to be invoked as part of CHRE initialization. (as an
32  * example for the Linux platform, any functions provided by the platform/linux
33  * directory must be available). If any platform specific initialization is
34  * required, it must be performed in step 1).
35  */
36 void init();
37 
38 /**
39  * Performs deinitialization of CHRE. The order of deinitialization must be as
40  * follows:
41  *
42  * 1) [required] Perform CHRE deinitialization by invoking this function. All
43  *               platforms must invoke chre::deinit() after unloading all apps
44  *               and upon termination.
45  * 2) [optional] Perform any additional teardown as required by the platform but
46  *               not covered by common deinitialization logic.
47  *
48  * After step 1 is complete, chre common code has been deinitialized and calling
49  * into it is undefined behavior. Portions of the platform (ie: sensors) are
50  * also deinitialized by step 1. Only perform additional deinitialization after
51  * this function as not handled by common CHRE code. The goal is to minimize
52  * this additional teardown as much as possible.
53  */
54 void deinit();
55 
56 }  // namespace chre
57 
58 #endif  // CHRE_CORE_INIT_H_
59