diff --git a/init/Android.bp b/init/Android.bp index 22c6a5a..7b1c818 100644 --- a/init/Android.bp +++ b/init/Android.bp @@ -26,6 +26,9 @@ cc_library_static { ], export_include_dirs: [ "include" + ], + shared_libs: [ + "libbase", ] } diff --git a/init/include/init_common.h b/init/include/init_common.h index f5602ce..0b2fdb3 100644 --- a/init/include/init_common.h +++ b/init/include/init_common.h @@ -2,5 +2,6 @@ #define __INIT_COMMON__H__ void load_common_properties(); +void property_override(char const prop[], char const value[], bool add = true); #endif diff --git a/init/init_common.cpp b/init/init_common.cpp index e7a0fc7..0b2fd62 100644 --- a/init/init_common.cpp +++ b/init/init_common.cpp @@ -23,7 +23,16 @@ #include "init_common.h" #include "property_service.h" -using android::init::property_set; +void property_override(char const prop[], char const value[], bool add) +{ + auto pi = (prop_info *) __system_property_find(prop); + + if (pi != nullptr) { + __system_property_update(pi, value, strlen(value)); + } else if (add) { + __system_property_add(prop, strlen(prop), value, strlen(value)); + } +} void load_dalvik_properties() { char const *heapstartsize; @@ -56,12 +65,12 @@ void load_dalvik_properties() { return; } - property_set("dalvik.vm.heapstartsize", heapstartsize); - property_set("dalvik.vm.heapgrowthlimit", heapgrowthlimit); - property_set("dalvik.vm.heapsize", heapsize); - property_set("dalvik.vm.heaptargetutilization", heaptargetutilization); - property_set("dalvik.vm.heapminfree", heapminfree); - property_set("dalvik.vm.heapmaxfree", heapmaxfree); + property_override("dalvik.vm.heapstartsize", heapstartsize); + property_override("dalvik.vm.heapgrowthlimit", heapgrowthlimit); + property_override("dalvik.vm.heapsize", heapsize); + property_override("dalvik.vm.heaptargetutilization", heaptargetutilization); + property_override("dalvik.vm.heapminfree", heapminfree); + property_override("dalvik.vm.heapmaxfree", heapmaxfree); } void load_common_properties() {