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