summaryrefslogtreecommitdiff
path: root/packages/Shell/src
diff options
context:
space:
mode:
author Josh Yang <yzj@google.com> 2022-01-11 17:33:44 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2022-01-11 17:33:44 +0000
commitf9965004c05e7018fd232d0e53b24b702bb3eaba (patch)
tree0676ec3f7aaf7d4594c1dc0278175d1e6b916add /packages/Shell/src
parentebe021a6182467678843dc0f58cb43a47fdc437f (diff)
parentc4e31b8d9ebd24be625a91b097810483e1df51d0 (diff)
Merge "Support adding System Traces to Wear Bugreports"
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 ee9d4301770a..a08997f36530 100644
--- a/packages/Shell/src/com/android/shell/BugreportProgressService.java
+++ b/packages/Shell/src/com/android/shell/BugreportProgressService.java
@@ -199,6 +199,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";
/**
@@ -1456,6 +1465,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>
@@ -1475,8 +1494,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) {
@@ -1487,7 +1515,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());
@@ -1508,6 +1539,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) {