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

Commit 634068b2 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "base: Use type8 and name8 to create the string when create idmap."

parents de6ed0a4 e5018ad2
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -226,6 +226,7 @@ private:
        String8 idmap;
    };

    void addAssetPathForOverlayRes(const asset_path& ap, const String8& overlayPath);
    Asset* openInPathLocked(const char* fileName, AccessMode mode,
        const asset_path& path);
    Asset* openNonAssetInPathLocked(const char* fileName, AccessMode mode,
+40 −20
Original line number Diff line number Diff line
@@ -208,19 +208,33 @@ bool AssetManager::addAssetPath(const String8& path, void** cookie)
        *cookie = (void*)mAssetPaths.size();
    }

    // add overlay packages for /system/framework; apps are handled by the
    // (Java) package manager
    // add overlay packages for /system/framework and /system/app
    if (strncmp(path.string(), "/system/framework/", 18) == 0) {
        // When there is an environment variable for /vendor, this
        // should be changed to something similar to how ANDROID_ROOT
        // and ANDROID_DATA are used in this file.
        String8 overlayPath("/vendor/overlay/framework/");
        overlayPath.append(path.getPathLeaf());
        addAssetPathForOverlayRes(ap, overlayPath);
    } else if (strncmp(path.string(), "/system/app/", 12) == 0) {
        // When there is an environment variable for /vendor, this
        // should be changed to something similar to how ANDROID_ROOT
        // and ANDROID_DATA are used in this file.
        String8 overlayPath("/vendor/overlay");
        overlayPath.append(path.getBasePath());
        overlayPath.append("-overlay.apk");
        addAssetPathForOverlayRes(ap, overlayPath);
    }

    return true;
}

void AssetManager::addAssetPathForOverlayRes(const asset_path& ap, const String8& overlayPath) {
    if (TEMP_FAILURE_RETRY(access(overlayPath.string(), R_OK)) == 0) {
        asset_path oap;
        oap.path = overlayPath;
        oap.type = ::getFileType(overlayPath.string());
            bool addOverlay = (oap.type == kFileTypeRegular); // only .apks supported as overlay
        bool addOverlay = (oap.type == kFileTypeRegular); // only .apk supported as overlay
        if (addOverlay) {
            oap.idmap = idmapPathForPackagePath(overlayPath);

@@ -236,9 +250,6 @@ bool AssetManager::addAssetPath(const String8& path, void** cookie)
    }
}

    return true;
}

bool AssetManager::isIdmapStaleLocked(const String8& originalPath, const String8& overlayPath,
                                      const String8& idmapPath)
{
@@ -324,6 +335,7 @@ bool AssetManager::createIdmapFileLocked(const String8& originalPath, const Stri
    int fd = 0;
    uint32_t* data = NULL;
    size_t size;
    mode_t process_umask;

    for (int i = 0; i < 2; ++i) {
        asset_path ap;
@@ -352,10 +364,18 @@ bool AssetManager::createIdmapFileLocked(const String8& originalPath, const Stri
        goto error;
    }

    // Set the mask to 0, caused by the current mask is "600", and it will create the idmap
    // file as "600", but not the expected "644".
    process_umask = umask(0);

    // This should be abstracted (eg replaced by a stand-alone
    // application like dexopt, triggered by something equivalent to
    // installd).
    fd = TEMP_FAILURE_RETRY(::open(idmapPath.string(), O_WRONLY | O_CREAT | O_TRUNC, 0644));

    // Reset the mask.
    umask(process_umask);

    if (fd == -1) {
        ALOGW("failed to write idmap file %s (open: %s)\n", idmapPath.string(), strerror(errno));
        goto error_free;
+12 −2
Original line number Diff line number Diff line
@@ -5375,8 +5375,18 @@ status_t ResTable::createIdmap(const ResTable& overlay, uint32_t originalCrc, ui
                continue;
            }

            const String16 overlayType(resName.type, resName.typeLen);
            const String16 overlayName(resName.name, resName.nameLen);
            String16 overlayType, overlayName;
            if (resName.type8 != NULL) {
                overlayType = String16(resName.type8, resName.typeLen);
            } else {
                overlayType = String16(resName.type, resName.typeLen);
            }
            if (resName.name8 != NULL) {
                overlayName = String16(resName.name8, resName.nameLen);
            } else {
                overlayName = String16(resName.name, resName.nameLen);
            }

            uint32_t overlayResID = overlay.identifierForName(overlayName.string(),
                                                              overlayName.size(),
                                                              overlayType.string(),