Skip to content

Commit

Permalink
Merge "Use String8/16 c_str [camera]" into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Treehugger Robot authored and Gerrit Code Review committed Aug 23, 2023
2 parents f67a94c + 12b04a5 commit 0188ed1
Show file tree
Hide file tree
Showing 16 changed files with 58 additions and 58 deletions.
4 changes: 2 additions & 2 deletions camera/CameraBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ sp<TCam> CameraBase<TCam, TCamTraits>::connect(int cameraId,
c->mStatus = NO_ERROR;
} else {
ALOGW("An error occurred while connecting to camera %d: %s", cameraId,
(cs == nullptr) ? "Service not available" : ret.toString8().string());
(cs == nullptr) ? "Service not available" : ret.toString8().c_str());
c.clear();
}
return c;
Expand Down Expand Up @@ -270,7 +270,7 @@ int CameraBase<TCam, TCamTraits>::getNumberOfCameras() {
&count);
if (!res.isOk()) {
ALOGE("Error reading number of cameras: %s",
res.toString8().string());
res.toString8().c_str());
count = 0;
}
return count;
Expand Down
4 changes: 2 additions & 2 deletions camera/CameraMetadata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ status_t CameraMetadata::update(uint32_t tag,
return res;
}
// string.size() doesn't count the null termination character.
return updateImpl(tag, (const void*)string.string(), string.size() + 1);
return updateImpl(tag, (const void*)string.c_str(), string.size() + 1);
}

status_t CameraMetadata::update(const camera_metadata_ro_entry &entry) {
Expand Down Expand Up @@ -809,7 +809,7 @@ status_t CameraMetadata::getTagFromName(const char *name,
for (size_t i = 0; i < totalSectionCount; ++i) {

const char *str = (i < ANDROID_SECTION_COUNT) ? camera_metadata_section_names[i] :
(*vendorSections)[i - ANDROID_SECTION_COUNT].string();
(*vendorSections)[i - ANDROID_SECTION_COUNT].c_str();

ALOGV("%s: Trying to match against section '%s'", __FUNCTION__, str);

Expand Down
10 changes: 5 additions & 5 deletions camera/CameraParameters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ String8 CameraParameters::flatten() const

void CameraParameters::unflatten(const String8 &params)
{
const char *a = params.string();
const char *a = params.c_str();
const char *b;

mMap.clear();
Expand Down Expand Up @@ -271,7 +271,7 @@ const char *CameraParameters::get(const char *key) const
String8 v = mMap.valueFor(String8(key));
if (v.length() == 0)
return 0;
return v.string();
return v.c_str();
}

int CameraParameters::getInt(const char *key) const
Expand Down Expand Up @@ -463,7 +463,7 @@ void CameraParameters::dump() const
String8 k, v;
k = mMap.keyAt(i);
v = mMap.valueAt(i);
ALOGD("%s: %s\n", k.string(), v.string());
ALOGD("%s: %s\n", k.c_str(), v.c_str());
}
}

Expand All @@ -478,10 +478,10 @@ status_t CameraParameters::dump(int fd, const Vector<String16>& /*args*/) const
String8 k, v;
k = mMap.keyAt(i);
v = mMap.valueAt(i);
snprintf(buffer, 255, "\t%s: %s\n", k.string(), v.string());
snprintf(buffer, 255, "\t%s: %s\n", k.c_str(), v.c_str());
result.append(buffer);
}
write(fd, result.string(), result.size());
write(fd, result.c_str(), result.size());
return NO_ERROR;
}

Expand Down
14 changes: 7 additions & 7 deletions camera/CameraParameters2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ String8 CameraParameters2::flatten() const
flattened += ";";
}

ALOGV("%s: Flattened params = %s", __FUNCTION__, flattened.string());
ALOGV("%s: Flattened params = %s", __FUNCTION__, flattened.c_str());

return flattened;
}

void CameraParameters2::unflatten(const String8 &params)
{
const char *a = params.string();
const char *a = params.c_str();
const char *b;

mMap.clear();
Expand Down Expand Up @@ -128,7 +128,7 @@ const char *CameraParameters2::get(const char *key) const
if (idx < 0) {
return NULL;
} else {
return mMap.valueAt(idx).string();
return mMap.valueAt(idx).c_str();
}
}

Expand Down Expand Up @@ -305,7 +305,7 @@ void CameraParameters2::getPreviewFpsRange(int *min_fps, int *max_fps) const
void CameraParameters2::setPreviewFpsRange(int min_fps, int max_fps)
{
String8 str = String8::format("%d,%d", min_fps, max_fps);
set(CameraParameters::KEY_PREVIEW_FPS_RANGE, str.string());
set(CameraParameters::KEY_PREVIEW_FPS_RANGE, str.c_str());
}

void CameraParameters2::setPreviewFormat(const char *format)
Expand Down Expand Up @@ -357,7 +357,7 @@ void CameraParameters2::dump() const
String8 k, v;
k = mMap.keyAt(i);
v = mMap.valueAt(i);
ALOGD("%s: %s\n", k.string(), v.string());
ALOGD("%s: %s\n", k.c_str(), v.c_str());
}
}

Expand All @@ -373,10 +373,10 @@ status_t CameraParameters2::dump(int fd, const Vector<String16>& args) const
String8 k, v;
k = mMap.keyAt(i);
v = mMap.valueAt(i);
snprintf(buffer, 255, "\t%s: %s\n", k.string(), v.string());
snprintf(buffer, 255, "\t%s: %s\n", k.c_str(), v.c_str());
result.append(buffer);
}
write(fd, result.string(), result.size());
write(fd, result.c_str(), result.size());
return NO_ERROR;
}

Expand Down
10 changes: 5 additions & 5 deletions camera/VendorTagDescriptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,15 +237,15 @@ const char* VendorTagDescriptor::getSectionName(uint32_t tag) const {
if (index < 0) {
return VENDOR_SECTION_NAME_ERR;
}
return mSections[mTagToSectionMap.valueAt(index)].string();
return mSections[mTagToSectionMap.valueAt(index)].c_str();
}

const char* VendorTagDescriptor::getTagName(uint32_t tag) const {
ssize_t index = mTagToNameMap.indexOfKey(tag);
if (index < 0) {
return VENDOR_TAG_NAME_ERR;
}
return mTagToNameMap.valueAt(index).string();
return mTagToNameMap.valueAt(index).c_str();
}

int VendorTagDescriptor::getTagType(uint32_t tag) const {
Expand Down Expand Up @@ -299,13 +299,13 @@ const SortedVector<String8>* VendorTagDescriptor::getAllSectionNames() const {
status_t VendorTagDescriptor::lookupTag(const String8& name, const String8& section, /*out*/uint32_t* tag) const {
ssize_t index = mReverseMapping.indexOfKey(section);
if (index < 0) {
ALOGE("%s: Section '%s' does not exist.", __FUNCTION__, section.string());
ALOGE("%s: Section '%s' does not exist.", __FUNCTION__, section.c_str());
return BAD_VALUE;
}

ssize_t nameIndex = mReverseMapping[index]->indexOfKey(name);
if (nameIndex < 0) {
ALOGE("%s: Tag name '%s' does not exist.", __FUNCTION__, name.string());
ALOGE("%s: Tag name '%s' does not exist.", __FUNCTION__, name.c_str());
return BAD_VALUE;
}

Expand Down Expand Up @@ -344,7 +344,7 @@ void VendorTagDescriptor::dump(int fd, int verbosity, int indentation) const {
const char* typeName = (type >= 0 && type < NUM_TYPES) ?
camera_metadata_type_names[type] : "UNKNOWN";
dprintf(fd, "%*s0x%x (%s) with type %d (%s) defined in section %s\n", indentation + 2,
"", tag, name.string(), type, typeName, sectionName.string());
"", tag, name.c_str(), type, typeName, sectionName.c_str());
}

}
Expand Down
2 changes: 1 addition & 1 deletion camera/camera2/OutputConfiguration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ status_t OutputConfiguration::readFromParcel(const android::Parcel* parcel) {
for (auto& surface : surfaceShims) {
ALOGV("%s: OutputConfiguration: %p, name %s", __FUNCTION__,
surface.graphicBufferProducer.get(),
toString8(surface.name).string());
toString8(surface.name).c_str());
mGbps.push_back(surface.graphicBufferProducer);
}

Expand Down
4 changes: 2 additions & 2 deletions camera/include/camera/StringUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@ namespace android {
}

inline std::string toStdString(const String8 &str) {
return std::string(str.string());
return std::string(str.c_str());
}

inline std::string toStdString(const String16 &str) {
std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> convert;
return convert.to_bytes(str.string());
return convert.to_bytes(str.c_str());
}

/**
Expand Down
28 changes: 14 additions & 14 deletions camera/ndk/impl/ACameraDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ CameraDevice::createCaptureRequest(
templateId);
return ACAMERA_ERROR_INVALID_PARAMETER;
} else if (!remoteRet.isOk()) {
ALOGE("Create capture request failed: %s", remoteRet.toString8().string());
ALOGE("Create capture request failed: %s", remoteRet.toString8().c_str());
return ACAMERA_ERROR_UNKNOWN;
}
ACaptureRequest* outReq = new ACaptureRequest();
Expand Down Expand Up @@ -317,22 +317,22 @@ camera_status_t CameraDevice::updateOutputConfigurationLocked(ACaptureSessionOut
switch (remoteRet.serviceSpecificErrorCode()) {
case hardware::ICameraService::ERROR_INVALID_OPERATION:
ALOGE("Camera device %s invalid operation: %s", getId(),
remoteRet.toString8().string());
remoteRet.toString8().c_str());
return ACAMERA_ERROR_INVALID_OPERATION;
break;
case hardware::ICameraService::ERROR_ALREADY_EXISTS:
ALOGE("Camera device %s output surface already exists: %s", getId(),
remoteRet.toString8().string());
remoteRet.toString8().c_str());
return ACAMERA_ERROR_INVALID_PARAMETER;
break;
case hardware::ICameraService::ERROR_ILLEGAL_ARGUMENT:
ALOGE("Camera device %s invalid input argument: %s", getId(),
remoteRet.toString8().string());
remoteRet.toString8().c_str());
return ACAMERA_ERROR_INVALID_PARAMETER;
break;
default:
ALOGE("Camera device %s failed to add shared output: %s", getId(),
remoteRet.toString8().string());
remoteRet.toString8().c_str());
return ACAMERA_ERROR_UNKNOWN;
}
}
Expand Down Expand Up @@ -494,7 +494,7 @@ CameraDevice::stopRepeatingLocked() {
ALOGV("Repeating request is already stopped.");
return ACAMERA_OK;
} else if (!remoteRet.isOk()) {
ALOGE("Stop repeating request fails in remote: %s", remoteRet.toString8().string());
ALOGE("Stop repeating request fails in remote: %s", remoteRet.toString8().c_str());
return ACAMERA_ERROR_UNKNOWN;
}
checkRepeatingSequenceCompleteLocked(repeatingSequenceId, lastFrameNumber);
Expand Down Expand Up @@ -546,7 +546,7 @@ CameraDevice::flushLocked(ACameraCaptureSession* session) {
int64_t lastFrameNumber;
binder::Status remoteRet = mRemote->flush(&lastFrameNumber);
if (!remoteRet.isOk()) {
ALOGE("Abort captures fails in remote: %s", remoteRet.toString8().string());
ALOGE("Abort captures fails in remote: %s", remoteRet.toString8().c_str());
return ACAMERA_ERROR_UNKNOWN;
}
if (mRepeatingSequenceId != REQUEST_ID_NONE) {
Expand All @@ -570,7 +570,7 @@ CameraDevice::waitUntilIdleLocked() {

binder::Status remoteRet = mRemote->waitUntilIdle();
if (!remoteRet.isOk()) {
ALOGE("Camera device %s waitUntilIdle failed: %s", getId(), remoteRet.toString8().string());
ALOGE("Camera device %s waitUntilIdle failed: %s", getId(), remoteRet.toString8().c_str());
// TODO: define a function to convert status_t -> camera_status_t
return ACAMERA_ERROR_UNKNOWN;
}
Expand Down Expand Up @@ -680,7 +680,7 @@ CameraDevice::configureStreamsLocked(const ACaptureSessionOutputContainer* outpu

binder::Status remoteRet = mRemote->beginConfigure();
if (!remoteRet.isOk()) {
ALOGE("Camera device %s begin configure failed: %s", getId(), remoteRet.toString8().string());
ALOGE("Camera device %s begin configure failed: %s", getId(), remoteRet.toString8().c_str());
return ACAMERA_ERROR_UNKNOWN;
}

Expand All @@ -689,7 +689,7 @@ CameraDevice::configureStreamsLocked(const ACaptureSessionOutputContainer* outpu
remoteRet = mRemote->deleteStream(streamId);
if (!remoteRet.isOk()) {
ALOGE("Camera device %s failed to remove stream %d: %s", getId(), streamId,
remoteRet.toString8().string());
remoteRet.toString8().c_str());
return ACAMERA_ERROR_UNKNOWN;
}
mConfiguredOutputs.erase(streamId);
Expand All @@ -701,7 +701,7 @@ CameraDevice::configureStreamsLocked(const ACaptureSessionOutputContainer* outpu
remoteRet = mRemote->createStream(outputPair.second, &streamId);
if (!remoteRet.isOk()) {
ALOGE("Camera device %s failed to create stream: %s", getId(),
remoteRet.toString8().string());
remoteRet.toString8().c_str());
return ACAMERA_ERROR_UNKNOWN;
}
mConfiguredOutputs.insert(std::make_pair(streamId, outputPair));
Expand All @@ -716,10 +716,10 @@ CameraDevice::configureStreamsLocked(const ACaptureSessionOutputContainer* outpu
ns2ms(startTimeNs), &offlineStreamIds);
if (remoteRet.serviceSpecificErrorCode() == hardware::ICameraService::ERROR_ILLEGAL_ARGUMENT) {
ALOGE("Camera device %s cannnot support app output configuration: %s", getId(),
remoteRet.toString8().string());
remoteRet.toString8().c_str());
return ACAMERA_ERROR_STREAM_CONFIGURE_FAIL;
} else if (!remoteRet.isOk()) {
ALOGE("Camera device %s end configure failed: %s", getId(), remoteRet.toString8().string());
ALOGE("Camera device %s end configure failed: %s", getId(), remoteRet.toString8().c_str());
return ACAMERA_ERROR_UNKNOWN;
}

Expand Down Expand Up @@ -866,7 +866,7 @@ CameraDevice::onCaptureErrorLocked(
if (cbh.mIsLogicalCameraCallback) {
if (resultExtras.errorPhysicalCameraId.size() > 0) {
String8 cameraId = toString8(resultExtras.errorPhysicalCameraId);
msg->setString(kFailingPhysicalCameraId, cameraId.string(), cameraId.size());
msg->setString(kFailingPhysicalCameraId, cameraId.c_str(), cameraId.size());
}
msg->setPointer(kCallbackFpKey, (void*) cbh.mOnLogicalCameraCaptureFailed);
} else {
Expand Down
2 changes: 1 addition & 1 deletion camera/ndk/impl/ACameraDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class CameraDevice final : public RefBase {
ACameraDevice* wrapper);
~CameraDevice();

inline const char* getId() const { return mCameraId.string(); }
inline const char* getId() const { return mCameraId.c_str(); }

camera_status_t createCaptureRequest(
ACameraDevice_request_template templateId,
Expand Down
8 changes: 4 additions & 4 deletions camera/ndk/impl/ACameraManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ sp<hardware::ICameraService> CameraManagerGlobal::getCameraServiceLocked() {
} else {
VendorTagDescriptorCache::clearGlobalVendorTagCache();
ALOGE("%s: Failed to setup vendor tag cache: %s",
__FUNCTION__, res.toString8().string());
__FUNCTION__, res.toString8().c_str());
}
}
} else if (ret.serviceSpecificErrorCode() ==
Expand All @@ -177,7 +177,7 @@ sp<hardware::ICameraService> CameraManagerGlobal::getCameraServiceLocked() {
VendorTagDescriptor::clearGlobalVendorTagDescriptor();
} else {
ALOGE("%s: Failed to get vendor tag descriptors: %s",
__FUNCTION__, ret.toString8().string());
__FUNCTION__, ret.toString8().c_str());
}
}
ALOGE_IF(mCameraService == nullptr, "no CameraService!?");
Expand Down Expand Up @@ -708,7 +708,7 @@ camera_status_t ACameraManager::getCameraCharacteristics(
return ACAMERA_ERROR_INVALID_PARAMETER;
default:
ALOGE("Get camera characteristics from camera service failed: %s",
serviceRet.toString8().string());
serviceRet.toString8().c_str());
return ACAMERA_ERROR_UNKNOWN; // should not reach here
}
}
Expand Down Expand Up @@ -752,7 +752,7 @@ ACameraManager::openCamera(
targetSdkVersion, /*overrideToPortrait*/false, /*out*/&deviceRemote);

if (!serviceRet.isOk()) {
ALOGE("%s: connect camera device failed: %s", __FUNCTION__, serviceRet.toString8().string());
ALOGE("%s: connect camera device failed: %s", __FUNCTION__, serviceRet.toString8().c_str());
// Convert serviceRet to camera_status_t
switch(serviceRet.serviceSpecificErrorCode()) {
case hardware::ICameraService::ERROR_DISCONNECTED:
Expand Down
2 changes: 1 addition & 1 deletion camera/ndk/impl/ACameraMetadata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ ACameraMetadata::derivePhysicalCameraIds() {
if (ids[i] == '\0') {
if (start != i) {
mStaticPhysicalCameraIdValues.push_back(String8((const char *)ids+start));
mStaticPhysicalCameraIds.push_back(mStaticPhysicalCameraIdValues.back().string());
mStaticPhysicalCameraIds.push_back(mStaticPhysicalCameraIdValues.back().c_str());
}
start = i+1;
}
Expand Down
2 changes: 1 addition & 1 deletion services/camera/libcameraservice/CameraService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1068,7 +1068,7 @@ Status CameraService::initializeShimMetadata(int cameraId) {
/*targetSdkVersion*/ __ANDROID_API_FUTURE__, /*overrideToPortrait*/ true,
/*forceSlowJpegMode*/false, /*out*/ tmp)
).isOk()) {
ALOGE("%s: Error initializing shim metadata: %s", __FUNCTION__, ret.toString8().string());
ALOGE("%s: Error initializing shim metadata: %s", __FUNCTION__, ret.toString8().c_str());
}
return ret;
}
Expand Down
4 changes: 2 additions & 2 deletions services/camera/libcameraservice/api1/Camera2Client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ status_t Camera2Client::initializeImpl(TProviderPtr providerPtr, const std::stri
SharedParameters::Lock l(mParameters);
ALOGD("%s: Default parameters converted from camera %d:", __FUNCTION__,
mCameraId);
ALOGD("%s", l.mParameters.paramsFlattened.string());
ALOGD("%s", l.mParameters.paramsFlattened.c_str());
}

return OK;
Expand Down Expand Up @@ -221,7 +221,7 @@ status_t Camera2Client::dumpClient(int fd, const Vector<String16>& args) {
result << fmt::sprintf(" GPS timestamp: %" PRId64 "\n",
p.gpsTimestamp);
result << fmt::sprintf(" GPS processing method: %s\n",
p.gpsProcessingMethod.string());
p.gpsProcessingMethod.c_str());
}

result << " White balance mode: ";
Expand Down
Loading

0 comments on commit 0188ed1

Please sign in to comment.