Search in sources :

Example 6 with ClientFactory

use of com.tencent.wstt.gt.manager.ClientFactory in project GT by Tencent.

the class GTAutoTestInternal method startProcTest.

/**
 * 启动指定应用的指定进程的数据采集
 * @param pkgName 指定的被测应用
 * @param pid 被测应用指定的被测进程,目前不使用,会同时采集应用的所有进程,请置-1
 */
public static void startProcTest(String pkgName, String verName, int pid) {
    ProcessUtils.initUidPkgCache();
    // 清理旧记录
    tempMap.clear();
    if (ClientManager.getInstance().getAUTClient() != null) {
        AUTManager.proNameIdMap.clear();
        AUTManager.proNameList.clear();
        AUTManager.proPidList.clear();
        // 清除旧的AUT_CLIENT
        ClientManager.getInstance().getAUTClient().clear();
        ClientManager.getInstance().removeClient(ClientManager.AUT_CLIENT);
    }
    // 新生的AUTClient
    ClientFactory cf = new SingleInstanceClientFactory();
    cf.orderClient(ClientManager.AUT_CLIENT, ClientManager.AUT_CLIENT.hashCode(), null, null);
    // 开启数据收集
    OpUIManager.gw_running = true;
    if (!ProcPerfParaRunEngine.getInstance().isStarted()) {
        ProcPerfParaRunEngine.getInstance().start();
    }
    AUTManager.appstatus = "running";
    Env.CUR_APP_VER = verName == null ? "unknow" : verName;
    // 同之后的操作点击应用列表的操作
    if (pkgName != null) {
        AUTManager.pkn = pkgName;
        Env.CUR_APP_NAME = pkgName;
        PackageInfo pi = null;
        try {
            pi = GTApp.getContext().getPackageManager().getPackageInfo(pkgName, 0);
            AUTManager.apn = pi.applicationInfo.loadLabel(GTApp.getContext().getPackageManager()).toString();
            AUTManager.appic = pi.applicationInfo.loadIcon(GTApp.getContext().getPackageManager());
            // MTA记录选中的AUT
            Properties prop = new Properties();
            prop.setProperty("pkgName", AUTManager.pkn);
            StatService.trackCustomKVEvent(GTApp.getContext(), "Connected AUT", prop);
            // 复杂的过程,修改需谨慎
            AUTManager.findProcess();
        } catch (NameNotFoundException e) {
            e.printStackTrace();
        }
    }
    // 通知AUT页同步状态
    GTApp.getAUTHandler().sendEmptyMessage(0);
}
Also used : NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException) PackageInfo(android.content.pm.PackageInfo) SingleInstanceClientFactory(com.tencent.wstt.gt.manager.SingleInstanceClientFactory) SingleInstanceClientFactory(com.tencent.wstt.gt.manager.SingleInstanceClientFactory) ClientFactory(com.tencent.wstt.gt.manager.ClientFactory) Properties(java.util.Properties)

Aggregations

ClientFactory (com.tencent.wstt.gt.manager.ClientFactory)6 SingleInstanceClientFactory (com.tencent.wstt.gt.manager.SingleInstanceClientFactory)5 Properties (java.util.Properties)2 Context (android.content.Context)1 PackageInfo (android.content.pm.PackageInfo)1 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)1 MtaSDkException (com.tencent.stat.MtaSDkException)1 Client (com.tencent.wstt.gt.manager.Client)1 ConnectedClientFactory (com.tencent.wstt.gt.manager.ConnectedClientFactory)1 AppInfo (com.tencent.wstt.gt.utils.AppInfo)1