Skip to content

Commit

Permalink
简化字段,hot-cold 公用一个patchVersion字段
Browse files Browse the repository at this point in the history
  • Loading branch information
zhongcang committed Nov 13, 2017
1 parent 62760e7 commit a70fab5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public static void dexpatchUpdate(Context context, UpdateInfo updateInfo, File p
);
DexPatchUpdater.installHotPatch(updateInfo.updateVersion, needPatchHotBundles, patchFile, hotMonitor);
}
updateInfo.updateBundles = DexPatchUpdater.filterNeedHotPatchList(
updateInfo.updateBundles = DexPatchUpdater.filterNeedColdPatchList(
DexPatchUpdater.dividePatchInfo(updateInfo.updateBundles, false)
);
DexPatchUpdater.installColdPatch(updateInfo, patchFile, coldMonitor);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ public static void installHotPatch(String updateVersion,List<UpdateInfo.Item> up
HashMap<String, Pair<Long, InputStream>> updateBundles = new HashMap<>(updateList.size());
for (UpdateInfo.Item bundle : updateList) {
String entryName = "com.taobao.maindex".equals(bundle.name)
? "hotfix.dex"
: String.format("%s%s/hotfix.dex", "lib", bundle.name.replace(".", "_"));
? "hot.dex"
: String.format("%s%s/hot.dex", "lib", bundle.name.replace(".", "_"));
InputStream entryIn = patchZip.getInputStream(patchZip.getEntry(entryName));
updateBundles.put(bundle.name, new Pair<>(bundle.hotPatchVersion, entryIn));
updateBundles.put(bundle.name, new Pair<>(bundle.dexpatchVersion, entryIn));
}
AtlasHotPatchManager.getInstance().installHotFixPatch(updateVersion, updateBundles);
} catch (IOException e) {
Expand All @@ -60,7 +60,7 @@ public static void installHotPatch(String updateVersion,List<UpdateInfo.Item> up
}
for (UpdateInfo.Item item : updateList) {
boolean success = hotPatchInstall.containsKey(item.name);
monitor.install(success, item.name, item.hotPatchVersion, "");
monitor.install(success, item.name, item.dexpatchVersion, "");
}
}
}
Expand Down Expand Up @@ -143,15 +143,7 @@ public static List<UpdateInfo.Item> filterNeedHotPatchList(List<Item> hotPatchLi
continue;
}
Long version = installMap.get(item.name);

if (item.hotPatchVersion == -1) {
//本地已经安装过,并且处于未回滚状态
if (null != version && version != -1) {
resultList.add(Item.makeCopy(item));
}
continue;
}
if (null == version || item.hotPatchVersion > version) {
if (null == version || item.dexpatchVersion > version) {
resultList.add(Item.makeCopy(item));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,6 @@ public static class Item implements Serializable {

public long dexpatchVersion = -1;

public long hotPatchVersion = -1;

public boolean reset = false;

public static Item makeCopy(Item origin) {
Expand All @@ -87,7 +85,6 @@ public static Item makeCopy(Item origin) {
item.inherit = origin.inherit;
item.patchType = origin.patchType;
item.dexpatchVersion = origin.dexpatchVersion;
item.hotPatchVersion = origin.hotPatchVersion;
item.reset = origin.reset;
if (null != origin.dependency) {
List<String> copyDependency = new ArrayList<>(origin.dependency.size());
Expand Down

0 comments on commit a70fab5

Please sign in to comment.