Speed up post-USBMS: no more reboots!

This commit is contained in:
Nicolas Mailloux 2021-09-26 16:46:25 -04:00
parent 180048235e
commit a217545fd6
4 changed files with 50 additions and 32 deletions

View file

@ -496,16 +496,7 @@ MainWindow::MainWindow(QWidget *parent)
} }
// Check for an update and ask if the user wants to install it // Check for an update and ask if the user wants to install it
if(checkconfig("/mnt/onboard/onboard/.inkbox/can_update") == true) { checkForUpdate();
if(checkconfig("/tmp/cancelUpdateDialog") == false) {
// I'm sorry.
qDebug() << "An update is available.";
QTimer::singleShot(2000, this, SLOT(openUpdateDialog()));
}
else {
qDebug() << "Not showing update dialog, user dismissed it...";
}
}
// Check if it's the first boot since an update and confirm that it installed successfully // Check if it's the first boot since an update and confirm that it installed successfully
if(checkconfig("/opt/inkbox_genuine") == true) { if(checkconfig("/opt/inkbox_genuine") == true) {
@ -1010,3 +1001,16 @@ void MainWindow::openReaderFramework() {
connect(readerWindow, SIGNAL(openBookFile(QString, bool)), SLOT(openBookFile(QString, bool))); connect(readerWindow, SIGNAL(openBookFile(QString, bool)), SLOT(openBookFile(QString, bool)));
readerWindow->showFullScreen(); readerWindow->showFullScreen();
} }
void MainWindow::checkForUpdate() {
if(checkconfig("/mnt/onboard/onboard/.inkbox/can_update") == true) {
if(checkconfig("/tmp/cancelUpdateDialog") == false) {
// I'm sorry.
qDebug() << "An update is available.";
QTimer::singleShot(2000, this, SLOT(openUpdateDialog()));
}
else {
qDebug() << "Not showing update dialog, user dismissed it...";
}
}
}

View file

@ -87,6 +87,7 @@ private slots:
void launchOtaUpdater(); void launchOtaUpdater();
void openBookFile(QString book, bool relativePath); void openBookFile(QString book, bool relativePath);
void openReaderFramework(); void openReaderFramework();
void checkForUpdate();
private: private:
Ui::MainWindow *ui; Ui::MainWindow *ui;

View file

@ -67,26 +67,16 @@ void usbms_splash::usbms_launch()
string_writeconfig("/tmp/in_usbms", "true"); string_writeconfig("/tmp/in_usbms", "true");
QTimer::singleShot(1500, this, SLOT(brightnessDown())); QTimer::singleShot(1500, this, SLOT(brightnessDown()));
QString umount_prog ("umount");
QStringList umount_args;
if(global::usbms::koboxExportExtensions == true) { if(global::usbms::koboxExportExtensions == true) {
umount_args << "/dev/loop10"; string_writeconfig("/opt/ibxd", "kobox_extensions_storage_unmount\n");
} }
else { else {
umount_args << "/dev/loop0"; string_writeconfig("/opt/ibxd", "onboard_unmount\n");
} }
QProcess *umount_proc = new QProcess(); QThread::msleep(500);
umount_proc->start(umount_prog, umount_args);
umount_proc->waitForFinished();
umount_proc->deleteLater();
QString rmmod ("rmmod"); string_writeconfig("/opt/ibxd", "usbnet_stop\n");
QStringList rmmod_args; QThread::msleep(200);
rmmod_args << "g_ether.ko";
QProcess *rmmod_proc = new QProcess();
rmmod_proc->start(rmmod, rmmod_args);
rmmod_proc->waitForFinished();
rmmod_proc->deleteLater();
QString prog ("insmod"); QString prog ("insmod");
QStringList args; QStringList args;
@ -128,13 +118,25 @@ void usbms_splash::usbms_launch()
std::string contentstr = content.toStdString(); std::string contentstr = content.toStdString();
modules.close(); modules.close();
if(contentstr.find("1") != std::string::npos) { if(contentstr.find("1") != std::string::npos) {
QString reboot_prog ("/sbin/reboot"); if(global::usbms::koboxExportExtensions == true) {
QStringList reboot_args; reboot(false);
reboot_args << "no_splash"; }
QProcess *reboot_proc = new QProcess(); else {
reboot_proc->start(reboot_prog, reboot_args); QString prog("rmmod");
reboot_proc->waitForFinished(); QStringList args;
reboot_proc->deleteLater(); args << "g_mass_storage";
QProcess * proc = new QProcess();
proc->start(prog, args);
proc->waitForFinished();
proc->deleteLater();
// NOTE: USBNet is only started if required conditions are met (see https://github.com/Kobo-InkBox/rootfs/blob/master/etc/init.d/usbnet.sh)
string_writeconfig("/opt/ibxd", "usbnet_start\n");
string_writeconfig("/opt/ibxd", "onboard_mount\n");
QThread::msleep(500);
quit_restart();
}
} }
else { else {
; ;
@ -151,3 +153,13 @@ usbms_splash::~usbms_splash()
void usbms_splash::brightnessDown() { void usbms_splash::brightnessDown() {
cinematicBrightness(0, 1); cinematicBrightness(0, 1);
} }
void usbms_splash::quit_restart() {
// If existing, cleaning bookconfig_mount mountpoint
string_writeconfig("/opt/ibxd", "bookconfig_unmount\n");
// Restarting InkBox
QProcess process;
process.startDetached("inkbox", QStringList());
qApp->quit();
}

View file

@ -19,6 +19,7 @@ public:
private slots: private slots:
void brightnessDown(); void brightnessDown();
void quit_restart();
private: private:
Ui::usbms_splash *ui; Ui::usbms_splash *ui;