diff options
-rw-r--r-- | core/java/android/app/ActivityThread.java | 14 | ||||
-rw-r--r-- | core/java/android/os/StrictMode.java | 17 | ||||
-rw-r--r-- | services/java/com/android/server/am/ActivityManagerService.java | 3 |
3 files changed, 34 insertions, 0 deletions
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java index 7315f01..47efddb 100644 --- a/core/java/android/app/ActivityThread.java +++ b/core/java/android/app/ActivityThread.java @@ -1781,6 +1781,17 @@ public final class ActivityThread { performNewIntents(data.token, data.intents); } + private static final ThreadLocal<Intent> sCurrentBroadcastIntent = new ThreadLocal<Intent>(); + + /** + * Return the Intent that's currently being handled by a + * BroadcastReceiver on this thread, or null if none. + * @hide + */ + public static Intent getIntentBeingBroadcast() { + return sCurrentBroadcastIntent.get(); + } + private final void handleReceiver(ReceiverData data) { // If we are getting ready to gc after going to the background, well // we are back active so skip it. @@ -1820,6 +1831,7 @@ public final class ActivityThread { + ", dir=" + packageInfo.getAppDir()); ContextImpl context = (ContextImpl)app.getBaseContext(); + sCurrentBroadcastIntent.set(data.intent); receiver.setPendingResult(data); receiver.onReceive(context.getReceiverRestrictedContext(), data.intent); @@ -1832,6 +1844,8 @@ public final class ActivityThread { "Unable to start receiver " + component + ": " + e.toString(), e); } + } finally { + sCurrentBroadcastIntent.set(null); } if (receiver.getPendingResult() != null) { diff --git a/core/java/android/os/StrictMode.java b/core/java/android/os/StrictMode.java index 5a6369c..34d3b85 100644 --- a/core/java/android/os/StrictMode.java +++ b/core/java/android/os/StrictMode.java @@ -17,7 +17,9 @@ package android.os; import android.animation.ValueAnimator; import android.app.ActivityManagerNative; +import android.app.ActivityThread; import android.app.ApplicationErrorReport; +import android.content.Intent; import android.util.Log; import android.util.Printer; @@ -1205,6 +1207,12 @@ public final class StrictMode { public long violationUptimeMillis; /** + * The action of the Intent being broadcast to somebody's onReceive + * on this thread right now, or null. + */ + public String broadcastIntentAction; + + /** * Create an uninitialized instance of ViolationInfo */ public ViolationInfo() { @@ -1220,6 +1228,10 @@ public final class StrictMode { violationUptimeMillis = SystemClock.uptimeMillis(); this.policy = policy; this.numAnimationsRunning = ValueAnimator.getCurrentAnimationsCount(); + Intent broadcastIntent = ActivityThread.getIntentBeingBroadcast(); + if (broadcastIntent != null) { + broadcastIntentAction = broadcastIntent.getAction(); + } } /** @@ -1247,6 +1259,7 @@ public final class StrictMode { violationNumThisLoop = in.readInt(); numAnimationsRunning = in.readInt(); violationUptimeMillis = in.readLong(); + broadcastIntentAction = in.readString(); } /** @@ -1259,6 +1272,7 @@ public final class StrictMode { dest.writeInt(violationNumThisLoop); dest.writeInt(numAnimationsRunning); dest.writeLong(violationUptimeMillis); + dest.writeString(broadcastIntentAction); } @@ -1278,6 +1292,9 @@ public final class StrictMode { pw.println(prefix + "numAnimationsRunning: " + numAnimationsRunning); } pw.println(prefix + "violationUptimeMillis: " + violationUptimeMillis); + if (broadcastIntentAction != null) { + pw.println(prefix + "broadcastIntentAction: " + broadcastIntentAction); + } } } diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java index 8d36e4f..60b2b67 100644 --- a/services/java/com/android/server/am/ActivityManagerService.java +++ b/services/java/com/android/server/am/ActivityManagerService.java @@ -6679,6 +6679,9 @@ public final class ActivityManagerService extends ActivityManagerNative if (info.numAnimationsRunning != 0) { sb.append("Animations-Running: ").append(info.numAnimationsRunning).append("\n"); } + if (info.broadcastIntentAction != null) { + sb.append("Broadcast-Intent-Action: ").append(info.broadcastIntentAction).append("\n"); + } if (info != null && info.durationMillis != -1) { sb.append("Duration-Millis: ").append(info.durationMillis).append("\n"); } |