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/aidl/android/hardware/ICameraService.aidl b/camera/aidl/android/hardware/ICameraService.aidl
index f8e1631..ed37b2d 100644
--- a/camera/aidl/android/hardware/ICameraService.aidl
+++ b/camera/aidl/android/hardware/ICameraService.aidl
@@ -82,7 +82,7 @@
*/
ICamera connect(ICameraClient client,
int cameraId,
- String opPackageName,
+ @utf8InCpp String opPackageName,
int clientUid, int clientPid,
int targetSdkVersion,
boolean overrideToPortrait,
@@ -93,9 +93,9 @@
* Only supported for device HAL versions >= 3.2
*/
ICameraDeviceUser connectDevice(ICameraDeviceCallbacks callbacks,
- String cameraId,
- String opPackageName,
- @nullable String featureId,
+ @utf8InCpp String cameraId,
+ @utf8InCpp String opPackageName,
+ @nullable @utf8InCpp String featureId,
int clientUid, int oomScoreOffset,
int targetSdkVersion,
boolean overrideToPortrait);
@@ -139,7 +139,7 @@
* Read the static camera metadata for a camera device.
* Only supported for device HAL versions >= 3.2
*/
- CameraMetadataNative getCameraCharacteristics(String cameraId, int targetSdkVersion,
+ CameraMetadataNative getCameraCharacteristics(@utf8InCpp String cameraId, int targetSdkVersion,
boolean overrideToPortrait);
/**
@@ -160,7 +160,7 @@
/**
* Read the legacy camera1 parameters into a String
*/
- String getLegacyParameters(int cameraId);
+ @utf8InCpp String getLegacyParameters(int cameraId);
/**
* apiVersion constants for supportsCameraApi
@@ -169,21 +169,21 @@
const int API_VERSION_2 = 2;
// Determines if a particular API version is supported directly for a cameraId.
- boolean supportsCameraApi(String cameraId, int apiVersion);
+ boolean supportsCameraApi(@utf8InCpp String cameraId, int apiVersion);
// Determines if a cameraId is a hidden physical camera of a logical multi-camera.
- boolean isHiddenPhysicalCamera(String cameraId);
+ boolean isHiddenPhysicalCamera(@utf8InCpp String cameraId);
// Inject the external camera to replace the internal camera session.
- ICameraInjectionSession injectCamera(String packageName, String internalCamId,
- String externalCamId, in ICameraInjectionCallback CameraInjectionCallback);
+ ICameraInjectionSession injectCamera(@utf8InCpp String packageName, @utf8InCpp String internalCamId,
+ @utf8InCpp String externalCamId, in ICameraInjectionCallback CameraInjectionCallback);
- void setTorchMode(String cameraId, boolean enabled, IBinder clientBinder);
+ void setTorchMode(@utf8InCpp String cameraId, boolean enabled, IBinder clientBinder);
// Change the brightness level of the flash unit associated with cameraId to strengthLevel.
// If the torch is in OFF state and strengthLevel > 0 then the torch will also be turned ON.
- void turnOnTorchWithStrengthLevel(String cameraId, int strengthLevel, IBinder clientBinder);
+ void turnOnTorchWithStrengthLevel(@utf8InCpp String cameraId, int strengthLevel, IBinder clientBinder);
// Get the brightness level of the flash unit associated with cameraId.
- int getTorchStrengthLevel(String cameraId);
+ int getTorchStrengthLevel(@utf8InCpp String cameraId);
/**
* Notify the camera service of a system event. Should only be called from system_server.
@@ -233,7 +233,7 @@
*
* @return the key that must be used to report updates to previously reported stats.
*/
- String reportExtensionSessionStats(in CameraExtensionSessionStats stats);
+ @utf8InCpp String reportExtensionSessionStats(in CameraExtensionSessionStats stats);
// Bitfield constants for notifyDeviceStateChange
// All bits >= 32 are for custom vendor states