Keep MT6351 VA18 enabled in MD1 deep flight / Airplane Mode
This commit is contained in:
1 parent
30348132fa
commit
21485612fb
7 files changed
+42
-4
No files matched your search
@@ -79,6 +79,25 @@ static void maybe_advance_ccci_stage(ccci_ctx_t *ctx) {
|
||||
(void)advance_ccci_stage(3);
|
||||
}
|
||||
|
||||
static bool load_persisted_airplane(void) {
|
||||
FILE *rf = fopen("/run/geminux/airplane-mode", "r");
|
||||
if (rf) {
|
||||
char buf[32] = {0};
|
||||
size_t n = fread(buf, 1, sizeof(buf) - 1, rf);
|
||||
fclose(rf);
|
||||
if (n > 0) return buf[0] == '1';
|
||||
}
|
||||
FILE *vf = fopen("/var/lib/geminux/airplane-mode", "r");
|
||||
if (vf) {
|
||||
char buf[160] = {0};
|
||||
size_t n = fread(buf, 1, sizeof(buf) - 1, vf);
|
||||
fclose(vf);
|
||||
buf[n] = '\0';
|
||||
return strstr(buf, "airplane=1") != NULL;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static void open_ccci_devs(ccci_ctx_t *ctx) {
|
||||
if (ctx->fs_fd < 0) {
|
||||
ctx->fs_fd = open("/dev/ccci_fs", O_RDWR | O_NONBLOCK | O_CLOEXEC);
|
||||
@@ -90,7 +109,11 @@ static void open_ccci_devs(ccci_ctx_t *ctx) {
|
||||
ctx->ctl_fd = open("/dev/ccci_md_ctl", O_RDWR | O_NONBLOCK | O_CLOEXEC);
|
||||
if (ctx->ctl_fd >= 0) {
|
||||
add_ep(ctx->epfd, ctx->ctl_fd);
|
||||
maybe_advance_ccci_stage(ctx);
|
||||
if (ctx->sm.flight_mode) {
|
||||
ioctl(ctx->ctl_fd, CCCI_IOC_ENTER_DEEP_FLIGHT);
|
||||
} else {
|
||||
maybe_advance_ccci_stage(ctx);
|
||||
}
|
||||
refresh_md_state(ctx);
|
||||
}
|
||||
}
|
||||
@@ -195,6 +218,7 @@ int main(void) {
|
||||
memset(&ctx, 0, sizeof(ctx));
|
||||
ctx.ctl_fd = ctx.fs_fd = -1;
|
||||
geminux_ccci_sm_init(&ctx.sm);
|
||||
ctx.sm.flight_mode = load_persisted_airplane();
|
||||
geminux_ccci_fs_init(&ctx.fs, NULL, CCCI_LOG);
|
||||
|
||||
mkdir("/run/geminux", 0755);
|
||||
|
||||
Reference in new issue
Block a user