37 Commits

Author SHA1 Message Date
Chih-Hung Hsieh
7a88a938d2 Fix/suppress incident* google-explicit-constructor warnings
* Add explicit to conversion constructors/operators
* Remove redundant explicit of copy constructors

Bug: 28341362
Test: make with WITH_TIDY=1 DEFAULT_GLOBAL_TIDY_CHECKS=-*,google-explicit-constructor
Change-Id: I26a11bb798d25605577269ed340e97afc8566960
2018-12-20 13:45:04 -08:00
Chih-Hung Hsieh
054dab1d47 Fix cert-dcl16-c clang-tidy warnings.
Bug: 120614316
Test: make with WITH_TIDY=1 DEFAULT_GLOBAL_TIDY_CHECKS=-*,cert-dcl16-c
Change-Id: I2dc262d3407aafa969e921236dc3fc3ae60eb9d4
2018-12-11 11:27:17 -08:00
Mike Ma
61b65dc245 Change owners of incidentd
Test: NA
Change-Id: Ic651a13bb145610de2b668b6b235228e1e5151c1
2018-12-06 13:44:44 -08:00
Mark Salyzyn
d100107806 switch to using android-base/file.h instead of android-base/test_utils.h
Test: compile
Bug: 119313545
Change-Id: I664fb32522d01909c603d7b903475c4e9aea9223
2018-11-14 15:54:32 -08:00
Kenneth Magic
93ca85a172 Update PageTypeInfoParser to be less restrictive.
The page block order is an independent variable from the free
page order table in the kernel, so the parser should not error
out if they do not match.

Bug: 110559361
Test: incident_helper_test
Change-Id: I08ad9c8f9b29cc15b80a89929f3a1fb6886852e6
Merged-In: I08ad9c8f9b29cc15b80a89929f3a1fb6886852e6
(cherry picked from commit 3abb43991685d0ba40e70dd5f81abe044f65b891)
2018-08-28 10:39:42 -07:00
Yi Kong
288f355e1a Modernize codebase by replacing NULL with nullptr
Fixes -Wzero-as-null-pointer-constant warning.

Test: m
Bug: 68236239
Change-Id: Ic440b9fcb9be97c316448b764f7110ef1f7eb525
Merged-In: Ic440b9fcb9be97c316448b764f7110ef1f7eb525
(cherry picked from commit 08a8d728dbe379cd70974ba98d59017f5506e0e5)
2018-08-08 14:08:35 -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
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
6bd2f25f19 Add HighAtomic to pagetypeinfo, and don't fail if a header can't be
found in proto definition.

Bug: 73656242
Test: atest incident_helper
Change-Id: Ib89b1a9189445a0598ec5da0c32046f75de3b0c5
2018-02-20 15:06:32 -08:00
TreeHugger Robot
15d8102111 Merge "Add owners file for statsd/incidentd" 2018-02-15 20:32:24 +00: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
51d4c54eba Make the platform proto naming consistent, Part 1
Change proto names in incident_helper

Bug: 72474563
Test: atest incident_helper_test
Change-Id: Ia416ef9726a19d247e62d7de1028874408ec53f1
2018-02-13 18:05:32 -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
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
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
Kweku Adams
59e6fd792d incidentd: Parsing battery_type data to proto.
Bug: 65750835
Test: atest incident_helper_test
Change-Id: I3afefcfbd68924f8b6bd384cf1c7a41daeb243e3
2017-12-27 15:48:14 -08:00
Yi Jin
526aa056bd Modify system properties proto
Test: atest incident_helper_test
Change-Id: Id81922e7f4412090e3b72b3a0fc1151995635885
2017-12-21 12:57:08 -08:00
Joe Onorato
c9f1a9e3dd Merge "Fix how we build the statsd protos." 2017-12-14 05:33:33 +00:00
Joe Onorato
62c220b20b Fix how we build the statsd protos.
This lets us include frameworks protos, and use the constants
and messages from them.

Change-Id: I609d6e524f780e6a5beea543a68561bede47813e
Test: make
2017-12-13 18:26:45 -08:00
Yi Jin
f77a07df1c Create a new stream option which generates field name to id mapping
recursively for all its submessages.

Also fix the wrong prefix for ro.build.version.XXX in proto.

It is safe to adjust proto number for now since it is not used yet.

Bug: 68774852
Test: atest incident_helper_test
Change-Id: I46e43a407da6efc393eb3c39733aaf25a5cceb13
2017-12-12 13:20:46 -08:00
Yi Jin
d04c00a479 Merge "Add AndroidTest.xml to incident_helper and incidentd" 2017-12-12 18:24:52 +00:00
Yi Jin
9299af9394 Refactor system properties protos to just include the list treble team
defines http://go/treble-sysprop-compatibility.

Also refactored system properties proto to have nested proto
definitions. The reason to do it is to have flat proto definition makes
it super hard to manage its field numbers as well as hard to use.
Since we have a predefined list. Support parsing nested proto here.

Bug: 68774852
Test: unit tested and on device test
      $ out/host/linux-x86/bin/incident_report -w system_properties
Change-Id: Icfc7cdcae184fb204c81e6434d21399aa84a1285
2017-12-11 15:05:25 -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
0dc7e54400 Merge "Implement Cpu Freq Section" 2017-11-20 19:34:15 +00: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
Yi Jin
0dfa752e67 Implement System Properties Section
Bug: 68774852
Test: unit tested and on device tests
Change-Id: I0d4aadf8d4203fe56e35bbfb77e5c532116fd27e
2017-11-14 10:54:24 -08:00
Yi Jin
e2f7f79d02 Implement Cpu Info Section
Support carriage return in Read class, and add a new way to parse lines
which is not able to split purly by delimiters

Bug: 65642861
Test: unit test and on device test
Change-Id: Ib82dd4e458bb7d2fa33462b23fbe11b828325916
2017-11-10 17:34:07 -08:00
Wei Wang
254102d858 Remove unnecessary parameter WriteStringToFile
By default, WriteStringToFile will not follow link, the 'false'
parameter is unnecessary.

Test: build
Change-Id: Ied6dcbf2a85533108dc2f6d71a4571b44684e800
2017-11-10 17:32:25 +00:00
Yi Jin
04625ad488 Refactor incident_helper to use protoutil and cppstream plugin.
1. Split the parsers to its own file to prevent all the parsers in one
gaint file.

2. Completely get rid of protobuf-cpp-full in incident_helper, use
ProtoOutputStream and cppstream instead, the incident_helper binary is
reduced from ~500K to ~113K.

3. Write data to protobuf even its values are zero/default, the reason
is for example we have a repeated int32 orders = 1; and people
explicitly append 0 so the total repeated field has 10 values, if zero
is not written to serialized data, this repeated field will only have 9
values which is not what we want at first place. This also aligns with
the default protobuf serialization behavior in incident_helper_test.

4. Use Android.bp for protoutil lib since it is not able to depend on
libs compiled by .mk file, it works the other way.

5. Add a new custom message option for streaming_proto, if specified,
the cppstream will create extra metadata to get field ids by field name.
A Table class is created in incident_helper to use it.

Bug: 67860303
Test: unit tested as well as on device test
Change-Id: I8e136fd15f343a4a623d20910ec64b622b478a3e
2017-10-31 16:54:38 -07:00
Yi Jin
810b14f5c2 Implement PageTypeInfo section
Bug: 65560369
Test: unit tests written, manually tested in incident_report tool
Change-Id: Ibb588fe3affc9675db4cfc2835eea31d1bbb701b
2017-09-14 11:47:44 -07:00
Yi Jin
99c248feb2 Implement PII Stripper, part 2
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
2017-09-07 10:53:51 -07:00
TreeHugger Robot
5748508642 Merge "Remove useless open modes" 2017-08-15 23:27:15 +00:00
George Burgess IV
f4160311dd Remove useless open modes
Previously, the machinery that detected these was only enabled in
optimized builds. We're expanding it to work in code built with -O0, as
well. Thus, we now get compile-time warnings about these calls (which
get turned into errors by -Werror).

Bug: 12231437
Test: Builds without warnings about useless mode bits in calls to open()
Change-Id: Icb1bc5f0a7941bb90d8581d6c3bde7cc076f3e01
2017-08-14 18:55:40 -07:00
Yi Jin
4ef28b7353 Use Descriptor and Reflection to set table-like data, in this case
protobuf-cpp-full is worth using.

Test: tested it locally by running the command in README.md
Change-Id: I1c38bd7fee6d914c4a579ed82b9be4a8177e45b9
2017-08-14 18:53:10 -07:00
Yi Jin
603f3b3c4f The proto field is set based on which header the data belongs to.
Bug: 64371071
Test: tested manually using native test
Change-Id: Ic7671041981d9a722ef00ce6c50cdb12b3e5414d
2017-08-07 15:55:10 -07:00
Yi Jin
b44f7d46b6 This cl implements CommandSection and use it to add procrank.proto Section
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
2017-08-02 16:33:17 -07:00
Yi Jin
0a3406fc4f This cl does the following things:
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
2017-07-24 11:50:33 -07:00