騰訊GT SDK3.1.0
app集成gt_sdk用與采集性能相關(guān)數(shù)據(jù) 通過aidl進(jìn)程間通信將數(shù)據(jù)上送到gt_app
1.數(shù)據(jù)采集
- 應(yīng)用包名,pid 通過綁定服務(wù)intent傳遞
- NormalMonitor基礎(chǔ)信息收集 cpu 內(nèi)存 流量等
- ScreenMonitor 廣播監(jiān)聽屏幕休眠及活動狀態(tài)收集
- LogcatMonitor 日志信息通過logcat收集
- ChoreographerMonitor 通過postFrameCallback 收集FPS信息
- HookMonitor 通過YAHFA--ART native hook方式獲取activity fragment生命周期 view創(chuàng)建時間 繪制時間 db插入線程等信息。
額外
1.判斷一個應(yīng)用是否安裝 gt用的這種方式
/**
* 通過被測應(yīng)用的Context查找GT主應(yīng)用是否存在,
* 如果存在,則返回一個GT應(yīng)用的Context對象,注意該Context并非GT應(yīng)用中的對象,
* 只是GT應(yīng)用Context的一個鏡像
*
* @param hostContext 被測應(yīng)用的Context
*
* @return GT應(yīng)用是否已安裝
*/
private boolean isGTInstalled(Context hostContext) {
return (getGTContext(hostContext) != null);
}
private static Context getGTContext(Context context) {
Context result = null;
try {
result = context.createPackageContext(GTInternal.GT_PACKAGE_NAME,
Context.CONTEXT_INCLUDE_CODE | Context.CONTEXT_IGNORE_SECURITY);
} catch (NameNotFoundException e) {
Log.d(GTInternal.GT_PACKAGE_NAME, "GT is uninstall.");
}
return result;
}
2.判斷進(jìn)程是否包含Application主線程
/**
* 判斷進(jìn)程是否包含Application主線程
* @param context
* @param pid
* @return
*/
public static boolean isUIProcess(Context context, int pid) {
String processName = null;
ActivityManager mActivityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
for (RunningAppProcessInfo appProcess : mActivityManager.getRunningAppProcesses()) {
if (appProcess.pid == pid) {
processName = appProcess.processName;
break;
}
}
String packageName = context.getPackageName();
return processName != null && processName.equals(packageName);
}