use of com.tencent.wstt.gt.manager.SingleInstanceClientFactory in project GT by Tencent.
the class GTAUTFragment method doResume.
private void doResume() {
// 判断是否选择了AUT
tv_Appstatus.setText(AUTManager.appstatus);
tv_refresh.setBackgroundResource(R.drawable.textview_bg_shape);
if (AUTManager.appic != null) {
syncProcessRunPkgState();
tv_selectedApp.setBackgroundDrawable(AUTManager.appic);
tv_PkName.setText(AUTManager.pkn);
tv_AppName.setText(AUTManager.apn);
tv_PkName.setVisibility(View.VISIBLE);
}
if (AUTManager.appstatus.equals("--")) {
// setenable false
setAllCheckbox(0);
} else {
// 在前面getAllRunProcesses方法被重置
tv_Appstatus.setText(AUTManager.appstatus);
tv_Appstatus.setClickable(true);
tv_Appstatus.setOnClickListener(launchapp);
if (OpUIManager.gw_running) {
// setenable false
setAllCheckbox(0);
} else {
// setenable true
setAllCheckbox(1);
}
}
/*
* 判断每次选择的应用是否为同样的,若不一样清空进程采集设置
*/
if (pkn_old != null && !pkn_old.equals(AUTManager.pkn)) {
AUTManager.proNameIdMap.clear();
for (int i = 0; i < cb_status.length; i++) {
cb_status[i] = false;
}
for (int i = 0; i < cb_status.length; i++) {
unregisterOutpara(i);
}
AUTManager.proNameList.clear();
AUTManager.proPidList.clear();
// 清除旧的AUT_CLIENT
ClientManager.getInstance().removeClient(ClientManager.AUT_CLIENT);
// 创建新的AUT_CLIENT
ClientFactory cf = new SingleInstanceClientFactory();
cf.orderClient(ClientManager.AUT_CLIENT, ClientManager.AUT_CLIENT.hashCode(), null, null);
}
// 保证GT读取到最新的应用状态
AUTManager.findProcess();
pkn_old = AUTManager.pkn;
// UI同步一下状态
for (int count = 0; count < cb_status.length; count++) {
cb_boxs[count].setChecked(cb_status[count]);
}
}
use of com.tencent.wstt.gt.manager.SingleInstanceClientFactory in project GT by Tencent.
the class GTShowPackageActivity method backToSetting.
private void backToSetting(int pos) {
AppInfo appSelected = dataList.get(pos);
AUTManager.pkn = appSelected.packageName;
AUTManager.apn = appSelected.appName;
AUTManager.appic = appSelected.appIcon;
Env.CUR_APP_NAME = appSelected.packageName;
Env.CUR_APP_VER = appSelected.versionName;
// 清除旧的AUT_CLIENT
ClientManager.getInstance().removeClient(ClientManager.AUT_CLIENT);
// 创建新的AUT_CLIENT
ClientFactory cf = new SingleInstanceClientFactory();
cf.orderClient(ClientManager.AUT_CLIENT, ClientManager.AUT_CLIENT.hashCode(), null, null);
// MTA记录选中的AUT
Properties prop = new Properties();
prop.setProperty("pkgName", AUTManager.pkn);
StatService.trackCustomKVEvent(this, "Selected AUT", prop);
this.finish();
}
use of com.tencent.wstt.gt.manager.SingleInstanceClientFactory in project GT by Tencent.
the class GTApp method onCreate.
@Override
public void onCreate() {
super.onCreate();
mContext = getApplicationContext();
// 初始化环境变量
Env.init();
// 设置主线程的未捕获异常记录
CrashReport.initCrashReport(mContext, "900010910", false);
// 初始化适配Android4.x和5.x以上的ProcessUtils
ProcessUtils.init();
// App启动的时候,把该拷贝的资源文件拷贝了
propareResourceFile();
// 信号值获取的模块需要在这里初始化
SignalUtils.init();
// 网络流量在这里初始化,从GT开始启动时统计
NetUtils.initNetValue();
// 在GT启动时,把默认提供的出参注册了
registerGTDefaultOutParas();
// 初始化全局客户端
ClientFactory cf = new SingleInstanceClientFactory();
cf.orderClient(ClientManager.GLOBAL_CLIENT, ClientManager.GLOBAL_CLIENT.hashCode(), null, null);
// 加载插件,这句要在初始化全局客户端之后执行
loadPlugins();
loadEnvInfo();
// 使用MAT平台进行统计上报
// 第二个参数是null,标识读取manifest里配置的appKey
// 第三个参数必须为:com.tencent.stat.common.StatConstants.VERSION
// 不打印MTA类日志
StatConfig.setDebugEnable(false);
// 是否WIFI网络下实时上报,如果是false,则在GT第二次启动上报
StatConfig.setEnableSmartReporting(true);
try {
StatService.startStatService(this, null, com.tencent.stat.common.StatConstants.VERSION);
} catch (MtaSDkException e) {
// MTA初始化失败
Log.e("gt_mta", "MTA start failed.");
}
// notify the existing clients to try to connect to
// current service if they are launched before GT
notifyGTRClient();
}
use of com.tencent.wstt.gt.manager.SingleInstanceClientFactory in project GT by Tencent.
the class GTAUTFragment1 method doResume.
private void doResume() {
if (AUTManager.appic != null) {
syncProcessRunPkgState();
resetAppInfo();
}
/*
* 判断每次选择的应用是否为同样的,若不一样清空进程采集设置
*/
if (pkn_old != null && !pkn_old.equals(AUTManager.pkn)) {
AUTManager.proNameIdMap.clear();
AUTManager.proNameList.clear();
AUTManager.proPidList.clear();
// 清除旧的AUT_CLIENT
ClientManager.getInstance().removeClient(ClientManager.AUT_CLIENT);
// 创建新的AUT_CLIENT
ClientFactory cf = new SingleInstanceClientFactory();
cf.orderClient(ClientManager.AUT_CLIENT, ClientManager.AUT_CLIENT.hashCode(), null, null);
}
// 保证GT读取到最新的应用状态
AUTManager.findProcess();
pkn_old = AUTManager.pkn;
addDataChangeCallBack();
thread = new Thread(new Runnable() {
public void run() {
AUTManager.appstatus = "running";
checkRegist();
}
});
thread.start();
}
use of com.tencent.wstt.gt.manager.SingleInstanceClientFactory 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);
}
Aggregations