summaryrefslogtreecommitdiff
path: root/cmds/incidentd/src/Reporter.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Optimize memory usage in incidentdMike Ma2020-03-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | EncodedBuffer is used a lot in incidentd. EncodedBuffer uses malloc internally to acquire memory. Frequently creating and destroying EncodedBuffer creates memory fragmentation, leading to high memory usage after taking an incident report. Also fixes a few other places with lots of malloc/free operations. This change: * Creates a pool of EncodedBuffer in incidentd. The saving is significant. It reduces EncodedBuffer creation from 3 per section to 3 per report. * Replaces malloc with mmap inside EncodedBuffer. mmap is guaranteed to be mem page aligned, so there will be no mem fragmentation after destroying EncodedBuffer. * Replaces new with mmap inside TombstoneSection * Forks a process to execute LogSection, because liblog malloc & free significant amount of memory Result: PSS before taking a report: 1295 KB PSS after taking a report: 1336 KB Bug: 150311553 Test: heapprofd Change-Id: I83bd9c969b751c80b2f42747020799bd85d8aae6
* Add an option to zip incident reportMike Ma2020-03-051-3/+57
| | | | | | | | | | Incident reports are getting bigger as we add more sections. Add an option (-z, default off) to zip incident report. Bug: 150160547 Test: atest incidentd_test Test: adb shell incident -z -p EXPLICIT | gunzip | ./out/soong/host/linux-x86/bin/aprotoc --decode=android.os.IncidentProto --proto_path=./ --proto_path=external/protobuf/src frameworks/base/core/proto/android/os/incident.proto Change-Id: I7c8ff1d91df842c200462ee29f15feae68e62739
* Incident Report Extension APIMike Ma2020-01-141-43/+59
| | | | | | | | | | | Add an API for priv and system app to register a dump callback with Incident Service. Bug: 145924375 Test: Register a callback dumping a string. Capture an incident report and verify that the customized section exist. Change-Id: I6fff6c1ee97e25963068d284ba37adce1bb5ec31
* Remove encryption from incidentdYao Chen2019-04-301-2/+1
| | | | | | | Test: build Bug: 131371777 Change-Id: I412c73658025246004412f3bcdcf30f74d766326
* Get incidentd cts working again.Joe Onorato2019-04-261-0/+16
| | | | | | | | | | | | | - The buffer size increased, and the CTS test that checked that was triggering. - Privacy filtering wasn't working for the stack trace sections - The incident command was not handling the default arguments correctly - The throttler was throttling streaming reports, which made the test flaky. Bug: 126253679 Test: atest CtsIncidentHostTestCases Change-Id: I342cd7d0421ea8c22b7796fc99e779f21855af73
* Don't include restricted images in incident reports unless they're ↵Joe Onorato2019-04-261-15/+17
| | | | | | | | | specifically mentioned in the IncidentReportArgs Test: adb shell incident -p EXPLICIT -s com.google.android.incident.gts/.ReportReadyReceiver 3025 Test: adb shell incident -p EXPLICIT -s com.google.android.incident.gts/.ReportReadyReceiver Bug: 123543706 Change-Id: I2c55831b73338f68196838ee529e595f566e657f
* Add encryption in incidentd.Yao Chen2019-04-231-1/+2
| | | | | | | | | | | | | | | + Sections which require encryption will be encryted on disk. + When the sections are requested by clients (e.g., permission controller, report assignee), incidentd will decrypte the data. + For efficiency, encryption is done ONLY for sections that require encryption. + Use Keystore API for key management. Bug: 131084614 Test: incidentd_test Change-Id: I84d6b86807ba5bbde1051e847b2df6e79e6b5be5
* Add metadata and headers to incident reports.Yao Chen2019-04-021-1/+1
| | | | | | | | | | | | | | | | | | + Remove the spawned thread inside the ReportFile for filter_and_write_report because it leads to accessing freed memory Instead, let the caller of ReportFile::startFileteringData create the thread. ReportFile class shouldn't care about whether it's writing to a pipe for IPC or regular file. + Add uri building in incidentd + Add metadata and headers to incident reports Test: existing passed tests in incidentd_test still pass. Manually tested with statsd Change-Id: I5fef900d31f5d181275814f1e1c8c98443f201a7
* incidentd sections for userdebug and eng are compiled outJoe Onorato2019-03-271-10/+0
| | | | | | | | | | | Previously, the decision to include or not include them was done at runtime. This changes them to be behind a compile time flag. It's just safer, because the code just isn't there instead of being dependent on a system property. Test: bit GtsIncidentManagerTestCases:* Bug: 123543706 Change-Id: If4e611914a7b0acd399ae27e55af8f718aee3ec8
* incidentd can now handle multiple callers asking it for incident reportsJoe Onorato2019-03-261-222/+593
| | | | | | Test: bit incident_test:* GtsIncidentManagerTestCases:* Bug: 123543706 Change-Id: I9f671dd5d8b2ad139f952a23e575c2be16120459
* Refine incidentd error handling and loggingMike Ma2018-12-051-4/+8
| | | | | | | | | | | Added or changed some error messages and logging for easier debugging. Log a few section errors to incident metadata in addition to logcat. Also let incident reporting continue instead of failing when non-fatal error occurs. Bug: 119417232 Test: Take an incident report, and logcat. Change-Id: Id18b7b690100923a8074d99b2312ee80c0bcd760
* Adding batterystats history to proto dump.Kweku Adams2018-05-071-0/+9
| | | | | | | | | | | | It will only print out a dump for userdebug or eng builds. This is the same change as the pi-dev one (http://ag/3909863), but due to changes in master, that change has a merge conflict, so I have to create a separate CL for master. Bug: 77727638 Test: it builds Change-Id: Ib74d4c664f23a61e6fc33f700ba6a3c6fad32c74
* Reduce disk space limit for incident reports.Yi Jin2018-04-121-2/+1
| | | | | | Bug: 77963176 Test: atest incidentd_test and manual Change-Id: I8ad1d10fcd40ff556255ac27c049265e79c7d558
* Use modern c++ code style for incidentd.Yi Jin2018-03-301-0/+8
| | | | | | | | This cl does not contain code logic changes. Bug: 77333635 Test: manual and incidentd_test Change-Id: Iea0a402b1051defd45159ca267e6dd705f9ffa49
* Optimize incidentd memory usageYi Jin2018-03-071-4/+4
| | | | | | | | | 1. Remove dependency of libprotobuf-cpp-lite, saves .so mmap ~200KB 2. Don't use auto except iterator for readability. Bug: 74254200 Test: adb shell dumpsys meminfo `pid incidentd` Change-Id: If6198521c3b80929d6ea3f7ed466b5195991ccfd
* Throttler for incidentd based on size putting into dropbox.Yi Jin2018-02-201-2/+3
| | | | | | | | | | The incidentd will accumulate the total size put into dropbox and once it exceeds a threshold (currently 20MB) daily, it will stop further requests. It allows collection again 24 hours later. Bug: 64219725 Test: atest incidentd_test and manually flashed incidentd and test. Change-Id: Iea21fbae40d5d01108797b190231d73e74eff213
* This cl formats incidentd and makes it easier for debugging.Yi Jin2018-02-151-75/+33
| | | | | | Bug: 72755317 Test: clang-format -type=file -i <files> Change-Id: Ide91227f26c6b1db6d2e5fe8117ca5cc4cf77fd3
* Put metadata or stats into each dropbox incident report.Yi Jin2018-02-141-4/+40
| | | | | | Bug: 65451198 Test: atest incidentd_test Change-Id: Ib406b177ad7f1b4bda7fef2e606fc66a9836e060
* Modify SystemApi so it can be used by CTS to trigger incident reportYi Jin2018-01-291-1/+11
| | | | | | Bug: 72502621 Test: Cts/Gts tests covered, see the cls from the same topic Change-Id: Id0c1cc0fc0054e620de1349dab66513e554b1caa
* Fix permissions problems of incidentd.Yi Jin2018-01-171-1/+1
| | | | | Test: manual Change-Id: I4ee0d1f2349ee1a25a422cabf1b5b87c612710d2
* Fixed several bugs found for incidentdYi Jin2017-10-181-0/+4
| | | | | | | | | | 1. Add logging for proto can't be parsed by incident_report 2. Close opened file descriptor of incident report request! 3. Fix invalid syntax of auto-gen section_list.cpp Bug: 67849582 Test: manually run incident and checks /proc/<its pid>/fd Change-Id: I38e6ac28de09aca6243ad536ed41d8059e08ba24
* Enable Diskstats SectionYi Jin2017-09-281-2/+2
| | | | | | Bug: 67019205 Test: manually tested in incident_report tool Change-Id: I291d4b0b0c01385e57c6ad83a12678c0f8d8746b
* Extract IncidentHeaderProto to a separated file for statsd to consumeYi Jin2017-09-071-24/+12
| | | | | | | | Create a HeaderSection to deal with header protos which is more testable Bug: 65422268 Test: unit tested Change-Id: Icdcbeded8bc963940a8f9e503cb65a9a247ca5b2
* Implement PII Stripper, part 2Yi Jin2017-09-071-48/+1
| | | | | | | | | | | | | | | | | | Implement EncodedBuffer that strip pii based on given privacy request. The reason to implement another buffer is the length-delimited field's size could change when its submessage gets stripped. It also intends to keep the orignal data around for other requests to consume it. In addition, the section implementation has adapted EncodedBuffer so write out to each request's fd could be request-specific. The next step is allow requests to set its privacy spec. Notice the current design set the privacy spec of dropbox to AUTOMATIC, this behavior might change in the future. Bug: 64687253 Test: unit tests are writtern, see README.md for how to run unit tests. Change-Id: I7ac236b8265ba9289dc6e17a8a5bf7f67ffb6bf5
* Fix parsing enum types in incident report tool as well as addingYi Jin2017-08-111-3/+6
| | | | | | | | some additional loggings Test: manually flashed to device and test calling IncidentManager.java functions Change-Id: I69610414edde865b20ba632837f037fbe43f99db
* Add tests for reporter classYi Jin2017-08-031-16/+33
| | | | | Test: Add test for Reporter class Change-Id: Ic1d87a26dd4b8271bab7b03374c7a1d4d7b87f92
* This cl implements CommandSection and use it to add procrank.proto SectionYi Jin2017-08-021-1/+1
| | | | | | | | | Bug: 63863444 Test: manual - create gtests for CommandSection and Procrank Parser following instructions in the README.md of incidentd and incident_helper on how to run them. Change-Id: I099808fd13bf9ed9a564b122f1126b1691a83291
* This cl does the following things:Yi Jin2017-07-241-3/+3
| | | | | | | | | | | | | | | | 0) Implements a skeleton of incident_helper 1) Implements FileSection class which calls incident_helper to parse file content to protobuf 2) Adds Kernel Wake Sources to incident.proto and makes it parsed by FileSection 3) Adds basic gtests to test FdBuffer, io_utils, FileSection implementation Bug: 62923266 Bug: 62926061 Test: manual - push incidentd, incident_helper and incident to my device and verify kernel wakeup sources file is able to be parsed. Change-Id: I2aa6b6158d962ce70e6fa6c8a9c42213a45ff41c
* First checkin of incident reporting.Joe Onorato2016-12-151-0/+352
There are a few major pieces here: incidentd --------- This daemon (started by init) runs and accepts incoming requests to take incident reports. When prompted, it calls into various system services and fills in an IncidentProto data structure, and then writes the report into dropbox. The next steps for incidentd: - Security review of SELinux policies. These will be a subset of the dumpstate permissions. Until this is done, incidentd is not started at boot time. incident -------- This shell command calls into incidentd, and can initiate an incident report and either capture the output or leave for dropbox. incident_report --------------- This host side tool can call adb shell with the correct parameters and also format the incident report as text. This formatting code was left of the device on purpose. Right now it's pretty small, but as the number of fields increases, the metadata and code to do the formatting will start to grow. The incident_report command also contains a workaround to let it work before incidentd is turned on by default. Right now, it is implemented to call adb shell dumpsys <service> --proto directly, whereas in the future it will go through the full incidentd flow. incident_section_gen -------------------- A build-time tool that generates a stripped down set of information about the fields that are available. libincident ----------- This library contains the code to connect to incidentd, and the meta proto definitions that are used by the framework protos. The basics are here now, but they are not fully fleshed out yet. The privacy.proto file contains annotations that can go in the proto file that we will later use to filter which fields are uploaded, and which are used by local sources. For example, a device in a test lab is safe to upload much much more information than a real user. These will share the same mechanism, but the user's output will be filtered according to these annotations. frameworks/core/proto --------------------- These .proto files contain the definitions of the system's output. There is one master android.os.IncidentProto file that is the top level of an incident report, but some other services (notification, fingerprint, batterystats, etc) will have others that are used directly by the logging mechanism. Other files which are shared by several of the services also go here, such as ComponentName, Locale, Configuration, etc. There will be many more. There is also a first iplementation of a dump method handling --proto in the fingerprint service. IncidentManager --------------- The java API to trigger an incident report. Test: Not written yet Change-Id: I59568b115ac7fcf73af70c946c95752bf33ae67f