lijuang | bdb18ea | 2018-02-06 17:21:18 +0800 | [diff] [blame] | 1 | /* Copyright (c) 2015-2018, The Linux Foundation. All rights reserved. |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 2 | * |
| 3 | * Redistribution and use in source and binary forms, with or without |
| 4 | * modification, are permitted provided that the following conditions are |
| 5 | * met: |
| 6 | * * Redistributions of source code must retain the above copyright |
| 7 | * notice, this list of conditions and the following disclaimer. |
| 8 | * * Redistributions in binary form must reproduce the above |
| 9 | * copyright notice, this list of conditions and the following |
| 10 | * disclaimer in the documentation and/or other materials provided |
| 11 | * with the distribution. |
| 12 | * * Neither the name of The Linux Foundation nor the names of its |
| 13 | * contributors may be used to endorse or promote products derived |
| 14 | * from this software without specific prior written permission. |
| 15 | * |
| 16 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED |
| 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT |
| 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS |
| 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
| 23 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
| 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE |
| 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN |
| 26 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | */ |
| 28 | |
| 29 | #include <debug.h> |
| 30 | #include <reg.h> |
| 31 | #include <stdlib.h> |
| 32 | #include <openssl/evp.h> |
| 33 | #include <dev/fbcon.h> |
| 34 | #include <kernel/thread.h> |
| 35 | #include <display_menu.h> |
| 36 | #include <menu_keys_detect.h> |
| 37 | #include <boot_verifier.h> |
| 38 | #include <string.h> |
| 39 | #include <platform.h> |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 40 | #include <smem.h> |
| 41 | #include <target.h> |
| 42 | #include <sys/types.h> |
| 43 | #include <../../../app/aboot/devinfo.h> |
lijuang | f55ad05 | 2018-04-23 18:30:50 +0800 | [diff] [blame] | 44 | #include <../../../app/aboot/recovery.h> |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 45 | |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 46 | #define TITLE_MSG "<!>\n\n" |
| 47 | |
jialongjhan | b2dda0b | 2020-04-21 20:20:51 +0800 | [diff] [blame] | 48 | //[Arima][8901][JialongJhan] Command mode update screen 20190516 Start |
| 49 | extern int msm_display_flush(); |
| 50 | //[Arima][8901][JialongJhan] Command mode update screen 20190516 End |
lijuang | f55ad05 | 2018-04-23 18:30:50 +0800 | [diff] [blame] | 51 | static const char *unlock_menu_common_msg = "By unlocking the bootloader, you will be able to install "\ |
| 52 | "custom operating system on this phone. "\ |
| 53 | "A custom OS is not subject to the same level of testing "\ |
| 54 | "as the original OS, and can cause your phone "\ |
| 55 | "and installed applications to stop working properly.\n\n"\ |
| 56 | "Software integrity cannot be guaranteed with a custom OS, "\ |
| 57 | "so any data stored on the phone while the bootloader "\ |
| 58 | "is unlocked may be at risk.\n\n"\ |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 59 | "To prevent unauthorized access to your personal data, "\ |
| 60 | "unlocking the bootloader will also delete all personal "\ |
lijuang | f55ad05 | 2018-04-23 18:30:50 +0800 | [diff] [blame] | 61 | "data on your phone.\n\n"\ |
| 62 | "Press the Volume keys to select whether to unlock the bootloader, "\ |
| 63 | "then the Power Button to continue.\n\n"; |
| 64 | |
| 65 | static const char *lock_menu_common_msg = "If you lock the bootloader, "\ |
| 66 | "you will not be able to install "\ |
| 67 | "custom operating system on this phone.\n\n"\ |
| 68 | "To prevent unauthorized access to your personal data, "\ |
| 69 | "locking the bootloader will also delete all personal "\ |
| 70 | "data on your phone.\n\n"\ |
| 71 | "Press the Volume keys to select whether to "\ |
| 72 | "lock the bootloader, then the power button to continue.\n\n"; |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 73 | |
Channagoud Kadabi | 86b0c11 | 2016-03-16 19:23:16 -0700 | [diff] [blame] | 74 | #define YELLOW_WARNING_MSG "Your device has loaded a different operating system\n\n "\ |
Brahmaji K | 0c2d598 | 2017-09-07 18:44:21 +0530 | [diff] [blame] | 75 | "Visit this link on another device:\n" |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 76 | |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 77 | #define ORANGE_WARNING_MSG "The boot loader is unlocked and software integrity cannot "\ |
| 78 | "be guaranteed. Any data stored on the device may be available to attackers. "\ |
| 79 | "Do not store any sensitive data on the device.\n\n"\ |
Brahmaji K | 0c2d598 | 2017-09-07 18:44:21 +0530 | [diff] [blame] | 80 | "Visit this link on another device:\n" |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 81 | |
Channagoud Kadabi | 86b0c11 | 2016-03-16 19:23:16 -0700 | [diff] [blame] | 82 | #define RED_WARNING_MSG "Your device is corrupt. It can't be\ntrusted and will not boot\n\n" \ |
Brahmaji K | 0c2d598 | 2017-09-07 18:44:21 +0530 | [diff] [blame] | 83 | "Visit this link on another device:\n" |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 84 | |
lijuang | bdd9bb4 | 2016-03-01 18:22:17 +0800 | [diff] [blame] | 85 | #define LOGGING_WARNING_MSG "The dm-verity is not started in enforcing mode and may "\ |
| 86 | "not work properly\n\nTo learn more, visit:\n" |
| 87 | |
Channagoud Kadabi | 86b0c11 | 2016-03-16 19:23:16 -0700 | [diff] [blame] | 88 | #define EIO_WARNING_MSG "Your device is corrupt. It can't be\n trusted and may not work properly.\n\n"\ |
Brahmaji K | 0c2d598 | 2017-09-07 18:44:21 +0530 | [diff] [blame] | 89 | "Visit this link on another device:\n" |
| 90 | |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 91 | #define PAUSE_BOOT_MSG "PRESS POWER KEY TO PAUSE BOOT\n\n" |
| 92 | |
| 93 | #define CONTINUE_BOOT_MSG "PRESS POWER KEY TO CONTINUE\n\n" |
| 94 | |
| 95 | #define URL_MSG "g.co/ABH\n\n" |
Channagoud Kadabi | 86b0c11 | 2016-03-16 19:23:16 -0700 | [diff] [blame] | 96 | |
Parth Dixit | 54ac3bb | 2017-03-07 15:52:48 +0530 | [diff] [blame] | 97 | #define DELAY_5SEC 5000 |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 98 | #define DELAY_10SEC 10000 |
Parth Dixit | 54ac3bb | 2017-03-07 15:52:48 +0530 | [diff] [blame] | 99 | #define DELAY_30SEC 30000 |
| 100 | |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 101 | static bool is_thread_start = false; |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 102 | static struct select_msg_info msg_info; |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 103 | |
Monika Singh | 5e17036 | 2018-03-14 00:48:36 +0530 | [diff] [blame] | 104 | #if VERIFIED_BOOT || VERIFIED_BOOT_2 |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 105 | struct boot_verify_info { |
| 106 | int msg_type; |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 107 | const char *title_msg; |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 108 | const char *warning_msg; |
Brahmaji K | 0c2d598 | 2017-09-07 18:44:21 +0530 | [diff] [blame] | 109 | const char *url_msg; |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 110 | const char *notice_msg; |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 111 | }; |
| 112 | |
| 113 | struct boot_verify_info boot_verify_info[] = { |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 114 | [DISPLAY_MENU_RED] = {FBCON_RED_MSG, TITLE_MSG, RED_WARNING_MSG, URL_MSG, NULL}, |
| 115 | [DISPLAY_MENU_YELLOW] = {FBCON_YELLOW_MSG, TITLE_MSG, YELLOW_WARNING_MSG, URL_MSG, PAUSE_BOOT_MSG}, |
| 116 | [DISPLAY_MENU_ORANGE] = {FBCON_ORANGE_MSG, TITLE_MSG, ORANGE_WARNING_MSG, URL_MSG, PAUSE_BOOT_MSG}, |
| 117 | [DISPLAY_MENU_LOGGING] = {FBCON_RED_MSG, TITLE_MSG, LOGGING_WARNING_MSG, NULL, NULL}, |
| 118 | [DISPLAY_MENU_EIO] = {FBCON_RED_MSG, TITLE_MSG, EIO_WARNING_MSG, URL_MSG, CONTINUE_BOOT_MSG}}; |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 119 | #endif |
| 120 | |
| 121 | static char *verify_option_menu[] = { |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 122 | [POWEROFF] = "Power off\n", |
| 123 | [RESTART] = "Restart\n", |
| 124 | [RECOVER] = "Recovery\n", |
| 125 | [FASTBOOT] = "Fastboot\n", |
| 126 | [BACK] = "Back to previous page\n"}; |
| 127 | |
tracychui | f6dd8d7 | 2020-01-20 16:53:15 +0800 | [diff] [blame] | 128 | /*[20200120][TracyChui]Remove FFBM item in fastboot mode start */ |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 129 | static char *fastboot_option_menu[] = { |
| 130 | [0] = "START\n", |
| 131 | [1] = "Restart bootloader\n", |
| 132 | [2] = "Recovery mode\n", |
tracychui | f6dd8d7 | 2020-01-20 16:53:15 +0800 | [diff] [blame] | 133 | [3] = "Power off\n"}; |
| 134 | /*[20200120][TracyChui]Remove FFBM item in fastboot mode end */ |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 135 | |
lijuang | f55ad05 | 2018-04-23 18:30:50 +0800 | [diff] [blame] | 136 | static struct unlock_info munlock_info[] = { |
| 137 | [DISPLAY_MENU_LOCK] = {UNLOCK, FALSE}, |
| 138 | [DISPLAY_MENU_UNLOCK] = {UNLOCK, TRUE}, |
| 139 | [DISPLAY_MENU_LOCK_CRITICAL] = {UNLOCK_CRITICAL, FALSE}, |
| 140 | [DISPLAY_MENU_UNLOCK_CRITICAL] = {UNLOCK_CRITICAL, TRUE}, |
| 141 | }; |
| 142 | |
| 143 | struct unlock_option_msg munlock_option_msg[] = { |
| 144 | [TRUE] = {"DO NOT UNLOCK THE BOOTLOADER \n", "UNLOCK THE BOOTLOADER \n"}, |
| 145 | [FALSE] = {"DO NOT LOCK THE BOOTLOADER \n", "LOCK THE BOOTLOADER \n"}, |
| 146 | }; |
| 147 | |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 148 | static int big_factor = 2; |
| 149 | static int common_factor = 1; |
| 150 | |
lijuang | de34d50 | 2016-02-26 16:04:50 +0800 | [diff] [blame] | 151 | static void wait_for_exit() |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 152 | { |
| 153 | struct select_msg_info *select_msg; |
| 154 | select_msg = &msg_info; |
| 155 | |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 156 | mutex_acquire(&select_msg->msg_lock); |
lijuang | de34d50 | 2016-02-26 16:04:50 +0800 | [diff] [blame] | 157 | while(!select_msg->info.rel_exit == true) { |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 158 | mutex_release(&select_msg->msg_lock); |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 159 | thread_sleep(10); |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 160 | mutex_acquire(&select_msg->msg_lock); |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 161 | } |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 162 | mutex_release(&select_msg->msg_lock); |
| 163 | |
lijuang | de34d50 | 2016-02-26 16:04:50 +0800 | [diff] [blame] | 164 | is_thread_start = false; |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 165 | fbcon_clear(); |
| 166 | display_image_on_screen(); |
jialongjhan | b2dda0b | 2020-04-21 20:20:51 +0800 | [diff] [blame] | 167 | //[Arima][8901][JialongJhan] Command mode update screen 20190618 Start |
| 168 | msm_display_flush(); |
| 169 | //[Arima][8901][JialongJhan] Command mode update screen 20190618 End |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 170 | } |
| 171 | |
lijuang | de34d50 | 2016-02-26 16:04:50 +0800 | [diff] [blame] | 172 | void wait_for_users_action() |
| 173 | { |
Krishna Manikandan | f2c8be9 | 2017-12-05 18:07:56 +0530 | [diff] [blame] | 174 | if (is_display_disabled()) |
| 175 | return; |
lijuang | de34d50 | 2016-02-26 16:04:50 +0800 | [diff] [blame] | 176 | /* Waiting for exit menu keys detection if there is no any usr action |
| 177 | * otherwise it will do the action base on the keys detection thread |
| 178 | */ |
| 179 | wait_for_exit(); |
| 180 | } |
| 181 | |
| 182 | void exit_menu_keys_detection() |
| 183 | { |
| 184 | struct select_msg_info *select_msg; |
| 185 | select_msg = &msg_info; |
| 186 | |
Krishna Manikandan | f2c8be9 | 2017-12-05 18:07:56 +0530 | [diff] [blame] | 187 | if (is_display_disabled()) |
| 188 | return; |
| 189 | |
lijuang | de34d50 | 2016-02-26 16:04:50 +0800 | [diff] [blame] | 190 | mutex_acquire(&select_msg->msg_lock); |
| 191 | select_msg->info.is_exit = true; |
| 192 | mutex_release(&select_msg->msg_lock); |
| 193 | |
| 194 | wait_for_exit(); |
| 195 | } |
| 196 | |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 197 | static void set_message_factor() |
| 198 | { |
| 199 | uint32_t tmp_factor = 0; |
lijuang | 9e73e5a | 2018-04-23 17:00:16 +0800 | [diff] [blame] | 200 | uint32_t max_x_count = 0; |
| 201 | uint32_t max_x = 0; |
| 202 | |
| 203 | if (fbcon_get_width() < fbcon_get_height()) |
| 204 | max_x_count = CHAR_NUM_PERROW_POR; |
| 205 | else |
| 206 | max_x_count = CHAR_NUM_PERROW_HOR; |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 207 | |
| 208 | max_x = fbcon_get_max_x(); |
| 209 | tmp_factor = max_x/max_x_count; |
| 210 | |
| 211 | if(tmp_factor <= 1) { |
| 212 | big_factor = 2; |
| 213 | common_factor = 1; |
| 214 | } else { |
| 215 | big_factor = tmp_factor*2; |
| 216 | common_factor = tmp_factor; |
| 217 | } |
| 218 | } |
| 219 | |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 220 | /* If y_start == 0, it will draw message from the current Y axis location, |
| 221 | otherwise it will start from the the value of y_start. */ |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 222 | static void display_fbcon_menu_message(char *str, unsigned type, |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 223 | unsigned scale_factor, int y_start) |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 224 | { |
| 225 | while(*str != 0) { |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 226 | fbcon_putc_factor(*str++, type, scale_factor, y_start); |
| 227 | y_start = 0; |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 228 | } |
| 229 | } |
| 230 | |
| 231 | static char *str_align_right(char *str, int factor) |
| 232 | { |
| 233 | uint32_t max_x = 0; |
| 234 | int diff = 0; |
| 235 | int i = 0; |
| 236 | char *str_target = NULL; |
| 237 | |
| 238 | max_x = fbcon_get_max_x(); |
| 239 | if (!str_target && max_x) { |
| 240 | str_target = malloc(max_x); |
| 241 | } |
| 242 | |
| 243 | if (str_target) { |
| 244 | memset(str_target, 0, max_x); |
| 245 | if ( max_x/factor > strlen(str)) { |
| 246 | if (factor == 1) |
| 247 | diff = max_x/factor - strlen(str) - 1; |
| 248 | else |
| 249 | diff = max_x/factor - strlen(str); |
| 250 | for (i = 0; i < diff; i++) { |
Parth Dixit | 73d3bd0 | 2016-01-07 14:29:41 +0530 | [diff] [blame] | 251 | strlcat(str_target, " ", max_x); |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 252 | } |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 253 | } |
lijuang | bdb18ea | 2018-02-06 17:21:18 +0800 | [diff] [blame] | 254 | strlcat(str_target, str, max_x); |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 255 | } |
lijuang | bdb18ea | 2018-02-06 17:21:18 +0800 | [diff] [blame] | 256 | return str_target; |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 257 | } |
| 258 | |
lijuang | f55ad05 | 2018-04-23 18:30:50 +0800 | [diff] [blame] | 259 | /** |
| 260 | Reset device unlock status |
| 261 | @param[in] Type The type of the unlock. |
| 262 | [DISPLAY_MENU_UNLOCK]: unlock the device |
| 263 | [DISPLAY_MENU_UNLOCK_CRITICAL]: critical unlock the device |
| 264 | [DISPLAY_MENU_LOCK]: lock the device |
| 265 | [DISPLAY_MENU_LOCK_CRITICAL]: critical lock the device |
| 266 | **/ |
| 267 | void reset_device_unlock_status (int type) |
| 268 | { |
| 269 | struct recovery_message msg; |
| 270 | |
| 271 | if (type == DISPLAY_MENU_LOCK || |
| 272 | type == DISPLAY_MENU_UNLOCK || |
| 273 | type == DISPLAY_MENU_LOCK_CRITICAL || |
| 274 | type == DISPLAY_MENU_UNLOCK_CRITICAL) { |
| 275 | set_device_unlock_value (munlock_info[type].unlock_type, |
| 276 | munlock_info[type].unlock_value); |
| 277 | memset(&msg, 0, sizeof(msg)); |
| 278 | snprintf(msg.recovery, sizeof(msg.recovery), "recovery\n--wipe_data"); |
| 279 | write_misc(0, &msg, sizeof(msg)); |
| 280 | } |
| 281 | } |
| 282 | |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 283 | /* msg_lock need to be holded when call this function. */ |
lijuang | f55ad05 | 2018-04-23 18:30:50 +0800 | [diff] [blame] | 284 | static void display_unlock_menu_renew(struct select_msg_info *unlock_msg_info, |
| 285 | int type, bool status) |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 286 | { |
| 287 | fbcon_clear(); |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 288 | memset(&unlock_msg_info->info, 0, sizeof(struct menu_info)); |
| 289 | |
lijuang | f55ad05 | 2018-04-23 18:30:50 +0800 | [diff] [blame] | 290 | display_fbcon_menu_message("<!>\n\n", |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 291 | FBCON_UNLOCK_TITLE_MSG, big_factor, 0); |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 292 | |
lijuang | f55ad05 | 2018-04-23 18:30:50 +0800 | [diff] [blame] | 293 | if (status) { |
| 294 | display_fbcon_menu_message((char*)unlock_menu_common_msg, |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 295 | FBCON_COMMON_MSG, common_factor, 0); |
lijuang | f55ad05 | 2018-04-23 18:30:50 +0800 | [diff] [blame] | 296 | } else { |
| 297 | display_fbcon_menu_message((char*)lock_menu_common_msg, |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 298 | FBCON_COMMON_MSG, common_factor, 0); |
lijuang | f55ad05 | 2018-04-23 18:30:50 +0800 | [diff] [blame] | 299 | } |
| 300 | |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 301 | fbcon_draw_line(FBCON_COMMON_MSG); |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 302 | unlock_msg_info->info.option_start[0] = fbcon_get_current_line(); |
lijuang | f55ad05 | 2018-04-23 18:30:50 +0800 | [diff] [blame] | 303 | display_fbcon_menu_message((char *)munlock_option_msg[status].ignore_msg, |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 304 | FBCON_COMMON_MSG, common_factor, 0); |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 305 | unlock_msg_info->info.option_bg[0] = fbcon_get_current_bg(); |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 306 | unlock_msg_info->info.option_end[0] = fbcon_get_current_line(); |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 307 | fbcon_draw_line(FBCON_COMMON_MSG); |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 308 | unlock_msg_info->info.option_start[1] = fbcon_get_current_line(); |
lijuang | f55ad05 | 2018-04-23 18:30:50 +0800 | [diff] [blame] | 309 | display_fbcon_menu_message((char *)munlock_option_msg[status].comfirm_msg, |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 310 | FBCON_COMMON_MSG, common_factor, 0); |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 311 | unlock_msg_info->info.option_bg[1] = fbcon_get_current_bg(); |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 312 | unlock_msg_info->info.option_end[1] = fbcon_get_current_line(); |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 313 | fbcon_draw_line(FBCON_COMMON_MSG); |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 314 | |
lijuang | f55ad05 | 2018-04-23 18:30:50 +0800 | [diff] [blame] | 315 | if (type == UNLOCK) { |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 316 | unlock_msg_info->info.msg_type = DISPLAY_MENU_UNLOCK; |
lijuang | f55ad05 | 2018-04-23 18:30:50 +0800 | [diff] [blame] | 317 | if (!status) |
| 318 | unlock_msg_info->info.msg_type = DISPLAY_MENU_LOCK; |
| 319 | } else if (type == UNLOCK_CRITICAL) { |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 320 | unlock_msg_info->info.msg_type = DISPLAY_MENU_UNLOCK_CRITICAL; |
lijuang | f55ad05 | 2018-04-23 18:30:50 +0800 | [diff] [blame] | 321 | if (!status) |
| 322 | unlock_msg_info->info.msg_type = DISPLAY_MENU_LOCK_CRITICAL; |
| 323 | } |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 324 | |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 325 | unlock_msg_info->info.option_num = 2; |
| 326 | |
| 327 | /* Initialize the option index */ |
| 328 | unlock_msg_info->info.option_index= 2; |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 329 | } |
| 330 | |
Monika Singh | 5e17036 | 2018-03-14 00:48:36 +0530 | [diff] [blame] | 331 | #if VERIFIED_BOOT || VERIFIED_BOOT_2 |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 332 | /* msg_lock need to be holded when call this function. */ |
| 333 | void display_bootverify_menu_renew(struct select_msg_info *msg_info, int type) |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 334 | { |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 335 | unsigned char* fp_buf = NULL; |
| 336 | char fp_str_temp[EVP_MAX_MD_SIZE] = {'\0'}; |
| 337 | char fp_str[EVP_MAX_MD_SIZE*2] = {'\0'}; |
| 338 | char str_temp[8]; |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 339 | uint32 fp_size = 0; |
| 340 | unsigned int i = 0; |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 341 | uint32_t timeout = DELAY_10SEC; |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 342 | |
| 343 | fbcon_clear(); |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 344 | memset(&msg_info->info, 0, sizeof(struct menu_info)); |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 345 | |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 346 | if(boot_verify_info[type].title_msg != NULL) |
| 347 | display_fbcon_menu_message((char*)boot_verify_info[type].title_msg, |
| 348 | boot_verify_info[type].msg_type, big_factor, 0); |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 349 | |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 350 | if(boot_verify_info[type].warning_msg != NULL) |
| 351 | display_fbcon_menu_message((char*)boot_verify_info[type].warning_msg, |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 352 | FBCON_COMMON_MSG, common_factor, 0); |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 353 | |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 354 | if(boot_verify_info[type].url_msg != NULL) { |
| 355 | dprintf(INFO, "display_fbcon_menu_message: Location=%d\n", fbcon_get_current_line()); |
Brahmaji K | 0c2d598 | 2017-09-07 18:44:21 +0530 | [diff] [blame] | 356 | display_fbcon_menu_message((char*)boot_verify_info[type].url_msg, |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 357 | boot_verify_info[type].msg_type, common_factor, 0); |
| 358 | dprintf(INFO, "display_fbcon_menu_message: Location=%d\n", fbcon_get_current_line()); |
| 359 | } |
| 360 | |
| 361 | if(boot_verify_info[type].notice_msg != NULL) { |
| 362 | msg_info->info.option_start[0] = fbcon_get_current_line(); |
| 363 | dprintf(INFO, "display_fbcon_menu_message: Location=%d\n", msg_info->info.option_start[0]); |
| 364 | display_fbcon_menu_message((char*)boot_verify_info[type].notice_msg, |
| 365 | FBCON_COMMON_MSG, common_factor, 0); |
| 366 | msg_info->info.option_end[0] = fbcon_get_current_line(); |
| 367 | } |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 368 | |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 369 | if (type == DISPLAY_MENU_YELLOW) { |
| 370 | fp_buf = get_boot_fingerprint(&fp_size); |
| 371 | if (fp_buf != NULL) { |
Parth Dixit | 73d3bd0 | 2016-01-07 14:29:41 +0530 | [diff] [blame] | 372 | strlcpy(fp_str_temp, (char const *)fp_buf, fp_size); |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 373 | for (i = 0; i < fp_size; i++) { |
| 374 | if(i == fp_size - 1) |
Parth Dixit | 73d3bd0 | 2016-01-07 14:29:41 +0530 | [diff] [blame] | 375 | snprintf(str_temp, sizeof(str_temp), "%02x", fp_str_temp[i]); |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 376 | else |
Parth Dixit | 73d3bd0 | 2016-01-07 14:29:41 +0530 | [diff] [blame] | 377 | snprintf(str_temp, sizeof(str_temp), "%02x-", fp_str_temp[i]); |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 378 | |
Parth Dixit | 73d3bd0 | 2016-01-07 14:29:41 +0530 | [diff] [blame] | 379 | strlcat(fp_str, str_temp, sizeof(fp_str)); |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 380 | } |
| 381 | } |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 382 | display_fbcon_menu_message("ID:", FBCON_COMMON_MSG, common_factor, 0); |
| 383 | display_fbcon_menu_message(fp_str, FBCON_COMMON_MSG, common_factor, 0); |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 384 | } |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 385 | |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 386 | switch (type) { |
| 387 | case DISPLAY_MENU_RED: |
| 388 | timeout = DELAY_30SEC; |
| 389 | break; |
| 390 | case DISPLAY_MENU_EIO: |
Parth Dixit | 54ac3bb | 2017-03-07 15:52:48 +0530 | [diff] [blame] | 391 | #if ENABLE_VB_ATTEST |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 392 | timeout = DELAY_30SEC; |
Parth Dixit | 54ac3bb | 2017-03-07 15:52:48 +0530 | [diff] [blame] | 393 | #endif |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 394 | break; |
| 395 | default: |
| 396 | timeout = DELAY_10SEC; |
| 397 | break; |
| 398 | } |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 399 | |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 400 | msg_info->info.msg_type = type; |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 401 | |
| 402 | /* Initialize the time out time */ |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 403 | msg_info->info.timeout_time = timeout; |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 404 | } |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 405 | |
| 406 | void display_bootverify_menu_update (struct select_msg_info *msg_info) |
| 407 | { |
| 408 | int location = msg_info->info.option_start[0]; |
| 409 | |
| 410 | /* clean the old msg */ |
| 411 | fbcon_clear_msg (location, msg_info->info.option_end[0]); |
| 412 | display_fbcon_menu_message(CONTINUE_BOOT_MSG, FBCON_COMMON_MSG, common_factor, location); |
| 413 | msg_info->info.timeout_time = DELAY_30SEC; |
| 414 | } |
| 415 | |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 416 | #endif |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 417 | |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 418 | /* msg_lock need to be holded when call this function. */ |
| 419 | void display_bootverify_option_menu_renew(struct select_msg_info *msg_info) |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 420 | { |
| 421 | int i = 0; |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 422 | int len = 0; |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 423 | |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 424 | fbcon_clear(); |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 425 | memset(&msg_info->info, 0, sizeof(struct menu_info)); |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 426 | |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 427 | len = ARRAY_SIZE(verify_option_menu); |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 428 | display_fbcon_menu_message("Options menu:\n\n", |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 429 | FBCON_COMMON_MSG, big_factor, 0); |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 430 | display_fbcon_menu_message("Press volume key to select, and "\ |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 431 | "press power key to select\n\n", FBCON_COMMON_MSG, common_factor, 0); |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 432 | |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 433 | for (i = 0; i < len; i++) { |
| 434 | fbcon_draw_line(FBCON_COMMON_MSG); |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 435 | msg_info->info.option_start[i] = fbcon_get_current_line(); |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 436 | display_fbcon_menu_message(verify_option_menu[i], |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 437 | FBCON_COMMON_MSG, common_factor, 0); |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 438 | msg_info->info.option_bg[i]= fbcon_get_current_bg(); |
| 439 | msg_info->info.option_end[i]= fbcon_get_current_line(); |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 440 | } |
| 441 | |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 442 | fbcon_draw_line(FBCON_COMMON_MSG); |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 443 | msg_info->info.msg_type = DISPLAY_MENU_MORE_OPTION; |
| 444 | msg_info->info.option_num = len; |
| 445 | |
| 446 | /* Initialize the option index */ |
| 447 | msg_info->info.option_index= len; |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 448 | } |
| 449 | |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 450 | /* msg_lock need to be holded when call this function. */ |
| 451 | void display_fastboot_menu_renew(struct select_msg_info *fastboot_msg_info) |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 452 | { |
| 453 | int len; |
| 454 | int msg_type = FBCON_COMMON_MSG; |
| 455 | char msg_buf[64]; |
| 456 | char msg[128]; |
| 457 | |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 458 | /* The fastboot menu is switched base on the option index |
| 459 | * So it's need to store the index for the menu switching |
| 460 | */ |
| 461 | uint32_t option_index = fastboot_msg_info->info.option_index; |
| 462 | |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 463 | fbcon_clear(); |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 464 | memset(&fastboot_msg_info->info, 0, sizeof(struct menu_info)); |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 465 | |
| 466 | len = ARRAY_SIZE(fastboot_option_menu); |
| 467 | switch(option_index) { |
| 468 | case 0: |
| 469 | msg_type = FBCON_GREEN_MSG; |
| 470 | break; |
| 471 | case 1: |
| 472 | case 2: |
| 473 | msg_type = FBCON_RED_MSG; |
| 474 | break; |
| 475 | case 3: |
lijuang | 42aefaa | 2016-04-14 15:55:17 +0800 | [diff] [blame] | 476 | case 4: |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 477 | msg_type = FBCON_COMMON_MSG; |
| 478 | break; |
| 479 | } |
| 480 | fbcon_draw_line(msg_type); |
| 481 | display_fbcon_menu_message(fastboot_option_menu[option_index], |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 482 | msg_type, big_factor, 0); |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 483 | fbcon_draw_line(msg_type); |
| 484 | display_fbcon_menu_message("\n\nPress volume key to select, and "\ |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 485 | "press power key to select\n\n", FBCON_COMMON_MSG, common_factor, 0); |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 486 | |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 487 | display_fbcon_menu_message("FASTBOOT MODE\n", FBCON_RED_MSG, common_factor, 0); |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 488 | |
| 489 | get_product_name((unsigned char *) msg_buf); |
| 490 | snprintf(msg, sizeof(msg), "PRODUCT_NAME - %s\n", msg_buf); |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 491 | display_fbcon_menu_message(msg, FBCON_COMMON_MSG, common_factor, 0); |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 492 | |
| 493 | memset(msg_buf, 0, sizeof(msg_buf)); |
| 494 | smem_get_hw_platform_name((unsigned char *) msg_buf, sizeof(msg_buf)); |
| 495 | snprintf(msg, sizeof(msg), "VARIANT - %s %s\n", |
| 496 | msg_buf, target_is_emmc_boot()? "eMMC":"UFS"); |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 497 | display_fbcon_menu_message(msg, FBCON_COMMON_MSG, common_factor, 0); |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 498 | |
| 499 | memset(msg_buf, 0, sizeof(msg_buf)); |
| 500 | get_bootloader_version((unsigned char *) msg_buf); |
| 501 | snprintf(msg, sizeof(msg), "BOOTLOADER VERSION - %s\n", |
| 502 | msg_buf); |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 503 | display_fbcon_menu_message(msg, FBCON_COMMON_MSG, common_factor, 0); |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 504 | |
| 505 | memset(msg_buf, 0, sizeof(msg_buf)); |
| 506 | get_baseband_version((unsigned char *) msg_buf); |
| 507 | snprintf(msg, sizeof(msg), "BASEBAND VERSION - %s\n", |
| 508 | msg_buf); |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 509 | display_fbcon_menu_message(msg, FBCON_COMMON_MSG, common_factor, 0); |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 510 | |
| 511 | memset(msg_buf, 0, sizeof(msg_buf)); |
| 512 | target_serialno((unsigned char *) msg_buf); |
| 513 | snprintf(msg, sizeof(msg), "SERIAL NUMBER - %s\n", msg_buf); |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 514 | display_fbcon_menu_message(msg, FBCON_COMMON_MSG, common_factor, 0); |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 515 | |
| 516 | snprintf(msg, sizeof(msg), "SECURE BOOT - %s\n", |
| 517 | is_secure_boot_enable()? "enabled":"disabled"); |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 518 | display_fbcon_menu_message(msg, FBCON_COMMON_MSG, common_factor, 0); |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 519 | |
| 520 | snprintf(msg, sizeof(msg), "DEVICE STATE - %s\n", |
| 521 | is_device_locked()? "locked":"unlocked"); |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 522 | display_fbcon_menu_message(msg, FBCON_RED_MSG, common_factor, 0); |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 523 | |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 524 | fastboot_msg_info->info.msg_type = DISPLAY_MENU_FASTBOOT; |
| 525 | fastboot_msg_info->info.option_num = len; |
| 526 | fastboot_msg_info->info.option_index = option_index; |
| 527 | } |
| 528 | |
| 529 | void msg_lock_init() |
| 530 | { |
| 531 | static bool is_msg_lock_init = false; |
| 532 | struct select_msg_info *msg_lock_info; |
| 533 | msg_lock_info = &msg_info; |
| 534 | |
| 535 | if (!is_msg_lock_init) { |
| 536 | mutex_init(&msg_lock_info->msg_lock); |
| 537 | is_msg_lock_init = true; |
| 538 | } |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 539 | } |
| 540 | |
| 541 | static void display_menu_thread_start(struct select_msg_info *msg_info) |
| 542 | { |
| 543 | thread_t *thr; |
| 544 | |
| 545 | if (!is_thread_start) { |
| 546 | thr = thread_create("selectkeydetect", &select_msg_keys_detect, |
| 547 | (void*)msg_info, DEFAULT_PRIORITY, DEFAULT_STACK_SIZE); |
| 548 | if (!thr) { |
| 549 | dprintf(CRITICAL, "ERROR: creat device status detect thread failed!!\n"); |
| 550 | return; |
| 551 | } |
| 552 | thread_resume(thr); |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 553 | is_thread_start = true; |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 554 | } |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 555 | } |
| 556 | |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 557 | /* The fuction be called after device in fastboot mode, |
| 558 | * so it's no need to initialize the msg_lock again |
| 559 | */ |
lijuang | f55ad05 | 2018-04-23 18:30:50 +0800 | [diff] [blame] | 560 | void display_unlock_menu(int type, bool status) |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 561 | { |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 562 | struct select_msg_info *unlock_menu_msg_info; |
| 563 | unlock_menu_msg_info = &msg_info; |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 564 | |
Krishna Manikandan | f2c8be9 | 2017-12-05 18:07:56 +0530 | [diff] [blame] | 565 | if (is_display_disabled()) |
| 566 | return; |
| 567 | |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 568 | set_message_factor(); |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 569 | |
| 570 | msg_lock_init(); |
| 571 | mutex_acquire(&unlock_menu_msg_info->msg_lock); |
| 572 | |
| 573 | /* Initialize the last_msg_type */ |
| 574 | unlock_menu_msg_info->last_msg_type = |
| 575 | unlock_menu_msg_info->info.msg_type; |
| 576 | |
lijuang | f55ad05 | 2018-04-23 18:30:50 +0800 | [diff] [blame] | 577 | display_unlock_menu_renew(unlock_menu_msg_info, type, status); |
jialongjhan | b2dda0b | 2020-04-21 20:20:51 +0800 | [diff] [blame] | 578 | //[Arima][8901][JialongJhan] Command mode update screen 20190618 Start |
| 579 | msm_display_flush(); |
| 580 | //[Arima][8901][JialongJhan] Command mode update screen 20190618 End |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 581 | mutex_release(&unlock_menu_msg_info->msg_lock); |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 582 | |
lijuang | f55ad05 | 2018-04-23 18:30:50 +0800 | [diff] [blame] | 583 | dprintf(INFO, "creating %s keys detect thread\n", |
| 584 | status ? "unlock":"lock"); |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 585 | display_menu_thread_start(unlock_menu_msg_info); |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 586 | } |
| 587 | |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 588 | void display_fastboot_menu() |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 589 | { |
| 590 | struct select_msg_info *fastboot_menu_msg_info; |
| 591 | fastboot_menu_msg_info = &msg_info; |
| 592 | |
Krishna Manikandan | f2c8be9 | 2017-12-05 18:07:56 +0530 | [diff] [blame] | 593 | if (is_display_disabled()) |
| 594 | return; |
| 595 | |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 596 | set_message_factor(); |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 597 | |
| 598 | msg_lock_init(); |
| 599 | mutex_acquire(&fastboot_menu_msg_info->msg_lock); |
| 600 | |
| 601 | /* There are 4 pages for fastboot menu: |
| 602 | * Page: Start/Fastboot/Recovery/Poweroff |
| 603 | * The menu is switched base on the option index |
| 604 | * Initialize the option index and last_msg_type |
| 605 | */ |
| 606 | fastboot_menu_msg_info->info.option_index = 0; |
| 607 | fastboot_menu_msg_info->last_msg_type = |
| 608 | fastboot_menu_msg_info->info.msg_type; |
| 609 | |
| 610 | display_fastboot_menu_renew(fastboot_menu_msg_info); |
jialongjhan | b2dda0b | 2020-04-21 20:20:51 +0800 | [diff] [blame] | 611 | //[Arima][8901][JialongJhan] Command mode update screen 20190618 Start |
| 612 | msm_display_flush(); |
| 613 | //[Arima][8901][JialongJhan] Command mode update screen 20190618 End |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 614 | mutex_release(&fastboot_menu_msg_info->msg_lock); |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 615 | |
| 616 | dprintf(INFO, "creating fastboot menu keys detect thread\n"); |
| 617 | display_menu_thread_start(fastboot_menu_msg_info); |
| 618 | } |
| 619 | |
Monika Singh | 5e17036 | 2018-03-14 00:48:36 +0530 | [diff] [blame] | 620 | #if VERIFIED_BOOT || VERIFIED_BOOT_2 |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 621 | void display_bootverify_menu(int type) |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 622 | { |
| 623 | struct select_msg_info *bootverify_menu_msg_info; |
| 624 | bootverify_menu_msg_info = &msg_info; |
| 625 | |
Krishna Manikandan | f2c8be9 | 2017-12-05 18:07:56 +0530 | [diff] [blame] | 626 | if (is_display_disabled()) |
| 627 | return; |
| 628 | |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 629 | set_message_factor(); |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 630 | |
| 631 | msg_lock_init(); |
| 632 | mutex_acquire(&bootverify_menu_msg_info->msg_lock); |
| 633 | |
| 634 | /* Initialize the last_msg_type */ |
| 635 | bootverify_menu_msg_info->last_msg_type = |
| 636 | bootverify_menu_msg_info->info.msg_type; |
| 637 | |
| 638 | display_bootverify_menu_renew(bootverify_menu_msg_info, type); |
jialongjhan | b2dda0b | 2020-04-21 20:20:51 +0800 | [diff] [blame] | 639 | //[Arima][8901][JialongJhan] Command mode update screen 201906118 Start |
| 640 | msm_display_flush(); |
| 641 | //[Arima][8901][JialongJhan] Command mode update screen 20190618 End |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 642 | mutex_release(&bootverify_menu_msg_info->msg_lock); |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 643 | |
| 644 | dprintf(INFO, "creating boot verify keys detect thread\n"); |
| 645 | display_menu_thread_start(bootverify_menu_msg_info); |
| 646 | } |
| 647 | #endif |