From 93059d2f0b1d742606650d2e8d610180082b25f3 Mon Sep 17 00:00:00 2001 From: Robin Lee Date: Wed, 25 Mar 2020 23:48:39 +0100 Subject: [PATCH] Take interactive bugreports on Android TV We want to take a screenshot immediately, not after dumpsys finished. This also gives the user some feedback that we took a screenshot when they were paying attention, whereas the notification might go under the radar if posted the 30-90 seconds later it will be shown otherwise. Also gives us the progress notification in the Android TV notification tray, which helps the user keep track of what is going on and how long it is expected to take. Previously either no feedback was shown at all on key press, or a simple Toast was shown on selecting the bugreport option from the TV Settings app. Test: Press DPAD_CENTER + BACK, observe screenshot and progress. Fix: 151865303 Change-Id: I78753697a7867042d28364a6b6d61fdb96f8bc96 --- .../com/android/shell/BugreportProgressService.java | 10 ++++++---- .../com/android/server/policy/PhoneWindowManager.java | 6 +++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/packages/Shell/src/com/android/shell/BugreportProgressService.java b/packages/Shell/src/com/android/shell/BugreportProgressService.java index 0ae00e1ac8b5a..0278294b6ea54 100644 --- a/packages/Shell/src/com/android/shell/BugreportProgressService.java +++ b/packages/Shell/src/com/android/shell/BugreportProgressService.java @@ -617,7 +617,7 @@ public class BugreportProgressService extends Service { return; } ParcelFileDescriptor screenshotFd = null; - if (isDefaultScreenshotRequired(bugreportType)) { + if (isDefaultScreenshotRequired(bugreportType, /* hasScreenshotButton= */ !mIsTv)) { screenshotFd = info.getDefaultScreenshotFd(); if (screenshotFd == null) { Log.e(TAG, "Failed to start bugreport generation as" @@ -652,10 +652,12 @@ public class BugreportProgressService extends Service { } private static boolean isDefaultScreenshotRequired( - @BugreportParams.BugreportMode int bugreportType) { + @BugreportParams.BugreportMode int bugreportType, + boolean hasScreenshotButton) { // Modify dumpstate#SetOptionsFromMode as well for default system screenshots. - // We override dumpstate for interactive bugreports. - return bugreportType == BugreportParams.BUGREPORT_MODE_FULL + // We override dumpstate for interactive bugreports with a screenshot button. + return (bugreportType == BugreportParams.BUGREPORT_MODE_INTERACTIVE && !hasScreenshotButton) + || bugreportType == BugreportParams.BUGREPORT_MODE_FULL || bugreportType == BugreportParams.BUGREPORT_MODE_WEAR; } diff --git a/services/core/java/com/android/server/policy/PhoneWindowManager.java b/services/core/java/com/android/server/policy/PhoneWindowManager.java index 1e1256547f2ca..791a857c181be 100644 --- a/services/core/java/com/android/server/policy/PhoneWindowManager.java +++ b/services/core/java/com/android/server/policy/PhoneWindowManager.java @@ -692,7 +692,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { accessibilityShortcutActivated(); break; case MSG_BUGREPORT_TV: - requestFullBugreportOrLaunchHandlerApp(); + requestBugreportForTv(); break; case MSG_ACCESSIBILITY_TV: if (mAccessibilityShortcutController.isAccessibilityShortcutAvailable(false)) { @@ -3030,13 +3030,13 @@ public class PhoneWindowManager implements WindowManagerPolicy { return mAccessibilityTvScheduled; } - private void requestFullBugreportOrLaunchHandlerApp() { + private void requestBugreportForTv() { if ("1".equals(SystemProperties.get("ro.debuggable")) || Settings.Global.getInt(mContext.getContentResolver(), Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0) == 1) { try { if (!ActivityManager.getService().launchBugReportHandlerApp()) { - ActivityManager.getService().requestFullBugReport(); + ActivityManager.getService().requestInteractiveBugReport(); } } catch (RemoteException e) { Slog.e(TAG, "Error taking bugreport", e);