QcomModulePkg: Library: Remove ASSERTS from draw UI functions

Remove the ASSERTS from UI related functions. It will cause the device
couldn't boot up if the display component is not enabled in core UEFI.
It should be gracefully exit UI related functions.

Modified:
1. Print error log instead of ASSERT device
2. Don't draw UI to the screen if it's failed to get graphics info
3. Don't create event to detect key's status

CRs-Fixed: 1055175
Change-Id: Icf004140d1a1faea205b142b9b922ac847af306d
diff --git a/QcomModulePkg/Library/BootLib/DrawUI.c b/QcomModulePkg/Library/BootLib/DrawUI.c
index d391995..bcb296e 100644
--- a/QcomModulePkg/Library/BootLib/DrawUI.c
+++ b/QcomModulePkg/Library/BootLib/DrawUI.c
@@ -73,17 +73,24 @@
 
 	if (GraphicsOutputProtocol == NULL) {
 		ConsoleHandle = gST->ConsoleOutHandle;
-		ASSERT( ConsoleHandle != NULL);
+		if (ConsoleHandle == NULL) {
+			DEBUG((EFI_D_ERROR, "Failed to get the handle for the active console input device.\n"));
+			return 0;
+		}
 
 		gBS->HandleProtocol (
 			ConsoleHandle,
 			&gEfiGraphicsOutputProtocolGuid,
 			(VOID **) &GraphicsOutputProtocol
 		);
-		ASSERT(GraphicsOutputProtocol != NULL);
+		if (GraphicsOutputProtocol == NULL) {
+			DEBUG((EFI_D_ERROR, "Failed to get the graphics output protocol.\n"));
+			return 0;
+		}
 	}
 	Width = GraphicsOutputProtocol->Mode->Info->HorizontalResolution;
-	ASSERT((Width != 0));
+	if (!Width)
+		DEBUG((EFI_D_ERROR, "Failed to get the width of the screen.\n"));
 
 	return Width;
 }
@@ -99,17 +106,24 @@
 
 	if (GraphicsOutputProtocol == NULL) {
 		ConsoleHandle = gST->ConsoleOutHandle;
-		ASSERT( ConsoleHandle != NULL);
+		if (ConsoleHandle == NULL) {
+			DEBUG((EFI_D_ERROR, "Failed to get the handle for the active console input device.\n"));
+			return 0;
+		}
 
 		gBS->HandleProtocol (
 			ConsoleHandle,
 			&gEfiGraphicsOutputProtocolGuid,
 			(VOID **) &GraphicsOutputProtocol
 		);
-		ASSERT(GraphicsOutputProtocol != NULL);
+		if (GraphicsOutputProtocol == NULL) {
+			DEBUG((EFI_D_ERROR, "Failed to get the graphics output protocol.\n"));
+			return 0;
+		}
 	}
 	Height = GraphicsOutputProtocol->Mode->Info->VerticalResolution;
-	ASSERT((Height !=0));
+	if (!Height)
+		DEBUG((EFI_D_ERROR, "Failed to get the height of the screen.\n"));
 
 	return Height;
 }
@@ -259,6 +273,11 @@
 	UINTN                   RowInfoArraySize;
 	CHAR16                  FontMessage[MAX_MSG_SIZE];
 
+	if (!GetResolutionHeight() || !GetResolutionWidth()) {
+		Status = EFI_OUT_OF_RESOURCES;
+		goto Exit;
+	}
+
 	BltBuffer = AllocateZeroPool (sizeof (EFI_IMAGE_OUTPUT));
 	if (BltBuffer == NULL) {
 		DEBUG((EFI_D_ERROR, "Failed to allocate zero pool for BltBuffer.\n"));
@@ -296,7 +315,10 @@
 		&RowInfoArraySize,
 		NULL
 	);
-	ASSERT_EFI_ERROR (Status);
+	if (Status != EFI_SUCCESS) {
+		DEBUG((EFI_D_ERROR, "Failed to render a string to the display: %r\n", Status));
+		goto Exit;
+	}
 
 	if (pHeight) {
 		*pHeight = RowInfoArraySize * RowInfoArray[0].LineHeight;