-
Notifications
You must be signed in to change notification settings - Fork 1.6k
重定向修改jar #301
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
重定向修改jar #301
Changes from 1 commit
cce6904
58e5a0d
82142dd
e27e49d
c03c6aa
a4c067f
d4853cb
c2ca290
0ca937c
a49598f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -110,47 +110,14 @@ public class Util { | |
| def jarPath = jar.absolutePath | ||
| if (jarPath.contains(File.separator + FD_INTERMEDIATES + File.separator + "replugin-jar")) { | ||
| // | ||
| }else if (!jarPath.contains(projectDir)) { | ||
| String jarZipDir = project.getBuildDir().path + | ||
| File.separator + FD_INTERMEDIATES + File.separator + "exploded-aar" + | ||
| File.separator + Hashing.sha1().hashString(jarPath, Charsets.UTF_16LE).toString() + File.separator + "class"; | ||
| if (unzip(jarPath, jarZipDir)) { | ||
| def jarZip = jarZipDir + ".jar" | ||
| includeJars << jarPath | ||
| classPath << jarZipDir | ||
| visitor.setBaseDir(jarZipDir) | ||
| Files.walkFileTree(Paths.get(jarZipDir), visitor) | ||
| map.put(jarPath, jarZip) | ||
| } | ||
| } else { | ||
| }else{ | ||
| //重定向jar | ||
|
||
| String md5 = md5File(jar); | ||
| File reJar = new File(injectDir + File.separator + md5 + ".jar"); | ||
| jarPath = reJar.getAbsolutePath() | ||
|
||
|
|
||
| boolean needInject = false | ||
| if (reJar.exists()) { | ||
| //检查修改插件版本 | ||
| JarPatchInfo info = infoMap.get(jar.getAbsolutePath()); | ||
| if (info != null) { | ||
| if(!activityMd5.equals(info.manifestActivitiesMd5)){ | ||
| needInject = true | ||
| }else if (!AppConstant.VER.equals(info.pluginVersion)) { | ||
| //版本变化了 | ||
| needInject = true | ||
| } else { | ||
| if (!md5.equals(info.jarMd5)) { | ||
| //原始jar内容变化 | ||
| needInject = true | ||
| } | ||
| } | ||
| } else { | ||
| //无记录 | ||
| needInject = true | ||
| } | ||
| } else { | ||
| needInject = true; | ||
| } | ||
| boolean needInject = checkNeedInjector(infoMap, jar, reJar, activityMd5, md5); | ||
|
|
||
| //设置重定向jar | ||
| setJarInput(jarInput, reJar) | ||
| if (needInject) { | ||
|
|
@@ -194,6 +161,34 @@ public class Util { | |
| return md5 | ||
| } | ||
|
|
||
|
|
||
| def static checkNeedInjector( Map<String, JarPatchInfo> infoMap, File jar,File reJar,String activityMd5,String md5){ | ||
| boolean needInject = false | ||
| if (reJar.exists()) { | ||
| //检查修改插件版本 | ||
| JarPatchInfo info = infoMap.get(jar.getAbsolutePath()); | ||
| if (info != null) { | ||
| if(!activityMd5.equals(info.manifestActivitiesMd5)){ | ||
| needInject = true | ||
| }else if (!AppConstant.VER.equals(info.pluginVersion)) { | ||
| //版本变化了 | ||
| needInject = true | ||
| } else { | ||
| if (!md5.equals(info.jarMd5)) { | ||
| //原始jar内容变化 | ||
| needInject = true | ||
| } | ||
| } | ||
| } else { | ||
| //无记录 | ||
| needInject = true | ||
| } | ||
| } else { | ||
| needInject = true; | ||
| } | ||
| return needInject; | ||
| } | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 代码逻辑可以精简为: def static checkNeedInjector(Map<String, JarPatchInfo> infoMap, File jar, File reJar, String activityMd5, String md5) {
boolean needInject = true
if (reJar.exists()) {
JarPatchInfo info = infoMap.get(jar.getAbsolutePath());
if (info != null) {
if (activityMd5.equals(info.manifestActivitiesMd5)
&& AppConstant.VER.equals(info.pluginVersion)
&& md5.equals(info.jarMd5)) {
needInject = false
}
}
}
return needInject;
} |
||
| /** | ||
| * 读取修改jar的记录 | ||
| */ | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里无需if...else逻辑,jarPath不会有build临时目录