#include "thread_monitor.h" thread_monitor::thread_monitor(device dev) { process = new adbProcess(); explainer = new textExplainer(); //timer = new QTimer(this); //connect(timer,SIGNAL(timeout()),this,SLOT(getInfo())); //adb shell cat /proc/meminfo //adb shell cat proc/stat } void thread_monitor::run() { process->thread = true; //timer->start(1000); /* while(true) { }*/ } void thread_monitor::getInfo() { //qDebug() << ">> getInfo()"; cpu_t2 = process->run("adb shell cat proc/stat", dev); mem = process->run("adb shell cat /proc/meminfo",dev); //qDebug() << "cpu_t2 =" << cpu_t2; //qDebug() << mem; if(cpu_t1 != "#FIRSTBOOT#" && !cpu_t2.isEmpty() && !mem.isEmpty()) { //qDebug() << "before, cpu_t1 = " <get_words_before(explainer->get_words_after(mem.split("\n")[0] , "MemTotal:") , "kB").simplified().simplified().toInt(); //int MemFree = explainer->get_words_before(explainer->get_words_after(mem.split("\n")[1] , "MemFree:") , "kB").simplified().simplified().toInt(); int MemAvailable = explainer->get_words_before(explainer->get_words_after(mem.split("\n")[2] , "MemAvailable:") , "kB").simplified().simplified().toInt(); qDebug() << "Mem = " << mem; qDebug() << "MemTotal = " << MemTotal; //qDebug() << "MemFree = " << MemFree; //float mem_use = (float)(MemTotal - MemFree) / (float)MemTotal; float mem_use = (float)(MemTotal - MemAvailable) / (float)MemTotal; qDebug() << "mem_use = " << mem_use; mem = ""; emit signal_monitor(cpu_use, mem_use); } else { //qDebug() << "cpu_t2.isEmpty?" << cpu_t2.isEmpty(); //qDebug() << "mem.isEmpty?" << mem.isEmpty(); cpu_t1 = process->run("adb shell cat proc/stat", dev); } //cpu_t1 = ""; }