static int
try_update_binary(const char* path, ZipArchive* zip, bool* wipe_cache) {
const ZipEntry* binary_entry =
mzFindZipEntry(zip, ASSUMED_UPDATE_BINARY_NAME);//lefty_lan:在zip格式的更新包文件中得到文件META-INF/com/google/android/update-binary的entry
if (binary_entry == NULL) {
mzCloseZipArchive(zip);
return INSTALL_CORRUPT;//lefty_lan注:安装包中找不到update_binary文件
}
const char* binary = "/tmp/update_binary";
unlink(binary);//lefty_lan注:清除软连接
int fd = creat(binary, 0755);//lefty_lan注:创建空文件update_binary
if (fd < 0) {
mzCloseZipArchive(zip);
LOGE("Can't make %s\n", binary);
return INSTALL_ERROR; //lefty_lan注:创建失败,返回
}
bool ok = mzExtractZipEntryToFile(zip, binary_entry, fd);//lefty_lan注:把zip更新包中的update_binary文件保存到/tmp/update_binary文件中
close(fd);
mzCloseZipArchive(zip);
if (!ok)
install.cpp文件try_update_binary()函数安装过程分析
最新推荐文章于 2023-08-17 16:04:37 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)