From 46fb01f785fc2fc7111b7870400768047d89be09 Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Thu, 16 May 2024 11:23:10 +0200 Subject: [PATCH] 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 --- src/plugins/android/androidavdmanager.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/plugins/android/androidavdmanager.cpp b/src/plugins/android/androidavdmanager.cpp index fc9148d3fe5..664f2346200 100644 --- a/src/plugins/android/androidavdmanager.cpp +++ b/src/plugins/android/androidavdmanager.cpp @@ -44,7 +44,9 @@ bool AndroidAvdManager::avdManagerCommand(const QStringList &args, QString *outp 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()) return; @@ -59,7 +61,7 @@ static void avdConfigEditManufacturerTag(const FilePath &avdPath, bool recoverMo while (!textStream.atEnd()) { QString line = textStream.readLine(); if (line.contains("hw.device.manufacturer")) { - if (recoverMode) + if (modification == Uncomment) line.replace("#", ""); else line.prepend("#"); @@ -92,12 +94,12 @@ static AndroidDeviceInfoList listVirtualDevices() const auto parsedAvdList = parseAvdList(output); if (parsedAvdList.errorPaths.isEmpty()) { for (const FilePath &avdPath : std::as_const(allAvdErrorPaths)) - avdConfigEditManufacturerTag(avdPath, true); // re-add manufacturer tag + modifyManufacturerTag(avdPath, Uncomment); return parsedAvdList.avdList; } allAvdErrorPaths << parsedAvdList.errorPaths; for (const FilePath &avdPath : parsedAvdList.errorPaths) - avdConfigEditManufacturerTag(avdPath); // comment out manufacturer tag + modifyManufacturerTag(avdPath, CommentOut); } return {}; }