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

Commit c1fd64b3 authored by jinfaw's avatar jinfaw
Browse files

Framework:cleanup framework res-overlay/idmap fd

Close framework res-overlay apk and idmap file fd after loading and idmap generation
during zygote preloading framework res-overlay customization

Change-Id: Ib330c62e43b89e1119e0373d178cd2f859514328
CRs-Fixed: 1094583
parent cb366e6b
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -359,7 +359,7 @@ private:

        void addOverlay(const String8& path, const asset_path& overlay);
        bool getOverlay(const String8& path, size_t idx, asset_path* out) const;
        
        void closeZipFromPath(const String8& zip);
    private:
        void closeZip(int idx);

+26 −2
Original line number Diff line number Diff line
@@ -804,6 +804,14 @@ void AssetManager::addSystemOverlays(const char* pathOverlaysList,
            sharedRes->add(oass, oidmap, offset + 1, false);
            const_cast<AssetManager*>(this)->mAssetPaths.add(oap);
            const_cast<AssetManager*>(this)->mZipSet.addOverlay(targetPackagePath, oap);

            oidmap->close();
            ALOGD("close idmap=%s pid=%d\n", oap.idmap.string(), getpid());
       }

        if (oap.path.find(OVERLAY_DIR) != -1) {
           const_cast<AssetManager*>(this)->mZipSet.closeZipFromPath(oap.path);
           ALOGD("close: %s and reset entry\n", oap.path.string());
      }
  }

@@ -2005,6 +2013,22 @@ AssetManager::ZipSet::~ZipSet(void)
        closeZip(i);
}

/*
 * Close a Zip file from path and reset the entry
 */
void AssetManager::ZipSet::closeZipFromPath(const String8& zip)
{
    //close zip fd
    int fd = getZip(zip)->getFileDescriptor();

    if (fd > 0) {
        close(fd);
        //reset zip object and entry
        int idx = getIndex(zip);
        mZipFile.editItemAt(idx) = NULL;
    }
}

/*
 * Close a Zip file and reset the entry.
 */