Use String8/16 c_str [camera]

Bug: 295394788
Test: make checkbuild
Change-Id: I7ca371112e891f4f40673b5c34e3b8ccc41841bf
Merged-In: I7ca371112e891f4f40673b5c34e3b8ccc41841bf
This commit is contained in:
Tomasz Wasilczyk 2023-08-23 18:46:52 +00:00
parent 7f2619ddff
commit 353d4c5c75
5 changed files with 18 additions and 19 deletions

View file

@ -275,7 +275,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) {
@ -483,9 +483,9 @@ status_t CameraMetadata::getTagFromName(const char *name,
size_t sectionLength = 0;
size_t totalSectionCount = ANDROID_SECTION_COUNT + vendorSectionCount;
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();
const char* str = (i < ANDROID_SECTION_COUNT)
? camera_metadata_section_names[i]
: (*vendorSections)[i - ANDROID_SECTION_COUNT].c_str();
ALOGV("%s: Trying to match against section '%s'", __FUNCTION__, str);

View file

@ -211,7 +211,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();
@ -277,7 +277,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
@ -469,7 +469,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());
}
}
@ -484,10 +484,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;
}

View file

@ -100,7 +100,7 @@ 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();
}
ssize_t VendorTagDescriptor::getSectionIndex(uint32_t tag) const {
@ -112,7 +112,7 @@ const char* VendorTagDescriptor::getTagName(uint32_t tag) const {
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 {
@ -130,13 +130,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;
}
@ -170,8 +170,8 @@ void VendorTagDescriptor::dump(int fd, int verbosity, int indentation) const {
int type = mTagToTypeMap.at(tag);
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());
dprintf(fd, "%*s0x%x (%s) with type %d (%s) defined in section %s\n", indentation + 2, "",
tag, name.c_str(), type, typeName, sectionName.c_str());
}
}

View file

@ -439,7 +439,7 @@ bool LegacyCameraProviderImpl_2_4::setUpVendorTags() {
}
mVendorTagSections.resize(numSections);
for (size_t s = 0; s < numSections; s++) {
mVendorTagSections[s].sectionName = (*sectionNames)[s].string();
mVendorTagSections[s].sectionName = (*sectionNames)[s].c_str();
mVendorTagSections[s].tags = tagsBySection[s];
}
return true;

View file

@ -244,7 +244,7 @@ namespace {
std::string* deviceVersion, std::string* cameraId) {
::android::String8 pattern;
pattern.appendFormat(kDeviceNameRE, providerType.c_str());
std::regex e(pattern.string());
std::regex e(pattern.c_str());
std::string deviceNameStd(deviceName.c_str());
std::smatch sm;
if (std::regex_match(deviceNameStd, sm, e)) {
@ -8801,8 +8801,7 @@ void CameraHidlTest::getParameters(
void CameraHidlTest::setParameters(
const sp<::android::hardware::camera::device::V1_0::ICameraDevice> &device,
const CameraParameters &cameraParams) {
Return<Status> returnStatus = device->setParameters(
cameraParams.flatten().string());
Return<Status> returnStatus = device->setParameters(cameraParams.flatten().c_str());
ASSERT_TRUE(returnStatus.isOk());
ASSERT_EQ(Status::OK, returnStatus);
}