platform: msm_shared: Add lock menu support

As a part of verified boot, it requires user to confirm whether
wipe user data when trying to lock the device. So add lock menu
support.

1. Add lock menu
2. Update the unlock warning message base on the newest requirements

Change-Id: I5d8764c27cbf5992d064c1ad4e7646ec134d3d52
diff --git a/platform/msm_shared/menu_keys_detect.c b/platform/msm_shared/menu_keys_detect.c
index 3a81b70..ed6a786 100644
--- a/platform/msm_shared/menu_keys_detect.c
+++ b/platform/msm_shared/menu_keys_detect.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2015-2018, The Linux Foundation. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
@@ -94,8 +94,8 @@
 };
 
 static uint32_t unlock_index_action[] = {
-		[0] = RECOVER,
-		[1] = RESTART,
+		[0] = RESTART,
+		[1] = RECOVER,
 };
 
 static int is_key_pressed(int keys_type)
@@ -118,21 +118,7 @@
 	fbcon_clear();
 	switch (reason) {
 		case RECOVER:
-			if (msg_info->info.msg_type == DISPLAY_MENU_UNLOCK) {
-				set_device_unlock_value(UNLOCK, TRUE);
-			} else if (msg_info->info.msg_type == DISPLAY_MENU_UNLOCK_CRITICAL) {
-				set_device_unlock_value(UNLOCK_CRITICAL, TRUE);
-			}
-
-			if (msg_info->info.msg_type == DISPLAY_MENU_UNLOCK ||
-				msg_info->info.msg_type == DISPLAY_MENU_UNLOCK_CRITICAL) {
-				/* wipe data */
-				struct recovery_message msg;
-
-				memset(&msg, 0, sizeof(msg));
-				snprintf(msg.recovery, sizeof(msg.recovery), "recovery\n--wipe_data");
-				write_misc(0, &msg, sizeof(msg));
-			}
+			reset_device_unlock_status(msg_info->info.msg_type);
 			reboot_device(RECOVERY_MODE);
 			break;
 		case RESTART:
@@ -267,6 +253,8 @@
 			break;
 		case DISPLAY_MENU_UNLOCK:
 		case DISPLAY_MENU_UNLOCK_CRITICAL:
+		case DISPLAY_MENU_LOCK:
+		case DISPLAY_MENU_LOCK_CRITICAL:
 			if(msg_info->info.option_index < ARRAY_SIZE(unlock_index_action))
 				reason = unlock_index_action[msg_info->info.option_index];
 			break;
@@ -308,6 +296,16 @@
 		menu_volume_down_func,
 		power_key_func,
 	},
+	[DISPLAY_MENU_LOCK] = {
+		menu_volume_up_func,
+		menu_volume_down_func,
+		power_key_func,
+	},
+	[DISPLAY_MENU_LOCK_CRITICAL] = {
+		menu_volume_up_func,
+		menu_volume_down_func,
+		power_key_func,
+	},
 	[DISPLAY_MENU_YELLOW] = {
 		boot_warning_volume_keys_func,
 		boot_warning_volume_keys_func,