diff options
author | bohu <bohu@google.com> | 2018-06-07 12:48:03 -0700 |
---|---|---|
committer | bohu <bohu@google.com> | 2018-06-07 15:39:07 -0700 |
commit | 317e1620eaf0fa4d64b9ac90a4bc5dfb4c0ae22b (patch) | |
tree | 1b98227abd1566c3ebfee3d5bb8f6620676b8f1a | |
parent | aa95367f9f97df374dbd2c174459c24d92e210e1 (diff) | |
download | device_generic_goldfish-317e1620eaf0fa4d64b9ac90a4bc5dfb4c0ae22b.tar.gz device_generic_goldfish-317e1620eaf0fa4d64b9ac90a4bc5dfb4c0ae22b.tar.bz2 device_generic_goldfish-317e1620eaf0fa4d64b9ac90a4bc5dfb4c0ae22b.zip |
goldfish: fix selinux denials from qemu-propspie-dev
This cl fixes qemu-props to work around the limitation brought
upon by PRODUCT_COMPATIBLE_PROPERTY_OVERRIDE := true, since many
system properties (such as bootcomplete) cannot be read/set anmore
Some properties are there for historical reason and they are kept
unchanged.
BUG: 109872686
this cl only impact emulator images
Change-Id: I8b5e43dbcf840966cb6d90ccaeae5ec50adbb5af
-rw-r--r-- | init.ranchu.rc | 12 | ||||
-rw-r--r-- | qemu-props/qemu-props.c | 32 |
2 files changed, 29 insertions, 15 deletions
diff --git a/init.ranchu.rc b/init.ranchu.rc index e654dc6d..2193c58a 100644 --- a/init.ranchu.rc +++ b/init.ranchu.rc @@ -27,6 +27,8 @@ on boot setprop wifi.interface wlan0 + start goldfish-logcat + service ranchu-setup /vendor/bin/init.ranchu-core.sh class core @@ -34,12 +36,15 @@ service ranchu-setup /vendor/bin/init.ranchu-core.sh group root oneshot -on property:qemu.timezone=* - setprop persist.sys.timezone ${qemu.timezone} +on property:vendor.qemu.timezone=* + setprop persist.sys.timezone ${vendor.qemu.timezone} on property:vendor.qemu.android.bootanim=0 setprop debug.sf.nobootanimation 1 +on property:dev.bootcomplete=1 + setprop vendor.qemu.dev.bootcomplete 1 + service ranchu-net /vendor/bin/init.ranchu-net.sh class late_start user root @@ -83,9 +88,6 @@ service qemu-props /vendor/bin/qemu-props group root oneshot -on property:qemu.logcat=start - start goldfish-logcat - # -Q is a special logcat option that forces the # program to check wether it runs on the emulator # if it does, it redirects its output to the device diff --git a/qemu-props/qemu-props.c b/qemu-props/qemu-props.c index e54c2d57..e1b8ae7d 100644 --- a/qemu-props/qemu-props.c +++ b/qemu-props/qemu-props.c @@ -27,7 +27,7 @@ #define DEBUG 1 #if DEBUG -# include <cutils/log.h> +# include <log/log.h> # define DD(...) ALOGI(__VA_ARGS__) #else # define DD(...) ((void)0) @@ -88,6 +88,7 @@ int main(void) DD("receiving.."); char* q; char temp[BUFF_SIZE]; + char vendortemp[BUFF_SIZE]; int len = qemud_channel_recv(qemud_fd, temp, sizeof temp - 1); /* lone NUL-byte signals end of properties */ @@ -106,9 +107,25 @@ int main(void) } *q++ = '\0'; + char* final_prop_name = NULL; + if (strcmp(temp, "qemu.sf.lcd.density") == 0 ) { + final_prop_name = temp; + } else if (strcmp(temp, "qemu.hw.mainkeys") == 0 ) { + final_prop_name = temp; + } else if (strcmp(temp, "qemu.cmdline") == 0 ) { + final_prop_name = temp; + } else if (strcmp(temp, "dalvik.vm.heapsize") == 0 ) { + continue; /* cannot set it here */ + } else if (strcmp(temp, "ro.opengles.version") == 0 ) { + continue; /* cannot set it here */ + } else { + snprintf(vendortemp, sizeof(vendortemp), "vendor.%s", temp); + final_prop_name = vendortemp; + } if (property_set(temp, q) < 0) { - DD("could not set property '%s' to '%s'", temp, q); + ALOGW("could not set property '%s' to '%s'", final_prop_name, q); } else { + ALOGI("successfully set property '%s' to '%s'", final_prop_name, q); count += 1; } } @@ -116,20 +133,15 @@ int main(void) char temp[BUFF_SIZE]; for (;;) { usleep(5000000); /* 5 seconds */ - property_get("sys.boot_completed", temp, ""); + property_get("vendor.qemu.dev.bootcomplete", temp, ""); int is_boot_completed = (strncmp(temp, "1", 1) == 0) ? 1 : 0; if (is_boot_completed) { + ALOGI("tell the host boot completed"); notifyHostBootComplete(); break; } } - /* HACK start adbd periodically every minute, if adbd is already running, this is a no-op */ - for(;;) { - usleep(60000000); /* 1 minute */ - property_set("qemu.adbd", "start"); - } - /* finally, close the channel and exit */ if (s_QemuMiscPipe >= 0) { close(s_QemuMiscPipe); @@ -153,7 +165,7 @@ void notifyHostBootComplete() { WriteFully(s_QemuMiscPipe, &pipe_command_length, sizeof(pipe_command_length)); WriteFully(s_QemuMiscPipe, set, pipe_command_length); ReadFully(s_QemuMiscPipe, &pipe_command_length, sizeof(pipe_command_length)); - if (pipe_command_length > sizeof(set) || pipe_command_length <= 0) + if (pipe_command_length > (int)(sizeof(set)) || pipe_command_length <= 0) return; ReadFully(s_QemuMiscPipe, set, pipe_command_length); } |