Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
关杰 committed Jun 30, 2017
2 parents 68b7317 + 057f44a commit abb9ac3
Showing 1 changed file with 18 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ private static void expandFieldList(Object instance, String fieldName,
}

private static boolean replaceElement(Object instance,String fieldName,Object replaceElement) throws NoSuchFieldException,IllegalArgumentException,
IllegalAccessException{
IllegalAccessException{
boolean replaceSuccess = false;
Field jlrField = findField(instance, fieldName);
Object[] original = (Object[]) jlrField.get(instance);
Expand Down Expand Up @@ -662,23 +662,31 @@ private void quietClose(Closeable closeable){
static Class[] constructorArgs2 = {File.class, File.class, DexFile.class};
static Class[] constructorArgs1 = {File.class, boolean.class, File.class, DexFile.class};

static Class[] constructorArgsO = {DexFile.class,File.class};


public static Object[] makeDexElement(File file,DexFile[] dex) throws Exception{
Object []objects = new Object[dex.length];
for (int i = 0; i < dex.length; i ++) {
try {
Class Element = Class.forName("dalvik.system.DexPathList$Element");
Constructor cons = getElementConstructor(Element, constructorArgs1);
File apkFile = new File(KernalConstants.baseContext.getApplicationInfo().sourceDir);
if (cons != null) {
objects[i] = cons.newInstance(apkFile, false, apkFile, dex[i]);
} else {
cons = getElementConstructor(Element, constructorArgs2);
if(Build.VERSION.SDK_INT>25 || Build.VERSION.SDK_INT==25&&Build.VERSION.PREVIEW_SDK_INT>0){
Constructor cons = getElementConstructor(Element, constructorArgsO);
objects[i] = cons.newInstance(dex[i],file);
}else {
File apkFile = new File(KernalConstants.baseContext.getApplicationInfo().sourceDir);
Constructor cons = getElementConstructor(Element, constructorArgs1);
if (cons != null) {
objects[i] = cons.newInstance(apkFile, apkFile, dex[i]);
objects[i] = cons.newInstance(apkFile, false, apkFile, dex[i]);
} else {
cons = getElementConstructor(Element, constructorArgs3);
cons = getElementConstructor(Element, constructorArgs2);
if (cons != null) {
objects[i] = cons.newInstance(apkFile, null, dex[i]);
objects[i] = cons.newInstance(apkFile, apkFile, dex[i]);
} else {
cons = getElementConstructor(Element, constructorArgs3);
if (cons != null) {
objects[i] = cons.newInstance(apkFile, null, dex[i]);
}
}
}
}
Expand Down

0 comments on commit abb9ac3

Please sign in to comment.