From 309ca5d947fffc6a8196be5e5148333803d442af Mon Sep 17 00:00:00 2001 From: riddle_hsu Date: Tue, 8 Apr 2014 02:44:03 +0800 Subject: [ActivityManager] Reduce report ANR on wrong activity. Symptom: ANR report on wrong activity. Root Cause: KK changed resume behavior that will not update focus when only resume, if the activity blocked, it may report ANR on previous focus. By original concept, it will try to correct the ANR target, but the stack of waiting(waitingVisible=true) activity may different with current top stack. If it gets key dispatch timeout, mResumedActivity and mPausingActivity of its stack will be null becuase it is not top stack. Then it is unable to change ANR target to the real no response activity. Solution: Use focused stack to get the real culprit. Reproduce steps: 1.Launch an Activity X from launcher, press home key. 2.Launch X from launcher again, X blocks(sleeps 15sec) in onResume, press back key in the beginning of blocking duration. 3.ANR dialog shows launcher is no response. Change-Id: I99416ad91e349096f995990f2240a97616fbaf28 --- services/java/com/android/server/am/ActivityRecord.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) mode change 100644 => 100755 services/java/com/android/server/am/ActivityRecord.java diff --git a/services/java/com/android/server/am/ActivityRecord.java b/services/java/com/android/server/am/ActivityRecord.java old mode 100644 new mode 100755 index 49f29fe6c372..63a52e60bb12 --- a/services/java/com/android/server/am/ActivityRecord.java +++ b/services/java/com/android/server/am/ActivityRecord.java @@ -942,8 +942,8 @@ final class ActivityRecord { // for another app to start, then we have paused dispatching // for this activity. ActivityRecord r = this; - final ActivityStack stack = task.stack; if (r.waitingVisible) { + final ActivityStack stack = mStackSupervisor.getFocusedStack(); // Hmmm, who might we be waiting for? r = stack.mResumedActivity; if (r == null) { -- cgit v1.2.3-59-g8ed1b