78 Commits

Author SHA1 Message Date
Yi Jin
e09cde0cd9 Merge "Add a section flag to bypass failure if a specific path can't be found." into pi-dev 2018-05-02 21:36:23 +00:00
Yi Jin
7fe3dee3ae Add a section flag to bypass failure if a specific path can't be found.
This is a temporary solution to bypass failure of reading cpu info or 
battery type in P if the path doesn't exist on some devices. See bug for
details. However in Q, incidentd should implement reading from the
common Linux kernel interfaces.

Bug: 78028767
Bug: 78239764
Test: atest incidentd_test
Change-Id: I08ffcb21709efe5478d2ac46121deb5795af1024
Merged-In: I08ffcb21709efe5478d2ac46121deb5795af1024
2018-05-02 01:31:08 +00:00
Kweku Adams
a8a56c8bd1 Preventing zombie process creation.
Bug: 78363774
Test: flash device, run 'adb shell incident', then check
'adb shell ps | grep incidentd'

Change-Id: I473894eb1c05ce8557da846d1ccdcbfa672356eb
2018-04-24 05:53:15 -07:00
TreeHugger Robot
c3116634e1 Merge "Free allocated varargs" into pi-dev 2018-04-17 19:08:26 +00:00
Yi Jin
480de784a3 Free allocated varargs
Bug: 78173836
Test: atest incidentd_test
Change-Id: I1e1b9f63d0e863c733c51efef432235eb94cdbab
2018-04-17 10:47:31 -07:00
TreeHugger Robot
0f0c9243be Merge "Fix incidentd skip collecting timedout of a section." into pi-dev 2018-04-17 16:22:20 +00:00
Yi Jin
98ce81050b Fix incidentd skip collecting timedout of a section.
By moving the section stats collection before any return statements,
it won't missing stats collection.

Bug: 77962855
Test: atest incidentd_test
Change-Id: I0900556428c51636e24df48a407eb916ccff795c
2018-04-16 13:42:48 -07:00
TreeHugger Robot
a991071db9 Merge "Reduce disk space limit for incident reports." into pi-dev 2018-04-13 20:34:31 +00:00
Yi Jin
ba7ee6ff11 Add tests to cover handling negative varint.
The gtest will fail if the fix of b/77291057 isn't there. Should make
this change in with the fix, but later than none.

Bug: 77291057
Test: atest incidentd_test
Change-Id: I48ece311f78ee18d97486839a3b8b434c9419cf3
2018-04-12 22:59:41 +00:00
Yi Jin
91d4330202 Reduce disk space limit for incident reports.
Bug: 77963176
Test: atest incidentd_test and manual
Change-Id: I8ad1d10fcd40ff556255ac27c049265e79c7d558
2018-04-12 11:06:57 -07:00
Yi Jin
ad3e6e5d5a This cl tries to fix cts tests IncidentdTest
1. Disable BatteryType section which is device-specific
2. Make timeout longer since meminfo section timedout in test
3. make some negative values sint
4. varint can be 64 bits, there is a bug implicitly convert it to 32
which loses values.
5. Found another bug which failed to read 64 bits varint, create a
native test to make sure it works.

Bug: 77291057
Test: atest CtsIncidentHostTestCases:com.android.server.cts.IncidentdTest
Change-Id: I04cc730741f7901f37ac57a11af7777d57118a23
2018-04-04 16:29:55 -07:00
Yi Jin
ea31cbea93 Remove some letters of verbose log
Bug: 77333635
Test: N/A
Change-Id: I94b288d070dfb372edf345d369d75bb3255f631b
2018-04-02 11:09:57 -07:00
Yi Jin
6cacbcbf43 Use modern c++ code style for incidentd.
This cl does not contain code logic changes.

Bug: 77333635
Test: manual and incidentd_test
Change-Id: Iea0a402b1051defd45159ca267e6dd705f9ffa49
2018-03-30 17:36:49 -07:00
Yi Jin
1ebfc94aa1 Merge "Use unique_fd with the clear ownership." into pi-dev 2018-03-30 20:53:30 +00:00
Yi Jin
c858e2781c Enable Last Kmsg, also fix the GZipSection test.
Bug: 73354384, 76208934
Test: atest incidentd_test and manual as well
Change-Id: I074027f4d972686ae3e9415b50e4d3967f6a2355
2018-03-29 18:44:54 -07:00
Yi Jin
e3dab2d906 Use unique_fd with the clear ownership.
FdBuffer won't take ownership of the `main` fd.
It only enforces transfer ownership in readProcessedDataInStream.

Bug: 74021345
Test: atest incidentd_test
Change-Id: I6182730241c81c34b3be865b827a2d3e8c10c21c
2018-03-28 12:44:36 -07:00
TreeHugger Robot
ab34199e9c Merge "Found out it is not possible to exec procrank as non-root/shell. But it is ok to disable procrank since the information can be obtain via dumpsys meminfo" into pi-dev 2018-03-28 19:37:46 +00:00
Yi Jin
c36e91dd12 Found out it is not possible to exec procrank as non-root/shell.
But it is ok to disable procrank since the information can be obtain via
dumpsys meminfo

Optimize the code style a bit.

Bug: 72510307
Test: atest incidentd_test
Change-Id: If06201aa708461b569d9fb007f20d1e51342d5c2
2018-03-27 15:01:20 -07:00
Yi Jin
a9635e442b Fix apct test.
Bug: 76208934
Test: atest incidentd_test
Change-Id: Ibc101aa3c523398b1e9dd6cff3d6735b4d704667
2018-03-23 12:05:32 -07:00
Yi Jin
83fb1d58b5 Fix the test failure of LogSection, don't consider read log msg error as
a failure since it is used to signal EOF.

Additionally tag this message as auto so user_id won't become explicit.

Bug: 75017304
Test: atest incidentd_test
Change-Id: I151bab5a72a532e7c9f54ae0686561001730bdeb
2018-03-16 16:03:18 -07:00
Yi Jin
6355d2f3ab Wrap fd with unique_fd so it won't leak.
Bug: 74021345
Test: manual and atest incidentd_test
Change-Id: Ib1000bfe6917c3d5cae7b9edce5b67d50897e10d
2018-03-14 16:26:28 -07:00
Yi Jin
86dce413f8 Optimize incidentd memory usage
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
2018-03-07 18:25:44 -08:00
Kweku Adams
eadd123d68 Dumping stack traces to proto.
Bug: 72177715
Test: flash device and check incident.proto output
Change-Id: Id2a15e0fc62b66efe875949af97f0eb651c7e322
(cherry picked from commit 5c804e2b9893c7892900148229cf19fa6268e7dc)
2018-03-07 21:50:12 +00:00
Yi Jin
5ee0787024 Use uint64_t instead of long long as API type for consistent reason.
Bug: 74118023
Test: manual
Change-Id: Icd5f506c76d3a008a79cb6c9d2061962ca7fdd40
2018-03-05 18:18:27 -08:00
Yi Jin
06ebd1af8e Fix heap buffer overflow
Bug: 74000767
Test: manual
Change-Id: Id57674c0ae527da055a06acf4f458c440328c5c3
2018-02-28 11:25:58 -08:00
TreeHugger Robot
16b989fc0e Merge "Add incidentd to readproc group." 2018-02-28 04:13:20 +00:00
Kweku Adams
391284396b Add incidentd to readproc group.
This allows it to get cpu info and ps data.

Bug: 72384374
Test: flash device and check incident.proto output
Change-Id: I09f6318861fbedbf4fae1a4325e6a7d12b32b10e
2018-02-27 12:26:13 -08:00
Yi Jin
1a11fa1097 Implement a new section to attach LAST_KMSG to incident report
This section simply gzip a large file and stores result in GZippedFileProto

This greatly improves the size, before gzip, the last kmsg size ~500KB,
after gzip the proto size is ~60KB.

Bug: 73354384
Test: atest incidentd_test and manual on device test
Change-Id: I9bfc2cf07384487671edbffb5f0bd8495608fea6
2018-02-27 11:36:29 -08:00
Yi Jin
4e843106a6 Throttler for incidentd based on size putting into dropbox.
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
2018-02-20 13:11:22 -08:00
Yi Jin
b592e3bc31 This cl formats incidentd and makes it easier for debugging.
Bug: 72755317
Test: clang-format -type=file -i <files>
Change-Id: Ide91227f26c6b1db6d2e5fe8117ca5cc4cf77fd3
2018-02-15 16:53:22 -08:00
TreeHugger Robot
9ed8ec9b49 Merge "Put metadata or stats into each dropbox incident report." 2018-02-15 20:42:00 +00:00
Yi Jin
329130b7e4 Put metadata or stats into each dropbox incident report.
Bug: 65451198
Test: atest incidentd_test
Change-Id: Ib406b177ad7f1b4bda7fef2e606fc66a9836e060
2018-02-14 16:12:57 -08:00
Yi Jin
4bad04eda4 Add owners file for statsd/incidentd
Test: N/A
Change-Id: I5536a239e0fefbc05a0db3b88de6d4a6ccddfdee
2018-02-14 15:47:39 -08:00
Yi Jin
7f9e63b632 Add clear method to ProtoOutputStream so it is reusable by just
rewinding its internal pointer.

Bug: 72319159
Test: atest incidentd_test and atest statsd_test
Change-Id: Id046b987a7460d68300e5d4d46ae56aec1eba2d0
2018-02-09 14:20:48 -08:00
Yi Jin
afb36062d5 Allow statsd_config be able to set destination value AUTO/EXPLICIT.
Also move incidentd integration to its own files.
clang-format -style=file -i src/anomaly/* and src/subscribers/Incidentd*

Bug: 70239380
Test: manual
Change-Id: I7bfe14d704d9e86d925365a8a21ffed726723e60
2018-02-06 11:15:09 -08:00
Yi Jin
3ec5cc792e Modify SystemApi so it can be used by CTS to trigger incident report
Bug: 72502621
Test: Cts/Gts tests covered, see the cls from the same topic
Change-Id: Id0c1cc0fc0054e620de1349dab66513e554b1caa
2018-01-29 21:01:09 -08:00
Yi Jin
b8344dc72f Fix command line tool to set the right privacy enum.
Test: manual
Change-Id: I3f0845ea32b46f1a028f8b6d3d4180a90a47beb5
2018-01-24 18:25:33 -08:00
Yi Jin
974e56f141 Enable incidentd.rc also add dump and usage_stats permission to statsd
so it bypass incidentd's permission check

Test: manual
Change-Id: I65b501fe46f66f9f62fedfcfc75aa17f29fc1076
2018-01-22 14:41:19 -08:00
Yi Jin
437aa6e8ad Add more information to incident header. Especially add config keys
to check if the report is uploadable.

Move incidentheader.proto to libincident so statds is able to include a lite
proto class for incident header.

Change IncidentReportArgs to add the proto object instead of serialized
bytes to prevent caller gives meaningless data.

Bug: 70241842
Test: push config to statsd and verify incidentd generate the report
with correct header.

Change-Id: If95b655be71047b019b229e5903a08f3c21a1f29
2018-01-21 22:36:01 -08:00
Yi Jin
4bab3a191a Fix permissions problems of incidentd.
Test: manual
Change-Id: I4ee0d1f2349ee1a25a422cabf1b5b87c612710d2
2018-01-17 19:16:49 -08:00
Yi Jin
30789db28c make incidentd run in its own uid under log group for reading logs.
Test: manual
Change-Id: I7106614c0bed1e862fbc80e42a87b43efc063145
2018-01-10 13:20:14 -08:00
TreeHugger Robot
c99dea0a4b Merge "Revert "Enable incidentd, it will just be idle while no one triggers it."" 2018-01-09 03:28:11 +00:00
Yi Jin
44ed76eb9f Revert "Enable incidentd, it will just be idle while no one triggers it."
This reverts commit d612df381e7867780266f0a1161b817e089c3bb6.

Reason for revert: Selinux denials, see b/71591707 for more details.

Change-Id: I864cd74e7ba57d67e2ed8328a7df9c5ff335508c
2018-01-09 01:44:47 +00:00
Yi Jin
3c034c987e Implement a new type of section which reads from logd and dumps proto.
And implement a file section which reads from event-log-tags for
decoding binary logs.

Bug: 70936599
Test: atest incidentd_test && atest incident_helper_test and flush on
device and test log sections and event_log_tag_map
Change-Id: Ib3d35e317f355de69f01ded012482486e9a43da6
2018-01-06 20:33:14 -08:00
TreeHugger Robot
e85fac24db Merge "Enable incidentd, it will just be idle while no one triggers it." 2018-01-04 01:40:41 +00:00
Yi Jin
d612df381e Enable incidentd, it will just be idle while no one triggers it.
Test: N/A
Change-Id: I169108f0d61fc1fffea629eb2e862bfa7aad65f9
2018-01-03 15:22:18 -08:00
Kweku Adams
f5cc5759d5 incidentd: parsing ps dump into proto.
Also changing from execv to execvp so that we don't have to specify the full command path.

Bug: 65750831
Test: atest incident_helper_test
Change-Id: I92191afff4e7f9a6d08ea22ecfc2de5623d3bde5
2018-01-02 15:49:23 -08:00
Yi Jin
5e4ce2c941 Add AndroidTest.xml to incident_helper and incidentd
This change depends on fix of b/69802886:
https://android-review.googlesource.com/#/c/platform/build/+/555203/

Bug: 65754586
Test: atest incident_helper_test && atest incidentd_test
Change-Id: I64d793c8abe4381114e5b38fa12d085b1d808cd1
2017-12-07 18:06:47 +00:00
Yi Jin
bdf58942c8 1. Implement Privacy Policy Tag Inheritance
2. Expose Dest values in IIncidentReportArgs.h

Please see bug for detail descriptions.

Bug: 67869340
Test: unit tested and on-device test. Ran command:
$ out/host/linux-x86/bin/incident-section-gen incidentd
to test various of privacy taggings.
Change-Id: I12af3d7da4c7c72bd63598893fe2c1f70b09baa4
2017-12-01 13:37:13 -08:00
Yi Jin
0eb223496c Implement Cpu Freq Section
When poll from sysfs, revents return POLLERR by default, handles
this edge case in this cl.

Bug: 68774444
Test: unit tested + on device tests
Change-Id: I23540299c026d3e7676497f56690e9f8646a47bd
2017-11-14 13:22:25 -08:00