forked from qt-creator/qt-creator
Android: Add updateRecipe
Change-Id: Id934f238cff579208f85af6f8b716871ba0c9321 Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
@@ -243,8 +243,20 @@ static void setupSdkProcess(const QStringList &args, Process *process,
|
|||||||
return;
|
return;
|
||||||
dialog->setProgress((current * 100.0 + *progress) / total);
|
dialog->setProgress((current * 100.0 + *progress) / total);
|
||||||
});
|
});
|
||||||
|
QObject::connect(process, &Process::readyReadStandardError, dialog, [process, dialog] {
|
||||||
|
QTextCodec *codec = QTextCodec::codecForLocale();
|
||||||
|
dialog->appendMessage(codec->toUnicode(process->readAllRawStandardError()), StdErrFormat);
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void handleSdkProcess(QuestionProgressDialog *dialog, DoneWith result)
|
||||||
|
{
|
||||||
|
if (result == DoneWith::Success)
|
||||||
|
dialog->appendMessage(Tr::tr("Finished successfully.") + "\n\n", StdOutFormat);
|
||||||
|
else
|
||||||
|
dialog->appendMessage(Tr::tr("Failed.") + "\n\n", StdErrFormat);
|
||||||
|
}
|
||||||
|
|
||||||
static GroupItem installationRecipe(const Storage<DialogStorage> &dialogStorage,
|
static GroupItem installationRecipe(const Storage<DialogStorage> &dialogStorage,
|
||||||
const InstallationChange &change)
|
const InstallationChange &change)
|
||||||
{
|
{
|
||||||
@@ -282,12 +294,7 @@ static GroupItem installationRecipe(const Storage<DialogStorage> &dialogStorage,
|
|||||||
};
|
};
|
||||||
|
|
||||||
const auto onDone = [dialogStorage](DoneWith result) {
|
const auto onDone = [dialogStorage](DoneWith result) {
|
||||||
if (result == DoneWith::Success) {
|
handleSdkProcess(dialogStorage->m_dialog.get(), result);
|
||||||
dialogStorage->m_dialog->appendMessage(Tr::tr("Finished successfully") + "\n\n",
|
|
||||||
StdOutFormat);
|
|
||||||
} else {
|
|
||||||
dialogStorage->m_dialog->appendMessage(Tr::tr("Failed") + "\n\n", StdErrFormat);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return Group {
|
return Group {
|
||||||
@@ -305,6 +312,22 @@ static GroupItem installationRecipe(const Storage<DialogStorage> &dialogStorage,
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static GroupItem updateRecipe(const Storage<DialogStorage> &dialogStorage)
|
||||||
|
{
|
||||||
|
const auto onUpdateSetup = [dialogStorage](Process &process) {
|
||||||
|
const QStringList args = {"--update", sdkRootArg(androidConfig())};
|
||||||
|
QuestionProgressDialog *dialog = dialogStorage->m_dialog.get();
|
||||||
|
setupSdkProcess(args, &process, dialog, 0, 1);
|
||||||
|
dialog->appendMessage(Tr::tr("Updating installed packages....") + '\n', NormalMessageFormat);
|
||||||
|
dialog->setProgress(0);
|
||||||
|
};
|
||||||
|
const auto onDone = [dialogStorage](DoneWith result) {
|
||||||
|
handleSdkProcess(dialogStorage->m_dialog.get(), result);
|
||||||
|
};
|
||||||
|
|
||||||
|
return ProcessTask(onUpdateSetup, onDone);
|
||||||
|
}
|
||||||
|
|
||||||
const int sdkManagerCmdTimeoutS = 60;
|
const int sdkManagerCmdTimeoutS = 60;
|
||||||
const int sdkManagerOperationTimeoutS = 600;
|
const int sdkManagerOperationTimeoutS = 600;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user