cameraserver: Use String8/String16 constructor conversions.

std::wstring_convert is deprecated and throws an exception, which we
can't catch (exceptions are banned). The patch replaces it with the
String8 / String16 constructors when converting from UTF-16 to
std::string.

Test: Ran fuzzers
Bug: 289467990, 289450759
Change-Id: Id956570cc85f22c81546eaf1aeb1e428c0a927a3
diff --git a/camera/include/camera/StringUtils.h b/camera/include/camera/StringUtils.h
index 547750f..80c419f 100644
--- a/camera/include/camera/StringUtils.h
+++ b/camera/include/camera/StringUtils.h
@@ -17,8 +17,6 @@
 #ifndef ANDROID_SERVERS_CAMERA_STRINGUTILS_H
 #define ANDROID_SERVERS_CAMERA_STRINGUTILS_H
 
-#include <codecvt>
-#include <locale>
 #include <memory>
 #include <optional>
 #include <string>
@@ -65,8 +63,8 @@
     }
 
     inline std::string toStdString(const String16 &str) {
-        std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> convert;
-        return convert.to_bytes(str.c_str());
+        String8 str8(str);
+        return std::string(str8.c_str());
     }
 
     /**
@@ -74,8 +72,9 @@
      * len is the number of characters.
      */
     inline std::string toStdString(const char16_t *str, size_t len) {
-        std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> convert;
-        return convert.to_bytes(str, str + len);
+        String16 str16(str, len);
+        String8 str8(str16);
+        return std::string(str8.c_str());
     }
 } // namespace android