static int print_setting_json(char *buf, struct setting_data *setting) { int ret=0; if (!buf) { ERROR("Received NULL buffer\n"); return -1; } /* Make sure there are at lease 128 bytes left in buffer */ if (strlen(buf) >= PAGE_BUFFER_SIZE - 128) { ERROR("Buffer running out of room\n"); return -1; } strcat(buf, " {\n"); sprintf(&buf[strlen(buf)], " \"type\":\"%s\",\n", str_type(setting->type)); sprintf(&buf[strlen(buf)], " \"mode\":\"%s\",\n", str_mode(setting->mode)); sprintf(&buf[strlen(buf)], " \"setpoint\":%.1f,\n", TEMP_C(setting->setpoint)); sprintf(&buf[strlen(buf)], " \"comp_time\":%d,\n", setting->min_compressor_time); sprintf(&buf[strlen(buf)], " \"range\":%.1f\n", TEMP_C(setting->range)); strcat(buf, " }"); return ret; }
/** * run_bootmenu() * */ static int run_bootmenu(void) { int defmode, mode, status = BUTTON_ERROR; int adb_started = 0; time_t start = time(NULL); LOGI("Starting bootmenu on %s", ctime(&start)); if (bypass_check()) { // init rootfs and mount cache exec_script(FILE_PRE_MENU, DISABLE); led_alert("blue", ENABLE); defmode = get_default_bootmode(); // get and clean one shot bootmode (or default) mode = get_bootmode(1,1); if (mode == int_mode("bootmenu") || mode == int_mode("recovery") || mode == int_mode("shell")) { // dont wait if these modes are asked } else { status = (wait_key(KEY_VOLUMEDOWN) ? BUTTON_PRESSED : BUTTON_TIMEOUT); } // only start adb if usb is connected if (usb_connected()) { if (mode == int_mode("2nd-init-adb") || mode == int_mode("2nd-boot-adb") || mode == int_mode("2nd-system-adb")) { exec_script(FILE_ADBD, DISABLE); adb_started = 1; } } // on timeout if (status != BUTTON_PRESSED) { if (mode == int_mode("bootmenu")) { led_alert("blue", DISABLE); status = BUTTON_PRESSED; } else if (mode == int_mode("2nd-init") || mode == int_mode("2nd-init-adb")) { led_alert("blue", DISABLE); led_alert("green", ENABLE); snd_init(DISABLE); led_alert("green", DISABLE); status = BUTTON_TIMEOUT; } else if (mode == int_mode("2nd-boot") || mode == int_mode("2nd-boot-adb")) { led_alert("blue", DISABLE); led_alert("red", ENABLE); snd_boot(DISABLE); led_alert("red", DISABLE); status = BUTTON_TIMEOUT; } else if (mode == int_mode("2nd-system") || mode == int_mode("2nd-system-adb")) { led_alert("blue", DISABLE); led_alert("red", ENABLE); led_alert("green", ENABLE); snd_system(DISABLE); led_alert("red", DISABLE); led_alert("green", DISABLE); status = BUTTON_TIMEOUT; } else if (mode == int_mode("recovery-dev")) { led_alert("blue", DISABLE); exec_script(FILE_CUSTOMRECOVERY, DISABLE); status = BUTTON_TIMEOUT; } else if (mode == int_mode("recovery")) { led_alert("blue", DISABLE); exec_script(FILE_STABLERECOVERY, DISABLE); status = BUTTON_TIMEOUT; } else if (mode == int_mode("shell")) { led_alert("blue", DISABLE); exec_script(FILE_ADBD, DISABLE); status = BUTTON_PRESSED; } else if (mode == int_mode("normal") || mode == int_mode("normal-adb")) { led_alert("blue", DISABLE); stk_boot(DISABLE); status = BUTTON_TIMEOUT; } } if (status == BUTTON_PRESSED ) { ui_init(); ui_set_background(BACKGROUND_DEFAULT); ui_show_text(ENABLE); led_alert("button-backlight", ENABLE); LOGI("Start Android BootMenu....\n"); main_headers = prepend_title((const char**)MENU_HEADERS); /* can be buggy, adb could lock filesystem if (!adb_started && usb_connected()) { ui_print("Usb connected, starting adb...\n\n"); exec_script(FILE_ADBD, DISABLE); } */ ui_print("Default mode: %s\n", str_mode(defmode)); if (mode == int_mode("shell")) { ui_print("\n"); ui_print("Current mode: %s\n", str_mode(mode)); if (!usb_connected()) { ui_print(" But USB is not connected !\n"); } } checkup_report(); ui_reset_progress(); prompt_and_wait(); free_menu_headers(main_headers); ui_finish(); } } return EXIT_SUCCESS; }