最近有个需求,要求制作一个用于Monkey测试的APK,然后在开始测试的时候打开MTKLogger,结束测试的时候关闭掉。
网上大多都是adb命令形式,有点难搞,后面问了下师傅,把问题解决了,这里就借花献佛了。
开启MTKLogger:
public void openMtkLog() {
Intent intent = new Intent();
//设置intent的动作为com.example.broadcast,可以任意定义
intent.setAction("com.mediatek.mtklogger.ADB_CMD");
Bundle bundle = new Bundle();
bundle.putString("cmd_name", "start");
bundle.putInt("cmd_target",1);
intent.putExtras(bundle);
sendBroadcast(intent);
Log.d("MonkeyTestService","MtkLog被开启");
}
关闭MTKLogger:
public void closeMtkLog(){
Intent intent = new Intent();
//设置intent的动作为com.example.broadcast,可以任意定义
intent.setAction("com.mediatek.mtklogger.ADB_CMD");
Bundle bundle = new Bundle();
bundle.putString("cmd_name", "stop");
bundle.putInt("cmd_target",1);
intent.putExtras(bundle);
sendBroadcast(intent);
Log.d("MonkeyTestService","MtkLog被关闭");
}