@@ -118,6 +118,17 @@ const char* format_ver(const char* format, uint32_t version) {
118118static uint16_t boot_background ;
119119static bool ble_name_show = false;
120120static int ui_bootloader_page_current = 0 ;
121+
122+ static int current_progress_value = 0 ;
123+
124+ int get_current_progress_value (void ) { return current_progress_value ; }
125+
126+ char * format_progress_value (char * prefix ) {
127+ static char buf [128 ] = {0 };
128+ mini_snprintf (buf , sizeof (buf ), "%s %d" , prefix , current_progress_value );
129+ return buf ;
130+ }
131+
121132int get_ui_bootloader_page_current (void ) { return ui_bootloader_page_current ; }
122133
123134void ui_logo_onekey (void ) {
@@ -252,9 +263,7 @@ void ui_screen_firmware_fingerprint(const image_header* const hdr) {
252263
253264// install UI
254265
255- void ui_screen_install_confirm_newvendor_or_downgrade_wipe (
256- const vendor_header * const vhdr , const image_header * const hdr ,
257- secbool downgrade_wipe ) {
266+ void ui_screen_install_confirm_newvendor_or_downgrade_wipe (char * new_version ) {
258267 vendor_header current_vhdr ;
259268 image_header current_hdr ;
260269 // char str[128] = {0};
@@ -272,10 +281,8 @@ void ui_screen_install_confirm_newvendor_or_downgrade_wipe(
272281 ui_statusbar_update ();
273282 ui_logo_warning ();
274283
275- display_text_center (
276- MAX_DISPLAY_RESX / 2 , TITLE_OFFSET_Y ,
277- (sectrue == downgrade_wipe ) ? "Firmware Downgrade" : "Vendor Change" , -1 ,
278- FONT_PJKS_BOLD_38 , COLOR_BL_FG , COLOR_BL_BG );
284+ display_text_center (MAX_DISPLAY_RESX / 2 , TITLE_OFFSET_Y , "Vendor Change" , -1 ,
285+ FONT_PJKS_BOLD_38 , COLOR_BL_FG , COLOR_BL_BG );
279286 display_text_center (DISPLAY_RESX / 2 , SUBTITLE_OFFSET_Y ,
280287 "Still installing this firmware?" , -1 , FONT_NORMAL ,
281288 COLOR_BL_SUBTITLE , COLOR_BL_BG );
@@ -293,17 +300,10 @@ void ui_screen_install_confirm_newvendor_or_downgrade_wipe(
293300 // } while (split);
294301 display_bar_radius_ex (BOARD_OFFSET_X , 295 , BUTTON_FULL_WIDTH , BUTTON_HEIGHT ,
295302 COLOR_BL_PANEL , COLOR_BL_BG , BUTTON_RADIUS );
296- const char * ver_str = format_ver ("%d.%d.%d" , current_hdr .onekey_version );
297- display_text_right (MAX_DISPLAY_RESX / 2 - 25 , 350 , ver_str , -1 , FONT_NORMAL ,
298- COLOR_BL_SUBTITLE , COLOR_BL_DARK );
299- ver_str = format_ver ("%d.%d.%d" , hdr -> onekey_version );
300303
301- display_text (MAX_DISPLAY_RESX / 2 + 25 , 350 , ver_str , -1 , FONT_NORMAL ,
304+ display_text (MAX_DISPLAY_RESX / 2 + 25 , 350 , new_version , -1 , FONT_NORMAL ,
302305 COLOR_BL_SUBTITLE , COLOR_BL_DARK );
303306
304- display_image (227 , 330 , 25 , 23 , toi_icon_arrow_right + 12 ,
305- sizeof (toi_icon_arrow_right ) - 12 );
306-
307307 ui_confirm_cancel_buttons ("Cancel" , "Install" , COLOR_BL_DARK , COLOR_BL_FAIL );
308308}
309309
@@ -333,20 +333,31 @@ void ui_screen_confirm(char* title, char* note_l1, char* note_l2, char* note_l3,
333333 ui_confirm_cancel_buttons ("Back" , "OK" , COLOR_BL_DARK , COLOR_BL_FAIL );
334334}
335335
336+ void ui_screen_progress_bar_init (char * title , char * notes , int progress ) {
337+ ui_statusbar_update ();
338+ ui_logo_onekey ();
339+ if (title != NULL ) {
340+ display_text_center (DISPLAY_RESX / 2 , TITLE_OFFSET_Y , title , -1 ,
341+ FONT_PJKS_BOLD_38 , COLOR_BL_FG , COLOR_BL_BG );
342+ }
343+ display_progress (notes ? notes : "Keep connected." , progress );
344+ }
345+
336346void ui_screen_progress_bar_prepare (char * title , char * notes ) {
337347 ui_statusbar_update ();
338348 ui_logo_onekey ();
339349 ui_screen_progress_bar_update (title , notes , -1 );
340350}
341351
342352void ui_screen_progress_bar_update (char * title , char * notes , int progress ) {
343- if (title != NULL )
353+ if (title != NULL ) {
344354 display_text_center (DISPLAY_RESX / 2 , TITLE_OFFSET_Y , title , -1 ,
345355 FONT_PJKS_BOLD_38 , COLOR_BL_FG , COLOR_BL_BG );
356+ }
346357
347358 if ((progress >= 0 ) && (progress <= 100 )) {
348359 if (progress > 0 ) {
349- display_progress (NULL , progress * 10 );
360+ display_progress (NULL , progress );
350361 }
351362 } else {
352363 display_progress (notes ? notes : "Keep connected." , 0 );
@@ -368,10 +379,13 @@ void ui_screen_install_progress_erase(int pos, int len) {
368379 display_text_center (DISPLAY_RESX / 2 , TITLE_OFFSET_Y , "Installing" , -1 ,
369380 FONT_PJKS_BOLD_38 , COLOR_BL_FG , COLOR_BL_BG );
370381
371- display_progress ("Keep connected." , 250 * pos / len );
382+ display_progress ("Keep connected." , 25 * pos / len );
372383}
373384
374- void ui_screen_install_progress_upload (int pos ) { display_progress (NULL , pos ); }
385+ void ui_screen_install_progress_upload (int pos ) {
386+ current_progress_value = pos ;
387+ display_progress (NULL , pos );
388+ }
375389
376390// wipe UI
377391
@@ -403,7 +417,7 @@ void ui_screen_wipe(void) {
403417}
404418
405419void ui_screen_wipe_progress (int pos , int len ) {
406- display_progress (NULL , 1000 * pos / len );
420+ display_progress (NULL , 100 * pos / len );
407421}
408422
409423void ui_screen_wipe_done (void ) {
@@ -657,6 +671,20 @@ void ui_wipe_confirm(const image_header* const hdr) {
657671 ui_confirm_cancel_buttons ("Cancel" , "Wipe" , COLOR_BL_DARK , COLOR_BL_FAIL );
658672}
659673
674+ void ui_screen_install_title_clear (void ) {
675+ display_bar (0 , TITLE_OFFSET_Y - 30 , DISPLAY_RESX , TITLE_OFFSET_Y + 90 ,
676+ COLOR_BLACK );
677+ }
678+
679+ void ui_show_version_info (int y , char * current_ver , char * new_ver ) {
680+ display_text_right (3 * DISPLAY_RESX / 4 - 15 , y , current_ver , -1 , FONT_NORMAL ,
681+ COLOR_WHITE , COLOR_BL_PANEL );
682+ display_text (3 * DISPLAY_RESX / 4 + 20 , y , new_ver , -1 , FONT_NORMAL ,
683+ COLOR_WHITE , COLOR_BL_PANEL );
684+ display_image (350 , y - 20 , 25 , 23 , toi_icon_arrow_right + 12 ,
685+ sizeof (toi_icon_arrow_right ) - 12 );
686+ }
687+
660688void ui_install_confirm (image_header * current_hdr ,
661689 const image_header * const new_hdr ) {
662690 if ((current_hdr == NULL ) || (new_hdr == NULL )) return ;
@@ -722,11 +750,89 @@ void ui_install_thd89_confirm(const char* old_ver, const char* boot_ver) {
722750 ui_confirm_cancel_buttons ("Cancel" , "Install" , COLOR_BL_DARK , COLOR_BL_DONE );
723751}
724752
753+ void ui_update_info_show (update_info_t update_info ) {
754+ int offset_y = SUBTITLE_OFFSET_Y ;
755+ int offset_x = 32 ;
756+ int bar_height = 66 ;
757+ int font_offset = 8 ;
758+
759+ ui_statusbar_update ();
760+ ui_logo_onekey ();
761+
762+ display_text_center (DISPLAY_RESX / 2 , TITLE_OFFSET_Y , "Update Firmware" , -1 ,
763+ FONT_PJKS_BOLD_38 , COLOR_BL_FG , COLOR_BL_BG );
764+
765+ if (update_info .boot .type == UPDATE_BOOTLOADER ) {
766+ display_bar_radius_ex (BUTTON_LEFT_OFFSET_X , offset_y - bar_height / 2 ,
767+ BUTTON_FULL_WIDTH , bar_height , COLOR_BL_PANEL ,
768+ COLOR_BL_BG , bar_height / 2 );
769+
770+ display_text (offset_x , offset_y + font_offset , "Bootloader" , -1 ,
771+ FONT_NORMAL , COLOR_BL_FG , COLOR_BL_BG );
772+
773+ ui_show_version_info (offset_y + font_offset ,
774+ update_info .boot .current_version ,
775+ update_info .boot .new_version );
776+ offset_y += 80 ;
777+ }
778+
779+ if (update_info .mcu_location ) {
780+ display_bar_radius_ex (BUTTON_LEFT_OFFSET_X , offset_y - bar_height / 2 ,
781+ BUTTON_FULL_WIDTH , bar_height , COLOR_BL_PANEL ,
782+ COLOR_BL_BG , bar_height / 2 );
783+
784+ display_text (offset_x , offset_y + font_offset , "System" , -1 , FONT_NORMAL ,
785+ COLOR_BL_FG , COLOR_BL_BG );
786+
787+ ui_show_version_info (
788+ offset_y + font_offset ,
789+ update_info .items [update_info .mcu_location - 1 ].current_version ,
790+ update_info .items [update_info .mcu_location - 1 ].new_version );
791+ offset_y += 80 ;
792+ }
793+
794+ if (update_info .se_count ) {
795+ display_bar_radius_ex (BUTTON_LEFT_OFFSET_X , offset_y - bar_height / 2 ,
796+ BUTTON_FULL_WIDTH , bar_height , COLOR_BL_PANEL ,
797+ COLOR_BL_BG , bar_height / 2 );
798+
799+ display_text (offset_x , offset_y + font_offset , "SE" , -1 , FONT_NORMAL ,
800+ COLOR_BL_FG , COLOR_BL_BG );
801+ ui_show_version_info (
802+ offset_y + font_offset ,
803+ update_info .items [update_info .se_location [0 ] - 1 ].current_version ,
804+ update_info .items [update_info .se_location [0 ] - 1 ].new_version );
805+ offset_y += 80 ;
806+ }
807+
808+ if (update_info .ble_location ) {
809+ display_bar_radius_ex (BUTTON_LEFT_OFFSET_X , offset_y - bar_height / 2 ,
810+ BUTTON_FULL_WIDTH , bar_height , COLOR_BL_PANEL ,
811+ COLOR_BL_BG , bar_height / 2 );
812+
813+ display_text (offset_x , offset_y + font_offset , "Bluetooth" , -1 , FONT_NORMAL ,
814+ COLOR_BL_FG , COLOR_BL_BG );
815+ ui_show_version_info (
816+ offset_y + font_offset ,
817+ update_info .items [update_info .ble_location - 1 ].current_version ,
818+ update_info .items [update_info .ble_location - 1 ].new_version );
819+ offset_y += 80 ;
820+ }
821+
822+ ui_confirm_cancel_buttons ("Cancel" , "Install" , COLOR_BL_DARK , COLOR_BL_DONE );
823+ }
824+
725825void ui_bootloader_first (const image_header * const hdr ) {
726826 ui_bootloader_page_current = 0 ;
727827 uint8_t se_state ;
728828 char se_info [64 ] = {0 };
729829
830+ static image_header * current_hdr = NULL ;
831+
832+ if (current_hdr == NULL && hdr ) {
833+ current_hdr = (image_header * )hdr ;
834+ }
835+
730836 ui_statusbar_update ();
731837 // info icon 48 * 48 - the entry point of the bootloader details
732838 display_icon (INFO_ICON_OFFSET_X , INFO_ICON_OFFSET_Y , INFO_ICON_SIZE ,
@@ -747,8 +853,8 @@ void ui_bootloader_first(const image_header* const hdr) {
747853
748854 display_text_center (DISPLAY_RESX / 2 , DISPLAY_RESY - 92 , "SafeOS" , -1 ,
749855 FONT_PJKS_BOLD_38 , COLOR_BL_FG , COLOR_BL_BG );
750- if (hdr ) {
751- const char * ver_str = format_ver ("%d.%d.%d" , (hdr -> onekey_version ));
856+ if (current_hdr ) {
857+ const char * ver_str = format_ver ("%d.%d.%d" , (current_hdr -> onekey_version ));
752858 display_text_center (DISPLAY_RESX / 2 , DISPLAY_RESY - 50 , ver_str , -1 ,
753859 FONT_NORMAL , COLOR_BL_SUBTITLE , COLOR_BL_BG );
754860 }
0 commit comments