Remove screenshot_fd as optional param
Binder does not allow invalid fd to be passed in function calls, so
remove "optional" in IDumpstate.aidl
Also, remove TODO to make screenshot fd optional, as the binder call
requires valid screenshot fd.
Also, we do not need valid screenshot fd for lite bugreports
(wifi/telephony/interactive etc). Although the Binder makes sure that
valid fds are passed, this is just an additional check on top of that.
Bug: 128981582
Test: * adb shell mkdir /data/nativetest64
* mmm -j frameworks/native/cmds/dumpstate/ &&
adb push ${OUT}/data/nativetest64/dumpstate_test* /data/nativetest64 &&
adb shell /data/nativetest64/dumpstate_test/dumpstate_test &&
printf "\n\n#### ALL TESTS PASSED ####\n"
Change-Id: Idf6093832fea0f11f12ff2bc0fd1dcec6fd502df
diff --git a/cmds/dumpstate/DumpstateService.cpp b/cmds/dumpstate/DumpstateService.cpp
index ddae9ea..37ba4f9 100644
--- a/cmds/dumpstate/DumpstateService.cpp
+++ b/cmds/dumpstate/DumpstateService.cpp
@@ -151,15 +151,15 @@
signalErrorAndExit(listener, IDumpstateListener::BUGREPORT_ERROR_INVALID_INPUT);
}
- if (bugreport_fd.get() == -1 || screenshot_fd.get() == -1) {
- // TODO(b/111441001): screenshot fd should be optional
+ std::unique_ptr<Dumpstate::DumpOptions> options = std::make_unique<Dumpstate::DumpOptions>();
+ options->Initialize(static_cast<Dumpstate::BugreportMode>(bugreport_mode), bugreport_fd,
+ screenshot_fd);
+
+ if (bugreport_fd.get() == -1 || (options->do_fb && screenshot_fd.get() == -1)) {
MYLOGE("Invalid filedescriptor");
signalErrorAndExit(listener, IDumpstateListener::BUGREPORT_ERROR_INVALID_INPUT);
}
- std::unique_ptr<Dumpstate::DumpOptions> options = std::make_unique<Dumpstate::DumpOptions>();
- options->Initialize(static_cast<Dumpstate::BugreportMode>(bugreport_mode), bugreport_fd,
- screenshot_fd);
ds_ = &(Dumpstate::GetInstance());
ds_->SetOptions(std::move(options));