summaryrefslogtreecommitdiff
path: root/packages/Shell/src
diff options
context:
space:
mode:
author Yeabkal Wubshit <yeabkal@google.com> 2021-04-07 23:59:51 -0700
committer Josh Yang <yzj@google.com> 2021-11-16 22:19:24 +0000
commitc4e31b8d9ebd24be625a91b097810483e1df51d0 (patch)
treee5b62c9a7b38f3e2894ae1ced5a79354413e12ff /packages/Shell/src
parentfbeb7661a5379b58655ddb75a4528d30f1b1a681 (diff)
Support adding System Traces to Wear Bugreports
System Traces collected with the native System Tracing App (Traceur) are now added under a separate directory (systraces) for Wear bugreports. Note that this change is functionally no-op for non-Wear form-factors (changes only one log's wordings for non-Wear form-factors). Bug: 183239853 Test: manual Change-Id: Id6b9aa0d38a0d465b763ec86fb1192875379431c (cherry picked from commit 7111510c691ccf20baf372dab5cea2ac30ae0c23)
Diffstat (limited to 'packages/Shell/src')
-rw-r--r--packages/Shell/src/com/android/shell/BugreportProgressService.java44
1 files changed, 41 insertions, 3 deletions
diff --git a/packages/Shell/src/com/android/shell/BugreportProgressService.java b/packages/Shell/src/com/android/shell/BugreportProgressService.java
index 8c7011253c8a..c4386490b109 100644
--- a/packages/Shell/src/com/android/shell/BugreportProgressService.java
+++ b/packages/Shell/src/com/android/shell/BugreportProgressService.java
@@ -198,6 +198,15 @@ public class BugreportProgressService extends Service {
*/
private static final String BUGREPORT_DIR = "bugreports";
+ /**
+ * The directory in which System Trace files from the native System Tracing app are stored for
+ * Wear devices.
+ */
+ private static final String WEAR_SYSTEM_TRACES_DIRECTORY_ON_DEVICE = "data/local/traces/";
+
+ /** The directory that contains System Traces in bugreports that include System Traces. */
+ private static final String WEAR_SYSTEM_TRACES_DIRECTORY_IN_BUGREPORT = "systraces/";
+
private static final String NOTIFICATION_CHANNEL_ID = "bugreports";
/**
@@ -1352,6 +1361,16 @@ public class BugreportProgressService extends Service {
}
}
+ /** Returns an array of the system trace files collected by the System Tracing native app. */
+ private static File[] getSystemTraceFiles() {
+ try {
+ return new File(WEAR_SYSTEM_TRACES_DIRECTORY_ON_DEVICE).listFiles();
+ } catch (SecurityException e) {
+ Log.e(TAG, "Error getting system trace files.", e);
+ return new File[]{};
+ }
+ }
+
/**
* Adds the user-provided info into the bugreport zip file.
* <p>
@@ -1371,8 +1390,17 @@ public class BugreportProgressService extends Service {
Log.wtf(TAG, "addDetailsToZipFile(): no bugreportFile on " + info);
return;
}
- if (TextUtils.isEmpty(info.getTitle()) && TextUtils.isEmpty(info.getDescription())) {
- Log.d(TAG, "Not touching zip file since neither title nor description are set");
+
+ File[] systemTracesToIncludeInBugreport = new File[] {};
+ if (mIsWatch) {
+ systemTracesToIncludeInBugreport = getSystemTraceFiles();
+ Log.d(TAG, "Found " + systemTracesToIncludeInBugreport.length + " system traces.");
+ }
+
+ if (TextUtils.isEmpty(info.getTitle())
+ && TextUtils.isEmpty(info.getDescription())
+ && systemTracesToIncludeInBugreport.length == 0) {
+ Log.d(TAG, "Not touching zip file: no detail to add.");
return;
}
if (info.addedDetailsToZip || info.addingDetailsToZip) {
@@ -1383,7 +1411,10 @@ public class BugreportProgressService extends Service {
// It's not possible to add a new entry into an existing file, so we need to create a new
// zip, copy all entries, then rename it.
- sendBugreportBeingUpdatedNotification(mContext, info.id); // ...and that takes time
+ if (!mIsWatch) {
+ // TODO(b/184854609): re-introduce this notification for Wear.
+ sendBugreportBeingUpdatedNotification(mContext, info.id); // ...and that takes time
+ }
final File dir = info.bugreportFile.getParentFile();
final File tmpZip = new File(dir, "tmp-" + info.bugreportFile.getName());
@@ -1404,6 +1435,13 @@ public class BugreportProgressService extends Service {
}
// Then add the user-provided info.
+ if (systemTracesToIncludeInBugreport.length != 0) {
+ for (File trace : systemTracesToIncludeInBugreport) {
+ addEntry(zos,
+ WEAR_SYSTEM_TRACES_DIRECTORY_IN_BUGREPORT + trace.getName(),
+ new FileInputStream(trace));
+ }
+ }
addEntry(zos, "title.txt", info.getTitle());
addEntry(zos, "description.txt", info.getDescription());
} catch (IOException e) {