Skip to content

Commit

Permalink
Changes PackageListOptions to an enum instead of struct
Browse files Browse the repository at this point in the history
  • Loading branch information
GrantComm committed Sep 19, 2024
1 parent 55715c1 commit b61c75b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 25 deletions.
9 changes: 4 additions & 5 deletions capture_service/device_mgr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ absl::StatusOr<std::vector<std::string>> AndroidDevice::ListPackage(PackageListO
{
std::vector<std::string> 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";
}
Expand All @@ -104,13 +104,13 @@ absl::StatusOr<std::vector<std::string>> 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())
Expand All @@ -125,7 +125,7 @@ absl::StatusOr<std::vector<std::string>> AndroidDevice::ListPackage(PackageListO
}
}

if (option.non_debuggable_only)
if (option == PackageListOptions::kNonDebuggableOnly)
{
result = Adb().RunAndGetResult("shell dumpsys package " + package);
if (!result.ok())
Expand All @@ -136,7 +136,6 @@ absl::StatusOr<std::vector<std::string>> AndroidDevice::ListPackage(PackageListO
if (!absl::StrContains(output, "DEBUGGABLE"))
{
package_list.push_back(package);
;
}
}
}
Expand Down
27 changes: 13 additions & 14 deletions capture_service/device_mgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::vector<std::string>> 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<std::vector<std::string>> 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();
Expand Down
14 changes: 8 additions & 6 deletions ui/trace_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -650,13 +650,15 @@ void TraceDialog::OnPackageListFilterApplied(QSet<QString> 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();
Expand Down

0 comments on commit b61c75b

Please sign in to comment.