I'm using the official Android Emulator. When I run this I get:
adb shell getprop | grep hardware
I get
[ro.boot.hardware]: [goldfish]
[ro.hardware]: [goldfish]
[ro.kernel.androidboot.hardware]: [goldfish]
I want to rename goldfish to any other word.
I can run the emulator in debug mode emulator -avd test -show-kernel -verbose
to see kernel parameters:
kernel.path = /home/artyom/android-sdk-linux/system-images/android-19/default/armeabi-v7a//kernel-qemu
kernel.parameters = androidboot.hardware=goldfish android.checkjni=1
kernel.newDeviceNaming = no
kernel.supportsYaffs2 = yes
So, Android Emulator passes androidboot.hardware=goldfish
to the QEMU.
Let's dive into Android source.
In /system/core/init/util.c we can see that passing hardware via kernel command line makes it unchangeable.
void get_hardware_name(char *hardware, unsigned int *revision)
{
const char *cpuinfo = "/proc/cpuinfo";
char *data = NULL;
size_t len = 0, limit = 1024;
int fd, n;
char *x, *hw, *rev;
/* Hardware string was provided on kernel command line */
if (hardware[0])
return;
According to the eLinux wiki, hardware name used to init file init.machine_name.rc, so renaming goldfish to any other name must be combined with renaming init.goldfish.rc to init.anyname.rc.
So my question is, how can I force a different hardware name? How I can different androidboot.hardware value to the qemu? What files, other than init.goldfish.rc should I change? Different hardware name must be forced while compiling?
I've tried adding this to the .config file:
CONFIG_CMDLINE="androidboot.hardware=randomname android.checkjni=1"
CONFIG_CMDLINE_EXTRA=y
CONFIG_CMDLINE_FORCE=y
It didn't help.
Related question: android boot - where is the init.%hardware%.rc read in init.c ? where are services started?
Additional info: Initialize Goldfish hardware