From e40ab122a16cafab2c4a25fec7dc44b35dd4f2eb Mon Sep 17 00:00:00 2001 From: Jeff Sharkey Date: Mon, 26 Sep 2022 15:05:47 -0600 Subject: [PATCH] BroadcastQueue: more exception details. Help understand more about CannotDeliverBroadcastException. Bug: 236556314 Test: atest FrameworksMockingServicesTests:BroadcastQueueTest Change-Id: I0dfeea12c7da1a5a2c33400ed9016b18c313a6e2 --- .../com/android/server/am/BroadcastQueueImpl.java | 14 ++++++++------ .../server/am/BroadcastQueueModernImpl.java | 12 +++++++----- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/services/core/java/com/android/server/am/BroadcastQueueImpl.java b/services/core/java/com/android/server/am/BroadcastQueueImpl.java index 5848011a508dd..645836b831de2 100644 --- a/services/core/java/com/android/server/am/BroadcastQueueImpl.java +++ b/services/core/java/com/android/server/am/BroadcastQueueImpl.java @@ -732,9 +732,10 @@ public class BroadcastQueueImpl extends BroadcastQueue { } catch (RemoteException ex) { // Failed to call into the process. It's either dying or wedged. Kill it gently. synchronized (mService) { - Slog.w(TAG, "Can't deliver broadcast to " + app.processName - + " (pid " + app.getPid() + "). Crashing it."); - app.scheduleCrashLocked("can't deliver broadcast", + final String msg = "Failed to schedule " + intent + " to " + receiver + + " via " + app + ": " + ex; + Slog.w(TAG, msg); + app.scheduleCrashLocked(msg, CannotDeliverBroadcastException.TYPE_ID, /* extras=*/ null); } throw ex; @@ -1379,9 +1380,10 @@ public class BroadcastQueueImpl extends BroadcastQueue { processCurBroadcastLocked(r, app); return; } catch (RemoteException e) { - Slog.w(TAG, "Exception when sending broadcast to " - + r.curComponent, e); - app.scheduleCrashLocked("can't deliver broadcast", + final String msg = "Failed to schedule " + r.intent + " to " + info + + " via " + app + ": " + e; + Slog.w(TAG, msg); + app.scheduleCrashLocked(msg, CannotDeliverBroadcastException.TYPE_ID, /* extras=*/ null); } catch (RuntimeException e) { Slog.wtf(TAG, "Failed sending broadcast to " diff --git a/services/core/java/com/android/server/am/BroadcastQueueModernImpl.java b/services/core/java/com/android/server/am/BroadcastQueueModernImpl.java index a13f48728374c..d6884633521e5 100644 --- a/services/core/java/com/android/server/am/BroadcastQueueModernImpl.java +++ b/services/core/java/com/android/server/am/BroadcastQueueModernImpl.java @@ -628,9 +628,10 @@ class BroadcastQueueModernImpl extends BroadcastQueue { app.mState.getReportedProcState()); } } catch (RemoteException e) { - Slog.w(TAG, "Failed to schedule " + r + " to " + receiver - + " via " + app + ": " + e); - app.scheduleCrashLocked(TAG, CannotDeliverBroadcastException.TYPE_ID, null); + final String msg = "Failed to schedule " + r + " to " + receiver + + " via " + app + ": " + e; + Slog.w(TAG, msg); + app.scheduleCrashLocked(msg, CannotDeliverBroadcastException.TYPE_ID, null); app.setKilled(true); finishReceiverLocked(queue, BroadcastRecord.DELIVERY_FAILURE); } @@ -655,8 +656,9 @@ class BroadcastQueueModernImpl extends BroadcastQueue { r.resultCode, r.resultData, r.resultExtras, false, r.initialSticky, r.userId, app.mState.getReportedProcState()); } catch (RemoteException e) { - Slog.w(TAG, "Failed to schedule result of " + r + " via " + app + ": " + e); - app.scheduleCrashLocked(TAG, CannotDeliverBroadcastException.TYPE_ID, null); + final String msg = "Failed to schedule result of " + r + " via " + app + ": " + e; + Slog.w(TAG, msg); + app.scheduleCrashLocked(msg, CannotDeliverBroadcastException.TYPE_ID, null); } } }