一个通过拦截Java方法调用用以检测应用是否合规的工具
一、Android Studio中引用插件miit-rule-checker
1.添加mavenCentral
allprojects {
repositories {
google()
jcenter()
mavenCentral()
}
}
2.添加Gradle依赖
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support27.1.1'
implementation 'com.android.support.constraint1.1.2'
testImplementation 'junit4.12'
androidTestImplementation 'com.android.support.test1.0.2'
androidTestImplementation 'com.android.support.test.espresso3.0.2'
implementation 'com.jakewharton8.8.1'
annotationProcessor 'com.jakewharton8.8.1'
implementation 'com.alibaba2.0.23'
implementation("org.greenrobot3.3.1")
implementation 'com.appsflyer6.9.0'
implementation "com.android.installreferrer2.2"
implementation("org.greenrobot3.3.1")
implementation 'com.squareup.okhttp35.0.0-alpha.10'
implementation 'io.github.loper70.2.0'
}
二、使用方法
1.检查APP内是否存在不合规的方法调用
检查MIITRuleChecker内置的不合规的方法
MIITRuleChecker.checkDefaults()
val list = MIITMethods.getDefaultMethods()
list.add(MainActivity::class.java.getDeclaredMethod("onCreate" , Bundle::class.java))
MIITRuleChecker.check(list)
2.检查指定方法调用并查看调用栈堆
//查看 WifiInfo class 内 getMacAddress 的调用栈堆 MIITRuleChecker.check(MIITMethods.WifiInfo.getMacAddress)
//多个方法统计 (deadline 为从方法调用开始到多少毫秒后截至统计) val list = mutableListOf().apply { add(MIITMethods.LocationManager.getLastKnownLocation) add(MIITMethods.LocationManager.requestLocationUpdates) add(MIITMethods.Secure.getString) } MIITMethodCountChecker.startCount( 20 * 1000,list) //单个方法统计(deadline 为从方法调用开始到多少毫秒后截至统计) MIITMethodCountChecker.startCount(20 * 1000,MIITMethods.LocationManager.getLastKnownLocation)
特别注意:
检查完成并完成整改后务必移除方法miit-rule-checker库内的所有方法调用,将库一起移除最好
三、内置方法表


审核编辑:汤梓红
全部0条评论
快来发表一下你的评论吧 !