原文:http://www.myhack58.com/Article/html/3/92/2013/36575_2.htm
反广告软件通过扫描程序内所有类文件,根据其包名、类名确定广告平台以及广告种类。
这个跟以前的杀毒软件原理类似,主动防御就是另外一回事了。
下面说下,获取程序的所有类名:
try {
path = getPackageManager().getApplicationInfo(
"com.xxx.xxx", 0).sourceDir;//获得某个程序的APK路径
} catch (NameNotFoundException e2) {
// TODO Auto-generated catch block
e2.printStackTrace();
}
try {
DexFile df = new DexFile(path);//传如APK实例一个dexfile
Enumeration<String> s = df.entries();
while (s.hasMoreElements()) {//遍历出所有类
String string = (String) s.nextElement();
Log.i("test", string);
}
Log.i("test", df.getName() + "");
} catch (IOException e1) {
// TODO Auto-generated catch block
Log.i("test", "error" + e1.getMessage());
e1.printStackTrace();
}
得到了想要的,接下来就是和收集到的广告平台做对比然后反馈给用户了。