Snap for 4448085 from 435a2031d62e868aae928ec3c4090ea3bbea3397 to oc-m3-release

Change-Id: Ifbd26654bc0a28d26bd5929e57d843a0e983912a
diff --git a/screen_ui.cpp b/screen_ui.cpp
index 5c93b66..b8f6ea2 100644
--- a/screen_ui.cpp
+++ b/screen_ui.cpp
@@ -69,7 +69,7 @@
       text_top_(0),
       show_text(false),
       show_text_ever(false),
-      menu_(nullptr),
+      menu_headers_(nullptr),
       show_menu(false),
       menu_items(0),
       menu_sel(0),
@@ -356,10 +356,10 @@
         DrawHighlightBar(0, y - 2, gr_fb_width(), char_height_ + 4);
         // Bold white text for the selected item.
         SetColor(MENU_SEL_FG);
-        y += DrawTextLine(x, y, menu_[i], true);
+        y += DrawTextLine(x, y, menu_[i].c_str(), true);
         SetColor(MENU);
       } else {
-        y += DrawTextLine(x, y, menu_[i], false);
+        y += DrawTextLine(x, y, menu_[i].c_str(), false);
       }
     }
     y += DrawHorizontalRule(y);
@@ -508,7 +508,6 @@
 
   text_ = Alloc2d(text_rows_, text_cols_ + 1);
   file_viewer_text_ = Alloc2d(text_rows_, text_cols_ + 1);
-  menu_ = Alloc2d(text_rows_, text_cols_ + 1);
 
   text_col_ = text_row_ = 0;
   text_top_ = 1;
@@ -771,12 +770,11 @@
   pthread_mutex_lock(&updateMutex);
   if (text_rows_ > 0 && text_cols_ > 0) {
     menu_headers_ = headers;
-    size_t i = 0;
-    for (; i < text_rows_ && items[i] != nullptr; ++i) {
-      strncpy(menu_[i], items[i], text_cols_ - 1);
-      menu_[i][text_cols_ - 1] = '\0';
+    menu_.clear();
+    for (size_t i = 0; i < text_rows_ && items[i] != nullptr; ++i) {
+      menu_.emplace_back(std::string(items[i], strnlen(items[i], text_cols_ - 1)));
     }
-    menu_items = i;
+    menu_items = static_cast<int>(menu_.size());
     show_menu = true;
     menu_sel = initial_selection;
     update_screen_locked();
diff --git a/screen_ui.h b/screen_ui.h
index 62dda75..8231a2b 100644
--- a/screen_ui.h
+++ b/screen_ui.h
@@ -21,6 +21,7 @@
 #include <stdio.h>
 
 #include <string>
+#include <vector>
 
 #include "ui.h"
 
@@ -127,7 +128,7 @@
   bool show_text;
   bool show_text_ever;  // has show_text ever been true?
 
-  char** menu_;
+  std::vector<std::string> menu_;
   const char* const* menu_headers_;
   bool show_menu;
   int menu_items, menu_sel;
diff --git a/tools/recovery_l10n/res/values-pa/strings.xml b/tools/recovery_l10n/res/values-pa/strings.xml
index 8564c9c..27972d1 100644
--- a/tools/recovery_l10n/res/values-pa/strings.xml
+++ b/tools/recovery_l10n/res/values-pa/strings.xml
@@ -1,9 +1,9 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
-    <string name="recovery_installing" msgid="2013591905463558223">"ਸਿਸਟਮ ਅੱਪਡੇਟ ਸਥਾਪਤ ਕੀਤੀ ਜਾ ਰਹੀ ਹੈ"</string>
+    <string name="recovery_installing" msgid="2013591905463558223">"ਸਿਸਟਮ ਅੱਪਡੇਟ ਸਥਾਪਤ ਕੀਤਾ ਜਾ ਰਿਹਾ ਹੈ"</string>
     <string name="recovery_erasing" msgid="7334826894904037088">"ਮਿਟਾਈ ਜਾ ਰਹੀ ਹੈ"</string>
-    <string name="recovery_no_command" msgid="4465476568623024327">"ਕੋਈ ਕਮਾਂਡ ਨਹੀਂ"</string>
+    <string name="recovery_no_command" msgid="4465476568623024327">"ਕੋਈ ਆਦੇਸ਼ ਨਹੀਂ"</string>
     <string name="recovery_error" msgid="5748178989622716736">"ਅਸ਼ੁੱਧੀ!"</string>
-    <string name="recovery_installing_security" msgid="9184031299717114342">"ਸੁਰੱਖਿਆ ਅੱਪਡੇਟ ਸਥਾਪਤ ਕੀਤੀ ਜਾ ਰਹੀ ਹੈ"</string>
+    <string name="recovery_installing_security" msgid="9184031299717114342">"ਸੁਰੱਖਿਆ ਅੱਪਡੇਟ ਸਥਾਪਤ ਕੀਤਾ ਜਾ ਰਿਹਾ ਹੈ"</string>
 </resources>
diff --git a/update_verifier/update_verifier.cpp b/update_verifier/update_verifier.cpp
index faebbed..ba7b7ae 100644
--- a/update_verifier/update_verifier.cpp
+++ b/update_verifier/update_verifier.cpp
@@ -137,11 +137,12 @@
     LOG(ERROR) << "Error in parsing range string.";
     return false;
   }
+  range_count /= 2;
 
   std::vector<std::future<bool>> threads;
   size_t thread_num = std::thread::hardware_concurrency() ?: 4;
-  thread_num = std::min(thread_num, range_count / 2);
-  size_t group_range_count = range_count / thread_num;
+  thread_num = std::min(thread_num, range_count);
+  size_t group_range_count = (range_count + thread_num - 1) / thread_num;
 
   for (size_t t = 0; t < thread_num; t++) {
     auto thread_func = [t, group_range_count, &dm_block_device, &ranges, &partition]() {
@@ -154,7 +155,8 @@
         return false;
       }
 
-      for (size_t i = 1 + group_range_count * t; i < group_range_count * (t + 1) + 1; i += 2) {
+      for (size_t i = group_range_count * 2 * t + 1;
+           i < std::min(group_range_count * 2 * (t + 1) + 1, ranges.size()); i += 2) {
         unsigned int range_start, range_end;
         bool parse_status = android::base::ParseUint(ranges[i], &range_start);
         parse_status = parse_status && android::base::ParseUint(ranges[i + 1], &range_end);
diff --git a/wear_ui.cpp b/wear_ui.cpp
index 169ef20..624116c 100644
--- a/wear_ui.cpp
+++ b/wear_ui.cpp
@@ -154,11 +154,11 @@
           // white text of selected item
           SetColor(MENU_SEL_FG);
           if (menu_[i][0]) {
-            gr_text(gr_sys_font(), x + 4, y, menu_[i], 1);
+            gr_text(gr_sys_font(), x + 4, y, menu_[i].c_str(), 1);
           }
           SetColor(MENU);
         } else if (menu_[i][0]) {
-          gr_text(gr_sys_font(), x + 4, y, menu_[i], 0);
+          gr_text(gr_sys_font(), x + 4, y, menu_[i].c_str(), 0);
         }
         y += char_height_ + 4;
       }
@@ -255,17 +255,16 @@
   pthread_mutex_lock(&updateMutex);
   if (text_rows_ > 0 && text_cols_ > 0) {
     menu_headers_ = headers;
-    size_t i = 0;
+    menu_.clear();
     // "i < text_rows_" is removed from the loop termination condition,
     // which is different from the one in ScreenRecoveryUI::StartMenu().
     // Because WearRecoveryUI supports scrollable menu, it's fine to have
     // more entries than text_rows_. The menu may be truncated otherwise.
     // Bug: 23752519
-    for (; items[i] != nullptr; i++) {
-      strncpy(menu_[i], items[i], text_cols_ - 1);
-      menu_[i][text_cols_ - 1] = '\0';
+    for (size_t i = 0; items[i] != nullptr; i++) {
+      menu_.emplace_back(std::string(items[i], strnlen(items[i], text_cols_ - 1)));
     }
-    menu_items = i;
+    menu_items = static_cast<int>(menu_.size());
     show_menu = true;
     menu_sel = initial_selection;
     menu_start = 0;