86 Commits

Author SHA1 Message Date
Kweku Adams
0f7167947a Increasing TombstoneSection timeout to 2 minutes.
Java trace dumps can take significantly longer than 30 seconds. Testing
suggests that 2 minutes should be ample time.

Bug: 111729299
Test: 'adb shell incident' and ensure the section doesn't time out.
Change-Id: I35e09fc1ca608122a1a352985ea3741f6ea0a344
2018-09-13 15:48:27 -07:00
Yi Jin
908c02f5c1 Add kernel version to incident report
Bug: 110230810
Test: atest incidentd_test
Change-Id: I502b34f23d61a7346d79ff0dc378add8461d2d27
2018-06-22 16:51:40 -07:00
Kweku Adams
e04ef777c1 Treating all FileSection files as device specific.
Arc++ devices don't have the /d/wakeup_sources file. There's a chance
other device won't have it either, and there may be other files that we
thought were standard but are actually not, so it's safer to just assume
that not every file will be available on every device and not treat a
missing file as an error.

Bug: 110109543
Test: atest incidentd_test
Change-Id: Ief09427f08d18aee611d057ddafdb9a3466744db
2018-06-13 12:46:12 -07:00
Kweku Adams
3d16091dd2 Adding batterystats history to proto dump.
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
2018-05-07 17:57:42 -07:00
android-build-team Robot
c4e8cde88d Merge "Preventing zombie process creation." into pi-dev am: ca6f36532d
am: 193c893b01

Change-Id: Id32203ab069343410a02c03956a7c6135f8a1b33
2018-05-02 18:05:11 -07:00
Yi Jin
3f3603587c 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
2018-05-01 16:25:52 -07: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
Yi Jin
8cb370f2a2 Use the right printf symbols rather than converting to ints.
Bug: 77333635
Test: make -j incidentd
Change-Id: I3338279c385051b5df334af481e7f47f16d16480
2018-04-23 13:03:14 -07:00
Yi Jin
74679ef6c4 Merge "Make the logging more concise." 2018-04-23 17:57:53 +00:00
Yi Jin
3be0b4327c Make the logging more concise.
Each section's name will start with its type, e.g. file, gzip, cmd.

Bug: 77333635
Test: atest incidentd_test
Change-Id: I7c86f2682b1c2055c6063f6395fc7fe7fc7ffea5
2018-04-20 17:10:11 -07:00
Yi Jin
0e5d577117 Retry when IO operations fail with EINTR, make incidentd more robust.
Bug: 77333635
Test: atest incidentd_test
Change-Id: I44929654b534aba9fcce7066a61c5c6e43644a50
2018-04-20 14:08:47 -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