Skip to content

Commit

Permalink
开发阻塞函数扫描功能
Browse files Browse the repository at this point in the history
  • Loading branch information
SusionSuc committed Jan 8, 2020
1 parent f5810ab commit 59f8dd1
Show file tree
Hide file tree
Showing 53 changed files with 1,081 additions and 86 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.susion.rabbit.demo.page

import android.content.Context
import android.os.Bundle
import androidx.recyclerview.widget.LinearLayoutManager
import com.susion.rabbit.demo.R
Expand Down Expand Up @@ -31,6 +32,8 @@ class SimpleListActivity : RabbitBaseActivity() {

mSimpleListPageRv.adapter = listAdapter

getSharedPreferences("test", Context.MODE_PRIVATE).edit().putBoolean("111", true).commit()

}

private fun getData(): List<RabbitSimpleKvInfo> {
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ buildscript {
maven { url 'https://jitpack.io' }
}
dependencies {
classpath 'com.susion:rabbit-gradle-transform:0.0.8.4.3'
classpath 'com.susion:rabbit-gradle-transform:0.0.8.4.5'
classpath 'com.android.tools.build:gradle:3.5.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'org.greenrobot:greendao-gradle-plugin:3.2.2' // add plugin
Expand Down
1 change: 1 addition & 0 deletions buildSystem/rabbit-plugin.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ if (inDebug) {
printLog = true // 编译时打印插桩log
pageSpeedMonitorPkgs = ['com.susion.rabbit.demo']
methodMonitorPkgs = ['com.susion.rabbit.demo', 'com.susion.rabbit.demo.page']
ioScanPkgs = ['com.susion.rabbit.demo.page']
}

rabbit = "com.susion:rabbit:$version"
Expand Down
2 changes: 1 addition & 1 deletion documents/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
- [FPS和内存监控](./memory-fps-monitor.md)
- [异常与内存泄漏捕获](./others-monitor.md)
- [apk包分析](./app-analyzer.md)
- [接入自定义业务面板](./cusom-page.md)
- [接入自定义业务面板](./custom-page.md)
- [数据上报](./data-report.md)
- [noop包接入](./noop-document.md)
- [日志逻辑](./log-document.md)
Expand Down
2 changes: 1 addition & 1 deletion documents/develop-plan.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## 客户端后续开发计划

1. 完善现有功能
2. 实现敏感代码检测功能(敏感权限、隐藏API等)
2. 实现敏感代码检测功能(IO操作、敏感权限、隐藏API等)
3. ...

## 服务端管理后台
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ interface RabbitMonitorProtocol {
"慢函数监控",
showInExternal = true
)

val IO_CALL = MonitorInfo("io_call", "加载阻塞调用列表", showInExternal = true)
}

class MonitorInfo(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ package com.susion.rabbit.base.common

import android.content.Context
import java.io.File
import java.io.FileWriter
import java.io.IOException
import java.security.MessageDigest

/**
* susionwang at 2019-09-24
*/

object FileUtils{
object FileUtils {

/**
* Create a file if it doesn't exist, otherwise delete old file before creating.
Expand All @@ -18,8 +19,8 @@ object FileUtils{
* @return `true`: success<br></br>`false`: fail
*/
fun createFileByDeleteOldFile(filePath: String): Boolean {
return com.susion.rabbit.base.common.FileUtils.createFileByDeleteOldFile(
com.susion.rabbit.base.common.FileUtils.getFileByPath(
return createFileByDeleteOldFile(
getFileByPath(
filePath
)
)
Expand All @@ -35,7 +36,7 @@ object FileUtils{
if (file == null) return false
// file exists and unsuccessfully delete then return false
if (file.exists() && !file.delete()) return false
if (!com.susion.rabbit.base.common.FileUtils.createOrExistsDir(file.parentFile)) return false
if (!createOrExistsDir(file.parentFile)) return false
try {
return file.createNewFile()
} catch (e: IOException) {
Expand All @@ -51,7 +52,9 @@ object FileUtils{
* @return the file
*/
private fun getFileByPath(filePath: String): File? {
return if (com.susion.rabbit.base.common.FileUtils.isSpace(filePath)) null else File(filePath)
return if (com.susion.rabbit.base.common.FileUtils.isSpace(filePath)) null else File(
filePath
)
}

private fun isSpace(s: String?): Boolean {
Expand Down Expand Up @@ -119,4 +122,11 @@ object FileUtils{
}
}

fun writeStrToFile(file: File, str: String) {
createFileByDeleteOldFile(file)
FileWriter(file).use {
it.write(str)
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ object RabbitAsync {
.subscribe({
completeCallBack(it)
}, {
RabbitLog.d(TAG, "asyncRun error")
RabbitLog.d(TAG, "asyncRun error ${it.message}")
})
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package com.susion.rabbit.base.entities;

import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Id;
import org.greenrobot.greendao.annotation.Generated;

/**
* susionwang at 2020-01-08
*/
@Entity
public class RabbitIoCallInfo {

@Id(autoincrement = true)
public Long id;

public String invokeStr;

public String becalledStr;

public Long time;

@Generated(hash = 135502539)
public RabbitIoCallInfo(Long id, String invokeStr, String becalledStr,
Long time) {
this.id = id;
this.invokeStr = invokeStr;
this.becalledStr = becalledStr;
this.time = time;
}

@Generated(hash = 1556471498)
public RabbitIoCallInfo() {
}

public Long getId() {
return this.id;
}

public void setId(Long id) {
this.id = id;
}

public String getInvokeStr() {
return this.invokeStr;
}

public void setInvokeStr(String invokeStr) {
this.invokeStr = invokeStr;
}

public String getBecalledStr() {
return this.becalledStr;
}

public void setBecalledStr(String becalledStr) {
this.becalledStr = becalledStr;
}

public Long getTime() {
return this.time;
}

public void setTime(Long time) {
this.time = time;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public static void createAllTables(Database db, boolean ifNotExists) {
RabbitPageSpeedInfoDao.createTable(db, ifNotExists);
RabbitMemoryInfoDao.createTable(db, ifNotExists);
RabbitFPSInfoDao.createTable(db, ifNotExists);
RabbitIoCallInfoDao.createTable(db, ifNotExists);
}

/** Drops underlying database table using DAOs. */
Expand All @@ -43,6 +44,7 @@ public static void dropAllTables(Database db, boolean ifExists) {
RabbitPageSpeedInfoDao.dropTable(db, ifExists);
RabbitMemoryInfoDao.dropTable(db, ifExists);
RabbitFPSInfoDao.dropTable(db, ifExists);
RabbitIoCallInfoDao.dropTable(db, ifExists);
}

/**
Expand Down Expand Up @@ -70,6 +72,7 @@ public DaoMaster(Database db) {
registerDaoClass(RabbitPageSpeedInfoDao.class);
registerDaoClass(RabbitMemoryInfoDao.class);
registerDaoClass(RabbitFPSInfoDao.class);
registerDaoClass(RabbitIoCallInfoDao.class);
}

public DaoSession newSession() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import com.susion.rabbit.base.entities.RabbitPageSpeedInfo;
import com.susion.rabbit.base.entities.RabbitMemoryInfo;
import com.susion.rabbit.base.entities.RabbitFPSInfo;
import com.susion.rabbit.base.entities.RabbitIoCallInfo;

import com.susion.rabbit.base.greendao.RabbitHttpLogInfoDao;
import com.susion.rabbit.base.greendao.RabbitBlockFrameInfoDao;
Expand All @@ -27,6 +28,7 @@
import com.susion.rabbit.base.greendao.RabbitPageSpeedInfoDao;
import com.susion.rabbit.base.greendao.RabbitMemoryInfoDao;
import com.susion.rabbit.base.greendao.RabbitFPSInfoDao;
import com.susion.rabbit.base.greendao.RabbitIoCallInfoDao;

// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.

Expand All @@ -46,6 +48,7 @@ public class DaoSession extends AbstractDaoSession {
private final DaoConfig rabbitPageSpeedInfoDaoConfig;
private final DaoConfig rabbitMemoryInfoDaoConfig;
private final DaoConfig rabbitFPSInfoDaoConfig;
private final DaoConfig rabbitIoCallInfoDaoConfig;

private final RabbitHttpLogInfoDao rabbitHttpLogInfoDao;
private final RabbitBlockFrameInfoDao rabbitBlockFrameInfoDao;
Expand All @@ -56,6 +59,7 @@ public class DaoSession extends AbstractDaoSession {
private final RabbitPageSpeedInfoDao rabbitPageSpeedInfoDao;
private final RabbitMemoryInfoDao rabbitMemoryInfoDao;
private final RabbitFPSInfoDao rabbitFPSInfoDao;
private final RabbitIoCallInfoDao rabbitIoCallInfoDao;

public DaoSession(Database db, IdentityScopeType type, Map<Class<? extends AbstractDao<?, ?>>, DaoConfig>
daoConfigMap) {
Expand Down Expand Up @@ -88,6 +92,9 @@ public DaoSession(Database db, IdentityScopeType type, Map<Class<? extends Abstr
rabbitFPSInfoDaoConfig = daoConfigMap.get(RabbitFPSInfoDao.class).clone();
rabbitFPSInfoDaoConfig.initIdentityScope(type);

rabbitIoCallInfoDaoConfig = daoConfigMap.get(RabbitIoCallInfoDao.class).clone();
rabbitIoCallInfoDaoConfig.initIdentityScope(type);

rabbitHttpLogInfoDao = new RabbitHttpLogInfoDao(rabbitHttpLogInfoDaoConfig, this);
rabbitBlockFrameInfoDao = new RabbitBlockFrameInfoDao(rabbitBlockFrameInfoDaoConfig, this);
rabbitReportInfoDao = new RabbitReportInfoDao(rabbitReportInfoDaoConfig, this);
Expand All @@ -97,6 +104,7 @@ public DaoSession(Database db, IdentityScopeType type, Map<Class<? extends Abstr
rabbitPageSpeedInfoDao = new RabbitPageSpeedInfoDao(rabbitPageSpeedInfoDaoConfig, this);
rabbitMemoryInfoDao = new RabbitMemoryInfoDao(rabbitMemoryInfoDaoConfig, this);
rabbitFPSInfoDao = new RabbitFPSInfoDao(rabbitFPSInfoDaoConfig, this);
rabbitIoCallInfoDao = new RabbitIoCallInfoDao(rabbitIoCallInfoDaoConfig, this);

registerDao(RabbitHttpLogInfo.class, rabbitHttpLogInfoDao);
registerDao(RabbitBlockFrameInfo.class, rabbitBlockFrameInfoDao);
Expand All @@ -107,6 +115,7 @@ public DaoSession(Database db, IdentityScopeType type, Map<Class<? extends Abstr
registerDao(RabbitPageSpeedInfo.class, rabbitPageSpeedInfoDao);
registerDao(RabbitMemoryInfo.class, rabbitMemoryInfoDao);
registerDao(RabbitFPSInfo.class, rabbitFPSInfoDao);
registerDao(RabbitIoCallInfo.class, rabbitIoCallInfoDao);
}

public void clear() {
Expand All @@ -119,6 +128,7 @@ public void clear() {
rabbitPageSpeedInfoDaoConfig.clearIdentityScope();
rabbitMemoryInfoDaoConfig.clearIdentityScope();
rabbitFPSInfoDaoConfig.clearIdentityScope();
rabbitIoCallInfoDaoConfig.clearIdentityScope();
}

public RabbitHttpLogInfoDao getRabbitHttpLogInfoDao() {
Expand Down Expand Up @@ -157,4 +167,8 @@ public RabbitFPSInfoDao getRabbitFPSInfoDao() {
return rabbitFPSInfoDao;
}

public RabbitIoCallInfoDao getRabbitIoCallInfoDao() {
return rabbitIoCallInfoDao;
}

}
Loading

0 comments on commit 59f8dd1

Please sign in to comment.