Commit c0056e72 authored by Dennis Rassmann's avatar Dennis Rassmann

flasher: use a thread for module pushing (avoids frozen ui)

Signed-off-by: Dennis Rassmann's avatarshowp1984 <showp1984@gmail.com>
parent fb836736
......@@ -15,10 +15,6 @@ flasher::flasher(QWidget *parent) :
flashtimer = new QTimer(this);
connect(flashtimer, SIGNAL(timeout()), this, SLOT(flash_device()));
pushtimer = new QTimer(this);
connect(pushtimer, SIGNAL(timeout()), this, SLOT(push_files_timed()));
pushtimer->setSingleShot(true);
list = QStringList() << "" << "" << "" << "" << "" << "" << "";
list2 = QStringList() << "" << "";
list3 = QStringList() << "" << "";
......@@ -43,8 +39,6 @@ flasher::~flasher()
{
flashtimer->stop();
delete flashtimer;
pushtimer->stop();
delete pushtimer;
delete ui;
delete this;
}
......@@ -516,20 +510,32 @@ void flasher::push_files(void)
if (!p_out.isEmpty()) {
ui->txt_out->append(p_out);
}
pushtimer->start(0);
ui->txt_out->append("Searching for modules...");
PushWorker *pworker = new PushWorker();
pworker->set_snr(snr);
pworker->set_abstemppath(abstemppath);
QObject::connect(pworker,
SIGNAL(finished()),
this,
SLOT(push_files_finished()));
ui->txt_out->append("Pushing modules... (may take a minute)");
pworker->start();
}
}
void flasher::push_files_timed(void)
void flasher::push_files_finished(void) {
ui->txt_out->append("Modules pushed...");
//REBOOT_FASTBOOT
flash_state = REBOOT_FASTBOOT;
}
void PushWorker::run(void)
{
ui->txt_out->append("Searching for modules...");
QProcess p;
QDirIterator it(QString(abstemppath), QDirIterator::Subdirectories);
while (it.hasNext()) {
if (it.next().contains(".ko") && !it.next().isEmpty()) {
ui->txt_out->append(it.next());
p.terminate();
p_out = "";
#ifdef Q_WS_X11
p.start( "tools/adb -s " + snr + " push " + it.next() + " /system/lib/modules/");
#endif
......@@ -540,13 +546,18 @@ void flasher::push_files_timed(void)
p.start( "tools\\adb.exe -s " + snr + " push " + it.next() + " /system/lib/modules/");
#endif
p.waitForFinished(-1);
p_out = p.readAllStandardOutput();
if (!p_out.isEmpty()) {
ui->txt_out->append(p_out);
}
}
}
ui->txt_out->append("Modules pushed...");
//REBOOT_FASTBOOT
flash_state = RELEASE_CONTROLS;
this->finished();
this->quit();
}
void PushWorker::set_snr(QString str)
{
snr = str;
}
void PushWorker::set_abstemppath(QString str)
{
abstemppath = str;
}
......@@ -41,7 +41,6 @@ private:
Ui::flasher *ui;
Info *infowind;
QTimer *flashtimer;
QTimer *pushtimer;
QTextCursor c;
QProcess p;
bool error;
......@@ -61,6 +60,7 @@ private:
QString filepath;
QString tmp_folder;
QString abstemppath;
QString itprev;
private slots:
void on_txt_out_textChanged();
......@@ -69,7 +69,7 @@ private slots:
void on_actionInfo_triggered();
void on_actionQuit_triggered();
void flash_device(void);
void push_files_timed(void);
void push_files_finished(void);
int extract(void);
int detect_device(void);
int get_booted(void);
......@@ -78,4 +78,18 @@ private slots:
bool rmdir_recursive(const QString&);
};
class PushWorker : public QThread {
Q_OBJECT
public:
void run();
void set_snr(QString);
void set_abstemppath(QString);
signals:
void finished();
void error(QString err);
private:
QString snr;
QString abstemppath;
};
#endif // FLASHER_H
/****************************************************************************
** Meta object code from reading C++ file 'detect.h'
**
** Created: Mon Jul 2 07:17:32 2012
** Created: Mon Jul 2 10:15:14 2012
** by: The Qt Meta Object Compiler version 62 (Qt 4.6.2)
**
** WARNING! All changes made in this file will be lost!
......
/****************************************************************************
** Meta object code from reading C++ file 'dragons.h'
**
** Created: Mon Jul 2 07:17:30 2012
** Created: Mon Jul 2 10:15:13 2012
** by: The Qt Meta Object Compiler version 62 (Qt 4.6.2)
**
** WARNING! All changes made in this file will be lost!
......
/****************************************************************************
** Meta object code from reading C++ file 'flasher.h'
**
** Created: Mon Jul 2 07:17:33 2012
** Created: Mon Jul 2 10:15:16 2012
** by: The Qt Meta Object Compiler version 62 (Qt 4.6.2)
**
** WARNING! All changes made in this file will be lost!
......@@ -38,12 +38,12 @@ static const uint qt_meta_data_flasher[] = {
105, 8, 8, 8, 0x08,
131, 8, 8, 8, 0x08,
146, 8, 8, 8, 0x08,
169, 8, 165, 8, 0x08,
179, 8, 165, 8, 0x08,
195, 8, 165, 8, 0x08,
208, 8, 8, 8, 0x08,
229, 226, 221, 8, 0x08,
266, 8, 221, 8, 0x08,
172, 8, 168, 8, 0x08,
182, 8, 168, 8, 0x08,
198, 8, 168, 8, 0x08,
211, 8, 8, 8, 0x08,
232, 229, 224, 8, 0x08,
269, 8, 224, 8, 0x08,
0 // eod
};
......@@ -53,7 +53,7 @@ static const char qt_meta_stringdata_flasher[] = {
"on_btn_start_clicked()\0on_btn_quit_clicked()\0"
"on_actionInfo_triggered()\0"
"on_actionQuit_triggered()\0flash_device()\0"
"push_files_timed()\0int\0extract()\0"
"push_files_finished()\0int\0extract()\0"
"detect_device()\0get_booted()\0push_files()\0"
"bool\0,,\0extract_zip(QString,QString,QString)\0"
"rmdir_recursive(QString)\0"
......@@ -94,7 +94,7 @@ int flasher::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
case 3: on_actionInfo_triggered(); break;
case 4: on_actionQuit_triggered(); break;
case 5: flash_device(); break;
case 6: push_files_timed(); break;
case 6: push_files_finished(); break;
case 7: { int _r = extract();
if (_a[0]) *reinterpret_cast< int*>(_a[0]) = _r; } break;
case 8: { int _r = detect_device();
......@@ -112,4 +112,78 @@ int flasher::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
}
return _id;
}
static const uint qt_meta_data_PushWorker[] = {
// content:
4, // revision
0, // classname
0, 0, // classinfo
2, 14, // methods
0, 0, // properties
0, 0, // enums/sets
0, 0, // constructors
0, // flags
2, // signalCount
// signals: signature, parameters, type, tag, flags
12, 11, 11, 11, 0x05,
27, 23, 11, 11, 0x05,
0 // eod
};
static const char qt_meta_stringdata_PushWorker[] = {
"PushWorker\0\0finished()\0err\0error(QString)\0"
};
const QMetaObject PushWorker::staticMetaObject = {
{ &QThread::staticMetaObject, qt_meta_stringdata_PushWorker,
qt_meta_data_PushWorker, 0 }
};
#ifdef Q_NO_DATA_RELOCATION
const QMetaObject &PushWorker::getStaticMetaObject() { return staticMetaObject; }
#endif //Q_NO_DATA_RELOCATION
const QMetaObject *PushWorker::metaObject() const
{
return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject;
}
void *PushWorker::qt_metacast(const char *_clname)
{
if (!_clname) return 0;
if (!strcmp(_clname, qt_meta_stringdata_PushWorker))
return static_cast<void*>(const_cast< PushWorker*>(this));
return QThread::qt_metacast(_clname);
}
int PushWorker::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
_id = QThread::qt_metacall(_c, _id, _a);
if (_id < 0)
return _id;
if (_c == QMetaObject::InvokeMetaMethod) {
switch (_id) {
case 0: finished(); break;
case 1: error((*reinterpret_cast< QString(*)>(_a[1]))); break;
default: ;
}
_id -= 2;
}
return _id;
}
// SIGNAL 0
void PushWorker::finished()
{
QMetaObject::activate(this, &staticMetaObject, 0, 0);
}
// SIGNAL 1
void PushWorker::error(QString _t1)
{
void *_a[] = { 0, const_cast<void*>(reinterpret_cast<const void*>(&_t1)) };
QMetaObject::activate(this, &staticMetaObject, 1, _a);
}
QT_END_MOC_NAMESPACE
/****************************************************************************
** Meta object code from reading C++ file 'mainwindow.h'
**
** Created: Mon Jul 2 07:17:29 2012
** Created: Mon Jul 2 10:15:11 2012
** by: The Qt Meta Object Compiler version 62 (Qt 4.6.2)
**
** WARNING! All changes made in this file will be lost!
......
/****************************************************************************
** Meta object code from reading C++ file 'openfile.h'
**
** Created: Mon Jul 2 07:17:35 2012
** Created: Mon Jul 2 10:15:17 2012
** by: The Qt Meta Object Compiler version 62 (Qt 4.6.2)
**
** WARNING! All changes made in this file will be lost!
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment