@@ -208,6 +208,9 @@ static const std::string ANR_TRACE_FILE_PREFIX = "trace_";
208208static const std::string SHUTDOWN_CHECKPOINTS_DIR = " /data/system/shutdown-checkpoints/" ;
209209static const std::string SHUTDOWN_CHECKPOINTS_FILE_PREFIX = " checkpoints-" ;
210210
211+ // File path to default screenshot image, that used when failed to capture the real screenshot.
212+ static const std::string DEFAULT_SCREENSHOT_PATH = " /system/etc/default_screenshot.png" ;
213+
211214// TODO: temporary variables and functions used during C++ refactoring
212215
213216#define RETURN_IF_USER_DENIED_CONSENT () \
@@ -767,10 +770,14 @@ android::binder::Status Dumpstate::ConsentCallback::onReportApproved() {
767770
768771 bool copy_succeeded = android::os::CopyFileToFd (ds.screenshot_path_ ,
769772 ds.options_ ->screenshot_fd .get ());
770- ds.options_ ->is_screenshot_copied = copy_succeeded;
771773 if (copy_succeeded) {
772774 android::os::UnlinkAndLogOnError (ds.screenshot_path_ );
775+ } else {
776+ MYLOGE (" Failed to copy screenshot to a permanent file.\n " );
777+ copy_succeeded = android::os::CopyFileToFd (DEFAULT_SCREENSHOT_PATH,
778+ ds.options_ ->screenshot_fd .get ());
773779 }
780+ ds.options_ ->is_screenshot_copied = copy_succeeded;
774781 return android::binder::Status::ok ();
775782}
776783
@@ -1854,6 +1861,11 @@ Dumpstate::RunStatus Dumpstate::dumpstate() {
18541861 RunCommand (" DUMP VENDOR RIL LOGS" , {" vril-dump" }, options.Build ());
18551862 }
18561863
1864+ /* Dump USB information */
1865+ RunCommand (" typec_connector_class" , {" typec_connector_class" },
1866+ CommandOptions::WithTimeout (10 ).AsRootIfAvailable ().Build ());
1867+ RunCommand (" lsusb" , {" lsusb" }, CommandOptions::WithTimeout (10 ).AsRootIfAvailable ().Build ());
1868+
18571869 printf (" ========================================================\n " );
18581870 printf (" == Android Framework Services\n " );
18591871 printf (" ========================================================\n " );
@@ -3464,7 +3476,9 @@ Dumpstate::RunStatus Dumpstate::RunInternal(int32_t calling_uid,
34643476 // Do an early return if there were errors. We make an exception for consent
34653477 // timing out because it's possible the user got distracted. In this case the
34663478 // bugreport is not shared but made available for manual retrieval.
3467- MYLOGI (" User denied consent. Returning\n " );
3479+ MYLOGI (" Bug report generation failed, this could have been due to"
3480+ " several reasons such as BR copy failed, user consent was"
3481+ " not grated etc. Returning\n " );
34683482 return status;
34693483 }
34703484 if (status == Dumpstate::RunStatus::USER_CONSENT_TIMED_OUT) {
@@ -3560,7 +3574,7 @@ std::future<std::string> Dumpstate::MaybeSnapshotSystemTraceAsync() {
35603574 // the dumpstate's own activity which is irrelevant.
35613575 RunCommand (
35623576 SERIALIZE_PERFETTO_TRACE_TASK, {" perfetto" , " --save-for-bugreport" },
3563- CommandOptions::WithTimeout (10 ).DropRoot ().CloseAllFileDescriptorsOnExec ().Build (),
3577+ CommandOptions::WithTimeout (30 ).DropRoot ().CloseAllFileDescriptorsOnExec ().Build (),
35643578 false , outFd);
35653579 // MaybeAddSystemTraceToZip() will take care of copying the trace in the zip
35663580 // file in the later stages.
@@ -3751,12 +3765,16 @@ Dumpstate::RunStatus Dumpstate::CopyBugreportIfUserConsented(int32_t calling_uid
37513765 if (options_->do_screenshot &&
37523766 options_->screenshot_fd .get () != -1 &&
37533767 !options_->is_screenshot_copied ) {
3754- copy_succeeded = android::os::CopyFileToFd (screenshot_path_,
3768+ bool is_screenshot_copied = android::os::CopyFileToFd (screenshot_path_,
37553769 options_->screenshot_fd .get ());
3756- options_->is_screenshot_copied = copy_succeeded;
3757- if (copy_succeeded) {
3770+ if (is_screenshot_copied) {
37583771 android::os::UnlinkAndLogOnError (screenshot_path_);
3772+ } else {
3773+ MYLOGE (" Failed to copy screenshot to a permanent file.\n " );
3774+ is_screenshot_copied = android::os::CopyFileToFd (DEFAULT_SCREENSHOT_PATH,
3775+ options_->screenshot_fd .get ());
37593776 }
3777+ options_->is_screenshot_copied = is_screenshot_copied;
37603778 }
37613779 }
37623780 return copy_succeeded ? Dumpstate::RunStatus::OK : Dumpstate::RunStatus::ERROR;
@@ -3847,7 +3865,7 @@ DurationReporter::DurationReporter(const std::string& title, bool logcat_only, b
38473865DurationReporter::~DurationReporter () {
38483866 if (!title_.empty ()) {
38493867 float elapsed = (float )(Nanotime () - started_) / NANOS_PER_SEC;
3850- if (elapsed >= . 5f || verbose_) {
3868+ if (elapsed >= 1 . 0f || verbose_) {
38513869 MYLOGD (" Duration of '%s': %.2fs\n " , title_.c_str (), elapsed);
38523870 }
38533871 if (!logcat_only_) {
0 commit comments