Loading cmds/dumpstate/dumpstate.cpp +39 −4 Original line number Original line Diff line number Diff line Loading @@ -209,6 +209,10 @@ static int Open(std::string path, int flags, mode_t mode = 0) { return fd; return fd; } } static int OpenForWrite(std::string path) { return Open(path, O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC | O_NOFOLLOW, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); } static int OpenForRead(std::string path) { static int OpenForRead(std::string path) { return Open(path, O_RDONLY | O_CLOEXEC | O_NOFOLLOW); return Open(path, O_RDONLY | O_CLOEXEC | O_NOFOLLOW); Loading Loading @@ -274,6 +278,27 @@ int64_t GetModuleMetadataVersion() { return version_code; return version_code; } } static bool PathExists(const std::string& path) { struct stat sb; return stat(path.c_str(), &sb) == 0; } static bool CopyFileToFile(const std::string& input_file, const std::string& output_file) { if (input_file == output_file) { MYLOGD("Skipping copying bugreport file since the destination is the same (%s)\n", output_file.c_str()); return false; } else if (PathExists(output_file)) { MYLOGD("Cannot overwrite an existing file (%s)\n", output_file.c_str()); return false; } MYLOGD("Going to copy bugreport file (%s) to %s\n", input_file.c_str(), output_file.c_str()); android::base::unique_fd out_fd(OpenForWrite(output_file)); return CopyFileToFd(input_file, out_fd.get()); } } // namespace } // namespace } // namespace os } // namespace os } // namespace android } // namespace android Loading Loading @@ -2092,11 +2117,12 @@ void Dumpstate::DumpstateBoard() { static void ShowUsage() { static void ShowUsage() { fprintf(stderr, fprintf(stderr, "usage: dumpstate [-h] [-b soundfile] [-e soundfile] [-d] [-p] " "usage: dumpstate [-h] [-b soundfile] [-e soundfile] [-o directory] [-d] [-p] " "[-z] [-s] [-S] [-q] [-P] [-R] [-L] [-V version]\n" "[-z] [-s] [-S] [-q] [-P] [-R] [-L] [-V version]\n" " -h: display this help message\n" " -h: display this help message\n" " -b: play sound file instead of vibrate, at beginning of job\n" " -b: play sound file instead of vibrate, at beginning of job\n" " -e: play sound file instead of vibrate, at end of job\n" " -e: play sound file instead of vibrate, at end of job\n" " -o: write to custom directory (only in limited mode)\n" " -d: append date to filename\n" " -d: append date to filename\n" " -p: capture screenshot to filename.png\n" " -p: capture screenshot to filename.png\n" " -z: generate zipped file\n" " -z: generate zipped file\n" Loading Loading @@ -2267,6 +2293,14 @@ static void FinalizeFile() { do_text_file = false; do_text_file = false; } } } } std::string final_path = ds.path_; if (ds.options_->OutputToCustomFile()) { std::string bugreport_dir = dirname(ds.options_->use_outfile.c_str()); final_path = ds.GetPath(bugreport_dir, ".zip"); android::os::CopyFileToFile(ds.path_, final_path); } if (ds.options_->use_control_socket) { if (ds.options_->use_control_socket) { if (do_text_file) { if (do_text_file) { dprintf(ds.control_socket_fd_, dprintf(ds.control_socket_fd_, Loading @@ -2274,7 +2308,7 @@ static void FinalizeFile() { "for more details\n", "for more details\n", ds.log_path_.c_str()); ds.log_path_.c_str()); } else { } else { dprintf(ds.control_socket_fd_, "OK:%s\n", ds.path_.c_str()); dprintf(ds.control_socket_fd_, "OK:%s\n", final_path.c_str()); } } } } } } Loading Loading @@ -2384,6 +2418,7 @@ Dumpstate::RunStatus Dumpstate::DumpOptions::Initialize(int argc, char* argv[]) // clang-format off // clang-format off case 'd': do_add_date = true; break; case 'd': do_add_date = true; break; case 'z': do_zip_file = true; break; case 'z': do_zip_file = true; break; case 'o': use_outfile = optarg; break; case 's': use_socket = true; break; case 's': use_socket = true; break; case 'S': use_control_socket = true; break; case 'S': use_control_socket = true; break; case 'v': show_header_only = true; break; case 'v': show_header_only = true; break; Loading Loading @@ -2505,8 +2540,8 @@ void Dumpstate::Cancel() { * If zipping, a bunch of other files and dumps also get added to the zip archive. The log file also * If zipping, a bunch of other files and dumps also get added to the zip archive. The log file also * gets added to the archive. * gets added to the archive. * * * Bugreports are first generated in a local directory and later copied to the caller's fd if * Bugreports are first generated in a local directory and later copied to the caller's fd * supplied. * or directory if supplied. */ */ Dumpstate::RunStatus Dumpstate::RunInternal(int32_t calling_uid, Dumpstate::RunStatus Dumpstate::RunInternal(int32_t calling_uid, const std::string& calling_package) { const std::string& calling_package) { Loading cmds/dumpstate/dumpstate.h +9 −1 Original line number Original line Diff line number Diff line Loading @@ -386,10 +386,12 @@ class Dumpstate { // The HAL is actually an API surface that can be validated, while the AIDL is not (@hide). // The HAL is actually an API surface that can be validated, while the AIDL is not (@hide). ::android::hardware::dumpstate::V1_1::DumpstateMode dumpstate_hal_mode = ::android::hardware::dumpstate::V1_1::DumpstateMode dumpstate_hal_mode = ::android::hardware::dumpstate::V1_1::DumpstateMode::DEFAULT; ::android::hardware::dumpstate::V1_1::DumpstateMode::DEFAULT; // File descriptor to output zip file. // File descriptor to output zip file. Takes precedence over use_outfile.. android::base::unique_fd bugreport_fd; android::base::unique_fd bugreport_fd; // File descriptor to screenshot file. // File descriptor to screenshot file. android::base::unique_fd screenshot_fd; android::base::unique_fd screenshot_fd; // Partial path to output file. std::string use_outfile; // Bugreport mode of the bugreport. // Bugreport mode of the bugreport. std::string bugreport_mode; std::string bugreport_mode; // Command-line arguments as string // Command-line arguments as string Loading @@ -415,6 +417,12 @@ class Dumpstate { // specified, it is preferred. If not bugreport is written to /bugreports. // specified, it is preferred. If not bugreport is written to /bugreports. return !use_socket; return !use_socket; } } /* Returns if options specified require writing to custom file location */ bool OutputToCustomFile() { // Custom location is only honored in limited mode. return limited_only && !use_outfile.empty() && bugreport_fd.get() == -1; } }; }; // TODO: initialize fields on constructor // TODO: initialize fields on constructor Loading cmds/dumpstate/tests/dumpstate_test.cpp +4 −1 Original line number Original line Diff line number Diff line Loading @@ -172,6 +172,7 @@ TEST_F(DumpOptionsTest, InitializeNone) { EXPECT_FALSE(options_.do_add_date); EXPECT_FALSE(options_.do_add_date); EXPECT_FALSE(options_.do_zip_file); EXPECT_FALSE(options_.do_zip_file); EXPECT_EQ("", options_.use_outfile); EXPECT_FALSE(options_.use_socket); EXPECT_FALSE(options_.use_socket); EXPECT_FALSE(options_.use_control_socket); EXPECT_FALSE(options_.use_control_socket); EXPECT_FALSE(options_.show_header_only); EXPECT_FALSE(options_.show_header_only); Loading Loading @@ -352,7 +353,8 @@ TEST_F(DumpOptionsTest, InitializeLimitedOnlyBugreport) { const_cast<char*>("-d"), const_cast<char*>("-d"), const_cast<char*>("-z"), const_cast<char*>("-z"), const_cast<char*>("-q"), const_cast<char*>("-q"), const_cast<char*>("-L") const_cast<char*>("-L"), const_cast<char*>("-o abc") }; }; // clang-format on // clang-format on Loading @@ -364,6 +366,7 @@ TEST_F(DumpOptionsTest, InitializeLimitedOnlyBugreport) { EXPECT_TRUE(options_.use_control_socket); EXPECT_TRUE(options_.use_control_socket); EXPECT_FALSE(options_.do_vibrate); EXPECT_FALSE(options_.do_vibrate); EXPECT_TRUE(options_.limited_only); EXPECT_TRUE(options_.limited_only); EXPECT_EQ(" abc", std::string(options_.use_outfile)); // Other options retain default values // Other options retain default values EXPECT_FALSE(options_.show_header_only); EXPECT_FALSE(options_.show_header_only); Loading opengl/libs/EGL/egl_platform_entries.cpp +1 −1 Original line number Original line Diff line number Diff line Loading @@ -96,7 +96,7 @@ char const * const gBuiltinExtensionString = "EGL_EXT_surface_CTA861_3_metadata " "EGL_EXT_surface_CTA861_3_metadata " ; ; // Whitelist of extensions exposed to applications if implemented in the vendor driver. // Allowed list of extensions exposed to applications if implemented in the vendor driver. char const * const gExtensionString = char const * const gExtensionString = "EGL_KHR_image " // mandatory "EGL_KHR_image " // mandatory "EGL_KHR_image_base " // mandatory "EGL_KHR_image_base " // mandatory Loading services/surfaceflinger/DisplayHardware/ComposerHal.cpp +1 −0 Original line number Original line Diff line number Diff line Loading @@ -1676,6 +1676,7 @@ void CommandReader::takeClientTargetProperty( if (found == mReturnData.end()) { if (found == mReturnData.end()) { outClientTargetProperty->pixelFormat = PixelFormat::RGBA_8888; outClientTargetProperty->pixelFormat = PixelFormat::RGBA_8888; outClientTargetProperty->dataspace = Dataspace::UNKNOWN; outClientTargetProperty->dataspace = Dataspace::UNKNOWN; return; } } ReturnData& data = found->second; ReturnData& data = found->second; Loading Loading
cmds/dumpstate/dumpstate.cpp +39 −4 Original line number Original line Diff line number Diff line Loading @@ -209,6 +209,10 @@ static int Open(std::string path, int flags, mode_t mode = 0) { return fd; return fd; } } static int OpenForWrite(std::string path) { return Open(path, O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC | O_NOFOLLOW, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); } static int OpenForRead(std::string path) { static int OpenForRead(std::string path) { return Open(path, O_RDONLY | O_CLOEXEC | O_NOFOLLOW); return Open(path, O_RDONLY | O_CLOEXEC | O_NOFOLLOW); Loading Loading @@ -274,6 +278,27 @@ int64_t GetModuleMetadataVersion() { return version_code; return version_code; } } static bool PathExists(const std::string& path) { struct stat sb; return stat(path.c_str(), &sb) == 0; } static bool CopyFileToFile(const std::string& input_file, const std::string& output_file) { if (input_file == output_file) { MYLOGD("Skipping copying bugreport file since the destination is the same (%s)\n", output_file.c_str()); return false; } else if (PathExists(output_file)) { MYLOGD("Cannot overwrite an existing file (%s)\n", output_file.c_str()); return false; } MYLOGD("Going to copy bugreport file (%s) to %s\n", input_file.c_str(), output_file.c_str()); android::base::unique_fd out_fd(OpenForWrite(output_file)); return CopyFileToFd(input_file, out_fd.get()); } } // namespace } // namespace } // namespace os } // namespace os } // namespace android } // namespace android Loading Loading @@ -2092,11 +2117,12 @@ void Dumpstate::DumpstateBoard() { static void ShowUsage() { static void ShowUsage() { fprintf(stderr, fprintf(stderr, "usage: dumpstate [-h] [-b soundfile] [-e soundfile] [-d] [-p] " "usage: dumpstate [-h] [-b soundfile] [-e soundfile] [-o directory] [-d] [-p] " "[-z] [-s] [-S] [-q] [-P] [-R] [-L] [-V version]\n" "[-z] [-s] [-S] [-q] [-P] [-R] [-L] [-V version]\n" " -h: display this help message\n" " -h: display this help message\n" " -b: play sound file instead of vibrate, at beginning of job\n" " -b: play sound file instead of vibrate, at beginning of job\n" " -e: play sound file instead of vibrate, at end of job\n" " -e: play sound file instead of vibrate, at end of job\n" " -o: write to custom directory (only in limited mode)\n" " -d: append date to filename\n" " -d: append date to filename\n" " -p: capture screenshot to filename.png\n" " -p: capture screenshot to filename.png\n" " -z: generate zipped file\n" " -z: generate zipped file\n" Loading Loading @@ -2267,6 +2293,14 @@ static void FinalizeFile() { do_text_file = false; do_text_file = false; } } } } std::string final_path = ds.path_; if (ds.options_->OutputToCustomFile()) { std::string bugreport_dir = dirname(ds.options_->use_outfile.c_str()); final_path = ds.GetPath(bugreport_dir, ".zip"); android::os::CopyFileToFile(ds.path_, final_path); } if (ds.options_->use_control_socket) { if (ds.options_->use_control_socket) { if (do_text_file) { if (do_text_file) { dprintf(ds.control_socket_fd_, dprintf(ds.control_socket_fd_, Loading @@ -2274,7 +2308,7 @@ static void FinalizeFile() { "for more details\n", "for more details\n", ds.log_path_.c_str()); ds.log_path_.c_str()); } else { } else { dprintf(ds.control_socket_fd_, "OK:%s\n", ds.path_.c_str()); dprintf(ds.control_socket_fd_, "OK:%s\n", final_path.c_str()); } } } } } } Loading Loading @@ -2384,6 +2418,7 @@ Dumpstate::RunStatus Dumpstate::DumpOptions::Initialize(int argc, char* argv[]) // clang-format off // clang-format off case 'd': do_add_date = true; break; case 'd': do_add_date = true; break; case 'z': do_zip_file = true; break; case 'z': do_zip_file = true; break; case 'o': use_outfile = optarg; break; case 's': use_socket = true; break; case 's': use_socket = true; break; case 'S': use_control_socket = true; break; case 'S': use_control_socket = true; break; case 'v': show_header_only = true; break; case 'v': show_header_only = true; break; Loading Loading @@ -2505,8 +2540,8 @@ void Dumpstate::Cancel() { * If zipping, a bunch of other files and dumps also get added to the zip archive. The log file also * If zipping, a bunch of other files and dumps also get added to the zip archive. The log file also * gets added to the archive. * gets added to the archive. * * * Bugreports are first generated in a local directory and later copied to the caller's fd if * Bugreports are first generated in a local directory and later copied to the caller's fd * supplied. * or directory if supplied. */ */ Dumpstate::RunStatus Dumpstate::RunInternal(int32_t calling_uid, Dumpstate::RunStatus Dumpstate::RunInternal(int32_t calling_uid, const std::string& calling_package) { const std::string& calling_package) { Loading
cmds/dumpstate/dumpstate.h +9 −1 Original line number Original line Diff line number Diff line Loading @@ -386,10 +386,12 @@ class Dumpstate { // The HAL is actually an API surface that can be validated, while the AIDL is not (@hide). // The HAL is actually an API surface that can be validated, while the AIDL is not (@hide). ::android::hardware::dumpstate::V1_1::DumpstateMode dumpstate_hal_mode = ::android::hardware::dumpstate::V1_1::DumpstateMode dumpstate_hal_mode = ::android::hardware::dumpstate::V1_1::DumpstateMode::DEFAULT; ::android::hardware::dumpstate::V1_1::DumpstateMode::DEFAULT; // File descriptor to output zip file. // File descriptor to output zip file. Takes precedence over use_outfile.. android::base::unique_fd bugreport_fd; android::base::unique_fd bugreport_fd; // File descriptor to screenshot file. // File descriptor to screenshot file. android::base::unique_fd screenshot_fd; android::base::unique_fd screenshot_fd; // Partial path to output file. std::string use_outfile; // Bugreport mode of the bugreport. // Bugreport mode of the bugreport. std::string bugreport_mode; std::string bugreport_mode; // Command-line arguments as string // Command-line arguments as string Loading @@ -415,6 +417,12 @@ class Dumpstate { // specified, it is preferred. If not bugreport is written to /bugreports. // specified, it is preferred. If not bugreport is written to /bugreports. return !use_socket; return !use_socket; } } /* Returns if options specified require writing to custom file location */ bool OutputToCustomFile() { // Custom location is only honored in limited mode. return limited_only && !use_outfile.empty() && bugreport_fd.get() == -1; } }; }; // TODO: initialize fields on constructor // TODO: initialize fields on constructor Loading
cmds/dumpstate/tests/dumpstate_test.cpp +4 −1 Original line number Original line Diff line number Diff line Loading @@ -172,6 +172,7 @@ TEST_F(DumpOptionsTest, InitializeNone) { EXPECT_FALSE(options_.do_add_date); EXPECT_FALSE(options_.do_add_date); EXPECT_FALSE(options_.do_zip_file); EXPECT_FALSE(options_.do_zip_file); EXPECT_EQ("", options_.use_outfile); EXPECT_FALSE(options_.use_socket); EXPECT_FALSE(options_.use_socket); EXPECT_FALSE(options_.use_control_socket); EXPECT_FALSE(options_.use_control_socket); EXPECT_FALSE(options_.show_header_only); EXPECT_FALSE(options_.show_header_only); Loading Loading @@ -352,7 +353,8 @@ TEST_F(DumpOptionsTest, InitializeLimitedOnlyBugreport) { const_cast<char*>("-d"), const_cast<char*>("-d"), const_cast<char*>("-z"), const_cast<char*>("-z"), const_cast<char*>("-q"), const_cast<char*>("-q"), const_cast<char*>("-L") const_cast<char*>("-L"), const_cast<char*>("-o abc") }; }; // clang-format on // clang-format on Loading @@ -364,6 +366,7 @@ TEST_F(DumpOptionsTest, InitializeLimitedOnlyBugreport) { EXPECT_TRUE(options_.use_control_socket); EXPECT_TRUE(options_.use_control_socket); EXPECT_FALSE(options_.do_vibrate); EXPECT_FALSE(options_.do_vibrate); EXPECT_TRUE(options_.limited_only); EXPECT_TRUE(options_.limited_only); EXPECT_EQ(" abc", std::string(options_.use_outfile)); // Other options retain default values // Other options retain default values EXPECT_FALSE(options_.show_header_only); EXPECT_FALSE(options_.show_header_only); Loading
opengl/libs/EGL/egl_platform_entries.cpp +1 −1 Original line number Original line Diff line number Diff line Loading @@ -96,7 +96,7 @@ char const * const gBuiltinExtensionString = "EGL_EXT_surface_CTA861_3_metadata " "EGL_EXT_surface_CTA861_3_metadata " ; ; // Whitelist of extensions exposed to applications if implemented in the vendor driver. // Allowed list of extensions exposed to applications if implemented in the vendor driver. char const * const gExtensionString = char const * const gExtensionString = "EGL_KHR_image " // mandatory "EGL_KHR_image " // mandatory "EGL_KHR_image_base " // mandatory "EGL_KHR_image_base " // mandatory Loading
services/surfaceflinger/DisplayHardware/ComposerHal.cpp +1 −0 Original line number Original line Diff line number Diff line Loading @@ -1676,6 +1676,7 @@ void CommandReader::takeClientTargetProperty( if (found == mReturnData.end()) { if (found == mReturnData.end()) { outClientTargetProperty->pixelFormat = PixelFormat::RGBA_8888; outClientTargetProperty->pixelFormat = PixelFormat::RGBA_8888; outClientTargetProperty->dataspace = Dataspace::UNKNOWN; outClientTargetProperty->dataspace = Dataspace::UNKNOWN; return; } } ReturnData& data = found->second; ReturnData& data = found->second; Loading