Add boot_complete trigger back

Samsung does not like running cmd before system services are started.
Instead of failing, it will enter an infinite wait on binder.
Move APK installation to boot complete to make sure pm can be run
without blocking process.
This commit is contained in:
topjohnwu
2019-04-05 07:00:30 -04:00
parent 5203886f0b
commit 24f5bc98d8
5 changed files with 40 additions and 51 deletions

View File

@@ -49,20 +49,16 @@ int fork_no_zombie() {
return 0;
}
static bool rand_init = false;
void gen_rand_str(char *buf, int len) {
const char base[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
int urandom;
if (access("/dev/urandom", R_OK) == 0) {
urandom = xopen("/dev/urandom", O_RDONLY | O_CLOEXEC);
} else {
mknod("/urandom", S_IFCHR | 0666, makedev(1, 9));
urandom = xopen("/urandom", O_RDONLY | O_CLOEXEC);
unlink("/urandom");
constexpr const char base[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
if (!rand_init) {
srand(time(nullptr));
rand_init = true;
}
xxread(urandom, buf, len - 1);
close(urandom);
for (int i = 0; i < len - 1; ++i) {
buf[i] = base[buf[i] % (sizeof(base) - 1)];
buf[i] = base[rand() % (sizeof(base) - 1)];
}
buf[len - 1] = '\0';
}