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: I59330ac03c8a52b6c21a2388bba0c143e68af4cf
Bug: 265487852
Test: Presubmit, ran CtsCameraTestCases on Cuttlefish, adb shell dumpsys media camera and observed output
diff --git a/camera/tests/CameraZSLTests.cpp b/camera/tests/CameraZSLTests.cpp
index 6423709..3ae7659 100644
--- a/camera/tests/CameraZSLTests.cpp
+++ b/camera/tests/CameraZSLTests.cpp
@@ -27,6 +27,7 @@
#include <camera/CameraParameters.h>
#include <camera/CameraMetadata.h>
#include <camera/Camera.h>
+#include <camera/StringUtils.h>
#include <android/hardware/ICameraService.h>
using namespace android;
@@ -169,7 +170,7 @@
sp<SurfaceControl> surfaceControl;
sp<ICamera> cameraDevice;
- String16 cameraIdStr = String16(String8::format("%d", cameraId));
+ std::string cameraIdStr = std::to_string(cameraId);
bool isSupported = false;
rc = mCameraService->supportsCameraApi(cameraIdStr,
hardware::ICameraService::API_VERSION_1, &isSupported);
@@ -208,7 +209,7 @@
}
rc = mCameraService->connect(this, cameraId,
- String16("ZSLTest"), hardware::ICameraService::USE_CALLING_UID,
+ "ZSLTest", hardware::ICameraService::USE_CALLING_UID,
hardware::ICameraService::USE_CALLING_PID,
/*targetSdkVersion*/__ANDROID_API_FUTURE__,
/*overrideToPortrait*/false, /*forceSlowJpegMode*/false, &cameraDevice);