fastboot: add secure & lock check for fastboot cmd [1/1]

BUG:202994010

Problem:
fastboot unlock & oem cmd maybe unsafe

Solution:
1. check lock state before fastboot cmds such as oem;

Verify:
adt3

Change-Id: Iefd67d45ba826ab4f9704643ca3afc2ba71ebc8a
Signed-off-by: Xindong Xu <xindong.xu@amlogic.com>
diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c
index 4664911..ae881de 100644
--- a/drivers/usb/gadget/f_fastboot.c
+++ b/drivers/usb/gadget/f_fastboot.c
@@ -1086,6 +1086,12 @@
 
 	printf("cmd cb_download is %s\n", cmd);
 
+	if (check_lock()) {
+		error("device is locked, can not run this cmd.Please flashing unlock & flashing unlock_critical\n");
+		fastboot_tx_write_str("FAILlocked device");
+		return;
+	}
+
 	strsep(&cmd, ":");
 	download_size = simple_strtoul(cmd, NULL, 16);
 	download_bytes = 0;
@@ -1154,6 +1160,11 @@
 
 static void cb_boot(struct usb_ep *ep, struct usb_request *req)
 {
+	if (check_lock()) {
+		error("device is locked, can not run this cmd.Please flashing unlock & flashing unlock_critical\n");
+		fastboot_tx_write_str("FAILlocked device");
+		return;
+	}
 	fastboot_func->in_req->complete = do_bootm_on_complete;
 	fastboot_tx_write_str("OKAY");
 }
@@ -1553,6 +1564,12 @@
 	char cmd_str[RESPONSE_LEN];
 	printf("oem cmd[%s]\n", cmd);
 
+	if (check_lock()) {
+		error("device is locked, can not run this cmd.Please flashing unlock & flashing unlock_critical\n");
+		fastboot_tx_write_str("FAILlocked device");
+		return;
+	}
+
 	strsep(&cmd, " ");
 	printf("To run cmd[%s]\n", cmd);