Skip to content

Commit

Permalink
Migrate from android::String isEmpty to empty
Browse files Browse the repository at this point in the history
This empty method is different from the old one - it aligns with
std::string definition.

Bug: 295394788
Test: make checkbuild
Change-Id: I890b3dfa930002f4406e9d9aec024f94ada1cad0
  • Loading branch information
twasilczyk committed Aug 31, 2023
1 parent 604c767 commit fd9ffd1
Show file tree
Hide file tree
Showing 19 changed files with 28 additions and 28 deletions.
4 changes: 2 additions & 2 deletions camera/VendorTagDescriptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ status_t VendorTagDescriptor::readFromParcel(const android::Parcel* parcel) {
break;
}
String8 tagName = parcel->readString8();
if (tagName.isEmpty()) {
if (tagName.empty()) {
ALOGE("%s: parcel tag name was NULL for tag %d.", __FUNCTION__, tag);
res = NOT_ENOUGH_DATA;
break;
Expand Down Expand Up @@ -190,7 +190,7 @@ status_t VendorTagDescriptor::readFromParcel(const android::Parcel* parcel) {
"Vector capacity must be positive");
for (size_t i = 0; i < sectionCount; ++i) {
String8 sectionName = parcel->readString8();
if (sectionName.isEmpty()) {
if (sectionName.empty()) {
ALOGE("%s: parcel section name was NULL for section %zu.",
__FUNCTION__, i);
return NOT_ENOUGH_DATA;
Expand Down
4 changes: 2 additions & 2 deletions cmds/stagefright/stagefright.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,8 @@ static void playSource(sp<MediaSource> &source) {
}
rawSource = SimpleDecodingSource::Create(
source, flags, gSurface,
gComponentNameOverride.isEmpty() ? nullptr : gComponentNameOverride.c_str(),
!gComponentNameOverride.isEmpty());
gComponentNameOverride.empty() ? nullptr : gComponentNameOverride.c_str(),
!gComponentNameOverride.empty());
if (rawSource == NULL) {
return;
}
Expand Down
4 changes: 2 additions & 2 deletions drm/drmserver/DrmManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ void DrmManager::recordEngineMetrics(
}
}

if (!mimeType.isEmpty()) {
if (!mimeType.empty()) {
metrics.mMimeTypes.insert(mimeType.c_str());
} else if (NULL != info) {
DrmSupportInfo::MimeTypeIterator mimeIter = info->getMimeTypeIterator();
Expand Down Expand Up @@ -395,7 +395,7 @@ String8 DrmManager::getOriginalMimeType(int uniqueId, const String8& path, int f
IDrmEngine& rDrmEngine = mPlugInManager.getPlugIn(plugInId);
mimeType = rDrmEngine.getOriginalMimeType(uniqueId, path, fd);
}
if (!mimeType.isEmpty()) {
if (!mimeType.empty()) {
recordEngineMetrics(__func__, plugInId, mimeType);
}
return mimeType;
Expand Down
6 changes: 3 additions & 3 deletions drm/libmediadrm/DrmHalAidl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ ::ndk::ScopedAStatus DrmHalAidl::DrmSessionClient::getName(::std::string* _aidl_
sp<DrmHalAidl> drm = mDrm.promote();
if (drm == NULL) {
name.append("<deleted>");
} else if (drm->getPropertyStringInternal(String8("vendor"), name) != OK || name.isEmpty()) {
} else if (drm->getPropertyStringInternal(String8("vendor"), name) != OK || name.empty()) {
name.append("<Get vendor failed or is empty>");
}
name.append("[");
Expand Down Expand Up @@ -947,12 +947,12 @@ DrmStatus DrmHalAidl::getMetrics(const sp<IDrmMetricsConsumer>& consumer) {

String8 vendor;
String8 description;
if (getPropertyStringInternal(String8("vendor"), vendor) != OK || vendor.isEmpty()) {
if (getPropertyStringInternal(String8("vendor"), vendor) != OK || vendor.empty()) {
ALOGE("Get vendor failed or is empty");
vendor = "NONE";
}
if (getPropertyStringInternal(String8("description"), description) != OK ||
description.isEmpty()) {
description.empty()) {
ALOGE("Get description failed or is empty.");
description = "NONE";
}
Expand Down
6 changes: 3 additions & 3 deletions drm/libmediadrm/DrmHalHidl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ ::ndk::ScopedAStatus DrmHalHidl::DrmSessionClient::getName(::std::string* _aidl_
sp<DrmHalHidl> drm = mDrm.promote();
if (drm == NULL) {
name.append("<deleted>");
} else if (drm->getPropertyStringInternal(String8("vendor"), name) != OK || name.isEmpty()) {
} else if (drm->getPropertyStringInternal(String8("vendor"), name) != OK || name.empty()) {
name.append("<Get vendor failed or is empty>");
}
name.append("[");
Expand Down Expand Up @@ -1261,12 +1261,12 @@ DrmStatus DrmHalHidl::getMetrics(const sp<IDrmMetricsConsumer>& consumer) {
if (mPluginV1_1 != NULL) {
String8 vendor;
String8 description;
if (getPropertyStringInternal(String8("vendor"), vendor) != OK || vendor.isEmpty()) {
if (getPropertyStringInternal(String8("vendor"), vendor) != OK || vendor.empty()) {
ALOGE("Get vendor failed or is empty");
vendor = "NONE";
}
if (getPropertyStringInternal(String8("description"), description) != OK ||
description.isEmpty()) {
description.empty()) {
ALOGE("Get description failed or is empty.");
description = "NONE";
}
Expand Down
2 changes: 1 addition & 1 deletion drm/mediacas/plugins/clearkey/ClearKeyCasPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ static String8 sessionIdToString(const std::vector<uint8_t> &array) {
for (size_t i = 0; i < array.size(); i++) {
result.appendFormat("%02x ", array[i]);
}
if (result.isEmpty()) {
if (result.empty()) {
result.append("(null)");
}
return result;
Expand Down
2 changes: 1 addition & 1 deletion drm/mediacas/plugins/clearkey/JsonAssetLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ bool JsonAssetLoader::parseJsonObject(const String8& jsonObject,
*/
bool JsonAssetLoader::parseJsonAssetString(const String8& jsonAsset,
Vector<String8>* jsonObjects) {
if (jsonAsset.isEmpty()) {
if (jsonAsset.empty()) {
ALOGE("Empty JSON Web Key");
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion drm/mediacas/plugins/mock/MockCasPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ static String8 arrayToString(const std::vector<uint8_t> &array) {
for (size_t i = 0; i < array.size(); i++) {
result.appendFormat("%02x ", array[i]);
}
if (result.isEmpty()) {
if (result.empty()) {
result.append("(null)");
}
return result;
Expand Down
4 changes: 2 additions & 2 deletions drm/mediadrm/plugins/clearkey/default/JsonWebKey.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ bool JsonWebKey::extractKeysFromJsonWebKeySet(const String8& jsonWebKeySet,
return false;

if (findKey(mJsonObjects[i], &encodedKeyId, &encodedKey)) {
if (encodedKeyId.isEmpty() || encodedKey.isEmpty()) {
if (encodedKeyId.empty() || encodedKey.empty()) {
ALOGE("Must have both key id and key in the JsonWebKey set.");
continue;
}
Expand Down Expand Up @@ -225,7 +225,7 @@ bool JsonWebKey::parseJsonObject(const String8& jsonObject,
*/
bool JsonWebKey::parseJsonWebKeySet(const String8& jsonWebKeySet,
Vector<String8>* jsonObjects) {
if (jsonWebKeySet.isEmpty()) {
if (jsonWebKeySet.empty()) {
ALOGE("Empty JSON Web Key");
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion media/libaudioclient/tests/audiotrack_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ TEST(AudioTrackTest, TestAudioCbNotifier) {
EXPECT_EQ(cb->mDeviceId, ap->getAudioTrackHandle()->getRoutedDeviceId());
String8 keys;
keys = ap->getAudioTrackHandle()->getParameters(keys);
if (!keys.isEmpty()) {
if (!keys.empty()) {
std::cerr << "track parameters :: " << keys << std::endl;
}
EXPECT_TRUE(checkPatchPlayback(cb->mAudioIo, cb->mDeviceId));
Expand Down
2 changes: 1 addition & 1 deletion media/libdatasource/DataSourceFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ sp<DataSource> DataSourceFactory::CreateFromURI(

source = NuCachedSource2::Create(
mediaHTTP,
cacheConfig.isEmpty() ? NULL : cacheConfig.c_str(),
cacheConfig.empty() ? NULL : cacheConfig.c_str(),
disconnectAtHighwatermark);
} else if (!strncasecmp("data:", uri, 5)) {
source = DataURISource::Create(uri);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,7 @@ void StagefrightMetadataRetriever::parseMetaData() {
// To save the language codes for all timed text tracks
// If multiple text tracks present, the format will look
// like "eng:chi"
if (!timedTextLang.isEmpty()) {
if (!timedTextLang.empty()) {
mMetaData.add(METADATA_KEY_TIMED_TEXT_LANGUAGES, timedTextLang);
}

Expand Down
2 changes: 1 addition & 1 deletion media/libnblog/PerformanceAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ void dump(int fd, int indent, PerformanceAnalysisMap &threadPerformanceAnalysis)
PerformanceAnalysis& curr = hash.second;
// write performance data to console
curr.reportPerformance(&body, thread.first, hash.first);
if (!body.isEmpty()) {
if (!body.empty()) {
dumpLine(fd, indent, body);
body.clear();
}
Expand Down
2 changes: 1 addition & 1 deletion media/libnblog/Reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ void DumpReader::dump(int fd, size_t indent)
default:
break;
}
if (!body.isEmpty()) {
if (!body.empty()) {
dprintf(fd, "%.*s%s %s\n", (int)indent, "", timestamp.c_str(), body.c_str());
body.clear();
}
Expand Down
2 changes: 1 addition & 1 deletion media/libstagefright/NuMediaExtractor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ static String8 arrayToString(const std::vector<uint8_t> &array) {
for (size_t i = 0; i < array.size(); i++) {
result.appendFormat("%02x ", array[i]);
}
if (result.isEmpty()) {
if (result.empty()) {
result.append("(null)");
}
return result;
Expand Down
2 changes: 1 addition & 1 deletion media/libstagefright/httplive/HTTPDownloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ ssize_t HTTPDownloader::fetchBlock(
*out = buffer;
if (actualUrl != NULL) {
*actualUrl = mDataSource->getUri();
if (actualUrl->isEmpty()) {
if (actualUrl->empty()) {
*actualUrl = url;
}
}
Expand Down
2 changes: 1 addition & 1 deletion services/audioflinger/PatchPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -928,7 +928,7 @@ void AudioFlinger::PatchPanel::dump(int fd) const
}
}

if (!patchPanelDump.isEmpty()) {
if (!patchPanelDump.empty()) {
write(fd, patchPanelDump.c_str(), patchPanelDump.size());
}
}
Expand Down
4 changes: 2 additions & 2 deletions services/audiopolicy/managerdefault/AudioPolicyManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6129,7 +6129,7 @@ status_t AudioPolicyManager::checkInputsForDevice(const sp<DeviceDescriptor>& de

if (status == NO_ERROR) {
const String8& address = String8(device->address().c_str());
if (!address.isEmpty()) {
if (!address.empty()) {
char *param = audio_device_address_to_parameter(device->type(), address);
mpClientInterface->setParameters(input, String8(param));
free(param);
Expand Down Expand Up @@ -7876,7 +7876,7 @@ sp<SwAudioOutputDescriptor> AudioPolicyManager::openOutputWithProfileAndDevice(
sp<DeviceDescriptor> device = devices.getDeviceForOpening();
const audio_devices_t deviceType = device->type();
const String8 &address = String8(device->address().c_str());
if (!address.isEmpty()) {
if (!address.empty()) {
char *param = audio_device_address_to_parameter(deviceType, address.c_str());
mpClientInterface->setParameters(output, String8(param));
free(param);
Expand Down
2 changes: 1 addition & 1 deletion services/mediaresourcemanager/ResourceObserverService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ binder_status_t ResourceObserverService::dump(
String8 enabledEventsStr;
for (auto &event : sEvents) {
if (((uint64_t)observable.eventFilter & (uint64_t)event) != 0) {
if (!enabledEventsStr.isEmpty()) {
if (!enabledEventsStr.empty()) {
enabledEventsStr.append("|");
}
enabledEventsStr.append(toString(event).c_str());
Expand Down

0 comments on commit fd9ffd1

Please sign in to comment.