From 66c017e708ff43001576e1544983f8f547147520 Mon Sep 17 00:00:00 2001 From: Matt Pietal Date: Fri, 5 May 2023 14:01:49 +0000 Subject: [PATCH] Capture all remote exceptions A surface may no longer be available on callback, which results in a Throwable exception. We've seen this mainly during tests. Capture and log the exception to prevent a crash. Fixes: 277481883 Test: manual Change-Id: Ie121aec4f1ff58cff432b94120efae00bdb97268 --- .../android/systemui/keyguard/KeyguardViewMediator.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java index b5ddc2ea91b79..552e5ea967cf2 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java +++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java @@ -2941,9 +2941,12 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable, if (mSurfaceBehindRemoteAnimationFinishedCallback != null) { try { mSurfaceBehindRemoteAnimationFinishedCallback.onAnimationFinished(); + } catch (Throwable t) { + // The surface may no longer be available. Just capture the exception + Log.w(TAG, "Surface behind remote animation callback failed, and it's probably ok: " + + t.getMessage()); + } finally { mSurfaceBehindRemoteAnimationFinishedCallback = null; - } catch (RemoteException e) { - e.printStackTrace(); } } }