diff --git a/capture_service/device_mgr.cc b/capture_service/device_mgr.cc index 2c88976a9..71ab94407 100644 --- a/capture_service/device_mgr.cc +++ b/capture_service/device_mgr.cc @@ -85,7 +85,7 @@ absl::StatusOr> AndroidDevice::ListPackage(PackageListO { std::vector package_list; std::string cmd = "shell pm list packages"; - if (!option.all && !option.non_debuggable_only) + if (option != PackageListOptions::kAll && option != PackageListOptions::kNonDebuggableOnly) { cmd += " -3"; } @@ -104,13 +104,13 @@ absl::StatusOr> AndroidDevice::ListPackage(PackageListO { std::string package(absl::StripAsciiWhitespace(fields[1])); - if (option.all) + if (option == PackageListOptions::kAll) { package_list.push_back(package); continue; } - if (option.debuggable_only) + if (option == PackageListOptions::kDebuggableOnly) { result = Adb().RunAndGetResult("shell dumpsys package " + package); if (!result.ok()) @@ -125,7 +125,7 @@ absl::StatusOr> AndroidDevice::ListPackage(PackageListO } } - if (option.non_debuggable_only) + if (option == PackageListOptions::kNonDebuggableOnly) { result = Adb().RunAndGetResult("shell dumpsys package " + package); if (!result.ok()) @@ -136,7 +136,6 @@ absl::StatusOr> AndroidDevice::ListPackage(PackageListO if (!absl::StrContains(output, "DEBUGGABLE")) { package_list.push_back(package); - ; } } } diff --git a/capture_service/device_mgr.h b/capture_service/device_mgr.h index d842511e0..93d696182 100644 --- a/capture_service/device_mgr.h +++ b/capture_service/device_mgr.h @@ -68,23 +68,22 @@ class AndroidDevice absl::Status SetupDevice(); absl::Status CleanupDevice(); - struct PackageListOptions + enum class PackageListOptions { - bool all; - bool debuggable_only; - bool non_debuggable_only; + kAll, + kDebuggableOnly, + kNonDebuggableOnly, }; - absl::StatusOr> ListPackage(PackageListOptions option = { 1, - 0, - 0 }) const; - std::string GetDeviceDisplayName() const; - absl::Status SetupApp(const std::string &package, - const ApplicationType type, - const std::string &command_args); - absl::Status SetupApp(const std::string &binary, - const std::string &args, - const ApplicationType type); + absl::StatusOr> ListPackage( + PackageListOptions option = PackageListOptions::kAll) const; + std::string GetDeviceDisplayName() const; + absl::Status SetupApp(const std::string &package, + const ApplicationType type, + const std::string &command_args); + absl::Status SetupApp(const std::string &binary, + const std::string &args, + const ApplicationType type); absl::Status CleanupAPP(); absl::Status StartApp(); diff --git a/ui/trace_window.cpp b/ui/trace_window.cpp index 46791f6fe..6d4e42ad7 100644 --- a/ui/trace_window.cpp +++ b/ui/trace_window.cpp @@ -83,7 +83,7 @@ TraceDialog::TraceDialog(QWidget *parent) m_pkg_filter_button->setDisabled(true); m_pkg_filter_button->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); m_pkg_filter->hide(); - m_pkg_list_options = { 1, 0, 0 }; + m_pkg_list_options = Dive::AndroidDevice::PackageListOptions::kAll; m_main_layout = new QVBoxLayout(); @@ -650,13 +650,15 @@ void TraceDialog::OnPackageListFilterApplied(QSet filters) { if (filters.contains("All")) { - m_pkg_list_options = { 1, 0, 0 }; + m_pkg_list_options = Dive::AndroidDevice::PackageListOptions::kAll; } - else + else if (filters.contains("Debuggable")) + { + m_pkg_list_options = Dive::AndroidDevice::PackageListOptions::kDebuggableOnly; + } + else if (filters.contains("Non-Debuggable")) { - m_pkg_list_options = { 0, - filters.contains("Debuggable"), - filters.contains("Non-Debuggable") }; + m_pkg_list_options = Dive::AndroidDevice::PackageListOptions::kNonDebuggableOnly; } UpdatePackageList(); m_pkg_filter_label->hide();