mirror of
https://github.com/CTCaer/hekate.git
synced 2024-11-20 05:11:42 +00:00
nyx: part manager: rename twrp to recovery
And add support for both twrp.img and recovery.img.
This commit is contained in:
parent
6337b06212
commit
5cdee01c05
@ -836,9 +836,10 @@ static lv_res_t _action_check_flash_linux(lv_obj_t *btn)
|
|||||||
if (f_stat(path, &fno))
|
if (f_stat(path, &fno))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
// Check if current part is unaligned.
|
||||||
if ((u64)fno.fsize % SZ_4M)
|
if ((u64)fno.fsize % SZ_4M)
|
||||||
{
|
{
|
||||||
// Check if last part.
|
// Get next part filename.
|
||||||
idx++;
|
idx++;
|
||||||
if (idx < 10)
|
if (idx < 10)
|
||||||
{
|
{
|
||||||
@ -848,7 +849,7 @@ static lv_res_t _action_check_flash_linux(lv_obj_t *btn)
|
|||||||
else
|
else
|
||||||
itoa(idx, &path[23], 10);
|
itoa(idx, &path[23], 10);
|
||||||
|
|
||||||
// If not the last part, unaligned size is not permitted.
|
// If it exists, unaligned size for current part is not permitted.
|
||||||
if (!f_stat(path, NULL)) // NULL: Don't override current part fs info.
|
if (!f_stat(path, NULL)) // NULL: Don't override current part fs info.
|
||||||
{
|
{
|
||||||
lv_label_set_text(lbl_status, "#FFDD00 Error:# The image is not aligned to 4 MiB!");
|
lv_label_set_text(lbl_status, "#FFDD00 Error:# The image is not aligned to 4 MiB!");
|
||||||
@ -892,7 +893,7 @@ exit:
|
|||||||
return LV_RES_OK;
|
return LV_RES_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static lv_res_t _action_reboot_twrp(lv_obj_t * btns, const char * txt)
|
static lv_res_t _action_reboot_recovery(lv_obj_t * btns, const char * txt)
|
||||||
{
|
{
|
||||||
int btn_idx = lv_btnm_get_pressed(btns);
|
int btn_idx = lv_btnm_get_pressed(btns);
|
||||||
|
|
||||||
@ -926,7 +927,7 @@ static lv_res_t _action_reboot_twrp(lv_obj_t * btns, const char * txt)
|
|||||||
static lv_res_t _action_flash_android_data(lv_obj_t * btns, const char * txt)
|
static lv_res_t _action_flash_android_data(lv_obj_t * btns, const char * txt)
|
||||||
{
|
{
|
||||||
int btn_idx = lv_btnm_get_pressed(btns);
|
int btn_idx = lv_btnm_get_pressed(btns);
|
||||||
bool boot_twrp = false;
|
bool boot_recovery = false;
|
||||||
|
|
||||||
// Delete parent mbox.
|
// Delete parent mbox.
|
||||||
mbox_action(btns, txt);
|
mbox_action(btns, txt);
|
||||||
@ -1031,18 +1032,23 @@ boot_img_not_found:
|
|||||||
lv_label_set_text(lbl_status, txt_buf);
|
lv_label_set_text(lbl_status, txt_buf);
|
||||||
manual_system_maintenance(true);
|
manual_system_maintenance(true);
|
||||||
|
|
||||||
// Check if TWRP should be flashed.
|
// Check if Recovery should be flashed.
|
||||||
|
strcpy(path, "switchroot/install/recovery.img");
|
||||||
|
if (f_stat(path, NULL))
|
||||||
|
{
|
||||||
|
// Not found, try twrp.img instead.
|
||||||
strcpy(path, "switchroot/install/twrp.img");
|
strcpy(path, "switchroot/install/twrp.img");
|
||||||
if (f_stat(path, NULL))
|
if (f_stat(path, NULL))
|
||||||
{
|
{
|
||||||
strcat(txt_buf, "#FF8000 Warning:# TWRP image not found!\n");
|
strcat(txt_buf, "#FF8000 Warning:# Recovery image not found!\n");
|
||||||
goto twrp_not_found;
|
goto recovery_not_found;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
offset_sct = 0;
|
offset_sct = 0;
|
||||||
size_sct = 0;
|
size_sct = 0;
|
||||||
|
|
||||||
// Find TWRP partition.
|
// Find Recovery partition.
|
||||||
for (u32 i = 0; i < gpt->header.num_part_ents; i++)
|
for (u32 i = 0; i < gpt->header.num_part_ents; i++)
|
||||||
{
|
{
|
||||||
if (!memcmp(gpt->entries[i].name, (char[]) { 'S', 0, 'O', 0, 'S', 0 }, 6))
|
if (!memcmp(gpt->entries[i].name, (char[]) { 'S', 0, 'O', 0, 'S', 0 }, 6))
|
||||||
@ -1056,7 +1062,7 @@ boot_img_not_found:
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Flash TWRP.
|
// Flash Recovery.
|
||||||
if (offset_sct && size_sct)
|
if (offset_sct && size_sct)
|
||||||
{
|
{
|
||||||
u32 file_size = 0;
|
u32 file_size = 0;
|
||||||
@ -1072,20 +1078,20 @@ boot_img_not_found:
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((file_size >> 9) > size_sct)
|
if ((file_size >> 9) > size_sct)
|
||||||
strcat(txt_buf, "#FF8000 Warning:# TWRP image too big!\n");
|
strcat(txt_buf, "#FF8000 Warning:# Recovery image too big!\n");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sdmmc_storage_write(&sd_storage, offset_sct, file_size >> 9, buf);
|
sdmmc_storage_write(&sd_storage, offset_sct, file_size >> 9, buf);
|
||||||
strcat(txt_buf, "#C7EA46 Success:# TWRP image flashed!\n");
|
strcat(txt_buf, "#C7EA46 Success:# Recovery image flashed!\n");
|
||||||
f_unlink(path);
|
f_unlink(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
free(buf);
|
free(buf);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
strcat(txt_buf, "#FF8000 Warning:# TWRP partition not found!\n");
|
strcat(txt_buf, "#FF8000 Warning:# Recovery partition not found!\n");
|
||||||
|
|
||||||
twrp_not_found:
|
recovery_not_found:
|
||||||
lv_label_set_text(lbl_status, txt_buf);
|
lv_label_set_text(lbl_status, txt_buf);
|
||||||
manual_system_maintenance(true);
|
manual_system_maintenance(true);
|
||||||
|
|
||||||
@ -1147,7 +1153,7 @@ twrp_not_found:
|
|||||||
dtb_not_found:
|
dtb_not_found:
|
||||||
lv_label_set_text(lbl_status, txt_buf);
|
lv_label_set_text(lbl_status, txt_buf);
|
||||||
|
|
||||||
// Check if TWRP is flashed unconditionally.
|
// Check if Recovery is flashed unconditionally.
|
||||||
for (u32 i = 0; i < gpt->header.num_part_ents; i++)
|
for (u32 i = 0; i < gpt->header.num_part_ents; i++)
|
||||||
{
|
{
|
||||||
if (!memcmp(gpt->entries[i].name, (char[]) { 'S', 0, 'O', 0, 'S', 0 }, 6))
|
if (!memcmp(gpt->entries[i].name, (char[]) { 'S', 0, 'O', 0, 'S', 0 }, 6))
|
||||||
@ -1155,7 +1161,7 @@ dtb_not_found:
|
|||||||
u8 *buf = malloc(512);
|
u8 *buf = malloc(512);
|
||||||
sdmmc_storage_read(&sd_storage, gpt->entries[i].lba_start, 1, buf);
|
sdmmc_storage_read(&sd_storage, gpt->entries[i].lba_start, 1, buf);
|
||||||
if (!memcmp(buf, "ANDROID", 7))
|
if (!memcmp(buf, "ANDROID", 7))
|
||||||
boot_twrp = true;
|
boot_recovery = true;
|
||||||
free(buf);
|
free(buf);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1165,12 +1171,12 @@ dtb_not_found:
|
|||||||
}
|
}
|
||||||
|
|
||||||
error:
|
error:
|
||||||
if (boot_twrp)
|
if (boot_recovery)
|
||||||
{
|
{
|
||||||
// If a TWRP partition was found, ask user if rebooting into it is wanted.
|
// If a Recovery partition was found, ask user if rebooting into it is wanted.
|
||||||
strcat(txt_buf,"\n\nDo you want to reboot into TWRP\nto finish Android installation?");
|
strcat(txt_buf,"\n\nDo you want to reboot into Recovery\nto finish Android installation?");
|
||||||
lv_label_set_text(lbl_status, txt_buf);
|
lv_label_set_text(lbl_status, txt_buf);
|
||||||
lv_mbox_add_btns(mbox, mbox_btn_map2, _action_reboot_twrp);
|
lv_mbox_add_btns(mbox, mbox_btn_map2, _action_reboot_recovery);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
lv_mbox_add_btns(mbox, mbox_btn_map, mbox_action);
|
lv_mbox_add_btns(mbox, mbox_btn_map, mbox_action);
|
||||||
@ -1201,7 +1207,7 @@ static lv_res_t _action_flash_android(lv_obj_t *btn)
|
|||||||
lv_obj_t *lbl_status = lv_label_create(mbox, NULL);
|
lv_obj_t *lbl_status = lv_label_create(mbox, NULL);
|
||||||
lv_label_set_recolor(lbl_status, true);
|
lv_label_set_recolor(lbl_status, true);
|
||||||
lv_label_set_text(lbl_status,
|
lv_label_set_text(lbl_status,
|
||||||
"This will flash #C7EA46 Kernel#, #C7EA46 DTB# and #C7EA46 TWRP# if found.\n"
|
"This will flash #C7EA46 Kernel#, #C7EA46 DTB# and #C7EA46 Recovery# if found.\n"
|
||||||
"Do you want to continue?");
|
"Do you want to continue?");
|
||||||
|
|
||||||
lv_mbox_add_btns(mbox, mbox_btn_map, _action_flash_android_data);
|
lv_mbox_add_btns(mbox, mbox_btn_map, _action_flash_android_data);
|
||||||
@ -2585,7 +2591,7 @@ lv_res_t create_window_partition_manager(lv_obj_t *btn)
|
|||||||
"Note 1: Only up to #C7EA46 1GB# can be backed up. If more, you will be asked to back them manually at the next step.\n"
|
"Note 1: Only up to #C7EA46 1GB# can be backed up. If more, you will be asked to back them manually at the next step.\n"
|
||||||
"Note 2: Resized emuMMC formats the USER partition. A save data manager can be used to move them over.\n"
|
"Note 2: Resized emuMMC formats the USER partition. A save data manager can be used to move them over.\n"
|
||||||
"Note 3: The #C7EA46 Flash Linux# and #C7EA46 Flash Android# will flash files if suitable partitions and installer files are found.\n"
|
"Note 3: The #C7EA46 Flash Linux# and #C7EA46 Flash Android# will flash files if suitable partitions and installer files are found.\n"
|
||||||
"Note 4: The installation folder is #C7EA46 switchroot/install#. Linux uses #C7EA46 l4t.XX# and Android uses #C7EA46 twrp.img# and #C7EA46 tegra210-icosa.dtb#.");
|
"Note 4: The installation folder is #C7EA46 switchroot/install#. Linux uses #C7EA46 l4t.XX# and Android uses #C7EA46 recovery/twrp.img# and #C7EA46 tegra210-icosa.dtb#.");
|
||||||
lv_label_set_style(lbl_notes, &hint_small_style);
|
lv_label_set_style(lbl_notes, &hint_small_style);
|
||||||
lv_obj_align(lbl_notes, lbl_and, LV_ALIGN_OUT_BOTTOM_LEFT, 0, LV_DPI / 5);
|
lv_obj_align(lbl_notes, lbl_and, LV_ALIGN_OUT_BOTTOM_LEFT, 0, LV_DPI / 5);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user