hook activity: https://github.com/zzz199316/Testhook/blob/master/app/src/main/java/com/plgf/testhook/HookUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.google.common.base.Joiner | |
import org.gradle.api.Project | |
import java.security.MessageDigest | |
/** | |
* A file utils. | |
*/ | |
public class FileUtils { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 获取 tansformTasks | |
Field transformsField = Class.forName("com.android.build.gradle.internal.pipeline.TransformManager").getDeclaredField("transforms") | |
transformsField.setAccessible(true) | |
List<Transform> transforms = transformsField.get(variant.variantData.scope.getTransformManager()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class AbstractFactory { | |
public static void main(String[] args) { | |
FactoryA factoryA = new FactoryA(); | |
factoryA.createAndroid().tel(); | |
factoryA.createIOS().play(); | |
FactoryB factoryB = new FactoryB(); | |
factoryB.createAndroid().tel(); | |
factoryB.createIOS().play(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Factory { | |
public static void main(String[] args) { | |
Dog dog = new FactoryDog().create(); | |
dog.walk(); | |
Cat cat = new FactoryCat().create(); | |
cat.walk(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SimpleFactory { | |
public static void main(String[] args) { | |
Platform platform = Platform.get(); | |
System.out.println(platform); | |
} | |
public static class Platform { |
gson解析时可以指定某个变量是否参与序列化与反序列化
比如:
main(){
String str = "{\"a\":\"1\",\"b\":\"2\",\"c\":\"3\"}";
Custom custom = gson.fromJson(str, Custom.class);
Log.d("@=>", custom.toString());
}
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.IOException; | |
import java.lang.reflect.Method; | |
import java.lang.reflect.Modifier; | |
import org.cc.core.asm.ClassReader; | |
import org.cc.core.asm.ClassVisitor; | |
import org.cc.core.asm.ClassWriter; | |
import org.cc.core.asm.Label; | |
import org.cc.core.asm.MethodVisitor; | |
import org.cc.core.asm.Opcodes; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 获取方法参数名称 | |
*/ | |
@Nullable | |
protected static String[] getMethodParamNames(CtMethod cm) { | |
String[] paramNames = null; | |
try { | |
MethodInfo methodInfo = cm.getMethodInfo(); | |
CodeAttribute codeAttribute = methodInfo.getCodeAttribute(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 解压原始的dex文件 | |
* | |
* @param context | |
* @return | |
* @throws IOException | |
*/ | |
private String unzipRAWFile(Context context) { | |
String apkFilePath; |