In Current UI code, we use oneof opcode without storage for language
menu. If we change the language form A->B, then go to another form and
then go back to the front page, the language menu always shows A. Now
we fix this issue by getting current language and set the related value
to oneof opcode when open the front page. Then the language menu can
show the language info correctly.

Cc: Liming Gao <[email protected]>
Cc: Eric Dong <[email protected]>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Dandan Bi <[email protected]>
Reviewed-by: Eric Dong <[email protected]>
---
 .../UiApp/FrontPageCustomizedUiSupport.c           | 61 ++++++++++++++++++++++
 1 file changed, 61 insertions(+)

diff --git a/MdeModulePkg/Application/UiApp/FrontPageCustomizedUiSupport.c 
b/MdeModulePkg/Application/UiApp/FrontPageCustomizedUiSupport.c
index dfb37ec..e4ca46c 100644
--- a/MdeModulePkg/Application/UiApp/FrontPageCustomizedUiSupport.c
+++ b/MdeModulePkg/Application/UiApp/FrontPageCustomizedUiSupport.c
@@ -155,10 +155,57 @@ LanguageChangeHandler (
 
   return EFI_SUCCESS;
 }
 
 /**
+  This function is to get current language and set value to oneof opcode of 
language menu.
+
+  @param Value           A pointer to the data being sent to the original 
exporting driver.
+
+**/
+VOID
+CurrentLanguageHandler (
+  IN OUT EFI_IFR_TYPE_VALUE                     *Value
+  )
+{
+  EFI_STATUS                    Status;
+  UINT8                         Index;
+  UINTN                         Length;
+  CHAR8                         *CurrentLang;
+  CHAR8                         *LangCode;
+  CHAR8                         *Lang;
+
+  Index  = 0;
+  Length = AsciiStrSize (gLanguageString);
+
+  Lang  = AllocateZeroPool (Length);
+  ASSERT (Lang != NULL);
+
+  CurrentLang = AllocateZeroPool (Length);
+  ASSERT (CurrentLang != NULL);
+  //
+  // Get the language of current Platform.
+  // And set the value to oneof opcode.
+  Status = gRT->GetVariable (L"PlatformLang", &gEfiGlobalVariableGuid, NULL, 
&Length, CurrentLang);
+  if (!EFI_ERROR (Status)) {
+    LangCode = gLanguageString;
+    while (*LangCode != 0) {
+      GetNextLanguage (&LangCode, Lang);
+      if (AsciiStrCmp (Lang, CurrentLang) == 0) {
+        Value->u8 = Index;
+        break;
+      }
+      Index++;
+      ZeroMem (Lang, Length);
+    }
+  }
+
+  FreePool (Lang);
+  FreePool (CurrentLang);
+}
+
+/**
   This function processes the results of changes in configuration.
 
 
   @param HiiHandle       Points to the hii handle for this formset.
   @param Action          Specifies the type of action taken by the browser.
@@ -188,10 +235,24 @@ UiSupportLibCallbackHandler (
       QuestionId != FRONT_PAGE_KEY_RESET &&
       QuestionId != FRONT_PAGE_KEY_LANGUAGE) {
     return FALSE;
   }
 
+  if (Action == EFI_BROWSER_ACTION_FORM_OPEN) {
+    //
+    // Get current language of platform.
+    // And show current language on the language menu.
+    //
+    if (QuestionId == FRONT_PAGE_KEY_LANGUAGE) {
+      CurrentLanguageHandler (Value);
+      *Status = EFI_SUCCESS;
+    } else {
+      *Status = EFI_UNSUPPORTED;
+    }
+    return TRUE;
+  }
+
   if (Action != EFI_BROWSER_ACTION_CHANGED) {
     //
     // Do nothing for other UEFI Action. Only do call back when data is 
changed.
     //
     *Status = EFI_UNSUPPORTED;
-- 
1.9.5.msysgit.1

_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to