Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d2a69835 authored by Tomasz Wasilczyk's avatar Tomasz Wasilczyk
Browse files

Use String8/16 c_str [tools]

Bug: 295394788
Test: make checkbuild
Change-Id: I82d6899d8c15a10b15399c39177290012bb5f13b
Merged-In: I82d6899d8c15a10b15399c39177290012bb5f13b
parent d122f435
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -111,7 +111,7 @@ Result<std::string> GetStringValue(const ResXMLParser& parser, const Res_value&
  switch (value.dataType) {
    case Res_value::TYPE_STRING: {
      if (auto str = parser.getStrings().string8ObjectAt(value.data); str.ok()) {
        return std::string(str->string());
        return std::string(str->c_str());
      }
      break;
    }
+1 −1
Original line number Diff line number Diff line
@@ -52,7 +52,7 @@ static void android_content_res_ObbScanner_getObbInfo(JNIEnv* env, jobject clazz

    env->ReleaseStringUTFChars(file, filePath);

    const char* packageNameStr = obb->getPackageName().string();
    const char* packageNameStr = obb->getPackageName().c_str();

    jstring packageName = env->NewStringUTF(packageNameStr);
    if (packageName == NULL) {
+2 −2
Original line number Diff line number Diff line
@@ -272,7 +272,7 @@ static jobject NativeGetAssetAllocations(JNIEnv* env, jobject /*clazz*/) {
  if (alloc.length() <= 0) {
    return nullptr;
  }
  return env->NewStringUTF(alloc.string());
  return env->NewStringUTF(alloc.c_str());
}

static jint NativeGetGlobalAssetManagerCount(JNIEnv* /*env*/, jobject /*clazz*/) {
@@ -427,7 +427,7 @@ static jobjectArray NativeList(JNIEnv* env, jclass /*clazz*/, jlong ptr, jstring
  }

  for (size_t i = 0; i < file_count; i++) {
    jstring java_string = env->NewStringUTF(asset_dir->getFileName(i).string());
    jstring java_string = env->NewStringUTF(asset_dir->getFileName(i).c_str());

    // Check for errors creating the strings (if malformed or no memory).
    if (env->ExceptionCheck()) {
+67 −67
Original line number Diff line number Diff line
@@ -91,7 +91,7 @@ String8 idmapPathForPackagePath(const String8& pkgPath) {
    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 @@ bool AssetManager::addAssetPath(
    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 @@ bool AssetManager::addAssetPath(
    }

    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 @@ bool AssetManager::addOverlayPath(const String8& packagePath, int32_t* cookie)

    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 @@ bool AssetManager::addOverlayPath(const String8& packagePath, int32_t* cookie)
    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 @@ bool AssetManager::addOverlayPath(const String8& packagePath, int32_t* cookie)

    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 @@ bool AssetManager::addAssetFd(
    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 @@ bool AssetManager::createIdmap(const char* targetApkPath, const char* overlayApk
            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 @@ Asset* AssetManager::open(const char* fileName, AccessMode mode)
    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 @@ Asset* AssetManager::openNonAsset(const char* fileName, AccessMode mode, int32_t
    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 @@ Asset* AssetManager::openNonAsset(const int32_t cookie, const char* fileName, Ac

    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 @@ bool AssetManager::appendPathToResTable(asset_path& ap, bool appAsLib) const {
    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 @@ bool AssetManager::appendPathToResTable(asset_path& ap, bool appAsLib) const {
            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 @@ bool AssetManager::appendPathToResTable(asset_path& ap, bool appAsLib) const {
                // 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 @@ bool AssetManager::appendPathToResTable(asset_path& ap, bool appAsLib) const {
                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 @@ bool AssetManager::appendPathToResTable(asset_path& ap, bool appAsLib) const {
    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 @@ Asset* AssetManager::openIdmapLocked(const struct asset_path& ap) const
        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 @@ Asset* AssetManager::openNonAssetInPathLocked(const char* fileName, AccessMode m
        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 @@ Asset* AssetManager::openNonAssetInPathLocked(const char* fileName, AccessMode m
        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 @@ ZipFileRO* AssetManager::getZipFileLocked(asset_path& ap)
    }

    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* AssetManager::openAssetFromFileLocked(const String8& pathName,
{
    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 @@ Asset* AssetManager::openAssetFromZipLocked(const ZipFileRO* pZipFile,

    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 @@ AssetDir* AssetManager::openDir(const char* dirName)
        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 @@ AssetDir* AssetManager::openNonAssetDir(const int32_t cookie, const char* dirNam
    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 @@ bool AssetManager::scanAndMergeDirLocked(SortedVector<AssetDir::FileInfo>* pMerg
{
    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 @@ bool AssetManager::scanAndMergeDirLocked(SortedVector<AssetDir::FileInfo>* pMerg
        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 @@ bool AssetManager::scanAndMergeDirLocked(SortedVector<AssetDir::FileInfo>* pMerg
            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 @@ SortedVector<AssetDir::FileInfo>* AssetManager::scanDirLocked(const String8& pat
    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 @@ SortedVector<AssetDir::FileInfo>* AssetManager::scanDirLocked(const String8& pat
            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 @@ SortedVector<AssetDir::FileInfo>* AssetManager::scanDirLocked(const String8& pat

        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 @@ bool AssetManager::scanAndMergeZipLocked(SortedVector<AssetDir::FileInfo>* pMerg

    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 @@ bool AssetManager::scanAndMergeZipLocked(SortedVector<AssetDir::FileInfo>* pMerg
     */
    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 @@ bool AssetManager::scanAndMergeZipLocked(SortedVector<AssetDir::FileInfo>* pMerg
            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 @@ bool AssetManager::scanAndMergeZipLocked(SortedVector<AssetDir::FileInfo>* pMerg
                    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 @@ bool AssetManager::scanAndMergeZipLocked(SortedVector<AssetDir::FileInfo>* pMerg
                    dirs.add(subdirName);
                }

                //printf("FOUND: dir '%s'\n", subdirName.string());
                //printf("FOUND: dir '%s'\n", subdirName.c_str());
            }
        }
    }
@@ -1427,10 +1427,10 @@ AssetManager::SharedZip::SharedZip(const String8& path, time_t modWhen)
    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 @@ AssetManager::SharedZip::SharedZip(int fd, const String8& path)
    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 @@ ResTable* AssetManager::SharedZip::setResourceTable(ResTable* res)

bool AssetManager::SharedZip::isUpToDate()
{
    time_t modWhen = getFileModDate(mPath.string());
    time_t modWhen = getFileModDate(mPath.c_str());
    return mModWhen == modWhen;
}

@@ -1551,7 +1551,7 @@ AssetManager::SharedZip::~SharedZip()
    }
    if (mZipFile != NULL) {
        delete mZipFile;
        ALOGV("Closed '%s'\n", mPath.string());
        ALOGV("Closed '%s'\n", mPath.c_str());
    }
}

+3 −3
Original line number Diff line number Diff line
@@ -106,8 +106,8 @@ BackupDataWriter::WriteEntityHeader(const String8& key, size_t dataSize)
        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 @@ BackupDataWriter::WriteEntityHeader(const String8& key, size_t dataSize)
    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;
Loading