From ae48859e88ea4570a1a8fcb0d0fcae8f1a66a172 Mon Sep 17 00:00:00 2001 From: Evan Laird Date: Fri, 2 Jun 2023 10:10:21 -0400 Subject: [PATCH] [Dumpsys CLI] Remove Exception bounds on LogBufferEulogizer LogBufferEulogizer previously used `` as a generic bound for its `record` method, but that doesn't seem necessary, since any `Throwable` would work. The method is used in situ when an exception is being handled, so that the handler can record the exception and still throw it. This change relaxes the bounds to `Throwable` and removes the one place that was filterig out non-exception throwables in SystemUIService. Test: all sysui tests Bug: 278094048 Change-Id: I6f7d1309890724c1e2d335602dd9706bac4f5aa4 --- .../SystemUI/src/com/android/systemui/SystemUIService.java | 7 ++----- .../src/com/android/systemui/dump/LogBufferEulogizer.kt | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/SystemUIService.java b/packages/SystemUI/src/com/android/systemui/SystemUIService.java index ba3c8602c6ff6..6cf9eff1da2f4 100644 --- a/packages/SystemUI/src/com/android/systemui/SystemUIService.java +++ b/packages/SystemUI/src/com/android/systemui/SystemUIService.java @@ -82,11 +82,8 @@ public class SystemUIService extends Service { mLogBufferFreezer.attach(mBroadcastDispatcher); // Attempt to dump all LogBuffers for any uncaught exception - mUncaughtExceptionPreHandlerManager.registerHandler((thread, throwable) -> { - if (throwable instanceof Exception) { - mLogBufferEulogizer.record(((Exception) throwable)); - } - }); + mUncaughtExceptionPreHandlerManager.registerHandler( + (thread, throwable) -> mLogBufferEulogizer.record(throwable)); // If configured, set up a battery notification if (getResources().getBoolean(R.bool.config_showNotificationForUnknownBatteryState)) { diff --git a/packages/SystemUI/src/com/android/systemui/dump/LogBufferEulogizer.kt b/packages/SystemUI/src/com/android/systemui/dump/LogBufferEulogizer.kt index 25b90bebf0d12..bd43302a8bb51 100644 --- a/packages/SystemUI/src/com/android/systemui/dump/LogBufferEulogizer.kt +++ b/packages/SystemUI/src/com/android/systemui/dump/LogBufferEulogizer.kt @@ -72,7 +72,7 @@ class LogBufferEulogizer( * The file will be prefaced by the [reason], which will then be returned (presumably so it can * be thrown). */ - fun record(reason: T): T { + fun record(reason: T): T { val start = systemClock.uptimeMillis() var duration = 0L