Add build id as part of bugreport name.
Rather than bugreport-DATE, the base bugreport name will be
bugreport-BUILD_ID-DATE, which will make it easier to identify
build associated with the report.
Since this change modifies the bugreport format, its version has been
increased to 'v1-dev4' and it is not enabled by default.
BUG: 27618668
Change-Id: I4492f8234520ee27c2eb0e4b8313fc937c498fea
diff --git a/cmds/dumpstate/bugreport-format.md b/cmds/dumpstate/bugreport-format.md
index 484f97f..d7837ae 100644
--- a/cmds/dumpstate/bugreport-format.md
+++ b/cmds/dumpstate/bugreport-format.md
@@ -26,16 +26,16 @@
is a failure, in which case it reverts to the flat file that is zipped by
**Shell** and hence the end result is the _v0_ format).
-The zip file is by default called _bugreport-DATE.zip_ and it contains a
-_bugreport-DATE.txt_ entry, although the end user can change the name (through
-**Shell**), in which case they would be called _bugreport-NEW_NAME.zip_ and
-_bugreport-NEW_NAME.txt_ respectively.
+The zip file is by default called _bugreport-BUILD_ID-DATE.zip_ and it contains a
+_bugreport-BUILD_ID-DATE.txt_ entry, although the end user can change the name (through
+**Shell**), in which case they would be called _bugreport-BUILD_ID-NEW_NAME.zip_ and
+_bugreport-BUILD_ID-NEW_NAME.txt_ respectively.
The zip file also contains 2 metadata entries generated by `dumpstate`:
- `version.txt`: whose value is **v1**.
- `main-entry.txt`: whose value is the name of the flat text entry (i.e.,
- _bugreport-DATE.txt_ or _bugreport-NEW_NAME.txt_).
+ _bugreport-BUILD_ID-DATE.txt_ or _bugreport-NEW_NAME.txt_).
`dumpstate` can also copy files from the device’s filesystem into the zip file
under the `FS` folder. For example, a `/dirA/dirB/fileC` file in the device
@@ -62,9 +62,9 @@
For example, the initial version during _Android N_ development was
**v1-dev1**. When `dumpsys` was split in 2 sections but not all tools were
-ready to parse that format, the version was named **v1-dev1-dumpsys-split**,
+ready to parse that format, the version was named **v1-dev2**,
which had to be passed do `dumpsys` explicitly (i.e., trhough a
-`-V v1-dev1-dumpsys-split` argument). Once that format became stable and tools
+`-V v1-dev2` argument). Once that format became stable and tools
knew how to parse it, the default version became **v1-dev2**.
Similarly, if changes in the file format are made after the initial release of
diff --git a/cmds/dumpstate/dumpstate.cpp b/cmds/dumpstate/dumpstate.cpp
index 30ddec3..883dce5 100644
--- a/cmds/dumpstate/dumpstate.cpp
+++ b/cmds/dumpstate/dumpstate.cpp
@@ -92,6 +92,7 @@
*/
// TODO: change to "v1" before final N build
static std::string VERSION_DEFAULT = "v1-dev3";
+static std::string VERSION_BUILD_ON_NAME = "v1-dev4";
/* gets the tombstone data, according to the bugreport type: if zipped gets all tombstones,
* otherwise gets just those modified in the last half an hour. */
@@ -939,8 +940,8 @@
" -B: send broadcast when finished (requires -o)\n"
" -P: send broadcast when started and update system properties on progress (requires -o and -B)\n"
" -R: take bugreport in remote mode (requires -o, -z, -d and -B, shouldn't be used with -P)\n"
- " -V: sets the bugreport format version (valid values: %s)\n",
- VERSION_DEFAULT.c_str());
+ " -V: sets the bugreport format version (valid values: %s, %s)\n",
+ VERSION_DEFAULT.c_str(), VERSION_BUILD_ON_NAME.c_str());
}
static void sigpipe_handler(int n) {
@@ -1092,7 +1093,7 @@
exit(1);
}
- if (version != VERSION_DEFAULT) {
+ if (version != VERSION_DEFAULT && version != VERSION_BUILD_ON_NAME) {
usage();
exit(1);
}
@@ -1145,6 +1146,11 @@
} else {
suffix = "undated";
}
+ if (version == VERSION_BUILD_ON_NAME) {
+ char build_id[PROPERTY_VALUE_MAX];
+ property_get("ro.build.id", build_id, "UNKNOWN_BUILD");
+ base_name = base_name + "-" + build_id;
+ }
if (do_fb) {
// TODO: if dumpstate was an object, the paths could be internal variables and then
// we could have a function to calculate the derived values, such as: