diff --git a/src/apk_normalized.cpp b/src/apk_normalized.cpp index 11e1062..d8ceb44 100644 --- a/src/apk_normalized.cpp +++ b/src/apk_normalized.cpp @@ -60,6 +60,7 @@ static void printUsage(){ " -as-alignSize\n" " set align size for uncompressed file in zip for optimize app run speed,\n" " 1 <= alignSize <= 4k, recommended 4,8, DEFAULT -as-8.\n" + " NOTE: if -ap-1, must 4096%%alignSize==0;\n" " -ap-isPageAlignSoFile\n" " if found uncompressed .so file in the zip, need align it to 4k page?\n" " -ap-0 not page-align uncompressed .so files;\n" diff --git a/src/diff/DiffData.cpp b/src/diff/DiffData.cpp index 49306eb..c598d69 100644 --- a/src/diff/DiffData.cpp +++ b/src/diff/DiffData.cpp @@ -60,11 +60,6 @@ bool zipFileData_isSame(UnZipper* selfZip,int selfIndex,UnZipper* srcZip,int src return 0==memcmp(buf.data(),buf.data()+selfFileSize,selfFileSize); } - -bool getIsStampCertFile(const UnZipper* self,int fileIndex){ - return UnZipper_file_is_lastNameWith(self,fileIndex,"stamp-cert-sha256",17); -} - bool getZipIsSameWithStream(const hpatch_TStreamInput* oldZipStream, const hpatch_TStreamInput* newZipStream, int newApkFilesRemoved,bool* out_isOldHaveApkV2Sign){ @@ -103,7 +98,7 @@ bool getZipIsSameWithStream(const hpatch_TStreamInput* oldZipStream, for (std::map::iterator it=oldMap.begin();it!=oldMap.end();++it){ int old_i=it->second; check_clear(UnZipper_file_isApkV1Sign(&oldZip,old_i) - ||getIsStampCertFile(&oldZip,old_i) + ||UnZipper_file_isStampCertFile(&oldZip,old_i) ||(UnZipper_file_uncompressedSize(&oldZip,old_i)==0)); } } diff --git a/src/diff/DiffData.h b/src/diff/DiffData.h index d3a0228..69a2fd9 100644 --- a/src/diff/DiffData.h +++ b/src/diff/DiffData.h @@ -61,7 +61,6 @@ static inline std::string zipFile_name(const UnZipper* self,int fileIndex){ const char* nameBegin=UnZipper_file_nameBegin(self,fileIndex); return std::string(nameBegin,nameBegin+nameLen); } -bool getIsStampCertFile(const UnZipper* self,int fileIndex); bool getSamePairList(UnZipper* newZip,UnZipper* oldZip, bool newCompressedDataIsNormalized, diff --git a/src/normalized/normalized.cpp b/src/normalized/normalized.cpp index 4f2853a..2f5bbb8 100644 --- a/src/normalized/normalized.cpp +++ b/src/normalized/normalized.cpp @@ -162,7 +162,7 @@ bool ZipNormalized(const char* srcApk,const char* dstApk,int ZipAlignSize,int co continue; //remove JarSign(ApkV1Sign) when found ApkV2Sign } } - if (getIsStampCertFile(&unzipper,fileIndex)){ + if (UnZipper_file_isStampCertFile(&unzipper,fileIndex)){ ++apkFilesRemoved; removedFiles.push_back(files[i].fileName); continue; //remove stamp cert file diff --git a/src/patch/Patcher.cpp b/src/patch/Patcher.cpp index b43215b..13e24c4 100644 --- a/src/patch/Patcher.cpp +++ b/src/patch/Patcher.cpp @@ -154,7 +154,7 @@ TPatchResult VirtualZipPatchWithStream(const hpatch_TStreamInput* oldZipStream,c check(oldStream.stream->streamSize==diffInfo.oldDataSize,PATCH_OLDDATA_ERROR); check(Zipper_openStream(&out_newZip,outNewZipStream,(int)zipDiffData.newZipFileCount, - (int)zipDiffData.newZipAlignSize,(int)zipDiffData.newCompressLevel, + (int)zipDiffData.newZipAlignSize,(int)zipDiffData.newZipAlignSize,(int)zipDiffData.newCompressLevel, (int)zipDiffData.newCompressMemLevel),PATCH_OPENWRITE_ERROR); check(NewStream_open(&newStream,&out_newZip,&oldZip, (size_t)diffInfo.newDataSize, zipDiffData.newZipIsDataNormalized!=0, diff --git a/src/patch/Zipper.cpp b/src/patch/Zipper.cpp index 2ad6236..c928aae 100644 --- a/src/patch/Zipper.cpp +++ b/src/patch/Zipper.cpp @@ -1020,7 +1020,8 @@ static bool _write_fileHeaderInfo(Zipper* self,int fileIndex,UnZipper* srcZip,in if (isNeedAlign){ size_t headInfoLen=30+fileNameLen+extraFieldLen; size_t skipLen=_getAlignSkipLen(self->_curFilePos+headInfoLen,self->_ZipAlignSize); - if (UnZipper_file_is_nameEndWith(srcZip,srcFileIndex,".so",3)){ + if ((self->_SoPageAlignSize!=self->_ZipAlignSize)&&UnZipper_file_is_nameEndWith(srcZip,srcFileIndex,".so",3)){ + check(0==(self->_SoPageAlignSize%self->_ZipAlignSize)); size_t skipSoLen=_getAlignSkipLen(self->_curFilePos+headInfoLen,self->_SoPageAlignSize); if (skipSoLen!=skipLen){ skipLen=skipSoLen; diff --git a/src/patch/Zipper.h b/src/patch/Zipper.h index 18062f2..e740744 100644 --- a/src/patch/Zipper.h +++ b/src/patch/Zipper.h @@ -120,6 +120,9 @@ bool UnZipper_file_is_sameName(const UnZipper* self,int fileIndex,const char* pa bool UnZipper_file_is_lastNameWith(const UnZipper* self,int fileIndex,const char* lastName,int lastNameLen); bool UnZipper_file_is_nameEndWith(const UnZipper* self,int fileIndex,const char* nameSuffix,int nameSuffixLen);//file name is end with nameSuffix +static inline bool UnZipper_file_isStampCertFile(const UnZipper* self,int fileIndex){ + return UnZipper_file_is_lastNameWith(self,fileIndex,"stamp-cert-sha256",17); +} struct TZipThreadWorks; struct TZipThreadWork;