summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Li Li <dualli@google.com> 2022-11-18 12:00:45 -0800
committer Li Li <dualli@google.com> 2022-11-19 03:21:16 +0000
commitb81fa07b64ebaf82f582a56ea5de17c6d5c478da (patch)
treeb2d794e1fcd7197fdcdbc7673d2121aa50f6abc8
parent43550d92a4f720c0fcddbf01f5c63c456012f93f (diff)
Add killing subreason for undelivered broadcast
Bug: 239419108 Test: atest ApplicationExitInfoTest Test: atest BroadcastQueueTest Test: use up async buffer, broadcast & dumpsys activity exit-info Change-Id: I6a1b8c5a96963af624b8254753c8d8c364d0bc78
-rw-r--r--core/java/android/app/ApplicationExitInfo.java12
-rw-r--r--services/core/java/com/android/server/am/BroadcastQueueImpl.java5
-rw-r--r--services/core/java/com/android/server/am/BroadcastQueueModernImpl.java6
3 files changed, 19 insertions, 4 deletions
diff --git a/core/java/android/app/ApplicationExitInfo.java b/core/java/android/app/ApplicationExitInfo.java
index 5517c57d1f1e..871d15ec0b40 100644
--- a/core/java/android/app/ApplicationExitInfo.java
+++ b/core/java/android/app/ApplicationExitInfo.java
@@ -407,6 +407,15 @@ public final class ApplicationExitInfo implements Parcelable {
*/
public static final int SUBREASON_PACKAGE_UPDATE = 25;
+ /**
+ * The process was killed because of undelivered broadcasts; this would be set only when the
+ * reason is {@link #REASON_OTHER}.
+ *
+ * For internal use only.
+ * @hide
+ */
+ public static final int SUBREASON_UNDELIVERED_BROADCAST = 26;
+
// If there is any OEM code which involves additional app kill reasons, it should
// be categorized in {@link #REASON_OTHER}, with subreason code starting from 1000.
@@ -579,6 +588,7 @@ public final class ApplicationExitInfo implements Parcelable {
SUBREASON_STOP_APP,
SUBREASON_KILL_BACKGROUND,
SUBREASON_PACKAGE_UPDATE,
+ SUBREASON_UNDELIVERED_BROADCAST,
})
@Retention(RetentionPolicy.SOURCE)
public @interface SubReason {}
@@ -1283,6 +1293,8 @@ public final class ApplicationExitInfo implements Parcelable {
return "KILL BACKGROUND";
case SUBREASON_PACKAGE_UPDATE:
return "PACKAGE UPDATE";
+ case SUBREASON_UNDELIVERED_BROADCAST:
+ return "UNDELIVERED BROADCAST";
default:
return "UNKNOWN";
}
diff --git a/services/core/java/com/android/server/am/BroadcastQueueImpl.java b/services/core/java/com/android/server/am/BroadcastQueueImpl.java
index 8ece1807a2ae..1a72fef0683e 100644
--- a/services/core/java/com/android/server/am/BroadcastQueueImpl.java
+++ b/services/core/java/com/android/server/am/BroadcastQueueImpl.java
@@ -735,7 +735,7 @@ public class BroadcastQueueImpl extends BroadcastQueue {
+ " via " + app + ": " + ex;
Slog.w(TAG, msg);
app.killLocked("Can't deliver broadcast", ApplicationExitInfo.REASON_OTHER,
- true);
+ ApplicationExitInfo.SUBREASON_UNDELIVERED_BROADCAST, true);
}
throw ex;
}
@@ -1388,7 +1388,8 @@ public class BroadcastQueueImpl extends BroadcastQueue {
final String msg = "Failed to schedule " + r.intent + " to " + info
+ " via " + app + ": " + e;
Slog.w(TAG, msg);
- app.killLocked("Can't deliver broadcast", ApplicationExitInfo.REASON_OTHER, true);
+ app.killLocked("Can't deliver broadcast", ApplicationExitInfo.REASON_OTHER,
+ ApplicationExitInfo.SUBREASON_UNDELIVERED_BROADCAST, true);
} catch (RuntimeException e) {
Slog.wtf(TAG, "Failed sending broadcast to "
+ r.curComponent + " with " + r.intent, e);
diff --git a/services/core/java/com/android/server/am/BroadcastQueueModernImpl.java b/services/core/java/com/android/server/am/BroadcastQueueModernImpl.java
index ad5aa87b6a50..5d5dbbbed03f 100644
--- a/services/core/java/com/android/server/am/BroadcastQueueModernImpl.java
+++ b/services/core/java/com/android/server/am/BroadcastQueueModernImpl.java
@@ -831,7 +831,8 @@ class BroadcastQueueModernImpl extends BroadcastQueue {
final String msg = "Failed to schedule " + r + " to " + receiver
+ " via " + app + ": " + e;
logw(msg);
- app.killLocked("Can't deliver broadcast", ApplicationExitInfo.REASON_OTHER, true);
+ app.killLocked("Can't deliver broadcast", ApplicationExitInfo.REASON_OTHER,
+ ApplicationExitInfo.SUBREASON_UNDELIVERED_BROADCAST, true);
enqueueFinishReceiver(queue, BroadcastRecord.DELIVERY_FAILURE, "remote app");
}
} else {
@@ -858,7 +859,8 @@ class BroadcastQueueModernImpl extends BroadcastQueue {
} catch (RemoteException e) {
final String msg = "Failed to schedule result of " + r + " via " + app + ": " + e;
logw(msg);
- app.killLocked("Can't deliver broadcast", ApplicationExitInfo.REASON_OTHER, true);
+ app.killLocked("Can't deliver broadcast", ApplicationExitInfo.REASON_OTHER,
+ ApplicationExitInfo.SUBREASON_UNDELIVERED_BROADCAST, true);
}
}
// Clear so both local and remote references can be GC'ed