Skip to content

Commit 4d68325

Browse files
David Ngmracar07
authored andcommitted
init: Add vendor-specific initialization hooks.
Allow optional vendor-specific initializations within init. This can be used for runtime initialization setup that init rc scripts do not support. Change-Id: I7623a0d59b18f9ec8e3623958e2f7ccd72b877bf Signed-off-by: Josh Fox (XlxFoXxlX) <[email protected]> Signed-off-by: mracar07 <[email protected]>
1 parent c690ced commit 4d68325

File tree

5 files changed

+109
-0
lines changed

5 files changed

+109
-0
lines changed

init/Android.bp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ cc_library_static {
136136
"ueventd.cpp",
137137
"ueventd_parser.cpp",
138138
"util.cpp",
139+
"vendor_init.cpp",
139140
],
140141
whole_static_libs: ["libcap", "com.android.sysprop.apex"],
141142
header_libs: ["bootimg_headers"],
@@ -150,6 +151,14 @@ cc_library_static {
150151
exclude_shared_libs: ["libbinder", "libutils"],
151152
},
152153
},
154+
155+
product_variables: {
156+
rr: {
157+
target_init_vendor_lib: {
158+
whole_static_libs: ["%s"],
159+
},
160+
},
161+
},
153162
}
154163

155164
cc_binary {

init/NOTICE

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,3 +188,29 @@
188188

189189
END OF TERMS AND CONDITIONS
190190

191+
Copyright (c) 2013, The Linux Foundation. All rights reserved.
192+
193+
Redistribution and use in source and binary forms, with or without
194+
modification, are permitted provided that the following conditions are
195+
met:
196+
* Redistributions of source code must retain the above copyright
197+
notice, this list of conditions and the following disclaimer.
198+
* Redistributions in binary form must reproduce the above
199+
copyright notice, this list of conditions and the following
200+
disclaimer in the documentation and/or other materials provided
201+
with the distribution.
202+
* Neither the name of The Linux Foundation nor the names of its
203+
contributors may be used to endorse or promote products derived
204+
from this software without specific prior written permission.
205+
206+
THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
207+
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
208+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
209+
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
210+
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
211+
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
212+
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
213+
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
214+
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
215+
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
216+
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

init/property_service.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
#include "selinux.h"
6565
#include "subcontext.h"
6666
#include "util.h"
67+
#include "vendor_init.h"
6768

6869
using namespace std::literals;
6970

@@ -912,6 +913,9 @@ void property_load_boot_defaults(bool load_debug_prop) {
912913
}
913914
}
914915

916+
// Update with vendor-specific property runtime overrides
917+
vendor_load_properties();
918+
915919
property_initialize_ro_product_props();
916920
property_derive_build_fingerprint();
917921

init/vendor_init.cpp

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
Copyright (c) 2013, The Linux Foundation. All rights reserved.
3+
4+
Redistribution and use in source and binary forms, with or without
5+
modification, are permitted provided that the following conditions are
6+
met:
7+
* Redistributions of source code must retain the above copyright
8+
notice, this list of conditions and the following disclaimer.
9+
* Redistributions in binary form must reproduce the above
10+
copyright notice, this list of conditions and the following
11+
disclaimer in the documentation and/or other materials provided
12+
with the distribution.
13+
* Neither the name of The Linux Foundation nor the names of its
14+
contributors may be used to endorse or promote products derived
15+
from this software without specific prior written permission.
16+
17+
THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
18+
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
20+
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
21+
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22+
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23+
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
24+
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25+
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
26+
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
27+
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28+
*/
29+
30+
#include "vendor_init.h"
31+
32+
/* init vendor override stubs */
33+
34+
__attribute__ ((weak))
35+
void vendor_load_properties()
36+
{
37+
}

init/vendor_init.h

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
Copyright (c) 2013, The Linux Foundation. All rights reserved.
3+
4+
Redistribution and use in source and binary forms, with or without
5+
modification, are permitted provided that the following conditions are
6+
met:
7+
* Redistributions of source code must retain the above copyright
8+
notice, this list of conditions and the following disclaimer.
9+
* Redistributions in binary form must reproduce the above
10+
copyright notice, this list of conditions and the following
11+
disclaimer in the documentation and/or other materials provided
12+
with the distribution.
13+
* Neither the name of The Linux Foundation nor the names of its
14+
contributors may be used to endorse or promote products derived
15+
from this software without specific prior written permission.
16+
17+
THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
18+
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
20+
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
21+
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22+
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23+
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
24+
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25+
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
26+
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
27+
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28+
*/
29+
30+
#ifndef __INIT_VENDOR__H__
31+
#define __INIT_VENDOR__H__
32+
extern void vendor_load_properties(void);
33+
#endif /* __INIT_VENDOR__H__ */

0 commit comments

Comments
 (0)