Skip to content

Commit 8bbe797

Browse files
committed
Minor cvd display fixes
1 parent 497b8b1 commit 8bbe797

File tree

3 files changed

+37
-1
lines changed

3 files changed

+37
-1
lines changed

base/cvd/cuttlefish/host/commands/display/main.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,24 @@
3636
namespace cuttlefish {
3737
namespace {
3838

39+
static const char kUsage[] =
40+
R"(
41+
42+
Interact with a Cuttlefish virtual device's displays.
43+
44+
usage: cvd display <subcommand> <args>
45+
46+
Commands:(cvd display help <subcommand> for more information):
47+
48+
add: Adds and connects displays.
49+
50+
list: Lists all of the displays currently connected.
51+
52+
remove: Disconnects and removes displays.
53+
54+
screenshot: Screenshots the contents of a given display.
55+
)";
56+
3957
static const char kAddUsage[] =
4058
R"(
4159
@@ -81,6 +99,11 @@ Result<int> GetInstanceNum(std::vector<std::string>& args) {
8199
}
82100

83101
Result<int> DoHelp(std::vector<std::string>& args) {
102+
if (args.empty()) {
103+
std::cerr << kUsage << std::endl;
104+
return 0;
105+
}
106+
84107
static const android::base::NoDestructor<
85108
std::unordered_map<std::string, std::string>>
86109
kSubCommandUsages({

base/cvd/cuttlefish/host/libs/vm_manager/crosvm_display_controller.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,9 @@ Result<int> CrosvmDisplayController::RunCrosvmDisplayCommand(
107107

108108
Result<std::string> res = RunAndCaptureStdout(std::move(command));
109109
if (res.ok()) {
110-
*stdout_str = CF_EXPECT(std::move(res));
110+
if (stdout_str != nullptr) {
111+
*stdout_str = std::move(*res);
112+
}
111113
return 0;
112114
} else {
113115
LOG(ERROR) << "Failed to run crosvm display command:\n"

e2etests/cvd/BUILD.bazel

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,17 @@ cvd_command_boot_test(
6565
target = "aosp_cf_x86_64_only_phone-userdebug",
6666
)
6767

68+
cvd_command_boot_test(
69+
name = "add_displays",
70+
branch = "aosp-android-latest-release",
71+
cvd_command = [
72+
"display",
73+
"add",
74+
"--display=width=500,height=500",
75+
],
76+
target = "aosp_cf_x86_64_only_phone-userdebug",
77+
)
78+
6879
cvd_command_boot_test(
6980
name = "list_displays",
7081
branch = "aosp-android-latest-release",

0 commit comments

Comments
 (0)