mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-12-25 01:27:38 +00:00
parent
44643ad7b3
commit
cf9957ce4d
@ -214,7 +214,11 @@ vector<string_view> split_ro(string_view s, string_view delims) {
|
|||||||
|
|
||||||
#undef vsnprintf
|
#undef vsnprintf
|
||||||
int vssprintf(char *dest, size_t size, const char *fmt, va_list ap) {
|
int vssprintf(char *dest, size_t size, const char *fmt, va_list ap) {
|
||||||
return std::min(vsnprintf(dest, size, fmt, ap), (int) size - 1);
|
if (size > 0) {
|
||||||
|
*dest = 0;
|
||||||
|
return std::min(vsnprintf(dest, size, fmt, ap), (int) size - 1);
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ssprintf(char *dest, size_t size, const char *fmt, ...) {
|
int ssprintf(char *dest, size_t size, const char *fmt, ...) {
|
||||||
|
@ -126,7 +126,7 @@ static bool magisk_env() {
|
|||||||
string pkg;
|
string pkg;
|
||||||
get_manager(0, &pkg);
|
get_manager(0, &pkg);
|
||||||
|
|
||||||
sprintf(buf, "%s/0/%s/install", APP_DATA_DIR,
|
ssprintf(buf, sizeof(buf), "%s/0/%s/install", APP_DATA_DIR,
|
||||||
pkg.empty() ? "xxx" /* Ensure non-exist path */ : pkg.data());
|
pkg.empty() ? "xxx" /* Ensure non-exist path */ : pkg.data());
|
||||||
|
|
||||||
// Alternative binaries paths
|
// Alternative binaries paths
|
||||||
|
@ -41,10 +41,6 @@ static void rescan_apps() {
|
|||||||
|
|
||||||
app_id_to_pkgs.clear();
|
app_id_to_pkgs.clear();
|
||||||
|
|
||||||
struct stat st{};
|
|
||||||
if (xstat("/data/data/com.android.systemui", &st) == 0)
|
|
||||||
sys_ui_app_id = to_app_id(st.st_uid);
|
|
||||||
|
|
||||||
auto data_dir = xopen_dir(APP_DATA_DIR);
|
auto data_dir = xopen_dir(APP_DATA_DIR);
|
||||||
if (!data_dir)
|
if (!data_dir)
|
||||||
return;
|
return;
|
||||||
@ -54,6 +50,7 @@ static void rescan_apps() {
|
|||||||
int dfd = xopenat(dirfd(data_dir.get()), entry->d_name, O_RDONLY);
|
int dfd = xopenat(dirfd(data_dir.get()), entry->d_name, O_RDONLY);
|
||||||
if (auto dir = xopen_dir(dfd)) {
|
if (auto dir = xopen_dir(dfd)) {
|
||||||
while ((entry = xreaddir(dir.get()))) {
|
while ((entry = xreaddir(dir.get()))) {
|
||||||
|
struct stat st{};
|
||||||
// For each package
|
// For each package
|
||||||
if (xfstatat(dfd, entry->d_name, &st, 0))
|
if (xfstatat(dfd, entry->d_name, &st, 0))
|
||||||
continue;
|
continue;
|
||||||
@ -61,6 +58,8 @@ static void rescan_apps() {
|
|||||||
if (auto it = pkg_to_procs.find(entry->d_name); it != pkg_to_procs.end()) {
|
if (auto it = pkg_to_procs.find(entry->d_name); it != pkg_to_procs.end()) {
|
||||||
app_id_to_pkgs[app_id].insert(it->first);
|
app_id_to_pkgs[app_id].insert(it->first);
|
||||||
}
|
}
|
||||||
|
if (entry->d_name == "com.android.systemui"sv)
|
||||||
|
sys_ui_app_id = app_id;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
close(dfd);
|
close(dfd);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user