Use String8/16 c_str [tools]
Bug: 295394788
Test: make checkbuild
Change-Id: I82d6899d8c15a10b15399c39177290012bb5f13b
Merged-In: I82d6899d8c15a10b15399c39177290012bb5f13b
diff --git a/libs/androidfw/AssetManager.cpp b/libs/androidfw/AssetManager.cpp
index fb2b571..795bb3c 100644
--- a/libs/androidfw/AssetManager.cpp
+++ b/libs/androidfw/AssetManager.cpp
@@ -91,7 +91,7 @@
path.appendPath(kResourceCache);
char buf[256]; // 256 chars should be enough for anyone...
- strncpy(buf, pkgPath.string(), 255);
+ strncpy(buf, pkgPath.c_str(), 255);
buf[255] = '\0';
char* filename = buf;
while (*filename && *filename == '/') {
@@ -183,15 +183,15 @@
if (kAppZipName) {
realPath.appendPath(kAppZipName);
}
- ap.type = ::getFileType(realPath.string());
+ ap.type = ::getFileType(realPath.c_str());
if (ap.type == kFileTypeRegular) {
ap.path = realPath;
} else {
ap.path = path;
- ap.type = ::getFileType(path.string());
+ ap.type = ::getFileType(path.c_str());
if (ap.type != kFileTypeDirectory && ap.type != kFileTypeRegular) {
ALOGW("Asset path %s is neither a directory nor file (type=%d).",
- path.string(), (int)ap.type);
+ path.c_str(), (int)ap.type);
return false;
}
}
@@ -207,7 +207,7 @@
}
ALOGV("In %p Asset %s path: %s", this,
- ap.type == kFileTypeDirectory ? "dir" : "zip", ap.path.string());
+ ap.type == kFileTypeDirectory ? "dir" : "zip", ap.path.c_str());
ap.isSystemAsset = isSystemAsset;
ssize_t apPos = mAssetPaths.add(ap);
@@ -248,7 +248,7 @@
Asset* idmap = NULL;
if ((idmap = openAssetFromFileLocked(idmapPath, Asset::ACCESS_BUFFER)) == NULL) {
- ALOGW("failed to open idmap file %s\n", idmapPath.string());
+ ALOGW("failed to open idmap file %s\n", idmapPath.c_str());
return false;
}
@@ -256,7 +256,7 @@
String8 overlayPath;
if (!ResTable::getIdmapInfo(idmap->getBuffer(false), idmap->getLength(),
NULL, NULL, NULL, &targetPath, &overlayPath)) {
- ALOGW("failed to read idmap file %s\n", idmapPath.string());
+ ALOGW("failed to read idmap file %s\n", idmapPath.c_str());
delete idmap;
return false;
}
@@ -264,29 +264,29 @@
if (overlayPath != packagePath) {
ALOGW("idmap file %s inconcistent: expected path %s does not match actual path %s\n",
- idmapPath.string(), packagePath.string(), overlayPath.string());
+ idmapPath.c_str(), packagePath.c_str(), overlayPath.c_str());
return false;
}
- if (access(targetPath.string(), R_OK) != 0) {
- ALOGW("failed to access file %s: %s\n", targetPath.string(), strerror(errno));
+ if (access(targetPath.c_str(), R_OK) != 0) {
+ ALOGW("failed to access file %s: %s\n", targetPath.c_str(), strerror(errno));
return false;
}
- if (access(idmapPath.string(), R_OK) != 0) {
- ALOGW("failed to access file %s: %s\n", idmapPath.string(), strerror(errno));
+ if (access(idmapPath.c_str(), R_OK) != 0) {
+ ALOGW("failed to access file %s: %s\n", idmapPath.c_str(), strerror(errno));
return false;
}
- if (access(overlayPath.string(), R_OK) != 0) {
- ALOGW("failed to access file %s: %s\n", overlayPath.string(), strerror(errno));
+ if (access(overlayPath.c_str(), R_OK) != 0) {
+ ALOGW("failed to access file %s: %s\n", overlayPath.c_str(), strerror(errno));
return false;
}
asset_path oap;
oap.path = overlayPath;
- oap.type = ::getFileType(overlayPath.string());
+ oap.type = ::getFileType(overlayPath.c_str());
oap.idmap = idmapPath;
#if 0
ALOGD("Overlay added: targetPath=%s overlayPath=%s idmapPath=%s\n",
- targetPath.string(), overlayPath.string(), idmapPath.string());
+ targetPath.c_str(), overlayPath.c_str(), idmapPath.c_str());
#endif
mAssetPaths.add(oap);
*cookie = static_cast<int32_t>(mAssetPaths.size());
@@ -310,7 +310,7 @@
ap.type = kFileTypeRegular;
ap.assumeOwnership = assume_ownership;
- ALOGV("In %p Asset fd %d name: %s", this, fd, ap.path.string());
+ ALOGV("In %p Asset fd %d name: %s", this, fd, ap.path.c_str());
ssize_t apPos = mAssetPaths.add(ap);
@@ -343,11 +343,11 @@
assets[i] = openNonAssetInPathLocked("resources.arsc",
Asset::ACCESS_BUFFER, ap);
if (assets[i] == NULL) {
- ALOGW("failed to find resources.arsc in %s\n", ap.path.string());
+ ALOGW("failed to find resources.arsc in %s\n", ap.path.c_str());
goto exit;
}
if (tables[i].add(assets[i]) != NO_ERROR) {
- ALOGW("failed to add %s to resource table", paths[i].string());
+ ALOGW("failed to add %s to resource table", paths[i].c_str());
goto exit;
}
}
@@ -449,8 +449,8 @@
while (i > 0) {
i--;
ALOGV("Looking for asset '%s' in '%s'\n",
- assetName.string(), mAssetPaths.itemAt(i).path.string());
- Asset* pAsset = openNonAssetInPathLocked(assetName.string(), mode,
+ assetName.c_str(), mAssetPaths.itemAt(i).path.c_str());
+ Asset* pAsset = openNonAssetInPathLocked(assetName.c_str(), mode,
mAssetPaths.editItemAt(i));
if (pAsset != NULL) {
return pAsset != kExcludedAsset ? pAsset : NULL;
@@ -478,7 +478,7 @@
size_t i = mAssetPaths.size();
while (i > 0) {
i--;
- ALOGV("Looking for non-asset '%s' in '%s'\n", fileName, mAssetPaths.itemAt(i).path.string());
+ ALOGV("Looking for non-asset '%s' in '%s'\n", fileName, mAssetPaths.itemAt(i).path.c_str());
Asset* pAsset = openNonAssetInPathLocked(
fileName, mode, mAssetPaths.editItemAt(i));
if (pAsset != NULL) {
@@ -500,7 +500,7 @@
if (which < mAssetPaths.size()) {
ALOGV("Looking for non-asset '%s' in '%s'\n", fileName,
- mAssetPaths.itemAt(which).path.string());
+ mAssetPaths.itemAt(which).path.c_str());
Asset* pAsset = openNonAssetInPathLocked(
fileName, mode, mAssetPaths.editItemAt(which));
if (pAsset != NULL) {
@@ -546,10 +546,10 @@
ResTable* sharedRes = NULL;
bool shared = true;
bool onlyEmptyResources = true;
- ATRACE_NAME(ap.path.string());
+ ATRACE_NAME(ap.path.c_str());
Asset* idmap = openIdmapLocked(ap);
size_t nextEntryIdx = mResources->getTableCount();
- ALOGV("Looking for resource asset in '%s'\n", ap.path.string());
+ ALOGV("Looking for resource asset in '%s'\n", ap.path.c_str());
if (ap.type != kFileTypeDirectory && ap.rawFd < 0) {
if (nextEntryIdx == 0) {
// The first item is typically the framework resources,
@@ -565,7 +565,7 @@
ass = const_cast<AssetManager*>(this)->
mZipSet.getZipResourceTableAsset(ap.path);
if (ass == NULL) {
- ALOGV("loading resource table %s\n", ap.path.string());
+ ALOGV("loading resource table %s\n", ap.path.c_str());
ass = const_cast<AssetManager*>(this)->
openNonAssetInPathLocked("resources.arsc",
Asset::ACCESS_BUFFER,
@@ -580,7 +580,7 @@
// If this is the first resource table in the asset
// manager, then we are going to cache it so that we
// can quickly copy it out for others.
- ALOGV("Creating shared resources for %s", ap.path.string());
+ ALOGV("Creating shared resources for %s", ap.path.c_str());
sharedRes = new ResTable();
sharedRes->add(ass, idmap, nextEntryIdx + 1, false);
#ifdef __ANDROID__
@@ -589,14 +589,14 @@
String8 overlaysListPath(data);
overlaysListPath.appendPath(kResourceCache);
overlaysListPath.appendPath("overlays.list");
- addSystemOverlays(overlaysListPath.string(), ap.path, sharedRes, nextEntryIdx);
+ addSystemOverlays(overlaysListPath.c_str(), ap.path, sharedRes, nextEntryIdx);
#endif
sharedRes = const_cast<AssetManager*>(this)->
mZipSet.setZipResourceTable(ap.path, sharedRes);
}
}
} else {
- ALOGV("loading resource table %s\n", ap.path.string());
+ ALOGV("loading resource table %s\n", ap.path.c_str());
ass = const_cast<AssetManager*>(this)->
openNonAssetInPathLocked("resources.arsc",
Asset::ACCESS_BUFFER,
@@ -607,10 +607,10 @@
if ((ass != NULL || sharedRes != NULL) && ass != kExcludedAsset) {
ALOGV("Installing resource asset %p in to table %p\n", ass, mResources);
if (sharedRes != NULL) {
- ALOGV("Copying existing resources for %s", ap.path.string());
+ ALOGV("Copying existing resources for %s", ap.path.c_str());
mResources->add(sharedRes, ap.isSystemAsset);
} else {
- ALOGV("Parsing resources for %s", ap.path.string());
+ ALOGV("Parsing resources for %s", ap.path.c_str());
mResources->add(ass, idmap, nextEntryIdx + 1, !shared, appAsLib, ap.isSystemAsset);
}
onlyEmptyResources = false;
@@ -692,9 +692,9 @@
ass = const_cast<AssetManager*>(this)->
openAssetFromFileLocked(ap.idmap, Asset::ACCESS_BUFFER);
if (ass) {
- ALOGV("loading idmap %s\n", ap.idmap.string());
+ ALOGV("loading idmap %s\n", ap.idmap.c_str());
} else {
- ALOGW("failed to load idmap %s\n", ap.idmap.string());
+ ALOGW("failed to load idmap %s\n", ap.idmap.c_str());
}
}
return ass;
@@ -812,7 +812,7 @@
ZipFileRO* pZip = getZipFileLocked(ap);
if (pZip != NULL) {
ALOGV("GOT zip, checking NA '%s'", (const char*) path);
- ZipEntryRO entry = pZip->findEntryByName(path.string());
+ ZipEntryRO entry = pZip->findEntryByName(path.c_str());
if (entry != NULL) {
ALOGV("FOUND NA in Zip file for %s", (const char*) path);
pAsset = openAssetFromZipLocked(pZip, entry, mode, path);
@@ -823,7 +823,7 @@
if (pAsset != NULL) {
/* create a "source" name, for debug/display */
pAsset->setAssetSource(
- createZipSourceNameLocked(ZipSet::getPathName(ap.path.string()), String8(""),
+ createZipSourceNameLocked(ZipSet::getPathName(ap.path.c_str()), String8(""),
String8(fileName)));
}
}
@@ -870,7 +870,7 @@
}
if (ap.rawFd < 0) {
- ALOGV("getZipFileLocked: Creating new zip from path %s", ap.path.string());
+ ALOGV("getZipFileLocked: Creating new zip from path %s", ap.path.c_str());
ap.zip = mZipSet.getSharedZip(ap.path);
} else {
ALOGV("getZipFileLocked: Creating new zip from fd %d", ap.rawFd);
@@ -897,12 +897,12 @@
{
Asset* pAsset = NULL;
- if (strcasecmp(pathName.getPathExtension().string(), ".gz") == 0) {
+ if (strcasecmp(pathName.getPathExtension().c_str(), ".gz") == 0) {
//printf("TRYING '%s'\n", (const char*) pathName);
- pAsset = Asset::createFromCompressedFile(pathName.string(), mode);
+ pAsset = Asset::createFromCompressedFile(pathName.c_str(), mode);
} else {
//printf("TRYING '%s'\n", (const char*) pathName);
- pAsset = Asset::createFromFile(pathName.string(), mode);
+ pAsset = Asset::createFromFile(pathName.c_str(), mode);
}
return pAsset;
@@ -940,12 +940,12 @@
if (method == ZipFileRO::kCompressStored) {
pAsset = Asset::createFromUncompressedMap(std::move(*dataMap), mode);
- ALOGV("Opened uncompressed entry %s in zip %s mode %d: %p", entryName.string(),
+ ALOGV("Opened uncompressed entry %s in zip %s mode %d: %p", entryName.c_str(),
dataMap->file_name(), mode, pAsset.get());
} else {
pAsset = Asset::createFromCompressedMap(std::move(*dataMap),
static_cast<size_t>(uncompressedLen), mode);
- ALOGV("Opened compressed entry %s in zip %s mode %d: %p", entryName.string(),
+ ALOGV("Opened compressed entry %s in zip %s mode %d: %p", entryName.c_str(),
dataMap->file_name(), mode, pAsset.get());
}
if (pAsset == NULL) {
@@ -993,10 +993,10 @@
i--;
const asset_path& ap = mAssetPaths.itemAt(i);
if (ap.type == kFileTypeRegular) {
- ALOGV("Adding directory %s from zip %s", dirName, ap.path.string());
+ ALOGV("Adding directory %s from zip %s", dirName, ap.path.c_str());
scanAndMergeZipLocked(pMergedInfo, ap, kAssetsRoot, dirName);
} else {
- ALOGV("Adding directory %s from dir %s", dirName, ap.path.string());
+ ALOGV("Adding directory %s from dir %s", dirName, ap.path.c_str());
scanAndMergeDirLocked(pMergedInfo, ap, kAssetsRoot, dirName);
}
}
@@ -1042,10 +1042,10 @@
if (which < mAssetPaths.size()) {
const asset_path& ap = mAssetPaths.itemAt(which);
if (ap.type == kFileTypeRegular) {
- ALOGV("Adding directory %s from zip %s", dirName, ap.path.string());
+ ALOGV("Adding directory %s from zip %s", dirName, ap.path.c_str());
scanAndMergeZipLocked(pMergedInfo, ap, NULL, dirName);
} else {
- ALOGV("Adding directory %s from dir %s", dirName, ap.path.string());
+ ALOGV("Adding directory %s from dir %s", dirName, ap.path.c_str());
scanAndMergeDirLocked(pMergedInfo, ap, NULL, dirName);
}
}
@@ -1075,7 +1075,7 @@
{
assert(pMergedInfo != NULL);
- //printf("scanAndMergeDir: %s %s %s\n", ap.path.string(), rootDir, dirName);
+ //printf("scanAndMergeDir: %s %s %s\n", ap.path.c_str(), rootDir, dirName);
String8 path = createPathNameLocked(ap, rootDir);
if (dirName[0] != '\0')
@@ -1100,7 +1100,7 @@
const char* name;
int nameLen;
- name = pContents->itemAt(i).getFileName().string();
+ name = pContents->itemAt(i).getFileName().c_str();
nameLen = strlen(name);
if (nameLen > exclExtLen &&
strcmp(name + (nameLen - exclExtLen), kExcludeExtension) == 0)
@@ -1111,8 +1111,8 @@
matchIdx = AssetDir::FileInfo::findEntry(pMergedInfo, match);
if (matchIdx > 0) {
ALOGV("Excluding '%s' [%s]\n",
- pMergedInfo->itemAt(matchIdx).getFileName().string(),
- pMergedInfo->itemAt(matchIdx).getSourceName().string());
+ pMergedInfo->itemAt(matchIdx).getFileName().c_str(),
+ pMergedInfo->itemAt(matchIdx).getSourceName().c_str());
pMergedInfo->removeAt(matchIdx);
} else {
//printf("+++ no match on '%s'\n", (const char*) match);
@@ -1150,9 +1150,9 @@
struct dirent* entry;
FileType fileType;
- ALOGV("Scanning dir '%s'\n", path.string());
+ ALOGV("Scanning dir '%s'\n", path.c_str());
- dir = opendir(path.string());
+ dir = opendir(path.c_str());
if (dir == NULL)
return NULL;
@@ -1176,7 +1176,7 @@
fileType = kFileTypeUnknown;
#else
// stat the file
- fileType = ::getFileType(path.appendPathCopy(entry->d_name).string());
+ fileType = ::getFileType(path.appendPathCopy(entry->d_name).c_str());
#endif
if (fileType != kFileTypeRegular && fileType != kFileTypeDirectory)
@@ -1184,7 +1184,7 @@
AssetDir::FileInfo info;
info.set(String8(entry->d_name), fileType);
- if (strcasecmp(info.getFileName().getPathExtension().string(), ".gz") == 0)
+ if (strcasecmp(info.getFileName().getPathExtension().c_str(), ".gz") == 0)
info.setFileName(info.getFileName().getBasePath());
info.setSourceName(path.appendPathCopy(info.getFileName()));
pContents->add(info);
@@ -1212,11 +1212,11 @@
pZip = mZipSet.getZip(ap.path);
if (pZip == NULL) {
- ALOGW("Failure opening zip %s\n", ap.path.string());
+ ALOGW("Failure opening zip %s\n", ap.path.c_str());
return false;
}
- zipName = ZipSet::getPathName(ap.path.string());
+ zipName = ZipSet::getPathName(ap.path.c_str());
/* convert "sounds" to "rootDir/sounds" */
if (rootDir != NULL) dirName = rootDir;
@@ -1240,7 +1240,7 @@
*/
int dirNameLen = dirName.length();
void *iterationCookie;
- if (!pZip->startIteration(&iterationCookie, dirName.string(), NULL)) {
+ if (!pZip->startIteration(&iterationCookie, dirName.c_str(), NULL)) {
ALOGW("ZipFileRO::startIteration returned false");
return false;
}
@@ -1254,7 +1254,7 @@
ALOGE("ARGH: name too long?\n");
continue;
}
- //printf("Comparing %s in %s?\n", nameBuf, dirName.string());
+ //printf("Comparing %s in %s?\n", nameBuf, dirName.c_str());
if (dirNameLen == 0 || nameBuf[dirNameLen] == '/')
{
const char* cp;
@@ -1275,7 +1275,7 @@
createZipSourceNameLocked(zipName, dirName, info.getFileName()));
contents.add(info);
- //printf("FOUND: file '%s'\n", info.getFileName().string());
+ //printf("FOUND: file '%s'\n", info.getFileName().c_str());
} else {
/* this is a subdir; add it if we don't already have it*/
String8 subdirName(cp, nextSlash - cp);
@@ -1291,7 +1291,7 @@
dirs.add(subdirName);
}
- //printf("FOUND: dir '%s'\n", subdirName.string());
+ //printf("FOUND: dir '%s'\n", subdirName.c_str());
}
}
}
@@ -1427,10 +1427,10 @@
if (kIsDebug) {
ALOGI("Creating SharedZip %p %s\n", this, (const char*)mPath);
}
- ALOGV("+++ opening zip '%s'\n", mPath.string());
- mZipFile = ZipFileRO::open(mPath.string());
+ ALOGV("+++ opening zip '%s'\n", mPath.c_str());
+ mZipFile = ZipFileRO::open(mPath.c_str());
if (mZipFile == NULL) {
- ALOGD("failed to open Zip archive '%s'\n", mPath.string());
+ ALOGD("failed to open Zip archive '%s'\n", mPath.c_str());
}
}
@@ -1441,11 +1441,11 @@
if (kIsDebug) {
ALOGI("Creating SharedZip %p fd=%d %s\n", this, fd, (const char*)mPath);
}
- ALOGV("+++ opening zip fd=%d '%s'\n", fd, mPath.string());
- mZipFile = ZipFileRO::openFd(fd, mPath.string());
+ ALOGV("+++ opening zip fd=%d '%s'\n", fd, mPath.c_str());
+ mZipFile = ZipFileRO::openFd(fd, mPath.c_str());
if (mZipFile == NULL) {
::close(fd);
- ALOGD("failed to open Zip archive fd=%d '%s'\n", fd, mPath.string());
+ ALOGD("failed to open Zip archive fd=%d '%s'\n", fd, mPath.c_str());
}
}
@@ -1520,7 +1520,7 @@
bool AssetManager::SharedZip::isUpToDate()
{
- time_t modWhen = getFileModDate(mPath.string());
+ time_t modWhen = getFileModDate(mPath.c_str());
return mModWhen == modWhen;
}
@@ -1551,7 +1551,7 @@
}
if (mZipFile != NULL) {
delete mZipFile;
- ALOGV("Closed '%s'\n", mPath.string());
+ ALOGV("Closed '%s'\n", mPath.c_str());
}
}
diff --git a/libs/androidfw/BackupData.cpp b/libs/androidfw/BackupData.cpp
index 76a430e..fec0e77 100644
--- a/libs/androidfw/BackupData.cpp
+++ b/libs/androidfw/BackupData.cpp
@@ -106,8 +106,8 @@
k = key;
}
if (kIsDebug) {
- ALOGD("Writing header: prefix='%s' key='%s' dataSize=%zu", m_keyPrefix.string(),
- key.string(), dataSize);
+ ALOGD("Writing header: prefix='%s' key='%s' dataSize=%zu", m_keyPrefix.c_str(),
+ key.c_str(), dataSize);
}
entity_header_v1 header;
@@ -128,7 +128,7 @@
m_pos += amt;
if (kIsDebug) ALOGI("writing entity header key, %zd bytes", keyLen+1);
- amt = write(m_fd, k.string(), keyLen+1);
+ amt = write(m_fd, k.c_str(), keyLen+1);
if (amt != keyLen+1) {
m_status = errno;
return m_status;
diff --git a/libs/androidfw/BackupHelpers.cpp b/libs/androidfw/BackupHelpers.cpp
index e80e948..3582609 100644
--- a/libs/androidfw/BackupHelpers.cpp
+++ b/libs/androidfw/BackupHelpers.cpp
@@ -179,7 +179,7 @@
}
// filename is not NULL terminated, but it is padded
- amt = write(fd, name.string(), nameLen);
+ amt = write(fd, name.c_str(), nameLen);
if (amt != nameLen) {
ALOGW("write_snapshot_file error writing filename %s", strerror(errno));
return 1;
@@ -203,7 +203,7 @@
static int
write_delete_file(BackupDataWriter* dataStream, const String8& key)
{
- LOGP("write_delete_file %s\n", key.string());
+ LOGP("write_delete_file %s\n", key.c_str());
return dataStream->WriteEntityHeader(key, -1);
}
@@ -211,7 +211,7 @@
write_update_file(BackupDataWriter* dataStream, int fd, int mode, const String8& key,
char const* realFilename)
{
- LOGP("write_update_file %s (%s) : mode 0%o\n", realFilename, key.string(), mode);
+ LOGP("write_update_file %s (%s) : mode 0%o\n", realFilename, key.c_str(), mode);
const int bufsize = 4*1024;
int err;
@@ -365,7 +365,7 @@
r.s.size = st.st_size;
if (newSnapshot.indexOfKey(key) >= 0) {
- LOGP("back_up_files key already in use '%s'", key.string());
+ LOGP("back_up_files key already in use '%s'", key.c_str());
return -1;
}
@@ -390,30 +390,30 @@
int cmp = p.compare(q);
if (cmp < 0) {
// file present in oldSnapshot, but not present in newSnapshot
- LOGP("file removed: %s", p.string());
+ LOGP("file removed: %s", p.c_str());
write_delete_file(dataStream, p);
n++;
} else if (cmp > 0) {
// file added
- LOGP("file added: %s crc=0x%08x", g.file.string(), g.s.crc32);
- write_update_file(dataStream, q, g.file.string());
+ LOGP("file added: %s crc=0x%08x", g.file.c_str(), g.s.crc32);
+ write_update_file(dataStream, q, g.file.c_str());
m++;
} else {
// same file exists in both old and new; check whether to update
const FileState& f = oldSnapshot.valueAt(n);
- LOGP("%s", q.string());
+ LOGP("%s", q.c_str());
LOGP(" old: modTime=%d,%d mode=%04o size=%-3d crc32=0x%08x",
f.modTime_sec, f.modTime_nsec, f.mode, f.size, f.crc32);
LOGP(" new: modTime=%d,%d mode=%04o size=%-3d crc32=0x%08x",
g.s.modTime_sec, g.s.modTime_nsec, g.s.mode, g.s.size, g.s.crc32);
if (f.modTime_sec != g.s.modTime_sec || f.modTime_nsec != g.s.modTime_nsec
|| f.mode != g.s.mode || f.size != g.s.size || f.crc32 != g.s.crc32) {
- int fd = open(g.file.string(), O_RDONLY);
+ int fd = open(g.file.c_str(), O_RDONLY);
if (fd < 0) {
- ALOGE("Unable to read file for backup: %s", g.file.string());
+ ALOGE("Unable to read file for backup: %s", g.file.c_str());
} else {
- write_update_file(dataStream, fd, g.s.mode, p, g.file.string());
+ write_update_file(dataStream, fd, g.s.mode, p, g.file.c_str());
close(fd);
}
}
@@ -432,7 +432,7 @@
while (m<M) {
const String8& q = newSnapshot.keyAt(m);
FileRec& g = newSnapshot.editValueAt(m);
- write_update_file(dataStream, q, g.file.string());
+ write_update_file(dataStream, q, g.file.c_str());
m++;
}
@@ -483,7 +483,7 @@
BackupDataWriter* writer)
{
// In the output stream everything is stored relative to the root
- const char* relstart = filepath.string() + rootpath.length();
+ const char* relstart = filepath.c_str() + rootpath.length();
if (*relstart == '/') relstart++; // won't be true when path == rootpath
String8 relpath(relstart);
@@ -514,9 +514,9 @@
int err = 0;
struct stat64 s;
- if (lstat64(filepath.string(), &s) != 0) {
+ if (lstat64(filepath.c_str(), &s) != 0) {
err = errno;
- ALOGE("Error %d (%s) from lstat64(%s)", err, strerror(err), filepath.string());
+ ALOGE("Error %d (%s) from lstat64(%s)", err, strerror(err), filepath.c_str());
return err;
}
@@ -541,10 +541,10 @@
// !!! TODO: use mmap when possible to avoid churning the buffer cache
// !!! TODO: this will break with symlinks; need to use readlink(2)
- int fd = open(filepath.string(), O_RDONLY);
+ int fd = open(filepath.c_str(), O_RDONLY);
if (fd < 0) {
err = errno;
- ALOGE("Error %d (%s) from open(%s)", err, strerror(err), filepath.string());
+ ALOGE("Error %d (%s) from open(%s)", err, strerror(err), filepath.c_str());
return err;
}
@@ -592,7 +592,7 @@
} else if (S_ISREG(s.st_mode)) {
type = '0'; // tar magic: '0' == normal file
} else {
- ALOGW("Error: unknown file mode 0%o [%s]", s.st_mode, filepath.string());
+ ALOGW("Error: unknown file mode 0%o [%s]", s.st_mode, filepath.c_str());
goto cleanup;
}
buf[156] = type;
@@ -620,16 +620,16 @@
// [ 345 : 155 ] filename path prefix
// We only use the prefix area if fullname won't fit in the path
if (fullname.length() > 100) {
- strncpy(buf, relpath.string(), 100);
- strncpy(buf + 345, prefix.string(), 155);
+ strncpy(buf, relpath.c_str(), 100);
+ strncpy(buf + 345, prefix.c_str(), 155);
} else {
- strncpy(buf, fullname.string(), 100);
+ strncpy(buf, fullname.c_str(), 100);
}
}
// [ 329 : 8 ] and [ 337 : 8 ] devmajor/devminor, not used
- ALOGI(" Name: %s", fullname.string());
+ ALOGI(" Name: %s", fullname.c_str());
// If we're using a pax extended header, build & write that here; lengths are
// already preflighted
@@ -647,7 +647,7 @@
// fullname was generated above with the ustar paths
paxLen += write_pax_header_entry(paxData + paxLen, PAXDATA_SIZE - paxLen,
- "path", fullname.string());
+ "path", fullname.c_str());
// Now we know how big the pax data is
@@ -656,9 +656,9 @@
String8 leaf = fullname.getPathLeaf();
memset(paxHeader, 0, 100); // rewrite the name area
- snprintf(paxHeader, 100, "PaxHeader/%s", leaf.string());
+ snprintf(paxHeader, 100, "PaxHeader/%s", leaf.c_str());
memset(paxHeader + 345, 0, 155); // rewrite the prefix area
- strncpy(paxHeader + 345, prefix.string(), 155);
+ strncpy(paxHeader + 345, prefix.c_str(), 155);
paxHeader[156] = 'x'; // mark it as a pax extended header
@@ -691,12 +691,12 @@
ssize_t nRead = read(fd, buf, toRead);
if (nRead < 0) {
err = errno;
- ALOGE("Unable to read file [%s], err=%d (%s)", filepath.string(),
+ ALOGE("Unable to read file [%s], err=%d (%s)", filepath.c_str(),
err, strerror(err));
break;
} else if (nRead == 0) {
ALOGE("EOF but expect %lld more bytes in [%s]", (long long) toWrite,
- filepath.string());
+ filepath.c_str());
err = EIO;
break;
}
@@ -762,7 +762,7 @@
file_metadata_v1 metadata;
amt = in->ReadEntityData(&metadata, sizeof(metadata));
if (amt != sizeof(metadata)) {
- ALOGW("Could not read metadata for %s -- %ld / %s", filename.string(),
+ ALOGW("Could not read metadata for %s -- %ld / %s", filename.c_str(),
(long)amt, strerror(errno));
return EIO;
}
@@ -779,9 +779,9 @@
// Write the file and compute the crc
crc = crc32(0L, Z_NULL, 0);
- fd = open(filename.string(), O_CREAT|O_RDWR|O_TRUNC, mode);
+ fd = open(filename.c_str(), O_CREAT|O_RDWR|O_TRUNC, mode);
if (fd == -1) {
- ALOGW("Could not open file %s -- %s", filename.string(), strerror(errno));
+ ALOGW("Could not open file %s -- %s", filename.c_str(), strerror(errno));
return errno;
}
@@ -789,7 +789,7 @@
err = write(fd, buf, amt);
if (err != amt) {
close(fd);
- ALOGW("Error '%s' writing '%s'", strerror(errno), filename.string());
+ ALOGW("Error '%s' writing '%s'", strerror(errno), filename.c_str());
return errno;
}
crc = crc32(crc, (Bytef*)buf, amt);
@@ -798,9 +798,9 @@
close(fd);
// Record for the snapshot
- err = stat(filename.string(), &st);
+ err = stat(filename.c_str(), &st);
if (err != 0) {
- ALOGW("Error stating file that we just created %s", filename.string());
+ ALOGW("Error stating file that we just created %s", filename.c_str());
return errno;
}
@@ -1104,9 +1104,9 @@
fprintf(stderr, "state %zu expected={%d/%d, %04o, 0x%08x, 0x%08x, %3zu} '%s'\n"
" actual={%d/%d, %04o, 0x%08x, 0x%08x, %3d} '%s'\n", i,
states[i].modTime_sec, states[i].modTime_nsec, states[i].mode, states[i].size,
- states[i].crc32, name.length(), filenames[i].string(),
+ states[i].crc32, name.length(), filenames[i].c_str(),
state.modTime_sec, state.modTime_nsec, state.mode, state.size, state.crc32,
- state.nameLen, name.string());
+ state.nameLen, name.c_str());
matched = false;
}
}
@@ -1152,9 +1152,9 @@
return err;
}
- err = writer.WriteEntityData(text.string(), text.length()+1);
+ err = writer.WriteEntityData(text.c_str(), text.length()+1);
if (err != 0) {
- fprintf(stderr, "write failed for data '%s'\n", text.string());
+ fprintf(stderr, "write failed for data '%s'\n", text.c_str());
return errno;
}
@@ -1230,7 +1230,7 @@
goto finished;
}
if (string != str) {
- fprintf(stderr, "ReadEntityHeader expected key '%s' got '%s'\n", str, string.string());
+ fprintf(stderr, "ReadEntityHeader expected key '%s' got '%s'\n", str, string.c_str());
err = EINVAL;
goto finished;
}
diff --git a/libs/androidfw/ConfigDescription.cpp b/libs/androidfw/ConfigDescription.cpp
index 19ead95..952101b 100644
--- a/libs/androidfw/ConfigDescription.cpp
+++ b/libs/androidfw/ConfigDescription.cpp
@@ -878,7 +878,7 @@
std::string ConfigDescription::to_string() const {
const String8 str = toString();
- return std::string(str.string(), str.size());
+ return std::string(str.c_str(), str.size());
}
bool ConfigDescription::Dominates(const ConfigDescription& o) const {
diff --git a/libs/androidfw/CursorWindow.cpp b/libs/androidfw/CursorWindow.cpp
index 3527eee..5aa8e70 100644
--- a/libs/androidfw/CursorWindow.cpp
+++ b/libs/androidfw/CursorWindow.cpp
@@ -84,7 +84,7 @@
String8 ashmemName("CursorWindow: ");
ashmemName.append(mName);
- ashmemFd = ashmem_create_region(ashmemName.string(), mInflatedSize);
+ ashmemFd = ashmem_create_region(ashmemName.c_str(), mInflatedSize);
if (ashmemFd < 0) {
PLOG(ERROR) << "Failed ashmem_create_region";
goto fail_silent;
diff --git a/libs/androidfw/ObbFile.cpp b/libs/androidfw/ObbFile.cpp
index 95332a3..c6a9632 100644
--- a/libs/androidfw/ObbFile.cpp
+++ b/libs/androidfw/ObbFile.cpp
@@ -217,7 +217,7 @@
free(scanBuf);
#ifdef DEBUG
- ALOGI("Obb scan succeeded: packageName=%s, version=%d\n", mPackageName.string(), mVersion);
+ ALOGI("Obb scan succeeded: packageName=%s, version=%d\n", mPackageName.c_str(), mVersion);
#endif
return true;
@@ -288,7 +288,7 @@
return false;
}
- if (write(fd, mPackageName.string(), packageNameLen) != (ssize_t)packageNameLen) {
+ if (write(fd, mPackageName.c_str(), packageNameLen) != (ssize_t)packageNameLen) {
ALOGW("couldn't write package name: %s\n", strerror(errno));
return false;
}
diff --git a/libs/androidfw/ResourceTypes.cpp b/libs/androidfw/ResourceTypes.cpp
index 5e8a623..0e7d841 100644
--- a/libs/androidfw/ResourceTypes.cpp
+++ b/libs/androidfw/ResourceTypes.cpp
@@ -1029,7 +1029,7 @@
if ((mHeader->flags&ResStringPool_header::UTF8_FLAG) != 0) {
if (kDebugStringPoolNoisy) {
- ALOGI("indexOfString UTF-8: %s", String8(str, strLen).string());
+ ALOGI("indexOfString UTF-8: %s", String8(str, strLen).c_str());
}
// The string pool contains UTF 8 strings; we don't want to cause
@@ -1090,7 +1090,7 @@
ALOGI("Looking at %s, i=%d\n", s->data(), i);
}
if (str8Len == s->size()
- && memcmp(s->data(), str8.string(), str8Len) == 0) {
+ && memcmp(s->data(), str8.c_str(), str8Len) == 0) {
if (kDebugStringPoolNoisy) {
ALOGI("MATCH!");
}
@@ -1102,7 +1102,7 @@
} else {
if (kDebugStringPoolNoisy) {
- ALOGI("indexOfString UTF-16: %s", String8(str, strLen).string());
+ ALOGI("indexOfString UTF-16: %s", String8(str, strLen).c_str());
}
if (mHeader->flags&ResStringPool_header::SORTED_FLAG) {
@@ -1120,7 +1120,7 @@
int c = s.has_value() ? strzcmp16(s->data(), s->size(), str, strLen) : -1;
if (kDebugStringPoolNoisy) {
ALOGI("Looking at %s, cmp=%d, l/mid/h=%d/%d/%d\n",
- String8(s->data(), s->size()).string(), c, (int)l, (int)mid, (int)h);
+ String8(s->data(), s->size()).c_str(), c, (int)l, (int)mid, (int)h);
}
if (c == 0) {
if (kDebugStringPoolNoisy) {
@@ -1144,7 +1144,7 @@
return base::unexpected(s.error());
}
if (kDebugStringPoolNoisy) {
- ALOGI("Looking at %s, i=%d\n", String8(s->data(), s->size()).string(), i);
+ ALOGI("Looking at %s, i=%d\n", String8(s->data(), s->size()).c_str(), i);
}
if (s.has_value() && strLen == s->size() &&
strzcmp16(s->data(), s->size(), str, strLen) == 0) {
@@ -1512,8 +1512,8 @@
{
String16 nsStr(ns != NULL ? ns : "");
String16 attrStr(attr);
- return indexOfAttribute(ns ? nsStr.string() : NULL, ns ? nsStr.size() : 0,
- attrStr.string(), attrStr.size());
+ return indexOfAttribute(ns ? nsStr.c_str() : NULL, ns ? nsStr.size() : 0,
+ attrStr.c_str(), attrStr.size());
}
ssize_t ResXMLParser::indexOfAttribute(const char16_t* ns, size_t nsLen,
@@ -1531,8 +1531,8 @@
}
attr8 = String8(attr, attrLen);
if (kDebugStringPoolNoisy) {
- ALOGI("indexOfAttribute UTF8 %s (%zu) / %s (%zu)", ns8.string(), nsLen,
- attr8.string(), attrLen);
+ ALOGI("indexOfAttribute UTF8 %s (%zu) / %s (%zu)", ns8.c_str(), nsLen,
+ attr8.c_str(), attrLen);
}
for (size_t i=0; i<N; i++) {
size_t curNsLen = 0, curAttrLen = 0;
@@ -1542,7 +1542,7 @@
ALOGI(" curNs=%s (%zu), curAttr=%s (%zu)", curNs, curNsLen, curAttr, curAttrLen);
}
if (curAttr != NULL && curNsLen == nsLen && curAttrLen == attrLen
- && memcmp(attr8.string(), curAttr, attrLen) == 0) {
+ && memcmp(attr8.c_str(), curAttr, attrLen) == 0) {
if (ns == NULL) {
if (curNs == NULL) {
if (kDebugStringPoolNoisy) {
@@ -1552,8 +1552,8 @@
}
} else if (curNs != NULL) {
//printf(" --> ns=%s, curNs=%s\n",
- // String8(ns).string(), String8(curNs).string());
- if (memcmp(ns8.string(), curNs, nsLen) == 0) {
+ // String8(ns).c_str(), String8(curNs).c_str());
+ if (memcmp(ns8.c_str(), curNs, nsLen) == 0) {
if (kDebugStringPoolNoisy) {
ALOGI(" FOUND!");
}
@@ -1565,8 +1565,8 @@
} else {
if (kDebugStringPoolNoisy) {
ALOGI("indexOfAttribute UTF16 %s (%zu) / %s (%zu)",
- String8(ns, nsLen).string(), nsLen,
- String8(attr, attrLen).string(), attrLen);
+ String8(ns, nsLen).c_str(), nsLen,
+ String8(attr, attrLen).c_str(), attrLen);
}
for (size_t i=0; i<N; i++) {
size_t curNsLen = 0, curAttrLen = 0;
@@ -1574,8 +1574,8 @@
const char16_t* curAttr = getAttributeName(i, &curAttrLen);
if (kDebugStringPoolNoisy) {
ALOGI(" curNs=%s (%zu), curAttr=%s (%zu)",
- String8(curNs, curNsLen).string(), curNsLen,
- String8(curAttr, curAttrLen).string(), curAttrLen);
+ String8(curNs, curNsLen).c_str(), curNsLen,
+ String8(curAttr, curAttrLen).c_str(), curAttrLen);
}
if (curAttr != NULL && curNsLen == nsLen && curAttrLen == attrLen
&& (memcmp(attr, curAttr, attrLen*sizeof(char16_t)) == 0)) {
@@ -1588,7 +1588,7 @@
}
} else if (curNs != NULL) {
//printf(" --> ns=%s, curNs=%s\n",
- // String8(ns).string(), String8(curNs).string());
+ // String8(ns).c_str(), String8(curNs).c_str());
if (memcmp(ns, curNs, nsLen*sizeof(char16_t)) == 0) {
if (kDebugStringPoolNoisy) {
ALOGI(" FOUND!");
@@ -4412,7 +4412,7 @@
return false;
}
- outName->package = grp->name.string();
+ outName->package = grp->name.c_str();
outName->packageLen = grp->name.size();
if (allowUtf8) {
outName->type8 = UnpackOptionalString(entry.typeStr.string8(), &outName->typeLen);
@@ -4518,7 +4518,7 @@
outValue->dataType,
outValue->dataType == Res_value::TYPE_STRING ?
String8(UnpackOptionalString(
- entry.package->header->values.stringAt(outValue->data), &len)).string() :
+ entry.package->header->values.stringAt(outValue->data), &len)).c_str() :
"",
outValue->data);
}
@@ -4888,7 +4888,7 @@
AutoMutex _lock2(mFilteredConfigLock);
if (kDebugTableGetEntry) {
- ALOGI("Setting parameters: %s\n", params->toString().string());
+ ALOGI("Setting parameters: %s\n", params->toString().c_str());
}
mParams = *params;
for (size_t p = 0; p < mPackageGroups.size(); p++) {
@@ -4999,7 +4999,7 @@
if (name[1] == 'i' && name[2] == 'n'
&& name[3] == 'd' && name[4] == 'e' && name[5] == 'x'
&& name[6] == '_') {
- int index = atoi(String8(name + 7, nameLen - 7).string());
+ int index = atoi(String8(name + 7, nameLen - 7).c_str());
if (Res_CHECKID(index)) {
ALOGW("Array resource index: %d is too large.",
index);
@@ -5065,9 +5065,9 @@
if (kDebugTableNoisy) {
printf("Looking for identifier: type=%s, name=%s, package=%s\n",
- String8(type, typeLen).string(),
- String8(name, nameLen).string(),
- String8(package, packageLen).string());
+ String8(type, typeLen).c_str(),
+ String8(name, nameLen).c_str(),
+ String8(package, packageLen).c_str());
}
const String16 attr("attr");
@@ -5078,9 +5078,9 @@
const PackageGroup* group = mPackageGroups[ig];
if (strzcmp16(package, packageLen,
- group->name.string(), group->name.size())) {
+ group->name.c_str(), group->name.size())) {
if (kDebugTableNoisy) {
- printf("Skipping package group: %s\n", String8(group->name).string());
+ printf("Skipping package group: %s\n", String8(group->name).c_str());
}
continue;
}
@@ -5105,8 +5105,8 @@
}
return identifier;
}
- } while (strzcmp16(attr.string(), attr.size(), targetType, targetTypeLen) == 0
- && (targetType = attrPrivate.string())
+ } while (strzcmp16(attr.c_str(), attr.size(), targetType, targetTypeLen) == 0
+ && (targetType = attrPrivate.c_str())
&& (targetTypeLen = attrPrivate.size())
);
}
@@ -5525,7 +5525,7 @@
}
}
- //printf("Value for: %s\n", String8(s, len).string());
+ //printf("Value for: %s\n", String8(s, len).c_str());
uint32_t l10nReq = ResTable_map::L10N_NOT_REQUIRED;
uint32_t attrMin = 0x80000000, attrMax = 0x7fffffff;
@@ -5580,7 +5580,7 @@
// be to any other type; we just need to count on the client making
// sure the referenced type is correct.
- //printf("Looking up ref: %s\n", String8(s, len).string());
+ //printf("Looking up ref: %s\n", String8(s, len).c_str());
// It's a reference!
if (len == 5 && s[1]=='n' && s[2]=='u' && s[3]=='l' && s[4]=='l') {
@@ -5620,8 +5620,8 @@
}
uint32_t specFlags = 0;
- uint32_t rid = identifierForName(name.string(), name.size(), type.string(),
- type.size(), package.string(), package.size(), &specFlags);
+ uint32_t rid = identifierForName(name.c_str(), name.size(), type.c_str(),
+ type.size(), package.c_str(), package.size(), &specFlags);
if (rid != 0) {
if (enforcePrivate) {
if (accessor == NULL || accessor->getAssetsPackage() != package) {
@@ -5640,8 +5640,8 @@
Res_GETTYPE(rid), Res_GETENTRY(rid));
if (kDebugTableNoisy) {
ALOGI("Incl %s:%s/%s: 0x%08x\n",
- String8(package).string(), String8(type).string(),
- String8(name).string(), rid);
+ String8(package).c_str(), String8(type).c_str(),
+ String8(name).c_str(), rid);
}
}
@@ -5659,8 +5659,8 @@
if (rid != 0) {
if (kDebugTableNoisy) {
ALOGI("Pckg %s:%s/%s: 0x%08x\n",
- String8(package).string(), String8(type).string(),
- String8(name).string(), rid);
+ String8(package).c_str(), String8(type).c_str(),
+ String8(name).c_str(), rid);
}
uint32_t packageId = Res_GETPACKAGE(rid) + 1;
if (packageId == 0x00) {
@@ -5749,7 +5749,7 @@
}
} else {
outValue->data = color;
- //printf("Color input=%s, output=0x%x\n", String8(s, len).string(), color);
+ //printf("Color input=%s, output=0x%x\n", String8(s, len).c_str(), color);
return true;
}
} else {
@@ -5761,8 +5761,8 @@
#if 0
fprintf(stderr, "%s: Color ID %s value %s is not valid\n",
"Resource File", //(const char*)in->getPrintableSource(),
- String8(*curTag).string(),
- String8(s, len).string());
+ String8(*curTag).c_str(),
+ String8(s, len).c_str());
#endif
return false;
}
@@ -5776,7 +5776,7 @@
// be to any other type; we just need to count on the client making
// sure the referenced type is correct.
- //printf("Looking up attr: %s\n", String8(s, len).string());
+ //printf("Looking up attr: %s\n", String8(s, len).c_str());
static const String16 attr16("attr");
String16 package, type, name;
@@ -5789,13 +5789,13 @@
}
//printf("Pkg: %s, Type: %s, Name: %s\n",
- // String8(package).string(), String8(type).string(),
- // String8(name).string());
+ // String8(package).c_str(), String8(type).c_str(),
+ // String8(name).c_str());
uint32_t specFlags = 0;
uint32_t rid =
- identifierForName(name.string(), name.size(),
- type.string(), type.size(),
- package.string(), package.size(), &specFlags);
+ identifierForName(name.c_str(), name.size(),
+ type.c_str(), type.size(),
+ package.c_str(), package.size(), &specFlags);
if (rid != 0) {
if (enforcePrivate) {
if ((specFlags&ResTable_typeSpec::SPEC_PUBLIC) == 0) {
@@ -5953,8 +5953,8 @@
if (getResourceName(bag->map.name.ident, false, &rname)) {
#if 0
printf("Matching %s against %s (0x%08x)\n",
- String8(s, len).string(),
- String8(rname.name, rname.nameLen).string(),
+ String8(s, len).c_str(),
+ String8(rname.name, rname.nameLen).c_str(),
bag->map.name.ident);
#endif
if (strzcmp16(s, len, rname.name, rname.nameLen) == 0) {
@@ -5997,7 +5997,7 @@
while (pos < end && *pos != '|') {
pos++;
}
- //printf("Looking for: %s\n", String8(start, pos-start).string());
+ //printf("Looking for: %s\n", String8(start, pos-start).c_str());
const bag_entry* bagi = bag;
ssize_t i;
for (i=0; i<cnt; i++, bagi++) {
@@ -6006,8 +6006,8 @@
if (getResourceName(bagi->map.name.ident, false, &rname)) {
#if 0
printf("Matching %s against %s (0x%08x)\n",
- String8(start,pos-start).string(),
- String8(rname.name, rname.nameLen).string(),
+ String8(start,pos-start).c_str(),
+ String8(rname.name, rname.nameLen).c_str(),
bagi->map.name.ident);
#endif
if (strzcmp16(start, pos-start, rname.name, rname.nameLen) == 0) {
@@ -6334,7 +6334,7 @@
}
static bool compareString8AndCString(const String8& str, const char* cStr) {
- return strcmp(str.string(), cStr) < 0;
+ return strcmp(str.c_str(), cStr) < 0;
}
void ResTable::getLocales(Vector<String8>* locales, bool includeSystemLocales,
@@ -6348,7 +6348,7 @@
const auto endIter = locales->end();
auto iter = std::lower_bound(beginIter, endIter, locale, compareString8AndCString);
- if (iter == endIter || strcmp(iter->string(), locale) != 0) {
+ if (iter == endIter || strcmp(iter->c_str(), locale) != 0) {
locales->insertAt(String8(locale), std::distance(beginIter, iter));
}
});
@@ -6940,7 +6940,7 @@
ResTable_config thisConfig;
thisConfig.copyFromDtoH(type->config);
ALOGI("Adding config to type %d: %s\n", type->id,
- thisConfig.toString().string());
+ thisConfig.toString().c_str());
}
}
} else {
@@ -7018,7 +7018,7 @@
char16_t tmpName[sizeof(entry->packageName) / sizeof(char16_t)];
strcpy16_dtoh(tmpName, entry->packageName, sizeof(entry->packageName) / sizeof(char16_t));
if (kDebugLibNoisy) {
- ALOGV("Found lib entry %s with id %d\n", String8(tmpName).string(),
+ ALOGV("Found lib entry %s with id %d\n", String8(tmpName).c_str(),
dtohl(entry->packageId));
}
if (packageId >= 256) {
@@ -7300,7 +7300,7 @@
current_res.nameLen,
current_res.type,
current_res.typeLen,
- targetPackageName.string(),
+ targetPackageName.c_str(),
targetPackageName.size(),
&typeSpecFlags);
@@ -7407,7 +7407,7 @@
}
-#define CHAR16_TO_CSTR(c16, len) (String8(String16(c16,len)).string())
+#define CHAR16_TO_CSTR(c16, len) (String8(String16(c16,len)).c_str())
#define CHAR16_ARRAY_EQ(constant, var, len) \
(((len) == (sizeof(constant)/sizeof((constant)[0]))) && (0 == memcmp((var), (constant), (len))))
@@ -7502,13 +7502,13 @@
const char* str8 = UnpackOptionalString(pkg->header->values.string8At(
value.data), &len);
if (str8 != NULL) {
- printf("(string8) \"%s\"\n", normalizeForOutput(str8).string());
+ printf("(string8) \"%s\"\n", normalizeForOutput(str8).c_str());
} else {
const char16_t* str16 = UnpackOptionalString(pkg->header->values.stringAt(
value.data), &len);
if (str16 != NULL) {
printf("(string16) \"%s\"\n",
- normalizeForOutput(String8(str16, len).string()).string());
+ normalizeForOutput(String8(str16, len).c_str()).c_str());
} else {
printf("(string) null\n");
}
@@ -7549,7 +7549,7 @@
const PackageGroup* pg = mPackageGroups[pgIndex];
printf("Package Group %d id=0x%02x packageCount=%d name=%s\n",
(int)pgIndex, pg->id, (int)pg->packages.size(),
- String8(pg->name).string());
+ String8(pg->name).c_str());
const KeyedVector<String16, uint8_t>& refEntries = pg->dynamicRefTable.entries();
const size_t refEntryCount = refEntries.size();
@@ -7558,7 +7558,7 @@
for (size_t refIndex = 0; refIndex < refEntryCount; refIndex++) {
printf(" 0x%02x -> %s\n",
refEntries.valueAt(refIndex),
- String8(refEntries.keyAt(refIndex)).string());
+ String8(refEntries.keyAt(refIndex)).c_str());
}
printf("\n");
}
@@ -7584,7 +7584,7 @@
strcpy16_dtoh(tmpName, pkg->package->name,
sizeof(pkg->package->name)/sizeof(pkg->package->name[0]));
printf(" Package %d id=0x%02x name=%s\n", (int)pkgIndex,
- pkg->package->id, String8(tmpName).string());
+ pkg->package->id, String8(tmpName).c_str());
}
for (size_t typeIndex = 0; typeIndex < pg->types.size(); typeIndex++) {
@@ -7626,7 +7626,7 @@
printf(" spec resource 0x%08x %s:%s/%s: flags=0x%08x\n",
resID,
CHAR16_TO_CSTR(resName.package, resName.packageLen),
- type8.string(), name8.string(),
+ type8.c_str(), name8.c_str(),
dtohl(typeConfigs->typeSpecFlags[entryIndex]));
} else {
printf(" INVALID TYPE CONFIG FOR RESOURCE 0x%08x\n", resID);
@@ -7647,7 +7647,7 @@
String8 configStr = thisConfig.toString();
printf(" config %s", configStr.size() > 0
- ? configStr.string() : "(default)");
+ ? configStr.c_str() : "(default)");
if (type->flags != 0u) {
printf(" flags=0x%02x", type->flags);
if (type->flags & ResTable_type::FLAG_SPARSE) {
@@ -7712,7 +7712,7 @@
}
printf(" resource 0x%08x %s:%s/%s: ", resID,
CHAR16_TO_CSTR(resName.package, resName.packageLen),
- type8.string(), name8.string());
+ type8.c_str(), name8.c_str());
} else {
printf(" INVALID RESOURCE 0x%08x: ", resID);
}
diff --git a/libs/androidfw/include/androidfw/Asset.h b/libs/androidfw/include/androidfw/Asset.h
index 19febcd..f3776b5 100644
--- a/libs/androidfw/include/androidfw/Asset.h
+++ b/libs/androidfw/include/androidfw/Asset.h
@@ -135,7 +135,7 @@
* This is NOT intended to be used for anything except debug output.
* DO NOT try to parse this or use it to open a file.
*/
- const char* getAssetSource(void) const { return mAssetSource.string(); }
+ const char* getAssetSource(void) const { return mAssetSource.c_str(); }
/*
* Create the asset from a file descriptor.
diff --git a/libs/androidfw/include/androidfw/ConfigDescription.h b/libs/androidfw/include/androidfw/ConfigDescription.h
index 61d10cd..1701f1b 100644
--- a/libs/androidfw/include/androidfw/ConfigDescription.h
+++ b/libs/androidfw/include/androidfw/ConfigDescription.h
@@ -207,7 +207,7 @@
inline ::std::ostream& operator<<(::std::ostream& out,
const ConfigDescription& o) {
- return out << o.toString().string();
+ return out << o.toString().c_str();
}
} // namespace android
diff --git a/libs/androidfw/tests/BackupData_test.cpp b/libs/androidfw/tests/BackupData_test.cpp
index e25b616..7d3a341 100644
--- a/libs/androidfw/tests/BackupData_test.cpp
+++ b/libs/androidfw/tests/BackupData_test.cpp
@@ -56,10 +56,10 @@
mFilename.append(m_external_storage);
mFilename.append(TEST_FILENAME);
- ::unlink(mFilename.string());
- int fd = ::open(mFilename.string(), O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR);
+ ::unlink(mFilename.c_str());
+ int fd = ::open(mFilename.c_str(), O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR);
if (fd < 0) {
- FAIL() << "Couldn't create " << mFilename.string() << " for writing";
+ FAIL() << "Couldn't create " << mFilename.c_str() << " for writing";
}
mKey1 = String8(KEY1);
mKey2 = String8(KEY2);
@@ -72,7 +72,7 @@
};
TEST_F(BackupDataTest, WriteAndReadSingle) {
- int fd = ::open(mFilename.string(), O_WRONLY);
+ int fd = ::open(mFilename.c_str(), O_WRONLY);
BackupDataWriter* writer = new BackupDataWriter(fd);
EXPECT_EQ(NO_ERROR, writer->WriteEntityHeader(mKey1, sizeof(DATA1)))
@@ -81,7 +81,7 @@
<< "WriteEntityData returned an error";
::close(fd);
- fd = ::open(mFilename.string(), O_RDONLY);
+ fd = ::open(mFilename.c_str(), O_RDONLY);
BackupDataReader* reader = new BackupDataReader(fd);
EXPECT_EQ(NO_ERROR, reader->Status())
<< "Reader ctor failed";
@@ -114,7 +114,7 @@
}
TEST_F(BackupDataTest, WriteAndReadMultiple) {
- int fd = ::open(mFilename.string(), O_WRONLY);
+ int fd = ::open(mFilename.c_str(), O_WRONLY);
BackupDataWriter* writer = new BackupDataWriter(fd);
writer->WriteEntityHeader(mKey1, sizeof(DATA1));
writer->WriteEntityData(DATA1, sizeof(DATA1));
@@ -122,7 +122,7 @@
writer->WriteEntityData(DATA2, sizeof(DATA2));
::close(fd);
- fd = ::open(mFilename.string(), O_RDONLY);
+ fd = ::open(mFilename.c_str(), O_RDONLY);
BackupDataReader* reader = new BackupDataReader(fd);
bool done;
@@ -162,7 +162,7 @@
}
TEST_F(BackupDataTest, SkipEntity) {
- int fd = ::open(mFilename.string(), O_WRONLY);
+ int fd = ::open(mFilename.c_str(), O_WRONLY);
BackupDataWriter* writer = new BackupDataWriter(fd);
writer->WriteEntityHeader(mKey1, sizeof(DATA1));
writer->WriteEntityData(DATA1, sizeof(DATA1));
@@ -172,7 +172,7 @@
writer->WriteEntityData(DATA3, sizeof(DATA3));
::close(fd);
- fd = ::open(mFilename.string(), O_RDONLY);
+ fd = ::open(mFilename.c_str(), O_RDONLY);
BackupDataReader* reader = new BackupDataReader(fd);
bool done;
@@ -217,14 +217,14 @@
}
TEST_F(BackupDataTest, DeleteEntity) {
- int fd = ::open(mFilename.string(), O_WRONLY);
+ int fd = ::open(mFilename.c_str(), O_WRONLY);
BackupDataWriter* writer = new BackupDataWriter(fd);
writer->WriteEntityHeader(mKey1, sizeof(DATA1));
writer->WriteEntityData(DATA1, sizeof(DATA1));
writer->WriteEntityHeader(mKey2, -1);
::close(fd);
- fd = ::open(mFilename.string(), O_RDONLY);
+ fd = ::open(mFilename.c_str(), O_RDONLY);
BackupDataReader* reader = new BackupDataReader(fd);
bool done;
@@ -256,7 +256,7 @@
}
TEST_F(BackupDataTest, EneityAfterDelete) {
- int fd = ::open(mFilename.string(), O_WRONLY);
+ int fd = ::open(mFilename.c_str(), O_WRONLY);
BackupDataWriter* writer = new BackupDataWriter(fd);
writer->WriteEntityHeader(mKey1, sizeof(DATA1));
writer->WriteEntityData(DATA1, sizeof(DATA1));
@@ -265,7 +265,7 @@
writer->WriteEntityData(DATA3, sizeof(DATA3));
::close(fd);
- fd = ::open(mFilename.string(), O_RDONLY);
+ fd = ::open(mFilename.c_str(), O_RDONLY);
BackupDataReader* reader = new BackupDataReader(fd);
bool done;
@@ -317,7 +317,7 @@
}
TEST_F(BackupDataTest, OnlyDeleteEntities) {
- int fd = ::open(mFilename.string(), O_WRONLY);
+ int fd = ::open(mFilename.c_str(), O_WRONLY);
BackupDataWriter* writer = new BackupDataWriter(fd);
writer->WriteEntityHeader(mKey1, -1);
writer->WriteEntityHeader(mKey2, -1);
@@ -325,7 +325,7 @@
writer->WriteEntityHeader(mKey4, -1);
::close(fd);
- fd = ::open(mFilename.string(), O_RDONLY);
+ fd = ::open(mFilename.c_str(), O_RDONLY);
BackupDataReader* reader = new BackupDataReader(fd);
bool done;
@@ -385,13 +385,13 @@
}
TEST_F(BackupDataTest, ReadDeletedEntityData) {
- int fd = ::open(mFilename.string(), O_WRONLY);
+ int fd = ::open(mFilename.c_str(), O_WRONLY);
BackupDataWriter* writer = new BackupDataWriter(fd);
writer->WriteEntityHeader(mKey1, -1);
writer->WriteEntityHeader(mKey2, -1);
::close(fd);
- fd = ::open(mFilename.string(), O_RDONLY);
+ fd = ::open(mFilename.c_str(), O_RDONLY);
BackupDataReader* reader = new BackupDataReader(fd);
bool done;
diff --git a/libs/androidfw/tests/CommonHelpers.cpp b/libs/androidfw/tests/CommonHelpers.cpp
index 3396729..10138de 100644
--- a/libs/androidfw/tests/CommonHelpers.cpp
+++ b/libs/androidfw/tests/CommonHelpers.cpp
@@ -60,7 +60,7 @@
std::string GetStringFromPool(const ResStringPool* pool, uint32_t idx) {
auto str = pool->string8ObjectAt(idx);
CHECK(str.has_value()) << "failed to find string entry";
- return std::string(str->string(), str->length());
+ return std::string(str->c_str(), str->length());
}
} // namespace android
diff --git a/libs/androidfw/tests/ConfigDescription_test.cpp b/libs/androidfw/tests/ConfigDescription_test.cpp
index ce7f805..7270357 100644
--- a/libs/androidfw/tests/ConfigDescription_test.cpp
+++ b/libs/androidfw/tests/ConfigDescription_test.cpp
@@ -50,10 +50,10 @@
TEST(ConfigDescriptionTest, ParseBasicQualifiers) {
ConfigDescription config;
EXPECT_TRUE(TestParse("", &config));
- EXPECT_EQ(std::string(""), config.toString().string());
+ EXPECT_EQ(std::string(""), config.toString().c_str());
EXPECT_TRUE(TestParse("fr-land", &config));
- EXPECT_EQ(std::string("fr-land"), config.toString().string());
+ EXPECT_EQ(std::string("fr-land"), config.toString().c_str());
EXPECT_TRUE(
TestParse("mcc310-pl-sw720dp-normal-long-port-night-"
@@ -61,22 +61,22 @@
&config));
EXPECT_EQ(std::string("mcc310-pl-sw720dp-normal-long-port-night-"
"xhdpi-keyssoft-qwerty-navexposed-nonav-v13"),
- config.toString().string());
+ config.toString().c_str());
}
TEST(ConfigDescriptionTest, ParseLocales) {
ConfigDescription config;
EXPECT_TRUE(TestParse("en-rUS", &config));
- EXPECT_EQ(std::string("en-rUS"), config.toString().string());
+ EXPECT_EQ(std::string("en-rUS"), config.toString().c_str());
}
TEST(ConfigDescriptionTest, ParseQualifierAddedInApi13) {
ConfigDescription config;
EXPECT_TRUE(TestParse("sw600dp", &config));
- EXPECT_EQ(std::string("sw600dp-v13"), config.toString().string());
+ EXPECT_EQ(std::string("sw600dp-v13"), config.toString().c_str());
EXPECT_TRUE(TestParse("sw600dp-v8", &config));
- EXPECT_EQ(std::string("sw600dp-v13"), config.toString().string());
+ EXPECT_EQ(std::string("sw600dp-v13"), config.toString().c_str());
}
TEST(ConfigDescriptionTest, ParseCarAttribute) {
@@ -91,13 +91,13 @@
EXPECT_EQ(android::ResTable_config::SCREENROUND_YES,
config.screenLayout2 & android::ResTable_config::MASK_SCREENROUND);
EXPECT_EQ(SDK_MARSHMALLOW, config.sdkVersion);
- EXPECT_EQ(std::string("round-v23"), config.toString().string());
+ EXPECT_EQ(std::string("round-v23"), config.toString().c_str());
EXPECT_TRUE(TestParse("notround", &config));
EXPECT_EQ(android::ResTable_config::SCREENROUND_NO,
config.screenLayout2 & android::ResTable_config::MASK_SCREENROUND);
EXPECT_EQ(SDK_MARSHMALLOW, config.sdkVersion);
- EXPECT_EQ(std::string("notround-v23"), config.toString().string());
+ EXPECT_EQ(std::string("notround-v23"), config.toString().c_str());
}
TEST(ConfigDescriptionTest, TestWideColorGamutQualifier) {
@@ -106,13 +106,13 @@
EXPECT_EQ(android::ResTable_config::WIDE_COLOR_GAMUT_YES,
config.colorMode & android::ResTable_config::MASK_WIDE_COLOR_GAMUT);
EXPECT_EQ(SDK_O, config.sdkVersion);
- EXPECT_EQ(std::string("widecg-v26"), config.toString().string());
+ EXPECT_EQ(std::string("widecg-v26"), config.toString().c_str());
EXPECT_TRUE(TestParse("nowidecg", &config));
EXPECT_EQ(android::ResTable_config::WIDE_COLOR_GAMUT_NO,
config.colorMode & android::ResTable_config::MASK_WIDE_COLOR_GAMUT);
EXPECT_EQ(SDK_O, config.sdkVersion);
- EXPECT_EQ(std::string("nowidecg-v26"), config.toString().string());
+ EXPECT_EQ(std::string("nowidecg-v26"), config.toString().c_str());
}
TEST(ConfigDescriptionTest, TestHdrQualifier) {
@@ -121,13 +121,13 @@
EXPECT_EQ(android::ResTable_config::HDR_YES,
config.colorMode & android::ResTable_config::MASK_HDR);
EXPECT_EQ(SDK_O, config.sdkVersion);
- EXPECT_EQ(std::string("highdr-v26"), config.toString().string());
+ EXPECT_EQ(std::string("highdr-v26"), config.toString().c_str());
EXPECT_TRUE(TestParse("lowdr", &config));
EXPECT_EQ(android::ResTable_config::HDR_NO,
config.colorMode & android::ResTable_config::MASK_HDR);
EXPECT_EQ(SDK_O, config.sdkVersion);
- EXPECT_EQ(std::string("lowdr-v26"), config.toString().string());
+ EXPECT_EQ(std::string("lowdr-v26"), config.toString().c_str());
}
TEST(ConfigDescriptionTest, ParseVrAttribute) {
@@ -135,7 +135,7 @@
EXPECT_TRUE(TestParse("vrheadset", &config));
EXPECT_EQ(android::ResTable_config::UI_MODE_TYPE_VR_HEADSET, config.uiMode);
EXPECT_EQ(SDK_O, config.sdkVersion);
- EXPECT_EQ(std::string("vrheadset-v26"), config.toString().string());
+ EXPECT_EQ(std::string("vrheadset-v26"), config.toString().c_str());
}
static inline ConfigDescription ParseConfigOrDie(const android::StringPiece& str) {
diff --git a/libs/androidfw/tests/ObbFile_test.cpp b/libs/androidfw/tests/ObbFile_test.cpp
index 1151121..ba818c4 100644
--- a/libs/androidfw/tests/ObbFile_test.cpp
+++ b/libs/androidfw/tests/ObbFile_test.cpp
@@ -43,9 +43,9 @@
mFileName.append(externalStorage);
mFileName.append(TEST_FILENAME);
- int fd = ::open(mFileName.string(), O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR);
+ int fd = ::open(mFileName.c_str(), O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR);
if (fd < 0) {
- FAIL() << "Couldn't create " << mFileName.string() << " for tests";
+ FAIL() << "Couldn't create " << mFileName.c_str() << " for tests";
}
}
@@ -69,17 +69,17 @@
EXPECT_TRUE(mObbFile->setSalt(salt, SALT_SIZE))
<< "Salt should be successfully set";
- EXPECT_TRUE(mObbFile->writeTo(mFileName.string()))
+ EXPECT_TRUE(mObbFile->writeTo(mFileName.c_str()))
<< "couldn't write to fake .obb file";
mObbFile = new ObbFile();
- EXPECT_TRUE(mObbFile->readFrom(mFileName.string()))
+ EXPECT_TRUE(mObbFile->readFrom(mFileName.c_str()))
<< "couldn't read from fake .obb file";
EXPECT_EQ(versionNum, mObbFile->getVersion())
<< "version didn't come out the same as it went in";
- const char* currentPackageName = mObbFile->getPackageName().string();
+ const char* currentPackageName = mObbFile->getPackageName().c_str();
EXPECT_STREQ(packageName, currentPackageName)
<< "package name didn't come out the same as it went in";
diff --git a/libs/androidfw/tests/ResTable_test.cpp b/libs/androidfw/tests/ResTable_test.cpp
index 9aeb00c..dc6dea9 100644
--- a/libs/androidfw/tests/ResTable_test.cpp
+++ b/libs/androidfw/tests/ResTable_test.cpp
@@ -57,7 +57,7 @@
String16 name(u"com.android.sparse:integer/foo_9");
uint32_t flags;
uint32_t resid =
- table.identifierForName(name.string(), name.size(), nullptr, 0, nullptr, 0, &flags);
+ table.identifierForName(name.c_str(), name.size(), nullptr, 0, nullptr, 0, &flags);
ASSERT_NE(0u, resid);
Res_value val;
@@ -91,8 +91,8 @@
String16 defPackage("com.android.basic");
String16 testName("@string/test1");
uint32_t resID =
- table.identifierForName(testName.string(), testName.size(), 0, 0,
- defPackage.string(), defPackage.size());
+ table.identifierForName(testName.c_str(), testName.size(), 0, 0,
+ defPackage.c_str(), defPackage.size());
ASSERT_NE(uint32_t(0x00000000), resID);
ASSERT_EQ(basic::R::string::test1, resID);
}
diff --git a/libs/androidfw/tests/Split_test.cpp b/libs/androidfw/tests/Split_test.cpp
index 2c242db..3d88577 100644
--- a/libs/androidfw/tests/Split_test.cpp
+++ b/libs/androidfw/tests/Split_test.cpp
@@ -261,8 +261,8 @@
const String16 package("com.android.basic");
ASSERT_EQ(
R::string::test3,
- table.identifierForName(name.string(), name.size(), type.string(),
- type.size(), package.string(), package.size()));
+ table.identifierForName(name.c_str(), name.size(), type.c_str(),
+ type.size(), package.c_str(), package.size()));
}
} // namespace
diff --git a/libs/androidfw/tests/TestHelpers.cpp b/libs/androidfw/tests/TestHelpers.cpp
index 10c0a4f..c6f657c 100644
--- a/libs/androidfw/tests/TestHelpers.cpp
+++ b/libs/androidfw/tests/TestHelpers.cpp
@@ -79,9 +79,9 @@
}
if (String8(expected_str) != *actual_str) {
- return AssertionFailure() << actual_str->string();
+ return AssertionFailure() << actual_str->c_str();
}
- return AssertionSuccess() << actual_str->string();
+ return AssertionSuccess() << actual_str->c_str();
}
} // namespace android