forked from qt-creator/qt-creator
Android: Make avdConfigEditManufacturerTag() more readable
Rename it to modifyManufacturerTag() and use newly introduced enum to describe the type of modification. Change-Id: I8e903891e87d7133ec37e9aecfd303b424a36d15 Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
committed by
Jarek Kobus
parent
7af6722c07
commit
46fb01f785
@@ -44,7 +44,9 @@ bool AndroidAvdManager::avdManagerCommand(const QStringList &args, QString *outp
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void avdConfigEditManufacturerTag(const FilePath &avdPath, bool recoverMode = false)
|
enum TagModification { CommentOut, Uncomment };
|
||||||
|
|
||||||
|
static void modifyManufacturerTag(const FilePath &avdPath, TagModification modification)
|
||||||
{
|
{
|
||||||
if (!avdPath.exists())
|
if (!avdPath.exists())
|
||||||
return;
|
return;
|
||||||
@@ -59,7 +61,7 @@ static void avdConfigEditManufacturerTag(const FilePath &avdPath, bool recoverMo
|
|||||||
while (!textStream.atEnd()) {
|
while (!textStream.atEnd()) {
|
||||||
QString line = textStream.readLine();
|
QString line = textStream.readLine();
|
||||||
if (line.contains("hw.device.manufacturer")) {
|
if (line.contains("hw.device.manufacturer")) {
|
||||||
if (recoverMode)
|
if (modification == Uncomment)
|
||||||
line.replace("#", "");
|
line.replace("#", "");
|
||||||
else
|
else
|
||||||
line.prepend("#");
|
line.prepend("#");
|
||||||
@@ -92,12 +94,12 @@ static AndroidDeviceInfoList listVirtualDevices()
|
|||||||
const auto parsedAvdList = parseAvdList(output);
|
const auto parsedAvdList = parseAvdList(output);
|
||||||
if (parsedAvdList.errorPaths.isEmpty()) {
|
if (parsedAvdList.errorPaths.isEmpty()) {
|
||||||
for (const FilePath &avdPath : std::as_const(allAvdErrorPaths))
|
for (const FilePath &avdPath : std::as_const(allAvdErrorPaths))
|
||||||
avdConfigEditManufacturerTag(avdPath, true); // re-add manufacturer tag
|
modifyManufacturerTag(avdPath, Uncomment);
|
||||||
return parsedAvdList.avdList;
|
return parsedAvdList.avdList;
|
||||||
}
|
}
|
||||||
allAvdErrorPaths << parsedAvdList.errorPaths;
|
allAvdErrorPaths << parsedAvdList.errorPaths;
|
||||||
for (const FilePath &avdPath : parsedAvdList.errorPaths)
|
for (const FilePath &avdPath : parsedAvdList.errorPaths)
|
||||||
avdConfigEditManufacturerTag(avdPath); // comment out manufacturer tag
|
modifyManufacturerTag(avdPath, CommentOut);
|
||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user