app固件支持锁定的话,不进行强制升级
This commit is contained in:
parent
62c1199965
commit
99659a0b0c
|
@ -91,8 +91,11 @@ QString MainWindow::passwordDecrypt(const QString& transcode)
|
|||
return password;
|
||||
}
|
||||
|
||||
QString MainWindow::GetDevType(const QString& fwVersion)
|
||||
QString MainWindow::GetDevType(const QString& fwVersion, bool *canLock)
|
||||
{
|
||||
if (NULL != canLock)
|
||||
*canLock = false;
|
||||
|
||||
QString devType;
|
||||
if (fwVersion.length() == 10)
|
||||
{
|
||||
|
@ -111,16 +114,42 @@ QString MainWindow::GetDevType(const QString& fwVersion)
|
|||
QString date = fwVersion.mid(5, 5);
|
||||
if ((dev == "G1" || dev == "G2") && ver == "393")
|
||||
{
|
||||
if (date >= "A1220" && date <= "A1228")
|
||||
devType = dev + ver + "/" + "A1220-A1228";
|
||||
else if (date >= "B0326" && date <= "B0331")
|
||||
devType = dev + ver + "/" + "B0326-B0331";
|
||||
if (date >= "A1220" && date <= "A1230")
|
||||
{
|
||||
devType = dev + ver + "/" + "A1220-A1230";
|
||||
if (date >= "A1224")
|
||||
{
|
||||
if (NULL != canLock)
|
||||
*canLock = true;
|
||||
}
|
||||
}
|
||||
else if (date >= "B0326" && date <= "B0334")
|
||||
{
|
||||
devType = dev + ver + "/" + "B0326-B0334";
|
||||
if (date >= "B0333")
|
||||
{
|
||||
if (NULL != canLock)
|
||||
*canLock = true;
|
||||
}
|
||||
}
|
||||
else if (date >= "B0429")
|
||||
{
|
||||
devType = dev + ver + "/" + "B0429-";
|
||||
if (date >= "B1031")
|
||||
{
|
||||
if (NULL != canLock)
|
||||
*canLock = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (dev == "G4" && ver == "393")
|
||||
{
|
||||
devType = dev + ver + "/";
|
||||
if (date >= "B1108")
|
||||
{
|
||||
if (NULL != canLock)
|
||||
*canLock = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -247,7 +276,7 @@ void MainWindow::on_comboDevList_currentIndexChanged(int index)
|
|||
}
|
||||
|
||||
m_curFwVersion = QString::fromStdString(versionNum.c_str());
|
||||
QString devType = GetDevType(m_curFwVersion);
|
||||
QString devType = GetDevType(m_curFwVersion, NULL);
|
||||
|
||||
ui->labelDevInfo->setText(QString(tr("device: %1, firmware version: %2, upgrade: %3")).arg(name)
|
||||
.arg(m_curFwVersion).arg(!devType.isEmpty() ? tr("support") : tr("do not support")));
|
||||
|
@ -304,7 +333,7 @@ void MainWindow::on_btnGetVersionList_clicked()
|
|||
m_vVersion.clear();
|
||||
ui->comboVersionList->clear();
|
||||
|
||||
QString devType = GetDevType(m_curFwVersion);
|
||||
QString devType = GetDevType(m_curFwVersion, NULL);
|
||||
assert(!devType.isEmpty());
|
||||
|
||||
HGVersionInfo *versionInfo = nullptr;
|
||||
|
@ -370,14 +399,14 @@ void MainWindow::on_btnOpenFilePath_clicked()
|
|||
QString filePath = QFileDialog::getOpenFileName(this, tr("Open File"), ".", tr("ZIP Files(*.zip *.zip)"));
|
||||
if (!filePath.isEmpty())
|
||||
{
|
||||
QString devType = GetDevType(m_curFwVersion);
|
||||
QString devType = GetDevType(m_curFwVersion, NULL);
|
||||
assert(!devType.isEmpty());
|
||||
|
||||
HGChar fileName[256] = {0};
|
||||
HGBase_GetFileName(filePath.toStdString().c_str(), fileName, 256);
|
||||
HGChar fileVersion[256] = {0};
|
||||
HGBase_GetFilePrefix(fileName, fileVersion, 256);
|
||||
if (devType == GetDevType(fileVersion))
|
||||
if (devType == GetDevType(fileVersion, NULL))
|
||||
{
|
||||
if (m_curFwVersion >= fileVersion)
|
||||
{
|
||||
|
|
|
@ -26,7 +26,7 @@ public:
|
|||
|
||||
static QString passwordEncrypt(const QString& password);
|
||||
static QString passwordDecrypt(const QString& transcode);
|
||||
static QString GetDevType(const QString& fwVersion);
|
||||
static QString GetDevType(const QString& fwVersion, bool *canLock);
|
||||
|
||||
signals:
|
||||
void sane_dev_arrive(QString devName, bool opened);
|
||||
|
|
|
@ -2595,71 +2595,73 @@ void HGAPI MainWindow::FwUpgradeAndDevLockThread(HGThread thread, HGPointer para
|
|||
|
||||
if (p->m_vFwUpgradeAndDevLock[index].m_checkFlag & FwUpgradeAndDevLock::FwUpgrade)
|
||||
{
|
||||
QString devType = GetDevType(p->m_devVersionNum);
|
||||
assert(!devType.isEmpty());
|
||||
|
||||
// 检查升级
|
||||
HGVersionInfo* versionInfo = nullptr;
|
||||
HGUInt versionCount = 0;
|
||||
p->m_versionDll->GetDriverVersionList(devType.toStdString().c_str(), &versionInfo, &versionCount);
|
||||
if (versionCount > 0)
|
||||
bool canLock;
|
||||
QString devType = GetDevType(p->m_devVersionNum, canLock);
|
||||
if (!devType.isEmpty() && !canLock)
|
||||
{
|
||||
HGUInt verionIndex = 0;
|
||||
QString currVersion = versionInfo[0].version;
|
||||
for (HGUInt i = 1; i < versionCount; ++i)
|
||||
// 检查升级
|
||||
HGVersionInfo* versionInfo = nullptr;
|
||||
HGUInt versionCount = 0;
|
||||
p->m_versionDll->GetDriverVersionList(devType.toStdString().c_str(), &versionInfo, &versionCount);
|
||||
if (versionCount > 0)
|
||||
{
|
||||
if (QString(versionInfo[i].version) > currVersion)
|
||||
HGUInt verionIndex = 0;
|
||||
QString currVersion = versionInfo[0].version;
|
||||
for (HGUInt i = 1; i < versionCount; ++i)
|
||||
{
|
||||
verionIndex = i;
|
||||
currVersion = QString(versionInfo[i].version);
|
||||
}
|
||||
}
|
||||
|
||||
if ((std::string)(versionInfo[verionIndex].version) > p->m_devVersionNum.toStdString()) // 比较版本号
|
||||
{
|
||||
HGChar suffix[64];
|
||||
HGBase_GetFileSuffix(versionInfo[verionIndex].url, suffix, 64);
|
||||
|
||||
HGChar savePath[512];
|
||||
HGBase_GetConfigPath(savePath, 512);
|
||||
HGBase_CreateDir(savePath);
|
||||
HGChar fileName[128];
|
||||
sprintf(fileName, "%s.%s", versionInfo[verionIndex].version, suffix);
|
||||
strcat(savePath, fileName);
|
||||
|
||||
QFile saveFile(savePath);
|
||||
saveFile.open(QFile::ReadOnly);
|
||||
QByteArray fileMsg = saveFile.readAll();
|
||||
saveFile.close();
|
||||
QString md5_2 = QCryptographicHash::hash(fileMsg, QCryptographicHash::Md5).toHex();
|
||||
|
||||
QFile f(savePath);
|
||||
if (!f.exists() || versionInfo[verionIndex].md5 != md5_2)
|
||||
{
|
||||
HGResult ret = p->m_versionDll->HttpDownload(versionInfo[verionIndex].url, savePath, NULL, NULL);
|
||||
if (HGBASE_ERR_OK == ret)
|
||||
if (QString(versionInfo[i].version) > currVersion)
|
||||
{
|
||||
QFile saveFile(savePath);
|
||||
saveFile.open(QFile::ReadOnly);
|
||||
QByteArray fileMsg = saveFile.readAll();
|
||||
saveFile.close();
|
||||
QString md5_2 = QCryptographicHash::hash(fileMsg, QCryptographicHash::Md5).toHex();
|
||||
|
||||
if (versionInfo[verionIndex].md5 == md5_2)
|
||||
{
|
||||
p->m_vFwUpgradeAndDevLock[index].m_upgradeFilePath = savePath;
|
||||
p->m_vFwUpgradeAndDevLock[index].m_handleFlag |= FwUpgradeAndDevLock::FwUpgrade;
|
||||
}
|
||||
verionIndex = i;
|
||||
currVersion = QString(versionInfo[i].version);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
if ((std::string)(versionInfo[verionIndex].version) > p->m_devVersionNum.toStdString()) // 比较版本号
|
||||
{
|
||||
p->m_vFwUpgradeAndDevLock[index].m_upgradeFilePath = savePath;
|
||||
p->m_vFwUpgradeAndDevLock[index].m_handleFlag |= FwUpgradeAndDevLock::FwUpgrade;
|
||||
HGChar suffix[64];
|
||||
HGBase_GetFileSuffix(versionInfo[verionIndex].url, suffix, 64);
|
||||
|
||||
HGChar savePath[512];
|
||||
HGBase_GetConfigPath(savePath, 512);
|
||||
HGBase_CreateDir(savePath);
|
||||
HGChar fileName[128];
|
||||
sprintf(fileName, "%s.%s", versionInfo[verionIndex].version, suffix);
|
||||
strcat(savePath, fileName);
|
||||
|
||||
QFile saveFile(savePath);
|
||||
saveFile.open(QFile::ReadOnly);
|
||||
QByteArray fileMsg = saveFile.readAll();
|
||||
saveFile.close();
|
||||
QString md5_2 = QCryptographicHash::hash(fileMsg, QCryptographicHash::Md5).toHex();
|
||||
|
||||
QFile f(savePath);
|
||||
if (!f.exists() || versionInfo[verionIndex].md5 != md5_2)
|
||||
{
|
||||
HGResult ret = p->m_versionDll->HttpDownload(versionInfo[verionIndex].url, savePath, NULL, NULL);
|
||||
if (HGBASE_ERR_OK == ret)
|
||||
{
|
||||
QFile saveFile(savePath);
|
||||
saveFile.open(QFile::ReadOnly);
|
||||
QByteArray fileMsg = saveFile.readAll();
|
||||
saveFile.close();
|
||||
QString md5_2 = QCryptographicHash::hash(fileMsg, QCryptographicHash::Md5).toHex();
|
||||
|
||||
if (versionInfo[verionIndex].md5 == md5_2)
|
||||
{
|
||||
p->m_vFwUpgradeAndDevLock[index].m_upgradeFilePath = savePath;
|
||||
p->m_vFwUpgradeAndDevLock[index].m_handleFlag |= FwUpgradeAndDevLock::FwUpgrade;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
p->m_vFwUpgradeAndDevLock[index].m_upgradeFilePath = savePath;
|
||||
p->m_vFwUpgradeAndDevLock[index].m_handleFlag |= FwUpgradeAndDevLock::FwUpgrade;
|
||||
}
|
||||
}
|
||||
}
|
||||
p->m_versionDll->ReleaseVersionList(versionInfo, versionCount);
|
||||
}
|
||||
p->m_versionDll->ReleaseVersionList(versionInfo, versionCount);
|
||||
|
||||
p->m_vFwUpgradeAndDevLock[index].m_checkFlag &= ~FwUpgradeAndDevLock::FwUpgrade;
|
||||
}
|
||||
|
@ -3741,8 +3743,10 @@ bool MainWindow::isLimitAccessFolder(QString filePath)
|
|||
return true;
|
||||
}
|
||||
|
||||
QString MainWindow::GetDevType(const QString& fwVersion)
|
||||
QString MainWindow::GetDevType(const QString& fwVersion, bool &canLock)
|
||||
{
|
||||
canLock = false;
|
||||
|
||||
QString devType;
|
||||
if (fwVersion.length() == 10)
|
||||
{
|
||||
|
@ -3761,16 +3765,38 @@ QString MainWindow::GetDevType(const QString& fwVersion)
|
|||
QString date = fwVersion.mid(5, 5);
|
||||
if ((dev == "G1" || dev == "G2") && ver == "393")
|
||||
{
|
||||
if (date >= "A1220" && date <= "A1228")
|
||||
devType = dev + ver + "/" + "A1220-A1228";
|
||||
else if (date >= "B0326" && date <= "B0331")
|
||||
devType = dev + ver + "/" + "B0326-B0331";
|
||||
if (date >= "A1220" && date <= "A1230")
|
||||
{
|
||||
devType = dev + ver + "/" + "A1220-A1230";
|
||||
if (date >= "A1224")
|
||||
{
|
||||
canLock = true;
|
||||
}
|
||||
}
|
||||
else if (date >= "B0326" && date <= "B0334")
|
||||
{
|
||||
devType = dev + ver + "/" + "B0326-B0334";
|
||||
if (date >= "B0333")
|
||||
{
|
||||
canLock = true;
|
||||
}
|
||||
}
|
||||
else if (date >= "B0429")
|
||||
{
|
||||
devType = dev + ver + "/" + "B0429-";
|
||||
if (date >= "B1031")
|
||||
{
|
||||
canLock = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (dev == "G4" && ver == "393")
|
||||
{
|
||||
devType = dev + ver + "/";
|
||||
if (date >= "B1108")
|
||||
{
|
||||
canLock = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -262,7 +262,7 @@ private:
|
|||
bool judgeDiskSpace(QString currentPath, bool showDlg = true);
|
||||
void upgradeApp(QString pkgPath);
|
||||
bool isLimitAccessFolder(QString filePath);
|
||||
static QString GetDevType(const QString& fwVersion);
|
||||
static QString GetDevType(const QString& fwVersion, bool &canLock);
|
||||
void upgradeFwAndLockDevice();
|
||||
void deleteOverdueLogFile(const QString& logFilePath);
|
||||
void deleteUpgradePkg(const QString& cfgFilePath);
|
||||
|
|
Loading…
Reference in New Issue