History log of /frameworks/native/cmds/dumpstate/dumpstate.h
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
b53a1c9b4df27a7a66c9448778eace166a0ce14c 17-Mar-2017 Naveen Kalla <mrnaveen@google.com> Add notification_title and notification_description to dumpstate

Initiator of dumpstate can set dumpstate.options.title and
dumpstate.options.description properties to notify dumpstate the details
that will be used to file a bug. dumpstate will send this information
along with the BUGREPORT_FINISHED intent.

Bug: 33561517
Test: Use the new API to invoke bugreport from TelephonyMonitor and
ensure that the bugreport is taken and title and description are
updated properly in the notification. Run dumpstate and
BugreportReceiver unit tests

Change-Id: Ia23a3ef4d5751be14f347ac38ef7c8a18f79799d
/frameworks/native/cmds/dumpstate/dumpstate.h
23ccc625fd60891d20977abc5f2c35cbe46142ac 28-Feb-2017 Elliott Hughes <enh@google.com> Move dumpstate to calling getprop.

There's no obvious reason for reinventing the wheel like this (given that
dumpstate already spends most of its time calling out to other utilities),
and I keep having to come and fix this code.

(This time the problem being that there's no longer a limit on system
property names.)

Bug: http://b/33926793
Test: ran dumpstate
Change-Id: I08281680df5aabfdb39228abf8c2aab089cc8b9e
/frameworks/native/cmds/dumpstate/dumpstate.h
8d2410eb937fdc27255b1129ed961463d64f847f 08-Feb-2017 Felipe Leme <felipeal@google.com> Explicitly sets Shell component on broadcast.

Change-Id: I11299885c300709d4b6c5a8b4d21bc31d96e2a62
Fixes: 34833915
Test: manual verification
Test: dumpstate_test passes
/frameworks/native/cmds/dumpstate/dumpstate.h
47e9be2d71c5eca9002e289c98e8bbc20dffc073 22-Dec-2016 Felipe Leme <felipeal@google.com> Moved DumpstateUtil.h functions to its own namespace.

Also make it a shared library.

Test: dumpstate_test passes
Test: manual verification

Bug: 26379932

Change-Id: I75dd3ef9fec3ac692a132bdd8c68307c1a1ee602
/frameworks/native/cmds/dumpstate/dumpstate.h
7440ddb786b7732478173fe142512dba4e2a8dfd 16-Dec-2016 Steven Moreland <smoreland@google.com> dumpstate: remove references to legacy dumpstate

Test: dumpstate_tests pass
Test: manual verification
Bug: 31982882

Change-Id: If48cccec2e334d54acf6f3a67098475d3122117a
/frameworks/native/cmds/dumpstate/dumpstate.h
cb7ef82aef52e766c45f65f446d02fd9356afea4 29-Nov-2016 Steven Moreland <smoreland@google.com> Use IVibrator hidl service in dumpstate.

Bug: 33067126
Test: Dumpstate vibrator works. dumpstate_test passes.
Change-Id: I9a87755f695829482d072e538e4938f35f393ae4
/frameworks/native/cmds/dumpstate/dumpstate.h
f029297f673ae06d219bd727a318a48b885db6fd 22-Nov-2016 Felipe Leme <felipeal@google.com> Even moar refactoring...

- Moved DumpstateUtil functions to its own .cpp file.
- Created a DumpstateInternal file.
- Moved properties setting to a PropertiesHelper class.
- Added title to functions that uses a FD.
- Moved Nanotime() out of DurationReporter.
- Restricted number of default CommandOptions constants.

BUG: 31982882
Test: manual verification
Test: dumpstate_test pass

Change-Id: Iab3e61594f6f7298484185f6f302472d31064f7d
/frameworks/native/cmds/dumpstate/dumpstate.h
46b85da716a32f285fe1222e9978beacc8697d09 22-Nov-2016 Felipe Leme <felipeal@google.com> Lotta of small dumpstate fixes...

- Fixed RunCommandToFd() so it respects DROP_ROOT.
- Renamed enums to be more consistent with fd model.
- Added tests to RunCommandToFd() and DumpFileToFd().
- Fixed RunCommandToFd() and DumpFileToFd(), which were rushed in.
- Disable tests that fail when running as suite.

BUG: 31982882
Test: manual verification
Test: dumpstate_tests pass

Change-Id: I1d8352a17be10a707a101fc1ac9c7d735e38f9fe
/frameworks/native/cmds/dumpstate/dumpstate.h
6f674aefab201fbf9141aabbb603bbfc84771927 19-Nov-2016 Felipe Leme <felipeal@google.com> Uses Dumpstate HIDL instead of dumpstate_board.

BUG: 31982882
Test: manual verification
Test: dumpstate_tests pass

Change-Id: I2d9a2658b52fba916984f0095edbd26ccd45a278
/frameworks/native/cmds/dumpstate/dumpstate.h
bda15a00929b836a53bf03473b1ec36285e5944b 17-Nov-2016 Felipe Leme <felipeal@google.com> Moved some functions to DumpstateUtil.h.

dumpstate_board() is been refactored into a HIDL interface, and the HIDL
implementations will need help functions to dump files and run commands into
a file descriptor.

BUG: 31982882
Test: dumpstate_test passes
Test: manual verification

Change-Id: I7a32f0ac236dae34fd85abe47bed0e52a34c5f36
/frameworks/native/cmds/dumpstate/dumpstate.h
009ecbbd3fcfd06735b0102f0342fc7e60166d9b 07-Nov-2016 Felipe Leme <felipeal@google.com> Deprecated system properties used to update progress:

- Uses just the binder listener.
- Don't send all updates to the listener.
- SetListener returns a token that can be used to watch for dumpstate death.

Bug: 31636879
Test: dumpstate_test passes

Change-Id: Ie73fa355809b3b628ee39d7c52ded4b99387b14d
/frameworks/native/cmds/dumpstate/dumpstate.h
7447d7c3d74b28f1a071b1d3503212cc8ad08d68 04-Nov-2016 Felipe Leme <felipeal@google.com> Save dumpstate duration stats so it can be tuned over time.

Fixes: 26373682
Test: dumpstate_test passes and manual verification

Change-Id: I72a308bfb314e157b12746c1be2c33833bdf9d8a
/frameworks/native/cmds/dumpstate/dumpstate.h
75876a2c0649b8cde36329ca0a1dc6e349af6493 28-Oct-2016 Felipe Leme <felipeal@google.com> Created a dumpstate service.

For now this is still a limited service:

- It's only created when running an interactive bugreport.
- It only provides a listener to get updates.
- It will be just used by Shell to get updates.

Test: dumpstate_test passes
BUG: 31636879

Change-Id: Iae820261d220523c979bf905030456fcf0b2b618
/frameworks/native/cmds/dumpstate/dumpstate.h
c6bc8bc4f05ad7d20e931944fb5042b578bc2e53 28-Oct-2016 Felipe Leme <felipeal@google.com> Encapsulates zip_writer_ on Dumpstate class.

BUG: 26379932
Test: DumpstateTest passes and manual verification of zip file.
Change-Id: I0113bec61cd32015fdd625afd2dca026bbf0ceab
/frameworks/native/cmds/dumpstate/dumpstate.h
062926ec7ccbd8cf4d49c98de742cdf3c338e275 28-Oct-2016 Felipe Leme <felipeal@google.com> Uses DISALLOW_COPY_AND_ASSIGN.

BUG: 26379932
Test: DumpstateTest passes

Change-Id: I544929fdd1f9777d6e2e6c602ca75d00fee358b9
/frameworks/native/cmds/dumpstate/dumpstate.h
e184f6610284ca80692d7e6789483375a7ca2f39 27-Oct-2016 Felipe Leme <felipeal@google.com> Add ANR traces to their own zip entries.

These files can be very large (O(20k) lines), so it makes more sense to
add them to their own zip entry.

Since this change could break tools that are expecting that section,
it's only enabled when setting the dumpstate version to 2.0-dev-1:

adb shell setprop dumpstate.version 2.0-dev-1

Test: DumpstateTest passes; manual verification
Bug: 32470528
Bug: 32064548

Change-Id: I4726b2209b15722c22defa87bffb24dc633d5bcd
/frameworks/native/cmds/dumpstate/dumpstate.h
d071c6802a03031b26de7b92a76d03849681149b 21-Oct-2016 Felipe Leme <felipeal@google.com> Sets dumpstate version using system properties.

Android N introduced a '-V' argument to change dumpstate's version, but
such argument can only be used when running dumpstate directly (as
root).
This CL uses a system property instead (dumpstate.version), so different
versions can be used while taking bugreports.

It also introduces a '-v' argument line to display the dumpstate header,
and removes the redundant dry_run check from _dump_file_from_fd().

Test: DumpstateTest passes
Change-Id: I46ec4bca133d16d8431358bb9f16eb89bb082be1
/frameworks/native/cmds/dumpstate/dumpstate.h
9a523aed06ef962f67385ac88191b08dc91059f4 21-Oct-2016 Felipe Leme <felipeal@google.com> Fixed variable names according to Google C++ style.

Trivia question: what do you get when Java developers refactor C into C++?
Anser: a_bigMess

BUG: 26379932

Test: DumpstateTest passes

Change-Id: I64c00f3b5953f077fb646cdc45a1656060a4b46e
/frameworks/native/cmds/dumpstate/dumpstate.h
1d486fe3847c831b9d57843cda209ed86853ee21 15-Oct-2016 Felipe Leme <felipeal@google.com> Refactor zip functions and state into Dumpstate class.

BUG: 26379932

Test: DumpstateTest passes

Change-Id: I8525b81c9239287a108aa6222048fa6171ddb15d
/frameworks/native/cmds/dumpstate/dumpstate.h
2b9b06ca7c54a6d7b6b2188dbd884b445b052d34 14-Oct-2016 Felipe Leme <felipeal@google.com> Minor dumpstate refactorings:

- Make some Dumpstate functions const.
- Renamed suffix_ to name_.

BUG: 26379932

Test: DumpstateTest passes

Change-Id: I324a6d63393f51ce27b2e95ce0e23296d97c328d
/frameworks/native/cmds/dumpstate/dumpstate.h
bbaf3c11c4723be0f6b56ef603e11b0baaa92429 11-Oct-2016 Felipe Leme <felipeal@google.com> Minor changes on dumpstate refactoring:

- Moved more attributes into Dumpstate class.
- Created a GetPath() method that encapsulates bugreportDir_.
- Moved TakeScreenshot() into Dumpstate class.
- Uses DropRoot() on TakeScreenshot().

BUG: 26379932

Test: mmm -j32 frameworks/native/cmds/dumpstate/ && adb push ${ANDROID_PRODUCT_OUT}/data/nativetest/dumpstate_test* /data/nativetest && adb shell /data/nativetest/dumpstate_test/dumpstate_test

Change-Id: I2d96460f9244d4e257a215e2fb1f00dfd466e059
/frameworks/native/cmds/dumpstate/dumpstate.h
d80e6b6109c52d57ebba675c1f97fcb2ca1d93c5 03-Oct-2016 Felipe Leme <felipeal@google.com> Moar Dumpstate refactoring and unit testing:

- Moves UpdateProgress() into Dumpstate object.
- Tests RunCommand.AsRoot().
- Tests RunCommand.DropRoot().
- Test update progress.

BUG: 26379932
BUG: 31807540
Test: mmm -j32 frameworks/native/cmds/dumpstate/ && adb push ${ANDROID_PRODUCT_OUT}/data/nativetest/dumpstate_test* /data/nativetest && adb shell /data/nativetest/dumpstate_test/dumpstate_test
Change-Id: I364d097487e090d201eb2e5f08fc794dce555510
/frameworks/native/cmds/dumpstate/dumpstate.h
fd8affa8840d2d9f7f320201521a702919c677ff 01-Oct-2016 Felipe Leme <felipeal@google.com> Moar tests for RunCommand:

- Command not found.
- Command returns non-0 status (and fixed return of RunCommand).
- Command times out.
- Command is killed.
- Command crashes.
- Command logs initial message.

BUG: 31807540
Test: mmm -j32 frameworks/native/cmds/dumpstate/ && adb push ${ANDROID_PRODUCT_OUT}/data/nativetest/dumpstate_test* /data/nativetest && adb shell /data/nativetest/dumpstate_test/dumpstate_test
Change-Id: I6459846791e45f4ebc4433b83feec81be4050167
/frameworks/native/cmds/dumpstate/dumpstate.h
4c2d66379753e2b7680811726424026b9e54b18a 28-Sep-2016 Felipe Leme <felipeal@google.com> Added initial tests for dumpstate.

BUG: 31807540
Test: mmm -j32 frameworks/native/cmds/dumpstate/ && adb push ${ANDROID_PRODUCT_OUT}/data/nativetest/dumpstate_test* /data/nativetest && adb shell /data/nativetest/dumpstate_test/dumpstate_test

Change-Id: If5497784052b8d13d7c856f9400dbcd8c2015d05
/frameworks/native/cmds/dumpstate/dumpstate.h
c7fe8fe5b525a1a071af92f3ebbeef2f6d4b06af 22-Sep-2016 Felipe Leme <felipeal@google.com> Deprecate run_command() and dump_file().

This change will break dumpstate_board() implementations that were not
refactored to use the equivalent functions in the Dumpstate
class. For example:

void dumpstate_board() {
dump_file("INTERRUPTS", "/proc/interrupts");
run_command("SUBSYSTEM TOMBSTONES", 5, SU_PATH, "root",
"ls", "-l", "/data/tombstones/ramdump", NULL);

}

Should be refactored to:

void dumpstate_board(){
Dumpstate& ds = Dumpstate::GetInstance();

ds.DumpFile("INTERRUPTS", "/proc/interrupts");
ds.RunCommand("SUBSYSTEM TOMBSTONES",
{"ls", "-l", "/data/tombstones/ramdump"},
CommandOptions::AS_ROOT_5);
}

BUG: 26379932
Test: manual / refactored code

Change-Id: Ia74515cc57abc18bc6966a5aed71dd679422fd0e
/frameworks/native/cmds/dumpstate/dumpstate.h
6ad9c06d9e2d3706ffdd0dcb943c8e877edf5ec6 28-Sep-2016 Felipe Leme <felipeal@google.com> Fixed and improve RunCommand() when running as root.

Improved it by not try to run 'su root' on user builds.
Fixed the logic that creates the args.

BUG: 29319732
BUG: 26379932
Test: manual

Change-Id: I6b39abc8ee907f638905913425218c0a50d767c6
/frameworks/native/cmds/dumpstate/dumpstate.h
678727af1ae44fe40a6d70fb175f8acfdb5d83d9 22-Sep-2016 Felipe Leme <felipeal@google.com> Moar C++ refactoring.

- Use std::string on runCommand(), DurationReport, dumpFile() and their
dependencies.
- Moves runCommand() and dumpFile() to Dumpstate class.

These 2 commands are the only ones currently used on dumpstate_board() implementations.

BUG: 26379932
Test: manual / refactored code

Change-Id: I09072d4e183851f90c07960d1f971a925ea2c801
/frameworks/native/cmds/dumpstate/dumpstate.h
e844a9d60a54c7dd6dbf0a8f44167b484324d08d 22-Sep-2016 Felipe Leme <felipeal@google.com> Initial work on a Dumpstate class.

dumpstate used to be a C binary that had to be "converted" to C++ in
order to use the zip_writer library, but it still keeps most of its C
idioms.

This change is the first step towards a new Dumpstate class; for now, it
just moves the state defined on dumpstate.h to it.

BUG: 26379932
Test: manual / refactored code

Change-Id: Ie689b87c4469a8951c35f3e642d7faa0722b0c03
/frameworks/native/cmds/dumpstate/dumpstate.h
5bcce574840ffc58916f6fa9beb39739b51508e6 27-Sep-2016 Felipe Leme <felipeal@google.com> Fix dumpsys timeouts.

Both dumpstate and dumpsys can timeout when a child process hangs;
usually these values match, except when running dumpsys to dump all
services, in which case we need a timeout for all services (90s) and
individual timeouts for each service (10s).

BUG: 26379932
Test: manual
Change-Id: I37129ba9980976aa9bfe8eb132cdd0870fd93e59
/frameworks/native/cmds/dumpstate/dumpstate.h
b0f669de54ffe3ef59f3597faf2b4885793853cf 27-Sep-2016 Felipe Leme <felipeal@google.com> Fixed C++ style on refactored function and variable names.

As described on
https://google.github.io/styleguide/cppguide.html#Function_Names :

"Ordinarily, functions should start with a capital letter and have a
capital letter for each new word (a.k.a. "upper camel case" or "Pascal
case")."

and

"Data members of classes (but not structs) additionally have trailing underscores. "

BUG: 26379932
Test: manual

Change-Id: I4b7f34b941c99547af667316d4b7d5e2749827d0
/frameworks/native/cmds/dumpstate/dumpstate.h
0bcc7caad03eed6190255591edc09a7ab3e5a7f3 14-Sep-2016 Felipe Leme <felipeal@google.com> Refactored dump_file() into dumpFile().

Also added a duration report for dumpstate_board().

BUG: 26379932
Test: manual

Change-Id: If80bb9699162ecb80715ef46c6ee039eb22ba6b7
/frameworks/native/cmds/dumpstate/dumpstate.h
30dbfa1c5fac2d8cbd5bc2e41616be9353c81733 02-Sep-2016 Felipe Leme <felipeal@google.com> Refactored run_command functions.

Back in the day, dumpstate.c had a simple run_command() function. Then on
Android N, dumpstate.c became dumpstate.cpp and that function multiplied into:

- run_command()
- run_command_as_shell()
- run_command_always()

Not only these 3 commands were pretty much copy-and-pasted, but they
didn't take advantage of C++ features (such as std::vector and
std::string).

This CL refactor them into a single runCommand() function that takes an
optional CommandOptions argument to set its behavior. Examples:

// Run as shell
runCommand("DUMPSYS MEMINFO", {"meminfo", "-a"},
CommandOptions::WithTimeout(90).DropRoot().Build());

// Run always, as shell
runCommand(nullptr, am, CommandOptions::WithTimeout(20).Build());

The legacy run_command() is still available since it's used by
device-specific dumpstate_board() implementations, but it will
eventually go away as well.

This change also:
- Refactored run_dumpsys() into runDumpsys().
- Added a .clang-format file (initially equals to dumpsys's).
- Renamed the variable names on those commands according to the style guide.

BUG: 26379932
Test: manual

Change-Id: Ie045eb2fb825e68088d231129044c59e61450d99
/frameworks/native/cmds/dumpstate/dumpstate.h
fd55a75bad077c62f76afdec85399dbe0a2f629a 11-Sep-2016 Chih-Hung Hsieh <chh@google.com> Merge "Fix google-explicit-constructor warnings in dumpstate." am: a70396971e am: 347b6f4c35 am: 666cd74e59
am: 4c8a923d4a

Change-Id: Ic8d133110bf9959c090042853bf2cce3a741b176
4c8a923d4a1f0c37361d19045ad4a89f829e75fd 11-Sep-2016 Chih-Hung Hsieh <chh@google.com> Merge "Fix google-explicit-constructor warnings in dumpstate." am: a70396971e am: 347b6f4c35
am: 666cd74e59

Change-Id: Ie02f5e2a30c5df43ce0d088f93e73c981537d792
759af114976862b2d75737f4f5752ae61231b9aa 01-Sep-2016 Chih-Hung Hsieh <chh@google.com> Fix google-explicit-constructor warnings in dumpstate.

* Add explicit keyword to conversion constructors.
Bug: 28341362
Test: build with WITH_TIDY=1

Change-Id: I61a0e9a8a38a09c1e33a479c3111c45c5fe7483d
/frameworks/native/cmds/dumpstate/dumpstate.h
35c94f3c4aa99b8ad099349d3b7b70e98e72a54b 12-Aug-2016 Felipe Leme <felipeal@google.com> Created constant for maximun number of args.

BUG: 26379932
Change-Id: I839f6e3f90010ee35bc5d40e96218e9c95afdf4e
/frameworks/native/cmds/dumpstate/dumpstate.h
d402e7dfe02e5097d1e7e62346953db3808b18cc 03-Aug-2016 Felipe Leme <felipeal@google.com> Refactored use of ON_DRY_RUN macros.

BUG: 26379932
Change-Id: Ie032d468540da3c4ac0df1ea2d88a0aac4c722a7
/frameworks/native/cmds/dumpstate/dumpstate.h
8268ed2d1c5afb1a29dfdafdcea82a8a52166b90 03-Aug-2016 Felipe Leme <felipeal@google.com> Uses a system property to set dry-run mode.

On Android N, dumpstate was using a #define to set dry-run mode, which
allows dumpstate to run much faster, which in turn is useful when
developing new dumpstate features.

The drawback of this approach is that it requires modifying dumpstate.h
locally, building a new binary, and re-redeploying it in the device; a
better and more flexible approach is to use a system
property (dumpstate.dry_run) so developers can enable /disable it during
runtime.

Change-Id: I41d1e6ae3fa6ca2be23887f59d5ad4e9df7c10e6
Fixes: 30604041
/frameworks/native/cmds/dumpstate/dumpstate.h
1b99fe95ffc7daeab51902863cca7a42b507392e 28-Jul-2016 Felipe Leme <felipeal@google.com> Added a -p option to bugreportz to show progress. am: 02b7e00c1e am: a12c863892
am: 84b0adaed4

Change-Id: Ib80ab3a5547c516dbd4b20b9f10931f069d7a84f
02b7e00c1e1b0bf22997ab7ed913a9451e5b6b8a 22-Jul-2016 Felipe Leme <felipeal@google.com> Added a -p option to bugreportz to show progress.

BUG: 28609499

Change-Id: I1e60078dfda7e5679fbd19f4981a5dc7a69c4fc7
/frameworks/native/cmds/dumpstate/dumpstate.h
0f3fb20cff288f2874c46c9f4102c6c9f273a0a3 11-Jun-2016 Felipe Leme <felipeal@google.com> Adds dumpstate log file to bugreport zip.

BUG: 29276583

Change-Id: I1e1346cbeb117f9945fbb0aa138986d9e791ae4f
/frameworks/native/cmds/dumpstate/dumpstate.h
249beee359da256f7c41c481d45c06765b6a1d8a 04-Jun-2016 Calvin On <con@google.com> Expose more useful functions that can be used by dumpstate_board().

BUG: 28640932
Fixes: 28867848
Change-Id: I38123e5b348f4560212559176eb60dbad4f22364
/frameworks/native/cmds/dumpstate/dumpstate.h
71ca15eadd3da0c102a8539f7a88294a94456623 20-May-2016 Felipe Leme <felipeal@google.com> Expose functions used to add entries to the zip file.

Currently only dumpstate.cpp is using the new functions and variables
used to add an entry to the zip file so they're defined locally, but
they should be exposed through the .h so they can be used by the
device-specific dumpstate_board() implementations.

This CL moves the following definitions to the .h:

- bugreport_dir
- ZIP_ROOT_DIR
- add_zip_entry()
- add_zip_entry_from_fd()

It also refactored functions that were taking a specific file location
to use bugreport_dir instead, to avoid pollution on main().

BUG: 28867848
Change-Id: Ic5faa203b0863bc950d640f22fb91977e52b6bfc
/frameworks/native/cmds/dumpstate/dumpstate.h
2628e9e939fda323fa44c5cb743f4a77b12a312a 13-Apr-2016 Felipe Leme <felipeal@google.com> Added support for 'bugreport -z'.

Dumpstate now supports zipped bugreport, whose output is more complete
than the flat-file bugreports provided prior to N.

The whole workflow is split in different components:

- adb supports a 'bugreport -z <ZIP_FILE>' option, which calls a
bugreportz binary.
- bugreportz starts the dumpstatez service.
- dumpstatez starts dumpstate with some flags that opens a socket for
control (not output).
- Once dumpstate is finished, it prints the bugreport location to
stdout.
- adb pulls the zip file and renames according to the command-line
argument.
- bugreport prints a deprecation message.

The reason for a new binary (bugreportz) instead of passing arguments to
bugreport (like -z) is backward compatibility: pre-N versions of
bugreport would ignore such argument and generate a text bugreport,
which is not what adb would be expecting.

BUG: 27653204

Change-Id: I47f6f677eba11d5fb54818ae5a0b3cab069776ee
/frameworks/native/cmds/dumpstate/dumpstate.h
29c39715b8a45ca2e97aecd8ebb63183f63da72b 01-Apr-2016 Felipe Leme <felipeal@google.com> Added option to redirect stdout on run_command_always.

There are cases where a command should not write to stdout. For example,
when sending the initial broadcast before the header is printed.

This change adds this option to run_command_always, and uses enums to
make it easier to read what's been passed to it.

BUG: 27953643

Change-Id: I9aed0cb0df4112b31d2079241114e206b9d0bb0c
/frameworks/native/cmds/dumpstate/dumpstate.h
faf67e3fe2451e75d0369906a579d3e1386a5064 28-Mar-2016 Felipe Leme <felipeal@google.com> Increased estimated max progress of bugreports.

The initial estimate was based on earlier work done before new sections
were added, and it was too slow.

Ideally we should have a per-device estimate, but for N we'll just
increase the common max.

BUG: 26373682
Change-Id: I1a8ce7f09fc6588ac1513a20fa1149aab8c38351
/frameworks/native/cmds/dumpstate/dumpstate.h
7363bafd0a94aa98a267edbbcb27abc9ef72f1dd 21-Mar-2016 Felipe Leme <felipeal@google.com> Merge "Don't use su to when calling am or dumpsys." into nyc-dev
71a74ac75c8687195d27642fa0db31a796102c59 17-Mar-2016 Felipe Leme <felipeal@google.com> Capture systrace buffers.

When tracing is enabled (/sys/kernel/debug/tracing/tracing_on = 1),
dumpstate will run 'atrace --async_dump' and redirect its output to a
systrace.txt entry in the zip file.

BUG: 27419521
Change-Id: Ia6de46a691b25febac31331fe0aa8701c9a84ebb
/frameworks/native/cmds/dumpstate/dumpstate.h
cf6a8b47dc04f1c33ddc337b5e21f2c5b7354cb5 11-Mar-2016 Felipe Leme <felipeal@google.com> Don't use su to when calling am or dumpsys.

su is not available on user builds anymore, hence the bugreport
notifications would never be sent on those builds. Instead, it should
explicitly drop root using system calls.

BUG: 27583193
Change-Id: Ia6256b241fdd6ab4c059fb764b10b4445ad6551d
/frameworks/native/cmds/dumpstate/dumpstate.h
a34efb7ae17a7ea1078cce75be634120bd72a421 11-Mar-2016 Felipe Leme <felipeal@google.com> Improve logging of child commands.

When execvpe() is called it doesn't return, so the child error handling
should be done at the parent, otherwise the failure is not printed in the bugreport.

BUG: 27583193
Change-Id: I6161e4c72b7b0da7b82bff7fd72d7a5aaf4d6e89
/frameworks/native/cmds/dumpstate/dumpstate.h
88c7933df551f6dadd8cc931d104b01d6d1609e4 22-Feb-2016 Felipe Leme <felipeal@google.com> Improved dumpstate logging.

BUG: 26906985
Change-Id: Id439560504a365961337fddcca4ba6c1ef9f377d
/frameworks/native/cmds/dumpstate/dumpstate.h
60869c9e1e91170d487715fc30b795d786630c54 10-Feb-2016 Felipe Leme <felipeal@google.com> Fixed C++ syntax.

Change-Id: I9702fdede589dd37cb498bbf63c0773816a7e3b8
/frameworks/native/cmds/dumpstate/dumpstate.h
a297c3258f6f7ea52cc2dcc42d62f85fda12a163 06-Feb-2016 Mark Salyzyn <salyzyn@google.com> dumpstate: report process times

(cherry picked from commit 0751efa64cddfab69749236193e776058c9db595)

- Fix per-pid helper to pick up comm if cmdline is empty
and assume kernel thread.
- Add per pid report command line user time if not kernel thread,
system time and I/O time, plus percentage if non zero.

Bug: 26966375
Change-Id: I6b499f535cc3687eb468b32ae39e7d151dffb11f
/frameworks/native/cmds/dumpstate/dumpstate.h
cbce55d4fdbdd2e5a5515054c48d2116c5db2712 08-Feb-2016 Felipe Leme <felipeal@google.com> Improved dumpstate logging.

dumpstate generates 3 types of output:

- stdout: used for the bugreport itself and is redirected to a file
if requested.
- stderr: used for errors, is only useful when dumpstate is called from
adb (otherwise is ignored).
- ALOG: logged into logcat and available in the bugreport.

This current approach has 2 problems:

- stderr output is ignored when dumpstatet is called from bugreport
services.
- bugs on dumpstate are often hard to diagnose
(AKA 'Who watches the watchmen?').

This change mitigates these problems by redirecting stderr into a log
file (which will also be included in the bugreport notification) and by
keeping the .tmp file around (for the extreme cases where the .zip file
could not be generated or got corrupted).

BUG: 26906985
Change-Id: I73e7b1dd10ad9f83b7aa1043131ff3b74c426fdb
/frameworks/native/cmds/dumpstate/dumpstate.h
111b9d06cc0fc72438782c9234f28675e5077ef4 03-Feb-2016 Felipe Leme <felipeal@google.com> Improved how the Shell directories are created.

When dumpstate is run for the first time, the
/data/data/com.android.shell/files/bugreports does not exist, which was
crashing dumpstate because the code that added the version.txt entry was
not checking if the zip_writer was NULL.

The crash itself was fixed by adding a sanity check in the functions
that add entries to the zip file, but that only hid the real problem:
it is necessary to create the parent directories before creating the zip
file, otherwise the first run will always generate a .txt file (since
dumpstate falls back to .txt when it cannot create the .zip).

This change also improves how the parent directories are created by
checking if they exist first, rather than always calling mkdir().

BUG: 26949960

Change-Id: I1434be5c36a3fad0b3a2a26c7eaaab03a1228c30
/frameworks/native/cmds/dumpstate/dumpstate.h
608385dd151e36a93f3e3f4a7514b1e720d20ae9 01-Feb-2016 Felipe Leme <felipeal@google.com> Redirect output to file ASAP, otherwise printf() calls might be missed.

Also removed the duraction reporter on add_zip_entry_from_fd - since it
was spamming the report and the timing could be infered by calculating the
delta between each ALOGD entry anyways - and logged PID and statistics.

BUG: 26885492
Change-Id: Iadb00957daac68b7a40b0e36ee5cce2b82264588
/frameworks/native/cmds/dumpstate/dumpstate.h
0c80cf0caaf5dce5ef4d0265b249bd1ec680cca1 05-Jan-2016 Felipe Leme <felipeal@google.com> Adds all tombstone files when writing to zipped file.

Currently, a bugreport simply cats any tombstone file modified in the
last half an hour into the bugreport. This is a problem since the
tombstones contain a lot of really valuable information, and sometimes
users don't get a bugreport in this time frame. In addition, some of our
monkey testing has the same problem.

Since now dumpstate can create a zip file, we can include all directly
on it, although still using the old mechanism when it's creating it (for example, when invoked through 'adb bugreport').

BUG: 25974224
Change-Id: Ie29fd7d91953d91232b0db1c9588043aee13f93e
/frameworks/native/cmds/dumpstate/dumpstate.h
78f2c86235d5882a8dc84c85a1c1864062e5f3af 21-Dec-2015 Felipe Leme <felipeal@google.com> Prints out how long it takes to generate each section.

It's done using a DurationReporter helper class that prints starts
counting when constructed and prints the duration when destructed.

Typical usage:

function do_something() {
DurationReporter duration_reporter(title);
// Do something.
}

Change-Id: I87134d9a1b003300384376c242a3c034a46244c4
/frameworks/native/cmds/dumpstate/dumpstate.h
f55d402132afa4b9dd38aa69e50ec7b7efb1927c 11-Dec-2015 Mark Salyzyn <salyzyn@google.com> resolve merge conflicts of 01c1129fe6 to master.

Change-Id: I84f862b4858ecc97461750833a0e6f9cf96c34c4
8c8130eb68c89987a94db084608a4229bad06c18 09-Dec-2015 Mark Salyzyn <salyzyn@google.com> dumpstate: Dump eMMC 5.0 stats

Extended csd EXT_CSD_REV, PRE_EOL_INFO, DEVICE_LIFE_TIME_EST_TYP_A,
and DEVICE_LIFE_TIME_EST_TYP_B fields printed if available. Allow
dumpstate access to /sys/kernel/debug/mmc0/mmc0:0001/ext_csd.

Bug: 24200279
Change-Id: I310bdcf546a9307cf927f109359ad5a6d24b70f8
/frameworks/native/cmds/dumpstate/dumpstate.h
3634a1e3459cb609da709646107e246cafbc01f9 09-Dec-2015 Felipe Leme <felipeal@google.com> Fixed logic that was passing NULL to a std::string parameter and
crashing dumpstate.

BUG: 8420215
Change-Id: If2f3ebad559683b5b6a8c2209de93ac3bec4fb1e
/frameworks/native/cmds/dumpstate/dumpstate.h
e338bf60701e5b955ab0a097f2631f2190218894 07-Dec-2015 Felipe Leme <felipeal@google.com> Take screenshot right away when invoked with -P.

Traditionally, the screenshot was not taken right away because it could
skew other services like the Surface Flinger, and such approach often
resulted on irrelevant screenshots.

Now there is more user-friendly workflow, where the bugreport progress
is shown in the UI and the user can take further actions. In this
workflow, it's ok to take the screeshot right away, since the other
features might already be causing interference: if the user doesn't want
interference, the old workflow should be used instead.

Since the new workflow requires the -P (for Progress) parameter, such
parameter can also be used to determine when to take the screenshot.

Also added progress statistics at the end of the bugreport.

BUG: 8420215
Change-Id: I9dad8ea59d47848f217182ccec0f527b42e07f50
/frameworks/native/cmds/dumpstate/dumpstate.h
ad5f6c475934ac6a658a203069a9f055540946e7 30-Nov-2015 Felipe Leme <felipeal@google.com> Minor improvements in the bugreport progress workflow:

- Allow users to rename the suffix in the bugreport files by setting the
dumpstate.pid.name system property. For example, instead of
bugreport-2015-12-02-15-23-46, it could be bugreport-My-App-Crashed.

- Dynamically adjust the max weight if the current progress overflows
the previous max (and set the dumpstate.pid.max system property
accordingly, so UI can be updated as well).

- Strip .txt from the name sent on BUGREPORT_STARTED.

BUG: 25794470
Change-Id: I7634ddd2975bcf93d6612d16c09da1cd7b4e1d91
/frameworks/native/cmds/dumpstate/dumpstate.h
71bbfc57974331dce79242ce806d92035fce06ba 23-Nov-2015 Felipe Leme <felipeal@google.com> Adds a -P option so dumpstate can report its progress.

The old workflow was:

1. dumpstate starts.
2. When dumpstate finishes, it sends a BUGREPORT_FINISHED event.
3. Shell's BugreportReceiver receives the BUGREPORT_FINISHED and issues a
system notification so user can share the bug report.

The new workflow is:

1. When dumpstate starts, it sends a BUGREPORT_STARTED with its pid and
the estimated total effort.
2. When Shell's BugreportReceiver receives the BUGREPORT_STARTED, it:
2.1 Issues a system notification so user can watch the
progresss (which is 0% initially).
2.2 Starts a service (BugreportProgressService) responsible for
polling the dumpstate progress (using system properties and the
pid) and updating the system notification.
3. As dumpstate progress, it updates the proper system property.
4. When dumpstate finishes, it sends a BUGREPORT_FINISHED event.
5. When Shell's BugreportReceiver receives the BUGREPORT_FINISHED, it:
5.1 Finishes the service if necessary.
5.2 Issues a system notification so user can share the bug report.

This CL handles the dumpstate changes only, the Shell changes will be
handled in a separate CL.

BUG: 25794470
Change-Id: I6e04203411802c88ab0d093420ccdfd26700d565
/frameworks/native/cmds/dumpstate/dumpstate.h
36b3f6ff17e456dea81501006e33d5fdd1d3b480 20-Nov-2015 Felipe Leme <felipeal@google.com> Allow broadcasting of bug reports without a screenshot.

BUG: 25751868
Change-Id: Ideaa6c549f639aa64b30225147b2fad6c5f2d556
/frameworks/native/cmds/dumpstate/dumpstate.h
ed24d2ae2cd6e8b0afb86efa555f18bcfaf74a64 12-Nov-2015 Christopher Ferris <cferris@google.com> Fix a few bugs related to dumping files.

Fixes:

- Fix double print of header in dump_file.

- Fix a few possible file descriptor leaks.

- Add /d/ as another directory which should be skipped when printing out
last mod time of a file.

- Fix possible crash if the path passed to _dump_file_from_fd is less than
the length of one of the directory checks.

Change-Id: I450dfab76fd0ce4d4dca9ed39c82a980054f3cc3
/frameworks/native/cmds/dumpstate/dumpstate.h
93d705b6d742e8f00167ff2384e35c2205a6f9da 11-Nov-2015 Felipe Leme <felipeal@google.com> Add option to #define _DUMPSTATE_DRY_RUN_ to skip the actual dumps.

Such option is useful when debugging dumpstate itself, since it will
finish much sooner and its output will be much smaller.

Change-Id: If821ed21715461bf82eea0b2be4b926239ad69da
/frameworks/native/cmds/dumpstate/dumpstate.h
8620bb4118a68721d10c29529dc6978847d08d00 10-Nov-2015 Felipe Leme <felipeal@google.com> Migrated dumpstate to C++.

Changes required:

- Explicity casting function pointers.
- Moving variables initialization before 'goto' statements.
- Changing string references from 'char *' to 'const char *'.
- Using 'extern "C"' so device-dependent implementation of
'dumpstate_board()' can be written in C or C++.

BUG: 25563823
Change-Id: I5712c2adbe181c6d17983cbb136b17757900b4ba
/frameworks/native/cmds/dumpstate/dumpstate.h
326842fca4883f1256aa9ed019bb3206ee76fca7 30-Apr-2015 Mark Salyzyn <salyzyn@google.com> dumpstate: report per-partition MMC performance

(Cherry pick from commit 540e3de99fa1baa5eaf3eb3d49f4e98fd9f5bd91)

Change-Id: If5cabe186d8377056effa1c0672a90e277cd7221
/frameworks/native/cmds/dumpstate/dumpstate.h
123edd9f812c93973de923397f2a5cb6fdaa4135 26-Feb-2015 Christopher Ferris <cferris@google.com> resolved conflicts for merge of 04e13acd to master

Change-Id: I9bbc9907a5cbde8b374398493bc0dc6b056ea734
54bcc5ffd5a79f4f194089c58d3de571532bf39b 10-Feb-2015 Christopher Ferris <cferris@google.com> Add timeout for dump_file.

It turns out dump_file is used on a number of /proc and system files.
In one case, the read of a file stalled and caused a bugreport to
hang forever. It's still possible if there is a kernel bug that this
could stall forever, but less likely.

Also, change the return type of nanotime to uint64_t.

Testing:
- Created a named fifo and verified that dump_file fails with a timeout.
- Created a large /data/anr/traces.txt to verify that large files still
dump properly and that the additional NONBLOCK parameter doesn't cause
a problem.
- Created a dummy /data/tombstones/tombstone_00 to verify that the
dump of these files still works.
- Compared a dump using the old dumpstate to the new dumpstate to verify
nothing obviously different.

Bug: 19117030
Change-Id: I0d3dd27583c853cdaccd2fd278748cb5f9ccd4fb
/frameworks/native/cmds/dumpstate/dumpstate.h
d527bcbc10b1fb6b998b94bbac7bfbfd3a9efdf6 17-Feb-2015 Svetoslav <svetoslavganov@google.com> Remove unnecessary settings state dump.

The settings provider now implements dump, hance special dump
code is no longer needed.

Change-Id: I93af3f6acac4ac70d6bbf569d2348cb16b8c0946
/frameworks/native/cmds/dumpstate/dumpstate.h
ff4a4dc7e6e3ead12020b4dc17548d767a419dde 10-Feb-2015 Christopher Ferris <cferris@google.com> Remove -z option.

This option doesn't work with the current selinux protections and
doesn't serve much of a purpose. You can get the same results running
this:

dumpstate | gzip > /data/local/tmp/dump.txt.gz

Bug: 19271141
Change-Id: Icc76200df33dc708e30c556ec8a0f393f995fe7c
/frameworks/native/cmds/dumpstate/dumpstate.h
672e3a51bd12d6d89078b4eb452199398334c800 24-Jul-2014 Christopher Ferris <cferris@google.com> resolved conflicts for merge of e8878921 to lmp-dev-plus-aosp

Change-Id: I930dda54336a3f6d694cec06299f09e3580671a0
1fe6107b66516b225e0843836d60a69b1b57f3c3 23-Jul-2014 Christopher Ferris <cferris@google.com> Add dumping of tombstones to dumpstate.

Dump only those tombstones modified within the last half an hour.

Change-Id: I8ce836b2e19eba7a9c0c31a4f312f9a382526da7
/frameworks/native/cmds/dumpstate/dumpstate.h
a055fd358bd64f5d49e7957fc8aeb83b170787e9 14-Jul-2014 Sreeram Ramachandran <sreeram@google.com> resolved conflicts for merge of 0d2bee0c to lmp-dev-plus-aosp

Change-Id: If782ce04be50e2154cec232c9e9d60fe38f41831
2b3bba34aec65b612be8d1f52cd124d9c30955f9 09-Jul-2014 Sreeram Ramachandran <sreeram@google.com> Dump all the correct routing tables.

The list of tables is maintained in /data/misc/net/rt_tables by netd.

Change-Id: I55475c08c5e43bcf61af916210e680c47480ac32
/frameworks/native/cmds/dumpstate/dumpstate.h
5ecd4beef8f10f91febf916414c65d3d0e1cf734 29-Jan-2014 John Spurlock <jspurlock@google.com> Dump system settings for all users

Change-Id: Ic832b19fe698da1984876b2949c3f26990ae5076
/frameworks/native/cmds/dumpstate/dumpstate.h
0c22e8b31651caf12a2b4d4acef5bc65d486e570 02-Nov-2012 Colin Cross <ccross@android.com> dumpstate: dump all threads in show_wchan

for_each_pid only finds processes and not their threads. Add
for_each_tid and call it for show_wchan so we can see where all
threads are blocked in the kernel.

Change-Id: Iffb59f7c2933cecf51cdd358a36e19932c2f24c7
/frameworks/native/cmds/dumpstate/dumpstate.h
bf7f49238d0af497d4300f7e611cf831854d6434 08-Jun-2012 Jeff Brown <jeffbrown@google.com> Include stack traces for certain native processes in bugreport.

Bug: 6615693
Change-Id: I64c3b3ce0bba62d9c332a795f7d979fb753dc27b
/frameworks/native/cmds/dumpstate/dumpstate.h
f45fa6b2853cc32385375a0b63ee39ad6a968869 26-Mar-2012 Colin Cross <ccross@android.com> move dumpstate and dumpsys from frameworks/base to frameworks/native

Change-Id: I8a5318022ce5cd3e7c8055f21fe5da74639aa6c0
/frameworks/native/cmds/dumpstate/dumpstate.h