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 | |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 128 | static char *fastboot_option_menu[] = { |
| 129 | [0] = "START\n", |
| 130 | [1] = "Restart bootloader\n", |
| 131 | [2] = "Recovery mode\n", |
lijuang | 42aefaa | 2016-04-14 15:55:17 +0800 | [diff] [blame] | 132 | [3] = "Power off\n", |
| 133 | [4] = "Boot to FFBM\n"}; |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 134 | |
lijuang | f55ad05 | 2018-04-23 18:30:50 +0800 | [diff] [blame] | 135 | static struct unlock_info munlock_info[] = { |
| 136 | [DISPLAY_MENU_LOCK] = {UNLOCK, FALSE}, |
| 137 | [DISPLAY_MENU_UNLOCK] = {UNLOCK, TRUE}, |
| 138 | [DISPLAY_MENU_LOCK_CRITICAL] = {UNLOCK_CRITICAL, FALSE}, |
| 139 | [DISPLAY_MENU_UNLOCK_CRITICAL] = {UNLOCK_CRITICAL, TRUE}, |
| 140 | }; |
| 141 | |
| 142 | struct unlock_option_msg munlock_option_msg[] = { |
| 143 | [TRUE] = {"DO NOT UNLOCK THE BOOTLOADER \n", "UNLOCK THE BOOTLOADER \n"}, |
| 144 | [FALSE] = {"DO NOT LOCK THE BOOTLOADER \n", "LOCK THE BOOTLOADER \n"}, |
| 145 | }; |
| 146 | |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 147 | static int big_factor = 2; |
| 148 | static int common_factor = 1; |
| 149 | |
lijuang | de34d50 | 2016-02-26 16:04:50 +0800 | [diff] [blame] | 150 | static void wait_for_exit() |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 151 | { |
| 152 | struct select_msg_info *select_msg; |
| 153 | select_msg = &msg_info; |
| 154 | |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 155 | mutex_acquire(&select_msg->msg_lock); |
lijuang | de34d50 | 2016-02-26 16:04:50 +0800 | [diff] [blame] | 156 | while(!select_msg->info.rel_exit == true) { |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 157 | mutex_release(&select_msg->msg_lock); |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 158 | thread_sleep(10); |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 159 | mutex_acquire(&select_msg->msg_lock); |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 160 | } |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 161 | mutex_release(&select_msg->msg_lock); |
| 162 | |
lijuang | de34d50 | 2016-02-26 16:04:50 +0800 | [diff] [blame] | 163 | is_thread_start = false; |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 164 | fbcon_clear(); |
| 165 | display_image_on_screen(); |
jialongjhan | b2dda0b | 2020-04-21 20:20:51 +0800 | [diff] [blame^] | 166 | //[Arima][8901][JialongJhan] Command mode update screen 20190618 Start |
| 167 | msm_display_flush(); |
| 168 | //[Arima][8901][JialongJhan] Command mode update screen 20190618 End |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 169 | } |
| 170 | |
lijuang | de34d50 | 2016-02-26 16:04:50 +0800 | [diff] [blame] | 171 | void wait_for_users_action() |
| 172 | { |
Krishna Manikandan | f2c8be9 | 2017-12-05 18:07:56 +0530 | [diff] [blame] | 173 | if (is_display_disabled()) |
| 174 | return; |
lijuang | de34d50 | 2016-02-26 16:04:50 +0800 | [diff] [blame] | 175 | /* Waiting for exit menu keys detection if there is no any usr action |
| 176 | * otherwise it will do the action base on the keys detection thread |
| 177 | */ |
| 178 | wait_for_exit(); |
| 179 | } |
| 180 | |
| 181 | void exit_menu_keys_detection() |
| 182 | { |
| 183 | struct select_msg_info *select_msg; |
| 184 | select_msg = &msg_info; |
| 185 | |
Krishna Manikandan | f2c8be9 | 2017-12-05 18:07:56 +0530 | [diff] [blame] | 186 | if (is_display_disabled()) |
| 187 | return; |
| 188 | |
lijuang | de34d50 | 2016-02-26 16:04:50 +0800 | [diff] [blame] | 189 | mutex_acquire(&select_msg->msg_lock); |
| 190 | select_msg->info.is_exit = true; |
| 191 | mutex_release(&select_msg->msg_lock); |
| 192 | |
| 193 | wait_for_exit(); |
| 194 | } |
| 195 | |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 196 | static void set_message_factor() |
| 197 | { |
| 198 | uint32_t tmp_factor = 0; |
lijuang | 9e73e5a | 2018-04-23 17:00:16 +0800 | [diff] [blame] | 199 | uint32_t max_x_count = 0; |
| 200 | uint32_t max_x = 0; |
| 201 | |
| 202 | if (fbcon_get_width() < fbcon_get_height()) |
| 203 | max_x_count = CHAR_NUM_PERROW_POR; |
| 204 | else |
| 205 | max_x_count = CHAR_NUM_PERROW_HOR; |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 206 | |
| 207 | max_x = fbcon_get_max_x(); |
| 208 | tmp_factor = max_x/max_x_count; |
| 209 | |
| 210 | if(tmp_factor <= 1) { |
| 211 | big_factor = 2; |
| 212 | common_factor = 1; |
| 213 | } else { |
| 214 | big_factor = tmp_factor*2; |
| 215 | common_factor = tmp_factor; |
| 216 | } |
| 217 | } |
| 218 | |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 219 | /* If y_start == 0, it will draw message from the current Y axis location, |
| 220 | otherwise it will start from the the value of y_start. */ |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 221 | static void display_fbcon_menu_message(char *str, unsigned type, |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 222 | unsigned scale_factor, int y_start) |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 223 | { |
| 224 | while(*str != 0) { |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 225 | fbcon_putc_factor(*str++, type, scale_factor, y_start); |
| 226 | y_start = 0; |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 227 | } |
| 228 | } |
| 229 | |
| 230 | static char *str_align_right(char *str, int factor) |
| 231 | { |
| 232 | uint32_t max_x = 0; |
| 233 | int diff = 0; |
| 234 | int i = 0; |
| 235 | char *str_target = NULL; |
| 236 | |
| 237 | max_x = fbcon_get_max_x(); |
| 238 | if (!str_target && max_x) { |
| 239 | str_target = malloc(max_x); |
| 240 | } |
| 241 | |
| 242 | if (str_target) { |
| 243 | memset(str_target, 0, max_x); |
| 244 | if ( max_x/factor > strlen(str)) { |
| 245 | if (factor == 1) |
| 246 | diff = max_x/factor - strlen(str) - 1; |
| 247 | else |
| 248 | diff = max_x/factor - strlen(str); |
| 249 | for (i = 0; i < diff; i++) { |
Parth Dixit | 73d3bd0 | 2016-01-07 14:29:41 +0530 | [diff] [blame] | 250 | strlcat(str_target, " ", max_x); |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 251 | } |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 252 | } |
lijuang | bdb18ea | 2018-02-06 17:21:18 +0800 | [diff] [blame] | 253 | strlcat(str_target, str, max_x); |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 254 | } |
lijuang | bdb18ea | 2018-02-06 17:21:18 +0800 | [diff] [blame] | 255 | return str_target; |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 256 | } |
| 257 | |
lijuang | f55ad05 | 2018-04-23 18:30:50 +0800 | [diff] [blame] | 258 | /** |
| 259 | Reset device unlock status |
| 260 | @param[in] Type The type of the unlock. |
| 261 | [DISPLAY_MENU_UNLOCK]: unlock the device |
| 262 | [DISPLAY_MENU_UNLOCK_CRITICAL]: critical unlock the device |
| 263 | [DISPLAY_MENU_LOCK]: lock the device |
| 264 | [DISPLAY_MENU_LOCK_CRITICAL]: critical lock the device |
| 265 | **/ |
| 266 | void reset_device_unlock_status (int type) |
| 267 | { |
| 268 | struct recovery_message msg; |
| 269 | |
| 270 | if (type == DISPLAY_MENU_LOCK || |
| 271 | type == DISPLAY_MENU_UNLOCK || |
| 272 | type == DISPLAY_MENU_LOCK_CRITICAL || |
| 273 | type == DISPLAY_MENU_UNLOCK_CRITICAL) { |
| 274 | set_device_unlock_value (munlock_info[type].unlock_type, |
| 275 | munlock_info[type].unlock_value); |
| 276 | memset(&msg, 0, sizeof(msg)); |
| 277 | snprintf(msg.recovery, sizeof(msg.recovery), "recovery\n--wipe_data"); |
| 278 | write_misc(0, &msg, sizeof(msg)); |
| 279 | } |
| 280 | } |
| 281 | |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 282 | /* msg_lock need to be holded when call this function. */ |
lijuang | f55ad05 | 2018-04-23 18:30:50 +0800 | [diff] [blame] | 283 | static void display_unlock_menu_renew(struct select_msg_info *unlock_msg_info, |
| 284 | int type, bool status) |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 285 | { |
| 286 | fbcon_clear(); |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 287 | memset(&unlock_msg_info->info, 0, sizeof(struct menu_info)); |
| 288 | |
lijuang | f55ad05 | 2018-04-23 18:30:50 +0800 | [diff] [blame] | 289 | display_fbcon_menu_message("<!>\n\n", |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 290 | FBCON_UNLOCK_TITLE_MSG, big_factor, 0); |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 291 | |
lijuang | f55ad05 | 2018-04-23 18:30:50 +0800 | [diff] [blame] | 292 | if (status) { |
| 293 | display_fbcon_menu_message((char*)unlock_menu_common_msg, |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 294 | FBCON_COMMON_MSG, common_factor, 0); |
lijuang | f55ad05 | 2018-04-23 18:30:50 +0800 | [diff] [blame] | 295 | } else { |
| 296 | display_fbcon_menu_message((char*)lock_menu_common_msg, |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 297 | FBCON_COMMON_MSG, common_factor, 0); |
lijuang | f55ad05 | 2018-04-23 18:30:50 +0800 | [diff] [blame] | 298 | } |
| 299 | |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 300 | fbcon_draw_line(FBCON_COMMON_MSG); |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 301 | unlock_msg_info->info.option_start[0] = fbcon_get_current_line(); |
lijuang | f55ad05 | 2018-04-23 18:30:50 +0800 | [diff] [blame] | 302 | display_fbcon_menu_message((char *)munlock_option_msg[status].ignore_msg, |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 303 | FBCON_COMMON_MSG, common_factor, 0); |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 304 | unlock_msg_info->info.option_bg[0] = fbcon_get_current_bg(); |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 305 | unlock_msg_info->info.option_end[0] = fbcon_get_current_line(); |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 306 | fbcon_draw_line(FBCON_COMMON_MSG); |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 307 | unlock_msg_info->info.option_start[1] = fbcon_get_current_line(); |
lijuang | f55ad05 | 2018-04-23 18:30:50 +0800 | [diff] [blame] | 308 | display_fbcon_menu_message((char *)munlock_option_msg[status].comfirm_msg, |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 309 | FBCON_COMMON_MSG, common_factor, 0); |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 310 | unlock_msg_info->info.option_bg[1] = fbcon_get_current_bg(); |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 311 | unlock_msg_info->info.option_end[1] = fbcon_get_current_line(); |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 312 | fbcon_draw_line(FBCON_COMMON_MSG); |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 313 | |
lijuang | f55ad05 | 2018-04-23 18:30:50 +0800 | [diff] [blame] | 314 | if (type == UNLOCK) { |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 315 | unlock_msg_info->info.msg_type = DISPLAY_MENU_UNLOCK; |
lijuang | f55ad05 | 2018-04-23 18:30:50 +0800 | [diff] [blame] | 316 | if (!status) |
| 317 | unlock_msg_info->info.msg_type = DISPLAY_MENU_LOCK; |
| 318 | } else if (type == UNLOCK_CRITICAL) { |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 319 | unlock_msg_info->info.msg_type = DISPLAY_MENU_UNLOCK_CRITICAL; |
lijuang | f55ad05 | 2018-04-23 18:30:50 +0800 | [diff] [blame] | 320 | if (!status) |
| 321 | unlock_msg_info->info.msg_type = DISPLAY_MENU_LOCK_CRITICAL; |
| 322 | } |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 323 | |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 324 | unlock_msg_info->info.option_num = 2; |
| 325 | |
| 326 | /* Initialize the option index */ |
| 327 | unlock_msg_info->info.option_index= 2; |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 328 | } |
| 329 | |
Monika Singh | 5e17036 | 2018-03-14 00:48:36 +0530 | [diff] [blame] | 330 | #if VERIFIED_BOOT || VERIFIED_BOOT_2 |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 331 | /* msg_lock need to be holded when call this function. */ |
| 332 | void display_bootverify_menu_renew(struct select_msg_info *msg_info, int type) |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 333 | { |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 334 | unsigned char* fp_buf = NULL; |
| 335 | char fp_str_temp[EVP_MAX_MD_SIZE] = {'\0'}; |
| 336 | char fp_str[EVP_MAX_MD_SIZE*2] = {'\0'}; |
| 337 | char str_temp[8]; |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 338 | uint32 fp_size = 0; |
| 339 | unsigned int i = 0; |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 340 | uint32_t timeout = DELAY_10SEC; |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 341 | |
| 342 | fbcon_clear(); |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 343 | memset(&msg_info->info, 0, sizeof(struct menu_info)); |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 344 | |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 345 | if(boot_verify_info[type].title_msg != NULL) |
| 346 | display_fbcon_menu_message((char*)boot_verify_info[type].title_msg, |
| 347 | boot_verify_info[type].msg_type, big_factor, 0); |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 348 | |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 349 | if(boot_verify_info[type].warning_msg != NULL) |
| 350 | display_fbcon_menu_message((char*)boot_verify_info[type].warning_msg, |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 351 | FBCON_COMMON_MSG, common_factor, 0); |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 352 | |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 353 | if(boot_verify_info[type].url_msg != NULL) { |
| 354 | 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] | 355 | display_fbcon_menu_message((char*)boot_verify_info[type].url_msg, |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 356 | boot_verify_info[type].msg_type, common_factor, 0); |
| 357 | dprintf(INFO, "display_fbcon_menu_message: Location=%d\n", fbcon_get_current_line()); |
| 358 | } |
| 359 | |
| 360 | if(boot_verify_info[type].notice_msg != NULL) { |
| 361 | msg_info->info.option_start[0] = fbcon_get_current_line(); |
| 362 | dprintf(INFO, "display_fbcon_menu_message: Location=%d\n", msg_info->info.option_start[0]); |
| 363 | display_fbcon_menu_message((char*)boot_verify_info[type].notice_msg, |
| 364 | FBCON_COMMON_MSG, common_factor, 0); |
| 365 | msg_info->info.option_end[0] = fbcon_get_current_line(); |
| 366 | } |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 367 | |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 368 | if (type == DISPLAY_MENU_YELLOW) { |
| 369 | fp_buf = get_boot_fingerprint(&fp_size); |
| 370 | if (fp_buf != NULL) { |
Parth Dixit | 73d3bd0 | 2016-01-07 14:29:41 +0530 | [diff] [blame] | 371 | strlcpy(fp_str_temp, (char const *)fp_buf, fp_size); |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 372 | for (i = 0; i < fp_size; i++) { |
| 373 | if(i == fp_size - 1) |
Parth Dixit | 73d3bd0 | 2016-01-07 14:29:41 +0530 | [diff] [blame] | 374 | snprintf(str_temp, sizeof(str_temp), "%02x", fp_str_temp[i]); |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 375 | else |
Parth Dixit | 73d3bd0 | 2016-01-07 14:29:41 +0530 | [diff] [blame] | 376 | snprintf(str_temp, sizeof(str_temp), "%02x-", fp_str_temp[i]); |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 377 | |
Parth Dixit | 73d3bd0 | 2016-01-07 14:29:41 +0530 | [diff] [blame] | 378 | strlcat(fp_str, str_temp, sizeof(fp_str)); |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 379 | } |
| 380 | } |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 381 | display_fbcon_menu_message("ID:", FBCON_COMMON_MSG, common_factor, 0); |
| 382 | display_fbcon_menu_message(fp_str, FBCON_COMMON_MSG, common_factor, 0); |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 383 | } |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 384 | |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 385 | switch (type) { |
| 386 | case DISPLAY_MENU_RED: |
| 387 | timeout = DELAY_30SEC; |
| 388 | break; |
| 389 | case DISPLAY_MENU_EIO: |
Parth Dixit | 54ac3bb | 2017-03-07 15:52:48 +0530 | [diff] [blame] | 390 | #if ENABLE_VB_ATTEST |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 391 | timeout = DELAY_30SEC; |
Parth Dixit | 54ac3bb | 2017-03-07 15:52:48 +0530 | [diff] [blame] | 392 | #endif |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 393 | break; |
| 394 | default: |
| 395 | timeout = DELAY_10SEC; |
| 396 | break; |
| 397 | } |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 398 | |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 399 | msg_info->info.msg_type = type; |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 400 | |
| 401 | /* Initialize the time out time */ |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 402 | msg_info->info.timeout_time = timeout; |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 403 | } |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 404 | |
| 405 | void display_bootverify_menu_update (struct select_msg_info *msg_info) |
| 406 | { |
| 407 | int location = msg_info->info.option_start[0]; |
| 408 | |
| 409 | /* clean the old msg */ |
| 410 | fbcon_clear_msg (location, msg_info->info.option_end[0]); |
| 411 | display_fbcon_menu_message(CONTINUE_BOOT_MSG, FBCON_COMMON_MSG, common_factor, location); |
| 412 | msg_info->info.timeout_time = DELAY_30SEC; |
| 413 | } |
| 414 | |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 415 | #endif |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 416 | |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 417 | /* msg_lock need to be holded when call this function. */ |
| 418 | void display_bootverify_option_menu_renew(struct select_msg_info *msg_info) |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 419 | { |
| 420 | int i = 0; |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 421 | int len = 0; |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 422 | |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 423 | fbcon_clear(); |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 424 | memset(&msg_info->info, 0, sizeof(struct menu_info)); |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 425 | |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 426 | len = ARRAY_SIZE(verify_option_menu); |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 427 | display_fbcon_menu_message("Options menu:\n\n", |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 428 | FBCON_COMMON_MSG, big_factor, 0); |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 429 | display_fbcon_menu_message("Press volume key to select, and "\ |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 430 | "press power key to select\n\n", FBCON_COMMON_MSG, common_factor, 0); |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 431 | |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 432 | for (i = 0; i < len; i++) { |
| 433 | fbcon_draw_line(FBCON_COMMON_MSG); |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 434 | msg_info->info.option_start[i] = fbcon_get_current_line(); |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 435 | display_fbcon_menu_message(verify_option_menu[i], |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 436 | FBCON_COMMON_MSG, common_factor, 0); |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 437 | msg_info->info.option_bg[i]= fbcon_get_current_bg(); |
| 438 | msg_info->info.option_end[i]= fbcon_get_current_line(); |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 439 | } |
| 440 | |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 441 | fbcon_draw_line(FBCON_COMMON_MSG); |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 442 | msg_info->info.msg_type = DISPLAY_MENU_MORE_OPTION; |
| 443 | msg_info->info.option_num = len; |
| 444 | |
| 445 | /* Initialize the option index */ |
| 446 | msg_info->info.option_index= len; |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 447 | } |
| 448 | |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 449 | /* msg_lock need to be holded when call this function. */ |
| 450 | void display_fastboot_menu_renew(struct select_msg_info *fastboot_msg_info) |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 451 | { |
| 452 | int len; |
| 453 | int msg_type = FBCON_COMMON_MSG; |
| 454 | char msg_buf[64]; |
| 455 | char msg[128]; |
| 456 | |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 457 | /* The fastboot menu is switched base on the option index |
| 458 | * So it's need to store the index for the menu switching |
| 459 | */ |
| 460 | uint32_t option_index = fastboot_msg_info->info.option_index; |
| 461 | |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 462 | fbcon_clear(); |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 463 | memset(&fastboot_msg_info->info, 0, sizeof(struct menu_info)); |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 464 | |
| 465 | len = ARRAY_SIZE(fastboot_option_menu); |
| 466 | switch(option_index) { |
| 467 | case 0: |
| 468 | msg_type = FBCON_GREEN_MSG; |
| 469 | break; |
| 470 | case 1: |
| 471 | case 2: |
| 472 | msg_type = FBCON_RED_MSG; |
| 473 | break; |
| 474 | case 3: |
lijuang | 42aefaa | 2016-04-14 15:55:17 +0800 | [diff] [blame] | 475 | case 4: |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 476 | msg_type = FBCON_COMMON_MSG; |
| 477 | break; |
| 478 | } |
| 479 | fbcon_draw_line(msg_type); |
| 480 | display_fbcon_menu_message(fastboot_option_menu[option_index], |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 481 | msg_type, big_factor, 0); |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 482 | fbcon_draw_line(msg_type); |
| 483 | display_fbcon_menu_message("\n\nPress volume key to select, and "\ |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 484 | "press power key to select\n\n", FBCON_COMMON_MSG, common_factor, 0); |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 485 | |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 486 | display_fbcon_menu_message("FASTBOOT MODE\n", FBCON_RED_MSG, common_factor, 0); |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 487 | |
| 488 | get_product_name((unsigned char *) msg_buf); |
| 489 | snprintf(msg, sizeof(msg), "PRODUCT_NAME - %s\n", msg_buf); |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 490 | display_fbcon_menu_message(msg, FBCON_COMMON_MSG, common_factor, 0); |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 491 | |
| 492 | memset(msg_buf, 0, sizeof(msg_buf)); |
| 493 | smem_get_hw_platform_name((unsigned char *) msg_buf, sizeof(msg_buf)); |
| 494 | snprintf(msg, sizeof(msg), "VARIANT - %s %s\n", |
| 495 | msg_buf, target_is_emmc_boot()? "eMMC":"UFS"); |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 496 | display_fbcon_menu_message(msg, FBCON_COMMON_MSG, common_factor, 0); |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 497 | |
| 498 | memset(msg_buf, 0, sizeof(msg_buf)); |
| 499 | get_bootloader_version((unsigned char *) msg_buf); |
| 500 | snprintf(msg, sizeof(msg), "BOOTLOADER VERSION - %s\n", |
| 501 | msg_buf); |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 502 | display_fbcon_menu_message(msg, FBCON_COMMON_MSG, common_factor, 0); |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 503 | |
| 504 | memset(msg_buf, 0, sizeof(msg_buf)); |
| 505 | get_baseband_version((unsigned char *) msg_buf); |
| 506 | snprintf(msg, sizeof(msg), "BASEBAND VERSION - %s\n", |
| 507 | msg_buf); |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 508 | display_fbcon_menu_message(msg, FBCON_COMMON_MSG, common_factor, 0); |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 509 | |
| 510 | memset(msg_buf, 0, sizeof(msg_buf)); |
| 511 | target_serialno((unsigned char *) msg_buf); |
| 512 | snprintf(msg, sizeof(msg), "SERIAL NUMBER - %s\n", msg_buf); |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 513 | display_fbcon_menu_message(msg, FBCON_COMMON_MSG, common_factor, 0); |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 514 | |
| 515 | snprintf(msg, sizeof(msg), "SECURE BOOT - %s\n", |
| 516 | is_secure_boot_enable()? "enabled":"disabled"); |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 517 | display_fbcon_menu_message(msg, FBCON_COMMON_MSG, common_factor, 0); |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 518 | |
| 519 | snprintf(msg, sizeof(msg), "DEVICE STATE - %s\n", |
| 520 | is_device_locked()? "locked":"unlocked"); |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 521 | display_fbcon_menu_message(msg, FBCON_RED_MSG, common_factor, 0); |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 522 | |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 523 | fastboot_msg_info->info.msg_type = DISPLAY_MENU_FASTBOOT; |
| 524 | fastboot_msg_info->info.option_num = len; |
| 525 | fastboot_msg_info->info.option_index = option_index; |
| 526 | } |
| 527 | |
| 528 | void msg_lock_init() |
| 529 | { |
| 530 | static bool is_msg_lock_init = false; |
| 531 | struct select_msg_info *msg_lock_info; |
| 532 | msg_lock_info = &msg_info; |
| 533 | |
| 534 | if (!is_msg_lock_init) { |
| 535 | mutex_init(&msg_lock_info->msg_lock); |
| 536 | is_msg_lock_init = true; |
| 537 | } |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 538 | } |
| 539 | |
| 540 | static void display_menu_thread_start(struct select_msg_info *msg_info) |
| 541 | { |
| 542 | thread_t *thr; |
| 543 | |
| 544 | if (!is_thread_start) { |
| 545 | thr = thread_create("selectkeydetect", &select_msg_keys_detect, |
| 546 | (void*)msg_info, DEFAULT_PRIORITY, DEFAULT_STACK_SIZE); |
| 547 | if (!thr) { |
| 548 | dprintf(CRITICAL, "ERROR: creat device status detect thread failed!!\n"); |
| 549 | return; |
| 550 | } |
| 551 | thread_resume(thr); |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 552 | is_thread_start = true; |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 553 | } |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 554 | } |
| 555 | |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 556 | /* The fuction be called after device in fastboot mode, |
| 557 | * so it's no need to initialize the msg_lock again |
| 558 | */ |
lijuang | f55ad05 | 2018-04-23 18:30:50 +0800 | [diff] [blame] | 559 | void display_unlock_menu(int type, bool status) |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 560 | { |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 561 | struct select_msg_info *unlock_menu_msg_info; |
| 562 | unlock_menu_msg_info = &msg_info; |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 563 | |
Krishna Manikandan | f2c8be9 | 2017-12-05 18:07:56 +0530 | [diff] [blame] | 564 | if (is_display_disabled()) |
| 565 | return; |
| 566 | |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 567 | set_message_factor(); |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 568 | |
| 569 | msg_lock_init(); |
| 570 | mutex_acquire(&unlock_menu_msg_info->msg_lock); |
| 571 | |
| 572 | /* Initialize the last_msg_type */ |
| 573 | unlock_menu_msg_info->last_msg_type = |
| 574 | unlock_menu_msg_info->info.msg_type; |
| 575 | |
lijuang | f55ad05 | 2018-04-23 18:30:50 +0800 | [diff] [blame] | 576 | display_unlock_menu_renew(unlock_menu_msg_info, type, status); |
jialongjhan | b2dda0b | 2020-04-21 20:20:51 +0800 | [diff] [blame^] | 577 | //[Arima][8901][JialongJhan] Command mode update screen 20190618 Start |
| 578 | msm_display_flush(); |
| 579 | //[Arima][8901][JialongJhan] Command mode update screen 20190618 End |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 580 | mutex_release(&unlock_menu_msg_info->msg_lock); |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 581 | |
lijuang | f55ad05 | 2018-04-23 18:30:50 +0800 | [diff] [blame] | 582 | dprintf(INFO, "creating %s keys detect thread\n", |
| 583 | status ? "unlock":"lock"); |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 584 | display_menu_thread_start(unlock_menu_msg_info); |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 585 | } |
| 586 | |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 587 | void display_fastboot_menu() |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 588 | { |
| 589 | struct select_msg_info *fastboot_menu_msg_info; |
| 590 | fastboot_menu_msg_info = &msg_info; |
| 591 | |
Krishna Manikandan | f2c8be9 | 2017-12-05 18:07:56 +0530 | [diff] [blame] | 592 | if (is_display_disabled()) |
| 593 | return; |
| 594 | |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 595 | set_message_factor(); |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 596 | |
| 597 | msg_lock_init(); |
| 598 | mutex_acquire(&fastboot_menu_msg_info->msg_lock); |
| 599 | |
| 600 | /* There are 4 pages for fastboot menu: |
| 601 | * Page: Start/Fastboot/Recovery/Poweroff |
| 602 | * The menu is switched base on the option index |
| 603 | * Initialize the option index and last_msg_type |
| 604 | */ |
| 605 | fastboot_menu_msg_info->info.option_index = 0; |
| 606 | fastboot_menu_msg_info->last_msg_type = |
| 607 | fastboot_menu_msg_info->info.msg_type; |
| 608 | |
| 609 | display_fastboot_menu_renew(fastboot_menu_msg_info); |
jialongjhan | b2dda0b | 2020-04-21 20:20:51 +0800 | [diff] [blame^] | 610 | //[Arima][8901][JialongJhan] Command mode update screen 20190618 Start |
| 611 | msm_display_flush(); |
| 612 | //[Arima][8901][JialongJhan] Command mode update screen 20190618 End |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 613 | mutex_release(&fastboot_menu_msg_info->msg_lock); |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 614 | |
| 615 | dprintf(INFO, "creating fastboot menu keys detect thread\n"); |
| 616 | display_menu_thread_start(fastboot_menu_msg_info); |
| 617 | } |
| 618 | |
Monika Singh | 5e17036 | 2018-03-14 00:48:36 +0530 | [diff] [blame] | 619 | #if VERIFIED_BOOT || VERIFIED_BOOT_2 |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 620 | void display_bootverify_menu(int type) |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 621 | { |
| 622 | struct select_msg_info *bootverify_menu_msg_info; |
| 623 | bootverify_menu_msg_info = &msg_info; |
| 624 | |
Krishna Manikandan | f2c8be9 | 2017-12-05 18:07:56 +0530 | [diff] [blame] | 625 | if (is_display_disabled()) |
| 626 | return; |
| 627 | |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 628 | set_message_factor(); |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 629 | |
| 630 | msg_lock_init(); |
| 631 | mutex_acquire(&bootverify_menu_msg_info->msg_lock); |
| 632 | |
| 633 | /* Initialize the last_msg_type */ |
| 634 | bootverify_menu_msg_info->last_msg_type = |
| 635 | bootverify_menu_msg_info->info.msg_type; |
| 636 | |
| 637 | display_bootverify_menu_renew(bootverify_menu_msg_info, type); |
jialongjhan | b2dda0b | 2020-04-21 20:20:51 +0800 | [diff] [blame^] | 638 | //[Arima][8901][JialongJhan] Command mode update screen 201906118 Start |
| 639 | msm_display_flush(); |
| 640 | //[Arima][8901][JialongJhan] Command mode update screen 20190618 End |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 641 | mutex_release(&bootverify_menu_msg_info->msg_lock); |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 642 | |
| 643 | dprintf(INFO, "creating boot verify keys detect thread\n"); |
| 644 | display_menu_thread_start(bootverify_menu_msg_info); |
| 645 | } |
| 646 | #endif |