騰訊GT SDK3.1.0了解

騰訊GT SDK3.1.0

app集成gt_sdk用與采集性能相關(guān)數(shù)據(jù) 通過aidl進(jìn)程間通信將數(shù)據(jù)上送到gt_app

1.數(shù)據(jù)采集

  1. 應(yīng)用包名,pid 通過綁定服務(wù)intent傳遞
  2. NormalMonitor基礎(chǔ)信息收集 cpu 內(nèi)存 流量等
  3. ScreenMonitor 廣播監(jiān)聽屏幕休眠及活動狀態(tài)收集
  4. LogcatMonitor 日志信息通過logcat收集
  5. ChoreographerMonitor 通過postFrameCallback 收集FPS信息
  6. 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);
    }
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容