diff options
| author | 2012-06-21 14:17:48 -0700 | |
|---|---|---|
| committer | 2012-06-21 14:17:48 -0700 | |
| commit | f530ac323b7230ec7b198f0af3f2fa1158913a08 (patch) | |
| tree | b1291463e326d13b1be54e705aad732e7ebe6448 | |
| parent | d5353b475001f19e3cbc9c1a4165c9e6038a812f (diff) | |
Fix issue #6700897: Activity paused by activating the...
...lock screen does not response to onNewIntent()
We now keep activities stopped even while the lock screen is
displayed. (We used to keep them stopped while the screen was
off, and then resume the top activity when the screen was turned
on even though they are covered by the lock screen.)
When a new intent is being delivered to an application, if it
is not resumed it is held in a pending list until the next
time the activity is resumed. Unfortunately that means for
the case where the activity is being held stopped due to the
screen off or lock screen, it will not receive any new intents,
even though it is at the top of the stack.
Fix this by adding an additional condition that allows the new
intent to be delivered immediately if the activity manager is
sleeping and the target activity is at the top of the stack.
Also some debug output improvements, since pending new intents
were not being included in the debug output, making it impossible
to see we were in that situation.
Change-Id: I5df82ac21657f1c82e05fd8bf21474e883f44e6f
| -rw-r--r-- | services/java/com/android/server/am/ActivityRecord.java | 47 |
1 files changed, 41 insertions, 6 deletions
diff --git a/services/java/com/android/server/am/ActivityRecord.java b/services/java/com/android/server/am/ActivityRecord.java index 17957d21d70d..c40abb736010 100644 --- a/services/java/com/android/server/am/ActivityRecord.java +++ b/services/java/com/android/server/am/ActivityRecord.java @@ -129,6 +129,7 @@ final class ActivityRecord { private boolean inHistory; // are we in the history stack? void dump(PrintWriter pw, String prefix) { + final long now = SystemClock.uptimeMillis(); pw.print(prefix); pw.print("packageName="); pw.print(packageName); pw.print(" processName="); pw.println(processName); pw.print(prefix); pw.print("launchedFromUid="); pw.print(launchedFromUid); @@ -161,8 +162,30 @@ final class ActivityRecord { if (results != null) { pw.print(prefix); pw.print("results="); pw.println(results); } - if (pendingResults != null) { - pw.print(prefix); pw.print("pendingResults="); pw.println(pendingResults); + if (pendingResults != null && pendingResults.size() > 0) { + pw.print(prefix); pw.println("Pending Results:"); + for (WeakReference<PendingIntentRecord> wpir : pendingResults) { + PendingIntentRecord pir = wpir != null ? wpir.get() : null; + pw.print(prefix); pw.print(" - "); + if (pir == null) { + pw.println("null"); + } else { + pw.println(pir); + pir.dump(pw, prefix + " "); + } + } + } + if (newIntents != null && newIntents.size() > 0) { + pw.print(prefix); pw.println("Pending New Intents:"); + for (int i=0; i<newIntents.size(); i++) { + Intent intent = (Intent)newIntents.get(i); + pw.print(prefix); pw.print(" - "); + if (intent == null) { + pw.println("null"); + } else { + pw.println(intent.toShortString(false, true, false, true)); + } + } } if (pendingOptions != null) { pw.print(prefix); pw.print("pendingOptions="); pw.println(pendingOptions); @@ -199,14 +222,20 @@ final class ActivityRecord { pw.print(prefix); pw.print("thumbHolder="); pw.println(thumbHolder); if (launchTime != 0 || startTime != 0) { pw.print(prefix); pw.print("launchTime="); - TimeUtils.formatDuration(launchTime, pw); pw.print(" startTime="); - TimeUtils.formatDuration(startTime, pw); pw.println(""); + if (launchTime == 0) pw.print("0"); + else TimeUtils.formatDuration(launchTime, now, pw); + pw.print(" startTime="); + if (startTime == 0) pw.print("0"); + else TimeUtils.formatDuration(startTime, now, pw); + pw.println(); } if (lastVisibleTime != 0 || waitingVisible || nowVisible) { pw.print(prefix); pw.print("waitingVisible="); pw.print(waitingVisible); pw.print(" nowVisible="); pw.print(nowVisible); pw.print(" lastVisibleTime="); - TimeUtils.formatDuration(lastVisibleTime, pw); pw.println(""); + if (lastVisibleTime == 0) pw.print("0"); + else TimeUtils.formatDuration(lastVisibleTime, now, pw); + pw.println(); } if (configDestroy || configChangeFlags != 0) { pw.print(prefix); pw.print("configDestroy="); pw.print(configDestroy); @@ -525,7 +554,13 @@ final class ActivityRecord { */ final void deliverNewIntentLocked(int callingUid, Intent intent) { boolean sent = false; - if (state == ActivityState.RESUMED + // We want to immediately deliver the intent to the activity if + // it is currently the top resumed activity... however, if the + // device is sleeping, then all activities are stopped, so in that + // case we will deliver it if this is the current top activity on its + // stack. + if ((state == ActivityState.RESUMED || (service.mSleeping + && stack.topRunningActivityLocked(null) == this)) && app != null && app.thread != null) { try { ArrayList<Intent> ar = new ArrayList<Intent>(); |