throne_tracker: Fix Manager sometimes not detecting KSU and optimize it (#1586)

The original logic was wrong and used 3 strlen()s for every file found,
wasting cpu.

Optimize it by first comparing only the filename length, given we
already know it,
and then strncmp() to compare with "base.apk"

Tested successfully on my Bandido Kernel (4.19)
This commit is contained in:
Heiler Bemerguy
2024-04-03 03:33:10 -03:00
committed by GitHub
parent a34090bc57
commit 4f9bbf199b

View File

@@ -159,8 +159,7 @@ FILLDIR_RETURN_TYPE my_actor(struct dir_context *ctx, const char *name,
iterate_dir(file, &sub_ctx.ctx); iterate_dir(file, &sub_ctx.ctx);
filp_close(file, NULL); filp_close(file, NULL);
} else { } else {
if ((strlen(name) == strlen("base.apk")) && if ((namelen == 8) && (strncmp(name, "base.apk", namelen) == 0)) {
(strncmp(name, "base.apk", strlen("base.apk")) == 0)) {
bool is_manager = is_manager_apk(dirpath); bool is_manager = is_manager_apk(dirpath);
pr_info("Found base.apk at path: %s, is_manager: %d\n", pr_info("Found base.apk at path: %s, is_manager: %d\n",
dirpath, is_manager); dirpath, is_manager);