Add boot.prop support.
This patch allows one to specify a custom list of boot properties that
will be injected into the guest system at boot time. The properties
must be placed in a file named 'boot.prop', which can appear in the
following locations:
For AVDs:
1) In the AVD's content directory.
2) Otherwise in the system image's directory.
For Android platform builds:
1) In the $ANDROID_BUILD_OUT directory.
Note that this is different from build.prop which will be read
from $ANDROID_BUILD_OUT/system/ instead (and isn't used to
inject any properties).
Note that any '-boot-property <name>=<value>' on the command-line will
be injected after the content of 'boot.prop', overriding it unless it
begins with a 'ro.' prefix.
The patch refactors a little how information is retrieved for builds
and AVD configurations. It also fixes a few bugs in the auto-detection
logic for the target architecture / ABI.
BUG=12819077
Change-Id: I9f41f21d9de3e4d25de427f0e5a6bb517f34c5ba
diff --git a/android/main.c b/android/main.c
index e0797d9..dc8bc83 100644
--- a/android/main.c
+++ b/android/main.c
@@ -41,6 +41,7 @@
#include "android/utils/filelock.h"
#include "android/utils/lineinput.h"
#include "android/utils/path.h"
+#include "android/utils/property_file.h"
#include "android/utils/tempfile.h"
#include "android/main-common.h"
@@ -991,7 +992,22 @@
args[n++] = "off";
}
- /* Pass boot properties to the core. */
+ /* Pass boot properties to the core. First, those from boot.prop,
+ * then those from the command-line */
+ const FileData* bootProperties = avdInfo_getBootProperties(avd);
+ if (!fileData_isEmpty(bootProperties)) {
+ PropertyFileIterator iter[1];
+ propertyFileIterator_init(iter,
+ bootProperties->data,
+ bootProperties->size);
+ while (propertyFileIterator_next(iter)) {
+ char temp[MAX_PROPERTY_NAME_LEN + MAX_PROPERTY_VALUE_LEN + 2];
+ snprintf(temp, sizeof temp, "%s=%s", iter->name, iter->value);
+ args[n++] = "-boot-property";
+ args[n++] = ASTRDUP(temp);
+ }
+ }
+
if (opts->prop != NULL) {
ParamList* pl = opts->prop;
for ( ; pl != NULL; pl = pl->next ) {