summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Austin Borger <borgera@google.com> 2023-06-01 16:52:05 -0700
committer Austin Borger <borgera@google.com> 2023-08-17 17:09:46 +0000
commit07eac69e2ebfca2246e829014d810f1512bfb8f3 (patch)
tree09337fefb77b738c17e821bb7e03b2da48cbbb8d
parent4edc37f2c5371f9077509660652f78071a3969fb (diff)
cameraservice: Migrate all internal String8/String16s to std::string
String8 and String16 are deprecated classes. It is recommended to use std::string or std::u16string wherever possible. String16 is the native string class for aidl, but Strings marked @utf8InCpp can use std::string directly. This patch standardizes libcameraservice's use of strings to std::string, which is capable of storing utf-8 strings. This makes the code more readable and potentially reduces the number of string copies to a minimum. A new set of string utils is added to frameworks/av/camera to aid this migration. Change-Id: I7aee6696f149244c643ec1399815155f3f562538 Merged-In: I7aee6696f149244c643ec1399815155f3f562538 Bug: 265487852 Test: Presubmit, ran CtsCameraTestCases on Cuttlefish, adb shell dumpsys media camera and observed output (cherry picked from commit b56b7e54b60ca930a44ea10e46e3ca1e1c714a5b)
-rw-r--r--core/jni/android_hardware_Camera.cpp23
1 files changed, 11 insertions, 12 deletions
diff --git a/core/jni/android_hardware_Camera.cpp b/core/jni/android_hardware_Camera.cpp
index 2a670e865ced..1c597424f221 100644
--- a/core/jni/android_hardware_Camera.cpp
+++ b/core/jni/android_hardware_Camera.cpp
@@ -17,22 +17,21 @@
//#define LOG_NDEBUG 0
#define LOG_TAG "Camera-JNI"
-#include <utils/Log.h>
-
-#include "jni.h"
-#include <nativehelper/JNIHelp.h>
-#include "core_jni_helpers.h"
#include <android_runtime/android_graphics_SurfaceTexture.h>
#include <android_runtime/android_view_Surface.h>
-
+#include <binder/IMemory.h>
+#include <camera/Camera.h>
+#include <camera/StringUtils.h>
#include <cutils/properties.h>
-#include <utils/Vector.h>
-#include <utils/Errors.h>
-
#include <gui/GLConsumer.h>
#include <gui/Surface.h>
-#include <camera/Camera.h>
-#include <binder/IMemory.h>
+#include <nativehelper/JNIHelp.h>
+#include <utils/Errors.h>
+#include <utils/Log.h>
+#include <utils/Vector.h>
+
+#include "core_jni_helpers.h"
+#include "jni.h"
using namespace android;
@@ -562,7 +561,7 @@ static jint android_hardware_Camera_native_setup(JNIEnv *env, jobject thiz, jobj
const char16_t *rawClientName = reinterpret_cast<const char16_t*>(
env->GetStringChars(clientPackageName, NULL));
jsize rawClientNameLen = env->GetStringLength(clientPackageName);
- String16 clientName(rawClientName, rawClientNameLen);
+ std::string clientName = toStdString(rawClientName, rawClientNameLen);
env->ReleaseStringChars(clientPackageName,
reinterpret_cast<const jchar*>(rawClientName));