diff options
author | Winson Chung <winsonc@google.com> | 2014-05-08 22:38:15 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2014-05-08 22:38:15 +0000 |
commit | 9194acc50f1b23e29cdfe5373e91fdd0657445cb (patch) | |
tree | e62971974f49a4bb886f18ec57b624c9806de6db | |
parent | 8f75156f2fd497db449a1ee3fec4a4fa46cc7ad2 (diff) | |
parent | 6e058419503910e0d5f67f9b51b84ad636ffa01f (diff) | |
download | frameworks_base-9194acc50f1b23e29cdfe5373e91fdd0657445cb.zip frameworks_base-9194acc50f1b23e29cdfe5373e91fdd0657445cb.tar.gz frameworks_base-9194acc50f1b23e29cdfe5373e91fdd0657445cb.tar.bz2 |
am 12c9e3a0: Merge "Removing the old tasks on launching recents task if they trigger a new task."
* commit '12c9e3a00bf912167d1c40a356d19301c93bfdd0':
Removing the old tasks on launching recents task if they trigger a new task.
6 files changed, 54 insertions, 19 deletions
diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java index 36f9f4b..ef6fcb7 100644 --- a/core/java/android/app/Activity.java +++ b/core/java/android/app/Activity.java @@ -4807,6 +4807,7 @@ public class Activity extends ContextThemeWrapper public void setRecentsActivityValues(ActivityManager.RecentsActivityValues values) { ActivityManager.RecentsActivityValues activityValues = new ActivityManager.RecentsActivityValues(values); + // Scale the icon down to something reasonable if (values.icon != null) { final int size = ActivityManager.getLauncherLargeIconSizeInner(this); activityValues.icon = Bitmap.createScaledBitmap(values.icon, size, size, true); diff --git a/packages/SystemUI/src/com/android/systemui/recents/RecentsTaskLoader.java b/packages/SystemUI/src/com/android/systemui/recents/RecentsTaskLoader.java index f3e411f..c64ca54 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/RecentsTaskLoader.java +++ b/packages/SystemUI/src/com/android/systemui/recents/RecentsTaskLoader.java @@ -554,14 +554,16 @@ public class RecentsTaskLoader { } /** Completely removes the resource data from the pool. */ - public void deleteTaskData(Task t) { + public void deleteTaskData(Task t, boolean notifyTaskDataUnloaded) { Console.log(Constants.Log.App.TaskDataLoader, "[RecentsTaskLoader|deleteTask]", t); mLoadQueue.removeTask(t); mThumbnailCache.remove(t.key); mApplicationIconCache.remove(t.key); - t.notifyTaskDataUnloaded(mDefaultThumbnail, mDefaultApplicationIcon); + if (notifyTaskDataUnloaded) { + t.notifyTaskDataUnloaded(mDefaultThumbnail, mDefaultApplicationIcon); + } } /** Stops the task loader and clears all pending tasks */ diff --git a/packages/SystemUI/src/com/android/systemui/recents/SystemServicesProxy.java b/packages/SystemUI/src/com/android/systemui/recents/SystemServicesProxy.java index b41555f..0d3ee38 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/SystemServicesProxy.java +++ b/packages/SystemUI/src/com/android/systemui/recents/SystemServicesProxy.java @@ -165,11 +165,12 @@ public class SystemServicesProxy { } /** Removes the task and kills the process */ - public void removeTask(int taskId) { + public void removeTask(int taskId, boolean isDocument) { if (mAm == null) return; if (Constants.DebugFlags.App.EnableSystemServicesProxy) return; - mAm.removeTask(taskId, ActivityManager.REMOVE_TASK_KILL_PROCESS); + // Remove the task, and only kill the process if it is not a document + mAm.removeTask(taskId, isDocument ? 0 : ActivityManager.REMOVE_TASK_KILL_PROCESS); } /** diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java b/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java index 8168619..a6d7e67 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java +++ b/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java @@ -346,7 +346,7 @@ public class RecentsView extends FrameLayout implements TaskStackView.TaskStackV RecentsTaskLoader.getInstance().getSystemServicesProxy() .moveTaskToFront(task.key.id, opts); } else { - // Launch the activity with the desired animation + // Launch the activity anew with the desired animation Intent i = new Intent(task.key.baseIntent); i.setFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY | Intent.FLAG_ACTIVITY_TASK_ON_HOME @@ -361,6 +361,9 @@ public class RecentsView extends FrameLayout implements TaskStackView.TaskStackV } catch (ActivityNotFoundException anfe) { Console.logError(getContext(), "Could not start Activity"); } + + // And clean up the old task + onTaskRemoved(task); } Console.logTraceTime(Constants.Log.App.TimeRecentsLaunchTask, @@ -390,6 +393,22 @@ public class RecentsView extends FrameLayout implements TaskStackView.TaskStackV .addNextIntentWithParentStack(intent).startActivities(); } + @Override + public void onTaskRemoved(Task t) { + // Remove any stored data from the loader. We currently don't bother notifying the views + // that the data has been unloaded because at the point we call onTaskRemoved(), the views + // either don't need to be updated, or have already been removed. + RecentsTaskLoader loader = RecentsTaskLoader.getInstance(); + loader.deleteTaskData(t, false); + + // Remove the old task from activity manager + int flags = t.key.baseIntent.getFlags(); + boolean isDocument = (flags & Intent.FLAG_ACTIVITY_NEW_DOCUMENT) == + Intent.FLAG_ACTIVITY_NEW_DOCUMENT; + RecentsTaskLoader.getInstance().getSystemServicesProxy().removeTask(t.key.id, + isDocument); + } + /**** RecentsPackageMonitor.PackageCallbacks Implementation ****/ @Override diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java index ad0f2f82..55c38a9 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java +++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java @@ -23,6 +23,7 @@ import android.animation.ValueAnimator; import android.app.Activity; import android.content.ComponentName; import android.content.Context; +import android.content.Intent; import android.graphics.Canvas; import android.graphics.Rect; import android.graphics.Region; @@ -60,6 +61,7 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal interface TaskStackViewCallbacks { public void onTaskLaunched(TaskStackView stackView, TaskView tv, TaskStack stack, Task t); public void onTaskAppInfoLaunched(Task t); + public void onTaskRemoved(Task t); } TaskStack mStack; @@ -1480,12 +1482,8 @@ class TaskStackViewTouchHandler implements SwipeHelper.Callback { // Remove the task from the view mSv.mStack.removeTask(task); - // Remove any stored data from the loader - RecentsTaskLoader loader = RecentsTaskLoader.getInstance(); - loader.deleteTaskData(task); - - // Remove the task from activity manager - RecentsTaskLoader.getInstance().getSystemServicesProxy().removeTask(tv.getTask().key.id); + // Notify the callback that we've removed the task and it can clean up after it + mSv.mCb.onTaskRemoved(task); // Disable HW layers mSv.decHwLayersRefCount("swipeComplete"); diff --git a/services/core/java/com/android/server/wm/AppTransition.java b/services/core/java/com/android/server/wm/AppTransition.java index 9039236..99ec242 100644 --- a/services/core/java/com/android/server/wm/AppTransition.java +++ b/services/core/java/com/android/server/wm/AppTransition.java @@ -116,7 +116,8 @@ public class AppTransition implements Dump { /** Fraction of animation at which the recents thumbnail becomes completely transparent */ private static final float RECENTS_THUMBNAIL_FADEOUT_FRACTION = 0.25f; - private static final long DEFAULT_APP_TRANSITION_DURATION = 250; + private static final int DEFAULT_APP_TRANSITION_DURATION = 250; + private static final int THUMBNAIL_APP_TRANSITION_DURATION = 225; private final Context mContext; private final Handler mH; @@ -160,6 +161,7 @@ public class AppTransition implements Dump { private final int mConfigShortAnimTime; private final Interpolator mDecelerateInterpolator; private final Interpolator mThumbnailFadeoutInterpolator; + private final Interpolator mThumbnailCubicInterpolator; private int mCurrentUserId = 0; @@ -170,6 +172,8 @@ public class AppTransition implements Dump { com.android.internal.R.integer.config_shortAnimTime); mDecelerateInterpolator = AnimationUtils.loadInterpolator(context, com.android.internal.R.interpolator.decelerate_cubic); + mThumbnailCubicInterpolator = AnimationUtils.loadInterpolator(context, + com.android.internal.R.interpolator.fast_out_slow_in); mThumbnailFadeoutInterpolator = new Interpolator() { @Override public float getInterpolation(float input) { @@ -401,11 +405,23 @@ public class AppTransition implements Dump { /** * Prepares the specified animation with a standard duration, interpolator, etc. */ + Animation prepareThumbnailAnimationWithDuration(Animation a, int appWidth, int appHeight, + int duration, Interpolator interpolator) { + a.setDuration(duration); + a.setFillAfter(true); + a.setInterpolator(interpolator); + a.initialize(appWidth, appHeight, appWidth, appHeight); + return a; + } + + /** + * Prepares the specified animation with a standard duration, interpolator, etc. + */ Animation prepareThumbnailAnimation(Animation a, int appWidth, int appHeight, int transit) { // Pick the desired duration. If this is an inter-activity transition, // it is the standard duration for that. Otherwise we use the longer // task transition duration. - final long duration; + final int duration; switch (transit) { case TRANSIT_ACTIVITY_OPEN: case TRANSIT_ACTIVITY_CLOSE: @@ -415,11 +431,8 @@ public class AppTransition implements Dump { duration = DEFAULT_APP_TRANSITION_DURATION; break; } - a.setDuration(duration); - a.setFillAfter(true); - a.setInterpolator(mDecelerateInterpolator); - a.initialize(appWidth, appHeight, appWidth, appHeight); - return a; + return prepareThumbnailAnimationWithDuration(a, appWidth, appHeight, duration, + mDecelerateInterpolator); } /** @@ -594,7 +607,8 @@ public class AppTransition implements Dump { throw new RuntimeException("Invalid thumbnail transition state"); } - return prepareThumbnailAnimation(a, appWidth, appHeight, transit); + return prepareThumbnailAnimationWithDuration(a, appWidth, appHeight, + THUMBNAIL_APP_TRANSITION_DURATION, mThumbnailCubicInterpolator); } /** |