Loading cmds/dumpstate/dumpstate.cpp +90 −30 Original line number Diff line number Diff line Loading @@ -135,6 +135,11 @@ typedef Dumpstate::ConsentCallback::ConsentResult UserConsentResult; static char cmdline_buf[16384] = "(unknown)"; static const char *dump_traces_path = nullptr; static const uint64_t USER_CONSENT_TIMEOUT_MS = 30 * 1000; // Because telephony reports are significantly faster to collect (< 10 seconds vs. > 2 minutes), // it's often the case that they time out far too quickly for consent with such a hefty dialog for // the user to read. For telephony reports only, we increase the default timeout to 2 minutes to // roughly match full reports' durations. static const uint64_t TELEPHONY_REPORT_USER_CONSENT_TIMEOUT_MS = 2 * 60 * 1000; // TODO: variables and functions below should be part of dumpstate object Loading Loading @@ -879,6 +884,14 @@ static void DoSystemLogcat(time_t since) { CommandOptions::WithTimeoutInMs(timeout_ms).Build()); } static void DoRadioLogcat() { unsigned long timeout_ms = logcat_timeout({"radio"}); RunCommand( "RADIO LOG", {"logcat", "-b", "radio", "-v", "threadtime", "-v", "printable", "-v", "uid", "-d", "*:v"}, CommandOptions::WithTimeoutInMs(timeout_ms).Build(), true /* verbose_duration */); } static void DoLogcat() { unsigned long timeout_ms; // DumpFile("EVENT LOG TAGS", "/etc/event-log-tags"); Loading @@ -897,11 +910,7 @@ static void DoLogcat() { "STATS LOG", {"logcat", "-b", "stats", "-v", "threadtime", "-v", "printable", "-v", "uid", "-d", "*:v"}, CommandOptions::WithTimeoutInMs(timeout_ms).Build(), true /* verbose_duration */); timeout_ms = logcat_timeout({"radio"}); RunCommand( "RADIO LOG", {"logcat", "-b", "radio", "-v", "threadtime", "-v", "printable", "-v", "uid", "-d", "*:v"}, CommandOptions::WithTimeoutInMs(timeout_ms).Build(), true /* verbose_duration */); DoRadioLogcat(); RunCommand("LOG STATISTICS", {"logcat", "-b", "all", "-S"}); Loading Loading @@ -1611,8 +1620,10 @@ Dumpstate::RunStatus Dumpstate::DumpstateDefaultAfterCritical() { return status; } // This method collects common dumpsys for telephony and wifi static void DumpstateRadioCommon() { // This method collects common dumpsys for telephony and wifi. Typically, wifi // reports are fine to include all information, but telephony reports on user // builds need to strip some content (see DumpstateTelephonyOnly). static void DumpstateRadioCommon(bool include_sensitive_info = true) { DumpIpTablesAsRoot(); ds.AddDir(LOGPERSIST_DATA_DIR, false); Loading @@ -1621,27 +1632,51 @@ static void DumpstateRadioCommon() { return; } // We need to be picky about some stuff for telephony reports on user builds. if (!include_sensitive_info) { // Only dump the radio log buffer (other buffers and dumps contain too much unrelated info). DoRadioLogcat(); } else { // Contains various system properties and process startup info. do_dmesg(); // Logs other than the radio buffer may contain package/component names and potential PII. DoLogcat(); DumpPacketStats(); // Too broad for connectivity problems. DoKmsg(); DumpIpAddrAndRules(); dump_route_tables(); // Contains unrelated hardware info (camera, NFC, biometrics, ...). DumpHals(); } DumpPacketStats(); DumpIpAddrAndRules(); dump_route_tables(); RunDumpsys("NETWORK DIAGNOSTICS", {"connectivity", "--diag"}, CommandOptions::WithTimeout(10).Build()); } // This method collects dumpsys for telephony debugging only // We use "telephony" here for legacy reasons, though this now really means "connectivity" (cellular // + wifi + networking). This method collects dumpsys for connectivity debugging only. General rules // for what can be included on user builds: all reported information MUST directly relate to // connectivity debugging or customer support and MUST NOT contain unrelated personally identifiable // information. This information MUST NOT identify user-installed packages (UIDs are OK, package // names are not), and MUST NOT contain logs of user application traffic. // TODO(b/148168577) rename this and other related fields/methods to "connectivity" instead. static void DumpstateTelephonyOnly() { DurationReporter duration_reporter("DUMPSTATE"); const CommandOptions DUMPSYS_COMPONENTS_OPTIONS = CommandOptions::WithTimeout(60).Build(); DumpstateRadioCommon(); const bool include_sensitive_info = !PropertiesHelper::IsUserBuild(); DumpstateRadioCommon(include_sensitive_info); if (include_sensitive_info) { // Contains too much unrelated PII, and given the unstructured nature of sysprops, we can't // really cherrypick all of the connectivity-related ones. Apps generally have no business // reading these anyway, and there should be APIs to supply the info in a more app-friendly // way. RunCommand("SYSTEM PROPERTIES", {"getprop"}); } printf("========================================================\n"); printf("== Android Framework Services\n"); Loading @@ -1649,15 +1684,28 @@ static void DumpstateTelephonyOnly() { RunDumpsys("DUMPSYS", {"connectivity"}, CommandOptions::WithTimeout(90).Build(), SEC_TO_MSEC(10)); RunDumpsys("DUMPSYS", {"connmetrics"}, CommandOptions::WithTimeout(90).Build(), SEC_TO_MSEC(10)); RunDumpsys("DUMPSYS", {"netd"}, CommandOptions::WithTimeout(90).Build(), SEC_TO_MSEC(10)); // TODO(b/146521742) build out an argument to include bound services here for user builds RunDumpsys("DUMPSYS", {"carrier_config"}, CommandOptions::WithTimeout(90).Build(), SEC_TO_MSEC(10)); RunDumpsys("DUMPSYS", {"wifi"}, CommandOptions::WithTimeout(90).Build(), SEC_TO_MSEC(10)); RunDumpsys("DUMPSYS", {"netpolicy"}, CommandOptions::WithTimeout(90).Build(), SEC_TO_MSEC(10)); RunDumpsys("DUMPSYS", {"network_management"}, CommandOptions::WithTimeout(90).Build(), SEC_TO_MSEC(10)); if (include_sensitive_info) { // Contains raw IP addresses, omit from reports on user builds. RunDumpsys("DUMPSYS", {"netd"}, CommandOptions::WithTimeout(90).Build(), SEC_TO_MSEC(10)); // Contains raw destination IP/MAC addresses, omit from reports on user builds. RunDumpsys("DUMPSYS", {"connmetrics"}, CommandOptions::WithTimeout(90).Build(), SEC_TO_MSEC(10)); // Contains package/component names, omit from reports on user builds. RunDumpsys("BATTERYSTATS", {"batterystats"}, CommandOptions::WithTimeout(90).Build(), SEC_TO_MSEC(10)); // Contains package names, but should be relatively simple to remove them (also contains // UIDs already), omit from reports on user builds. RunDumpsys("BATTERYSTATS", {"deviceidle"}, CommandOptions::WithTimeout(90).Build(), SEC_TO_MSEC(10)); } printf("========================================================\n"); printf("== Running Application Services\n"); Loading @@ -1665,10 +1713,14 @@ static void DumpstateTelephonyOnly() { RunDumpsys("TELEPHONY SERVICES", {"activity", "service", "TelephonyDebugService"}); if (include_sensitive_info) { printf("========================================================\n"); printf("== Running Application Services (non-platform)\n"); printf("========================================================\n"); // Contains package/component names and potential PII, omit from reports on user builds. // To get dumps of the active CarrierService(s) on user builds, we supply an argument to the // carrier_config dumpsys instead. RunDumpsys("APP SERVICES NON-PLATFORM", {"activity", "service", "all-non-platform"}, DUMPSYS_COMPONENTS_OPTIONS); Loading @@ -1676,7 +1728,9 @@ static void DumpstateTelephonyOnly() { printf("== Checkins\n"); printf("========================================================\n"); // Contains package/component names, omit from reports on user builds. RunDumpsys("CHECKIN BATTERYSTATS", {"batterystats", "-c"}); } printf("========================================================\n"); printf("== dumpstate: done (id %d)\n", ds.id_); Loading Loading @@ -2157,6 +2211,7 @@ static void SetOptionsFromMode(Dumpstate::BugreportMode mode, Dumpstate::DumpOpt break; case Dumpstate::BugreportMode::BUGREPORT_TELEPHONY: options->telephony_only = true; options->do_progress_updates = true; options->do_fb = false; break; case Dumpstate::BugreportMode::BUGREPORT_WIFI: Loading Loading @@ -2641,8 +2696,13 @@ Dumpstate::RunStatus Dumpstate::CopyBugreportIfUserConsented(int32_t calling_uid if (consent_result == UserConsentResult::UNAVAILABLE) { // User has not responded yet. uint64_t elapsed_ms = consent_callback_->getElapsedTimeMs(); if (elapsed_ms < USER_CONSENT_TIMEOUT_MS) { uint delay_seconds = (USER_CONSENT_TIMEOUT_MS - elapsed_ms) / 1000; // Telephony is a fast report type, particularly on user builds where information may be // more aggressively limited. To give the user time to read the consent dialog, increase the // timeout. uint64_t timeout_ms = options_->telephony_only ? TELEPHONY_REPORT_USER_CONSENT_TIMEOUT_MS : USER_CONSENT_TIMEOUT_MS; if (elapsed_ms < timeout_ms) { uint delay_seconds = (timeout_ms - elapsed_ms) / 1000; MYLOGD("Did not receive user consent yet; going to wait for %d seconds", delay_seconds); sleep(delay_seconds); } Loading cmds/dumpstate/tests/dumpstate_test.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -295,12 +295,12 @@ TEST_F(DumpOptionsTest, InitializeTelephonyBugReport) { EXPECT_FALSE(options_.do_fb); EXPECT_TRUE(options_.do_zip_file); EXPECT_TRUE(options_.telephony_only); EXPECT_TRUE(options_.do_progress_updates); // Other options retain default values EXPECT_TRUE(options_.do_vibrate); EXPECT_FALSE(options_.use_control_socket); EXPECT_FALSE(options_.show_header_only); EXPECT_FALSE(options_.do_progress_updates); EXPECT_FALSE(options_.is_remote_mode); EXPECT_FALSE(options_.use_socket); } Loading Loading
cmds/dumpstate/dumpstate.cpp +90 −30 Original line number Diff line number Diff line Loading @@ -135,6 +135,11 @@ typedef Dumpstate::ConsentCallback::ConsentResult UserConsentResult; static char cmdline_buf[16384] = "(unknown)"; static const char *dump_traces_path = nullptr; static const uint64_t USER_CONSENT_TIMEOUT_MS = 30 * 1000; // Because telephony reports are significantly faster to collect (< 10 seconds vs. > 2 minutes), // it's often the case that they time out far too quickly for consent with such a hefty dialog for // the user to read. For telephony reports only, we increase the default timeout to 2 minutes to // roughly match full reports' durations. static const uint64_t TELEPHONY_REPORT_USER_CONSENT_TIMEOUT_MS = 2 * 60 * 1000; // TODO: variables and functions below should be part of dumpstate object Loading Loading @@ -879,6 +884,14 @@ static void DoSystemLogcat(time_t since) { CommandOptions::WithTimeoutInMs(timeout_ms).Build()); } static void DoRadioLogcat() { unsigned long timeout_ms = logcat_timeout({"radio"}); RunCommand( "RADIO LOG", {"logcat", "-b", "radio", "-v", "threadtime", "-v", "printable", "-v", "uid", "-d", "*:v"}, CommandOptions::WithTimeoutInMs(timeout_ms).Build(), true /* verbose_duration */); } static void DoLogcat() { unsigned long timeout_ms; // DumpFile("EVENT LOG TAGS", "/etc/event-log-tags"); Loading @@ -897,11 +910,7 @@ static void DoLogcat() { "STATS LOG", {"logcat", "-b", "stats", "-v", "threadtime", "-v", "printable", "-v", "uid", "-d", "*:v"}, CommandOptions::WithTimeoutInMs(timeout_ms).Build(), true /* verbose_duration */); timeout_ms = logcat_timeout({"radio"}); RunCommand( "RADIO LOG", {"logcat", "-b", "radio", "-v", "threadtime", "-v", "printable", "-v", "uid", "-d", "*:v"}, CommandOptions::WithTimeoutInMs(timeout_ms).Build(), true /* verbose_duration */); DoRadioLogcat(); RunCommand("LOG STATISTICS", {"logcat", "-b", "all", "-S"}); Loading Loading @@ -1611,8 +1620,10 @@ Dumpstate::RunStatus Dumpstate::DumpstateDefaultAfterCritical() { return status; } // This method collects common dumpsys for telephony and wifi static void DumpstateRadioCommon() { // This method collects common dumpsys for telephony and wifi. Typically, wifi // reports are fine to include all information, but telephony reports on user // builds need to strip some content (see DumpstateTelephonyOnly). static void DumpstateRadioCommon(bool include_sensitive_info = true) { DumpIpTablesAsRoot(); ds.AddDir(LOGPERSIST_DATA_DIR, false); Loading @@ -1621,27 +1632,51 @@ static void DumpstateRadioCommon() { return; } // We need to be picky about some stuff for telephony reports on user builds. if (!include_sensitive_info) { // Only dump the radio log buffer (other buffers and dumps contain too much unrelated info). DoRadioLogcat(); } else { // Contains various system properties and process startup info. do_dmesg(); // Logs other than the radio buffer may contain package/component names and potential PII. DoLogcat(); DumpPacketStats(); // Too broad for connectivity problems. DoKmsg(); DumpIpAddrAndRules(); dump_route_tables(); // Contains unrelated hardware info (camera, NFC, biometrics, ...). DumpHals(); } DumpPacketStats(); DumpIpAddrAndRules(); dump_route_tables(); RunDumpsys("NETWORK DIAGNOSTICS", {"connectivity", "--diag"}, CommandOptions::WithTimeout(10).Build()); } // This method collects dumpsys for telephony debugging only // We use "telephony" here for legacy reasons, though this now really means "connectivity" (cellular // + wifi + networking). This method collects dumpsys for connectivity debugging only. General rules // for what can be included on user builds: all reported information MUST directly relate to // connectivity debugging or customer support and MUST NOT contain unrelated personally identifiable // information. This information MUST NOT identify user-installed packages (UIDs are OK, package // names are not), and MUST NOT contain logs of user application traffic. // TODO(b/148168577) rename this and other related fields/methods to "connectivity" instead. static void DumpstateTelephonyOnly() { DurationReporter duration_reporter("DUMPSTATE"); const CommandOptions DUMPSYS_COMPONENTS_OPTIONS = CommandOptions::WithTimeout(60).Build(); DumpstateRadioCommon(); const bool include_sensitive_info = !PropertiesHelper::IsUserBuild(); DumpstateRadioCommon(include_sensitive_info); if (include_sensitive_info) { // Contains too much unrelated PII, and given the unstructured nature of sysprops, we can't // really cherrypick all of the connectivity-related ones. Apps generally have no business // reading these anyway, and there should be APIs to supply the info in a more app-friendly // way. RunCommand("SYSTEM PROPERTIES", {"getprop"}); } printf("========================================================\n"); printf("== Android Framework Services\n"); Loading @@ -1649,15 +1684,28 @@ static void DumpstateTelephonyOnly() { RunDumpsys("DUMPSYS", {"connectivity"}, CommandOptions::WithTimeout(90).Build(), SEC_TO_MSEC(10)); RunDumpsys("DUMPSYS", {"connmetrics"}, CommandOptions::WithTimeout(90).Build(), SEC_TO_MSEC(10)); RunDumpsys("DUMPSYS", {"netd"}, CommandOptions::WithTimeout(90).Build(), SEC_TO_MSEC(10)); // TODO(b/146521742) build out an argument to include bound services here for user builds RunDumpsys("DUMPSYS", {"carrier_config"}, CommandOptions::WithTimeout(90).Build(), SEC_TO_MSEC(10)); RunDumpsys("DUMPSYS", {"wifi"}, CommandOptions::WithTimeout(90).Build(), SEC_TO_MSEC(10)); RunDumpsys("DUMPSYS", {"netpolicy"}, CommandOptions::WithTimeout(90).Build(), SEC_TO_MSEC(10)); RunDumpsys("DUMPSYS", {"network_management"}, CommandOptions::WithTimeout(90).Build(), SEC_TO_MSEC(10)); if (include_sensitive_info) { // Contains raw IP addresses, omit from reports on user builds. RunDumpsys("DUMPSYS", {"netd"}, CommandOptions::WithTimeout(90).Build(), SEC_TO_MSEC(10)); // Contains raw destination IP/MAC addresses, omit from reports on user builds. RunDumpsys("DUMPSYS", {"connmetrics"}, CommandOptions::WithTimeout(90).Build(), SEC_TO_MSEC(10)); // Contains package/component names, omit from reports on user builds. RunDumpsys("BATTERYSTATS", {"batterystats"}, CommandOptions::WithTimeout(90).Build(), SEC_TO_MSEC(10)); // Contains package names, but should be relatively simple to remove them (also contains // UIDs already), omit from reports on user builds. RunDumpsys("BATTERYSTATS", {"deviceidle"}, CommandOptions::WithTimeout(90).Build(), SEC_TO_MSEC(10)); } printf("========================================================\n"); printf("== Running Application Services\n"); Loading @@ -1665,10 +1713,14 @@ static void DumpstateTelephonyOnly() { RunDumpsys("TELEPHONY SERVICES", {"activity", "service", "TelephonyDebugService"}); if (include_sensitive_info) { printf("========================================================\n"); printf("== Running Application Services (non-platform)\n"); printf("========================================================\n"); // Contains package/component names and potential PII, omit from reports on user builds. // To get dumps of the active CarrierService(s) on user builds, we supply an argument to the // carrier_config dumpsys instead. RunDumpsys("APP SERVICES NON-PLATFORM", {"activity", "service", "all-non-platform"}, DUMPSYS_COMPONENTS_OPTIONS); Loading @@ -1676,7 +1728,9 @@ static void DumpstateTelephonyOnly() { printf("== Checkins\n"); printf("========================================================\n"); // Contains package/component names, omit from reports on user builds. RunDumpsys("CHECKIN BATTERYSTATS", {"batterystats", "-c"}); } printf("========================================================\n"); printf("== dumpstate: done (id %d)\n", ds.id_); Loading Loading @@ -2157,6 +2211,7 @@ static void SetOptionsFromMode(Dumpstate::BugreportMode mode, Dumpstate::DumpOpt break; case Dumpstate::BugreportMode::BUGREPORT_TELEPHONY: options->telephony_only = true; options->do_progress_updates = true; options->do_fb = false; break; case Dumpstate::BugreportMode::BUGREPORT_WIFI: Loading Loading @@ -2641,8 +2696,13 @@ Dumpstate::RunStatus Dumpstate::CopyBugreportIfUserConsented(int32_t calling_uid if (consent_result == UserConsentResult::UNAVAILABLE) { // User has not responded yet. uint64_t elapsed_ms = consent_callback_->getElapsedTimeMs(); if (elapsed_ms < USER_CONSENT_TIMEOUT_MS) { uint delay_seconds = (USER_CONSENT_TIMEOUT_MS - elapsed_ms) / 1000; // Telephony is a fast report type, particularly on user builds where information may be // more aggressively limited. To give the user time to read the consent dialog, increase the // timeout. uint64_t timeout_ms = options_->telephony_only ? TELEPHONY_REPORT_USER_CONSENT_TIMEOUT_MS : USER_CONSENT_TIMEOUT_MS; if (elapsed_ms < timeout_ms) { uint delay_seconds = (timeout_ms - elapsed_ms) / 1000; MYLOGD("Did not receive user consent yet; going to wait for %d seconds", delay_seconds); sleep(delay_seconds); } Loading
cmds/dumpstate/tests/dumpstate_test.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -295,12 +295,12 @@ TEST_F(DumpOptionsTest, InitializeTelephonyBugReport) { EXPECT_FALSE(options_.do_fb); EXPECT_TRUE(options_.do_zip_file); EXPECT_TRUE(options_.telephony_only); EXPECT_TRUE(options_.do_progress_updates); // Other options retain default values EXPECT_TRUE(options_.do_vibrate); EXPECT_FALSE(options_.use_control_socket); EXPECT_FALSE(options_.show_header_only); EXPECT_FALSE(options_.do_progress_updates); EXPECT_FALSE(options_.is_remote_mode); EXPECT_FALSE(options_.use_socket); } Loading