134 Commits

Author SHA1 Message Date
joker.yang
6955f0c97e Always use a positive value for timestamp
on go device when try to get timestamp, the value over-followed sometimes
as a result, GtsIncidentManagerTestCases would fail due to a negative timestamp

Bug: 142513252
Change-Id: I7d5e701bb8bf4e788a718e093681f97b95cb8551
2019-12-18 21:31:01 -08:00
Jiyong Park
573fd3dfe0 unique_fd is passed by value in AIDL interfaces
FileDescriptor type in AIDL was translated into const unique_fd& in C++.
Now, it is unique_fd, i.e. passed by value, to make it easier to keep it
beyond the scope of the call.

Bug: 144943748
Test: m

Exempt-From-Owner-Approval: cherry-pick from internal

Merged-In: I2b87761401361f9cf96cdda070f26e70a5c6c935
(cherry picked from commit b8ba23418aa6868ec14e82c29311021e382a19bc)
Change-Id: I2b87761401361f9cf96cdda070f26e70a5c6c935
2019-12-18 05:32:25 +00:00
Xin Li
6f48900f50 DO NOT MERGE - qt-qpr1-dev-plus-aosp-without-vendor@5915889 into stage-aosp-master
Bug: 142003500
Change-Id: If5056a73ede668b0048ca107b686413695e5b3b6
2019-10-30 14:33:01 -07:00
Tom Cherry
d02698938e Remove legacy logger_entry_v* structs
These are obsolete so we move all users to a single format.

Test: build, logging unit tests
Change-Id: I05ebb0b9135c61585ff103d24b785b9f21197257
2019-10-24 10:56:34 -07:00
Mike Ma
262a3b0009 Merge "Add an API to dump incident report for dumpstate" am: a11beeca12 am: af1f91a133
am: 3343814a57

Change-Id: I2d4bfdf8537adf1541a78c264a36f95e1384af71
2019-09-23 21:40:26 -07:00
Mike Ma
15f83a3118 Add an API to dump incident report for dumpstate
Instead of just relying on the regular iteration through the system
services inside dumpstate, add another API to IIncidentManager
dedicated for dumpstate.

- It is only callable by dumpstate() (check the calling uid)
- It has the same behavior as the current call inside dump()

Advantages:
- More explicit function name, right next to takeIncidentReport will
  make it easier to keep them in sync.
- Nobody else can call it, make security easier.
- If dumpstate calls it explicitly, it can skip the 10 second timeout
- The regular dump() call should provide debugging data about
  incidentd itself, for example timestamps for the most recent N
  incident reports taken and the current state of the work directory,
  allowing us to debug incidentd itself.

Bug: 137493082
Test: Manually trigger a bug report, and verify
      /proto/incident_log.proto in the zip file.

Change-Id: I19139c765b53ede63d3beb3ea3ac40ada1aba42d
Merged-In: I19139c765b53ede63d3beb3ea3ac40ada1aba42d
2019-09-23 16:20:53 -07:00
Roman Kiryanov
bf069a495b Merge "Fix integer overflow in make_timestamp_ns_locked" into qt-qpr1-dev
am: 1d20f2096c

Change-Id: I963c419c063447a54b35aa1dff282cd058368af7
2019-08-23 20:55:09 -07:00
Roman Kiryanov
9872a4d42b Fix integer overflow in make_timestamp_ns_locked
timespec::tv_sec is time_t which is 32bit wide on
32bit platforms. Multipliyng 32bit integers (tv_sec and
1000) produces another 32bit integer which overflows
in this case and turns into a negative value which
confuses the logic downstream. This change makes the
multiplication to be 64bit which prevent the overflow.

Bug: 139320584
Bug: 139538727
Test: GtsIncidentManagerTestCases
Change-Id: Ie956074961c7c1f08e2519920f7ce69d5c9e12d3
Signed-off-by: Roman Kiryanov <rkir@google.com>
(cherry picked from commit e9db937f4008f097f4ee9dc341a3afc219a96fd9)
2019-08-22 22:46:54 +00:00
Colin Cross
dfa50902b8 Adapt to google::protobuf::int64 type change
Protobuf 3.9.1 redefines google::protobuf::int64 from long long
to int64_t, which is sometimes long and sometimes long long.  Use
PRIi64 to print it.  Also temporarily cast to int64_t to decouple
this change from the change that updates protobuf.

Bug: 117607748
Test: m checkbuild
Change-Id: I482b957d2262e5001140ed1153c7de2b17facae2
2019-08-14 16:32:22 -07:00
Ryan Savitski
cc7d9973c6 userdebug: support perfetto traces as a section in incident reports
This set of patches adds a way for the perfetto command line client to
save a trace to a hardcoded location,
/data/misc/perfetto-traces/incident-trace, and call into incidentd to
start a report, which will include said trace in a new section.

This is not a long-term solution, and is structured to minimize changes
to perfetto and incidentd. The latter is currently architected in a way
where it can only pull pre-defined information out of the system, so
we're resorting to persisting the intermediate results in a hardcoded
location.

This will introduce at most two more linked files at the same time.

Bug: 130543265
Tested: manually on crosshatch-userdebug
Merged-In: Iaaa312d2d9da73ca329807211227a8c7a049102c
Change-Id: Iaaa312d2d9da73ca329807211227a8c7a049102c
(cherry picked from commit 09a847902fa428f97841c3689b9f11243cc60460)
2019-06-07 18:13:56 +01:00
Joe Onorato
f7c2bceafe Do not include specific_mention sections in bugreports either.
Test: adb bugreport & manually verify
Bug: 134583922
Change-Id: I6b4df17fc729f78e70e126882bce611a33c8ef9a
2019-06-05 11:57:39 -07:00
Yao Chen
318296726d Increase the size limit of incident reports.
Bug: 133425862
Test: incidentd_test
Change-Id: I323878958a93e0280b782de1745ed59e44f79b0b
2019-05-23 21:31:25 +00:00
Yao Chen
a8a18f6d32 Merge "Remove encryption from incidentd" into qt-dev 2019-05-08 21:31:04 +00:00
Joe Onorato
12a704dfb4 Update owners files
Test: none
Bug: 12345
Change-Id: I3e42ce95abca629259608209e5865c76cc01b231
2019-05-01 18:04:24 +00:00
Yao Chen
a51f3fa6fe Remove encryption from incidentd
Test: build
Bug: 131371777

Change-Id: I412c73658025246004412f3bcdcf30f74d766326
2019-04-30 11:51:24 -07:00
Joe Onorato
e547205eec Get incidentd cts working again.
- 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
2019-04-26 17:44:10 -07:00
Joe Onorato
7a406b47eb Don't include restricted images in incident reports unless they're 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
2019-04-26 16:00:05 -07:00
Yao Chen
35be60eb22 Disable incidentd encryption.
Bug: 131332217
Test: manually tested
Change-Id: If98d73978eb06a616e89025fcd615750976406e1
2019-04-25 11:52:10 -07:00
Yao Chen
43706b4470 Add encryption in incidentd.
+ 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
2019-04-23 15:20:38 -07:00
Yao Chen
9f433c8509 Fix a bug in ProtoFileReader.
Classic and consuming

Bug: 131037240
Test: unit test added in incidentd_test
Change-Id: I9200122ed35e874ef453eb12adc7fbf28c22003e
2019-04-21 20:10:27 -07:00
Yao Chen
cbafce94c9 Add metadata and headers to incident reports.
+ 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
2019-04-02 16:12:10 -07:00
Joe Onorato
20a0d1309b Raise the max section size of an incident report to 24 mb
Test: bit GtsIncidentManagerTestCases:*
Bug: 123543706
Change-Id: If46fb3c3972b0367e57e6dcb49edd9e3fe834a98
2019-03-28 11:05:55 -07:00
Joe Onorato
fe7bbf410c incidentd sections for userdebug and eng are compiled out
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
2019-03-27 00:23:20 -07:00
Joe Onorato
99598ee6ee incidentd can now handle multiple callers asking it for incident reports
Test: bit incident_test:* GtsIncidentManagerTestCases:*
Bug: 123543706
Change-Id: I9f671dd5d8b2ad139f952a23e575c2be16120459
2019-03-26 11:20:48 -07:00
Yao Chen
ec216489fc Remove the IncidentHeaderProto dependency from statsd.
+ IncidentReportArgs takes the bytes instead of IncidentHeaderProto object

This cl is the ag/6287053 + build fix.

Test: incidentd_test && statsd_test
Change-Id: I86bcb48f4ab212b36ca4611a1fa05faace9c3702
2019-02-07 09:45:13 -08:00
Chih-hung Hsieh
b708a7953d Merge "Fix/suppress incident* google-explicit-constructor warnings" am: 6af0e228f3 am: 78085ba0a3
am: ee844ad9a2

Change-Id: I53c2fd3886e565d824e2765671fb7965f07bd08d
2018-12-21 09:24:28 -08:00
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
Mike Ma
db32e713b1 Merge "Change owners of incidentd" am: 349377724e am: 069da8fef7
am: 829a76321a

Change-Id: I55204af015da0db2157343a3a2f1a280190e0c19
2018-12-06 18:07:59 -08:00
Mike Ma
61b65dc245 Change owners of incidentd
Test: NA
Change-Id: Ic651a13bb145610de2b668b6b235228e1e5151c1
2018-12-06 13:44:44 -08:00
Mike Ma
3505666137 Remove deprecated cutils/log.h
Test: build
Change-Id: I6f9b400173618bdf31ddbd8eacedea62669dfa27
2018-12-06 13:34:21 -08:00
Mike Ma
28381694ab Refine incidentd error handling and logging
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
2018-12-05 19:04:57 -08:00
Mike Ma
85434ec8ca Implement dumpsys for incident service
Implement dump() function in IncidentService so that it can be dumped by
default. Dumpstate calls it twice, one with and one without '--proto'.
dump() ignores the former.
Dumpsys allows 10s max for each service. Hence, section 1200, 1201, 1202
are skipped because they take too long. Section 3008 and 3015 are
skipped temporarily due to errors. All sections should be enabled once
we find a workaround.
A follow-up change in SELinux is needed to allow dumpstate to access
incidentd.

Bug: 119417232
Test: Run `adb shell dumpsys incident --proto`, inspect result and logs
Test: Run `adb bugreport`, make sure incident.proto is in the zip file
      Check the proto for validity via aprotoc:
      cat incident.proto | ./out/soong/host/linux-x86/bin/aprotoc --decode_raw
Exempt-From-Owner-Approval: The original owners no longer work on this
                            project.
Change-Id: I7d08f6b644cb6751b201fb7ba37ac5e1c42fd3c5
2018-12-03 07:52:50 +00:00
Mark Salyzyn
adc63f02b3 Merge changes I664fb325,I5e289469 am: 701001688f am: 833a491fab
am: beea2153ab

Change-Id: Ifd30d79d06e4e80103ff2f09b0ae960ceb8bc7f9
2018-11-19 13:46:31 -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
Mark Salyzyn
7751045a3a Remove unused reference to android-base/test_utils.h
Test: compile
Bug: 119313545
Change-Id: I5e289469b40ccf5bf17982197a3cdefad1254f78
2018-11-14 15:53:27 -08:00
Bookatz
da9b8d0ad1 Incidentd: Fix switch break warnings
A few switches didn't have explicit breaks in them, which was causing
warnings. They were all benign, as the logic did not necessitate a
break. But this is will stop the warnings and perhaps prevent future
bugs.

Change-Id: Idb293a4896f4df8d3f11d748e0e716efc26bbd6a
Fixes: 119047812
Test: N/A
2018-11-14 13:35:30 -08:00
Colin Cross
05c9e5c24a Convert statsd and incidentd to Android.bp
See build/soong/README.md for more information.

Test: m checkbuild
Merged-In: I8c80878cec46c9299234c6f4c1e0e19efc0a221e
Change-Id: I8c80878cec46c9299234c6f4c1e0e19efc0a221e
2018-10-31 08:01:59 -07:00
Colin Cross
bc2dc31c4d Convert statsd and incidentd to Android.bp
See build/soong/README.md for more information.

Fixes: 110563449
Test: m checkbuild
Change-Id: I8c80878cec46c9299234c6f4c1e0e19efc0a221e
2018-10-30 13:30:23 -07:00
Chih-Hung Hsieh
e1afb6cb29 Allow implicit-fallthrough warnings locally.
It will be a global error by default.
Cherry pick lost changes from AOSP, for Android.mk and main.cpp.

Test: make checkbuild
Bug: 112564944
Change-Id: I6f1024fa5e31302af27fa9d5bac195e511f4ba20
Exempt-From-Owner-Approval: do not block on new warnings
2018-10-22 12:25:50 -07:00
Chih-Hung Hsieh
8767a4ede6 Allow implicit-fallthrough warnings locally.
It will be a global error by default.

Test: make checkbuild
Bug: 112564944
Change-Id: Ib23d0cc8b95a3734d5bd28f8c9d967df669cfdf8
Exempt-From-Owner-Approval: do not block on new warnings
2018-10-19 12:13:48 -07:00
Treehugger Robot
935f97ade5 Merge "Handling potential SIGPIPE signals." 2018-09-29 07:39:04 +00:00
Kweku Adams
4d4a23306a Handling potential SIGPIPE signals.
There are cases where dumping Java traces times out and then later tries
to write to a closed pipe, causing incidentd to crash. This introduces a
handler for the SIGPIPE signal so it doesn't crash due to a closed pipe.

Bug: 111729299
Test: lower section timeout to 5 seconds and make sure incident service
doesn't crash

Change-Id: I868aba1ae21a50ae76977e0e09e782cf94198473
(cherry picked from commit 5b763c13472effa7df25cc53a44d5bdae9392410)
2018-09-18 18:55:19 -07:00
TreeHugger Robot
027a559172 Merge "Handling potential SIGPIPE signals." 2018-09-19 00:48:42 +00:00
Kweku Adams
10e38c9432 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
(cherry picked from commit 0f7167947a6e3180da0964ec6187f9f01642fb6d)
2018-09-14 16:54:32 -07:00
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
Kweku Adams
5b763c1347 Handling potential SIGPIPE signals.
There are cases where dumping Java traces times out and then later tries
to write to a closed pipe, causing incidentd to crash. This introduces a
handler for the SIGPIPE signal so it doesn't crash due to a closed pipe.

Bug: 111729299
Test: lower section timeout to 5 seconds and make sure incident service
doesn't crash

Change-Id: I868aba1ae21a50ae76977e0e09e782cf94198473
2018-09-13 15:47:49 -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
Kweku Adams
71a9531806 Adding batterystats history to proto dump.
It will only print out a dump for userdebug or eng builds.

Bug: 77727638
Test: flash device and check output of incident proto and
'dumpsys batterystats -c --history'

Merged-In: Ib74d4c664f23a61e6fc33f700ba6a3c6fad32c74
Change-Id: Ia0c993d1281cc350d93f9c13f5540b349a4bfb84
2018-05-07 17:53:57 -07:00