summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCraig Mautner <cmautner@google.com>2013-04-17 22:35:02 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2013-04-17 22:35:02 +0000
commit61cc1b632ad250c359499173f37b9f013f0f9415 (patch)
tree08e6a9fa971235ea62c8d6fe027709b5dd36a060
parentd5e1495723778b6765b42b1828fe32b5ec99750c (diff)
parent29219d963d1ec29ddea3e5814eb82c2aeaccc1ac (diff)
downloadframeworks_base-61cc1b632ad250c359499173f37b9f013f0f9415.zip
frameworks_base-61cc1b632ad250c359499173f37b9f013f0f9415.tar.gz
frameworks_base-61cc1b632ad250c359499173f37b9f013f0f9415.tar.bz2
Merge "Steady improvement to multi stack."
-rw-r--r--core/java/android/widget/AbsListView.java4
-rw-r--r--services/java/com/android/server/am/ActivityManagerService.java22
-rw-r--r--services/java/com/android/server/am/ActivityStack.java26
-rw-r--r--services/java/com/android/server/am/ActivityStackSupervisor.java98
-rw-r--r--services/java/com/android/server/wm/WindowAnimator.java8
-rw-r--r--services/java/com/android/server/wm/WindowManagerService.java1
6 files changed, 119 insertions, 40 deletions
diff --git a/core/java/android/widget/AbsListView.java b/core/java/android/widget/AbsListView.java
index c72853f..2012988 100644
--- a/core/java/android/widget/AbsListView.java
+++ b/core/java/android/widget/AbsListView.java
@@ -2398,7 +2398,7 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
* @return True if the selector should be shown
*/
boolean shouldShowSelector() {
- return (hasFocus() && !isInTouchMode()) || touchModeDrawsInPressedState();
+ return (!isInTouchMode()) || touchModeDrawsInPressedState();
}
private void drawSelector(Canvas canvas) {
@@ -2736,7 +2736,7 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
}
public boolean sameWindow() {
- return hasWindowFocus() && getWindowAttachCount() == mOriginalAttachCount;
+ return getWindowAttachCount() == mOriginalAttachCount;
}
}
diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java
index a3bb823..4f0000e 100644
--- a/services/java/com/android/server/am/ActivityManagerService.java
+++ b/services/java/com/android/server/am/ActivityManagerService.java
@@ -1925,6 +1925,7 @@ public final class ActivityManagerService extends ActivityManagerNative
final void setFocusedActivityLocked(ActivityRecord r) {
if (mFocusedActivity != r) {
mFocusedActivity = r;
+ mStackSupervisor.setFocusedStack(r);
if (r != null) {
mWindowManager.setFocusedApp(r.appToken, true);
}
@@ -2955,10 +2956,10 @@ public final class ActivityManagerService extends ActivityManagerNative
Slog.w(TAG, msg);
throw new SecurityException(msg);
}
-
+
synchronized(this) {
ProcessRecord proc = null;
-
+
// Figure out which process to kill. We don't trust that initialPid
// still has any relation to current pids, so must scan through the
// list.
@@ -2979,14 +2980,14 @@ public final class ActivityManagerService extends ActivityManagerNative
}
}
}
-
+
if (proc == null) {
Slog.w(TAG, "crashApplication: nothing for uid=" + uid
+ " initialPid=" + initialPid
+ " packageName=" + packageName);
return;
}
-
+
if (proc.thread != null) {
if (proc.pid == Process.myPid()) {
Log.w(TAG, "crashApplication: trying to crash self!");
@@ -3001,7 +3002,7 @@ public final class ActivityManagerService extends ActivityManagerNative
}
}
}
-
+
@Override
public final void finishSubActivity(IBinder token, String resultWho,
int requestCode) {
@@ -3050,17 +3051,17 @@ public final class ActivityManagerService extends ActivityManagerNative
}
final long origId = Binder.clearCallingIdentity();
-
+
if (self.state == ActivityState.RESUMED
|| self.state == ActivityState.PAUSING) {
mWindowManager.overridePendingAppTransition(packageName,
enterAnim, exitAnim, null);
}
-
+
Binder.restoreCallingIdentity(origId);
}
}
-
+
/**
* Main function for removing an existing process from the activity manager
* as a result of that process going away. Clears out all connections
@@ -4815,6 +4816,7 @@ public final class ActivityManagerService extends ActivityManagerNative
return rec;
}
+ @Override
public void cancelIntentSender(IIntentSender sender) {
if (!(sender instanceof PendingIntentRecord)) {
return;
@@ -4848,6 +4850,7 @@ public final class ActivityManagerService extends ActivityManagerNative
}
}
+ @Override
public String getPackageForIntentSender(IIntentSender pendingResult) {
if (!(pendingResult instanceof PendingIntentRecord)) {
return null;
@@ -4860,6 +4863,7 @@ public final class ActivityManagerService extends ActivityManagerNative
return null;
}
+ @Override
public int getUidForIntentSender(IIntentSender sender) {
if (sender instanceof PendingIntentRecord) {
try {
@@ -4871,6 +4875,7 @@ public final class ActivityManagerService extends ActivityManagerNative
return -1;
}
+ @Override
public boolean isIntentSenderTargetedToPackage(IIntentSender pendingResult) {
if (!(pendingResult instanceof PendingIntentRecord)) {
return false;
@@ -4892,6 +4897,7 @@ public final class ActivityManagerService extends ActivityManagerNative
return false;
}
+ @Override
public boolean isIntentSenderAnActivity(IIntentSender pendingResult) {
if (!(pendingResult instanceof PendingIntentRecord)) {
return false;
diff --git a/services/java/com/android/server/am/ActivityStack.java b/services/java/com/android/server/am/ActivityStack.java
index 0ca5db5..5aa056c 100644
--- a/services/java/com/android/server/am/ActivityStack.java
+++ b/services/java/com/android/server/am/ActivityStack.java
@@ -75,7 +75,7 @@ final class ActivityStack {
static final boolean localLOGV = ActivityManagerService.localLOGV;
static final boolean DEBUG_SWITCH = ActivityManagerService.DEBUG_SWITCH;
static final boolean DEBUG_PAUSE = ActivityManagerService.DEBUG_PAUSE;
- static final boolean DEBUG_VISBILITY = ActivityManagerService.DEBUG_VISBILITY || true;
+ static final boolean DEBUG_VISBILITY = ActivityManagerService.DEBUG_VISBILITY;
static final boolean DEBUG_USER_LEAVING = ActivityManagerService.DEBUG_USER_LEAVING;
static final boolean DEBUG_TRANSITION = ActivityManagerService.DEBUG_TRANSITION;
static final boolean DEBUG_RESULTS = ActivityManagerService.DEBUG_RESULTS;
@@ -984,10 +984,12 @@ final class ActivityStack {
destroyActivityLocked(prev, true, false, "pause-config");
} else {
mStackSupervisor.mStoppingActivities.add(prev);
- if (mStackSupervisor.mStoppingActivities.size() > 3) {
+ if (mStackSupervisor.mStoppingActivities.size() > 3 ||
+ prev.frontOfTask && mTaskHistory.size() <= 1) {
// If we already have a few activities waiting to stop,
// then give up on things going idle and start clearing
- // them out.
+ // them out. Or if r is the last of activity of the last task the stack
+ // will be empty and must be cleared immediately.
if (DEBUG_PAUSE) Slog.v(TAG, "To many pending stops, forcing idle");
scheduleIdleLocked();
} else {
@@ -1750,9 +1752,13 @@ final class ActivityStack {
if (prev != null) {
// We don't want to reuse the previous starting preview if:
// (1) The current activity is in a different task.
- if (prev.task != r.task) prev = null;
+ if (prev.task != r.task) {
+ prev = null;
+ }
// (2) The current activity is already displayed.
- else if (prev.nowVisible) prev = null;
+ else if (prev.nowVisible) {
+ prev = null;
+ }
}
mService.mWindowManager.setAppStartingWindow(
r.appToken, r.packageName, r.theme,
@@ -1774,7 +1780,7 @@ final class ActivityStack {
}
if (doResume) {
- mStackSupervisor.getTopStack().resumeTopActivityLocked(null);
+ mStackSupervisor.resumeTopActivitiesLocked();
}
}
@@ -2569,7 +2575,7 @@ final class ActivityStack {
r.pauseKeyDispatchingLocked();
if (mStackSupervisor.isFrontStack(this)) {
if (mService.mFocusedActivity == r) {
- mService.setFocusedActivityLocked(topRunningActivityLocked(null));
+ mService.setFocusedActivityLocked(mStackSupervisor.topRunningActivityLocked());
}
}
@@ -2623,10 +2629,12 @@ final class ActivityStack {
if (mode == FINISH_AFTER_VISIBLE && r.nowVisible) {
if (!mStackSupervisor.mStoppingActivities.contains(r)) {
mStackSupervisor.mStoppingActivities.add(r);
- if (mStackSupervisor.mStoppingActivities.size() > 3) {
+ if (mStackSupervisor.mStoppingActivities.size() > 3
+ || r.frontOfTask && mTaskHistory.size() <= 1) {
// If we already have a few activities waiting to stop,
// then give up on things going idle and start clearing
- // them out.
+ // them out. Or if r is the last of activity of the last task the stack
+ // will be empty and must be cleared immediately.
scheduleIdleLocked();
} else {
checkReadyForSleepLocked();
diff --git a/services/java/com/android/server/am/ActivityStackSupervisor.java b/services/java/com/android/server/am/ActivityStackSupervisor.java
index 8768688..8b946e4 100644
--- a/services/java/com/android/server/am/ActivityStackSupervisor.java
+++ b/services/java/com/android/server/am/ActivityStackSupervisor.java
@@ -17,6 +17,8 @@
package com.android.server.am;
import static android.Manifest.permission.START_ANY_ACTIVITY;
+import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;
+import static android.content.Intent.FLAG_ACTIVITY_TASK_ON_HOME;
import static android.content.pm.PackageManager.PERMISSION_GRANTED;
import static com.android.server.am.ActivityManagerService.localLOGV;
import static com.android.server.am.ActivityManagerService.DEBUG_CONFIGURATION;
@@ -99,8 +101,8 @@ public class ActivityStackSupervisor {
private ActivityStack mHomeStack;
/** The non-home stack currently receiving input or launching the next activity. If home is
- * in front then mHomeStack overrides mMainStack. */
- private ActivityStack mMainStack;
+ * in front then mHomeStack overrides mFocusedStack. */
+ private ActivityStack mFocusedStack;
/** All the non-launcher stacks */
private ArrayList<ActivityStack> mStacks = new ArrayList<ActivityStack>();
@@ -150,7 +152,7 @@ public class ActivityStackSupervisor {
case STACK_STATE_HOME_IN_BACK:
case STACK_STATE_HOME_TO_BACK:
default:
- return mMainStack;
+ return mFocusedStack;
}
}
@@ -162,7 +164,7 @@ public class ActivityStackSupervisor {
case STACK_STATE_HOME_TO_FRONT:
case STACK_STATE_HOME_IN_BACK:
default:
- return mMainStack;
+ return mFocusedStack;
}
}
@@ -238,8 +240,8 @@ public class ActivityStackSupervisor {
mStacks.remove(stack);
final int stackId = stack.mStackId;
final int nextStackId = mService.mWindowManager.removeStack(stackId);
- if (mMainStack.mStackId == stackId) {
- mMainStack = nextStackId == HOME_STACK_ID ? null : getStack(nextStackId);
+ if (mFocusedStack.mStackId == stackId) {
+ mFocusedStack = nextStackId == HOME_STACK_ID ? null : getStack(nextStackId);
}
}
}
@@ -329,10 +331,9 @@ public class ActivityStackSupervisor {
}
boolean allPausedActivitiesComplete() {
- final boolean homeInBack = !homeIsInFront();
for (int stackNdx = mStacks.size() - 1; stackNdx >= 0; --stackNdx) {
final ActivityStack stack = mStacks.get(stackNdx);
- if (stack.isHomeStack() ^ homeInBack) {
+ if (isFrontStack(stack)) {
final ActivityRecord r = stack.mLastPausedActivity;
if (r != null && r.state != ActivityState.PAUSED
&& r.state != ActivityState.STOPPED
@@ -353,6 +354,35 @@ public class ActivityStackSupervisor {
return true;
}
+ ActivityRecord topRunningActivityLocked() {
+ ActivityRecord r = null;
+ if (mFocusedStack != null) {
+ r = mFocusedStack.topRunningActivityLocked(null);
+ if (r != null) {
+ return r;
+ }
+ }
+ for (int stackNdx = mStacks.size() - 1; stackNdx >= 0; --stackNdx) {
+ final ActivityStack stack = mStacks.get(stackNdx);
+ if (stack != mFocusedStack && isFrontStack(stack)) {
+ r = stack.topRunningActivityLocked(null);
+ if (r != null) {
+ return r;
+ }
+ }
+ }
+ return null;
+ }
+
+ void resumeTopActivitiesLocked() {
+ for (int stackNdx = mStacks.size() - 1; stackNdx >= 0; --stackNdx) {
+ final ActivityStack stack = mStacks.get(stackNdx);
+ if (isFrontStack(stack)) {
+ stack.resumeTopActivityLocked(null);
+ }
+ }
+ }
+
ActivityRecord getTasksLocked(int maxNum, IThumbnailReceiver receiver,
PendingThumbnailsRecord pending, List<RunningTaskInfo> list) {
ActivityRecord r = null;
@@ -1043,13 +1073,29 @@ public class ActivityStackSupervisor {
// Time to create the first app stack.
int stackId = mService.createStack(-1, HOME_STACK_ID,
StackBox.TASK_STACK_GOES_OVER, 1.0f);
- mMainStack = getStack(stackId);
+ mFocusedStack = getStack(stackId);
}
- return mMainStack;
+ return mFocusedStack;
}
return mHomeStack;
}
+ void setFocusedStack(ActivityRecord r) {
+ if (r == null) {
+ return;
+ }
+ if (r.isHomeActivity) {
+ if (mStackState != STACK_STATE_HOME_IN_FRONT) {
+ mStackState = STACK_STATE_HOME_TO_FRONT;
+ }
+ } else {
+ mFocusedStack = r.task.stack;
+ if (mStackState != STACK_STATE_HOME_IN_BACK) {
+ mStackState = STACK_STATE_HOME_TO_BACK;
+ }
+ }
+ }
+
final int startActivityUncheckedLocked(ActivityRecord r,
ActivityRecord sourceRecord, int startFlags, boolean doResume,
Bundle options) {
@@ -1091,8 +1137,8 @@ public class ActivityStackSupervisor {
// This activity is not being started from another... in this
// case we -always- start a new task.
if ((launchFlags&Intent.FLAG_ACTIVITY_NEW_TASK) == 0) {
- Slog.w(TAG, "startActivity called from non-Activity context; forcing Intent.FLAG_ACTIVITY_NEW_TASK for: "
- + intent);
+ Slog.w(TAG, "startActivity called from non-Activity context; forcing " +
+ "Intent.FLAG_ACTIVITY_NEW_TASK for: " + intent);
launchFlags |= Intent.FLAG_ACTIVITY_NEW_TASK;
}
} else if (sourceRecord.launchMode == ActivityInfo.LAUNCH_SINGLE_INSTANCE) {
@@ -1150,6 +1196,9 @@ public class ActivityStackSupervisor {
? findTaskLocked(intent, r.info)
: findActivityLocked(intent, r.info);
if (intentActivity != null) {
+ if (r.task == null) {
+ r.task = intentActivity.task;
+ }
targetStack = intentActivity.task.stack;
moveHomeStack(targetStack.isHomeStack());
if (intentActivity.task.intent == null) {
@@ -1174,8 +1223,8 @@ public class ActivityStackSupervisor {
// user's face, right now.
movedHome = true;
if ((launchFlags &
- (Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_TASK_ON_HOME))
- == (Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_TASK_ON_HOME)) {
+ (FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_TASK_ON_HOME))
+ == (FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_TASK_ON_HOME)) {
// Caller wants to appear on home activity, so before starting
// their own activity we will bring home to the front.
r.mLaunchHomeTaskNext = true;
@@ -1200,6 +1249,9 @@ public class ActivityStackSupervisor {
} else {
ActivityOptions.abort(options);
}
+ if (r.task == null) Slog.v(TAG,
+ "startActivityUncheckedLocked: task left null",
+ new RuntimeException("here").fillInStackTrace());
return ActivityManager.START_RETURN_INTENT_TO_CALLER;
}
if ((launchFlags &
@@ -1293,6 +1345,9 @@ public class ActivityStackSupervisor {
} else {
ActivityOptions.abort(options);
}
+ if (r.task == null) Slog.v(TAG,
+ "startActivityUncheckedLocked: task left null",
+ new RuntimeException("here").fillInStackTrace());
return ActivityManager.START_TASK_TO_FRONT;
}
}
@@ -1330,9 +1385,15 @@ public class ActivityStackSupervisor {
// We don't need to start a new activity, and
// the client said not to do anything if that
// is the case, so this is it!
+ if (r.task == null) Slog.v(TAG,
+ "startActivityUncheckedLocked: task left null",
+ new RuntimeException("here").fillInStackTrace());
return ActivityManager.START_RETURN_INTENT_TO_CALLER;
}
top.deliverNewIntentLocked(callingUid, r.intent);
+ if (r.task == null) Slog.v(TAG,
+ "startActivityUncheckedLocked: task left null",
+ new RuntimeException("here").fillInStackTrace());
return ActivityManager.START_DELIVERED_TO_TOP;
}
}
@@ -1345,6 +1406,9 @@ public class ActivityStackSupervisor {
r.requestCode, Activity.RESULT_CANCELED, null);
}
ActivityOptions.abort(options);
+ if (r.task == null) Slog.v(TAG,
+ "startActivityUncheckedLocked: task left null",
+ new RuntimeException("here").fillInStackTrace());
return ActivityManager.START_CLASS_NOT_FOUND;
}
@@ -1394,6 +1458,9 @@ public class ActivityStackSupervisor {
targetStack.resumeTopActivityLocked(null);
}
ActivityOptions.abort(options);
+ if (r.task == null) Slog.v(TAG,
+ "startActivityUncheckedLocked: task left null",
+ new RuntimeException("here").fillInStackTrace());
return ActivityManager.START_DELIVERED_TO_TOP;
}
} else if (!addingToTask &&
@@ -1413,6 +1480,9 @@ public class ActivityStackSupervisor {
setLaunchHomeTaskNextFlag(sourceRecord, null, targetStack);
targetStack.resumeTopActivityLocked(null);
}
+ if (r.task == null) Slog.v(TAG,
+ "startActivityUncheckedLocked: task left null",
+ new RuntimeException("here").fillInStackTrace());
return ActivityManager.START_DELIVERED_TO_TOP;
}
}
diff --git a/services/java/com/android/server/wm/WindowAnimator.java b/services/java/com/android/server/wm/WindowAnimator.java
index 0fb4c71..3147497 100644
--- a/services/java/com/android/server/wm/WindowAnimator.java
+++ b/services/java/com/android/server/wm/WindowAnimator.java
@@ -305,7 +305,8 @@ public class WindowAnimator {
wallpaperInUnForceHiding = true;
}
}
- if (mCurrentFocus == null || mCurrentFocus.mLayer < win.mLayer) {
+ final WindowState currentFocus = mService.mCurrentFocus;
+ if (currentFocus == null || currentFocus.mLayer < win.mLayer) {
// We are showing on to of the current
// focus, so re-evaluate focus to make
// sure it is correct.
@@ -670,11 +671,6 @@ public class WindowAnimator {
}
}
- WindowState mCurrentFocus;
- void setCurrentFocus(final WindowState currentFocus) {
- mCurrentFocus = currentFocus;
- }
-
boolean isDimmingLocked(int displayId) {
return getDisplayContentsAnimatorLocked(displayId).mDimAnimator.isDimming();
}
diff --git a/services/java/com/android/server/wm/WindowManagerService.java b/services/java/com/android/server/wm/WindowManagerService.java
index da28cd8..a16a8e6 100644
--- a/services/java/com/android/server/wm/WindowManagerService.java
+++ b/services/java/com/android/server/wm/WindowManagerService.java
@@ -9514,7 +9514,6 @@ public class WindowManagerService extends IWindowManager.Stub
TAG, "Changing focus from " + mCurrentFocus + " to " + newFocus);
final WindowState oldFocus = mCurrentFocus;
mCurrentFocus = newFocus;
- mAnimator.setCurrentFocus(newFocus);
mLosingFocus.remove(newFocus);
int focusChanged = mPolicy.focusChangedLw(oldFocus, newFocus);