From 482f159dc46c2aab5990b4a12294623d28447e2e Mon Sep 17 00:00:00 2001 From: Michael Jurka Date: Thu, 13 Sep 2012 11:05:59 -0700 Subject: [PATCH] Fix crash in recents Bug: 7128044 Change-Id: Icaec50ef9dfbc5da78d71925215c3363f58d7d3d --- .../android/systemui/recent/RecentsActivity.java | 16 +++++++++------- .../systemui/recent/RecentsPanelView.java | 15 +++++++-------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/recent/RecentsActivity.java b/packages/SystemUI/src/com/android/systemui/recent/RecentsActivity.java index baacde016f07e..cd339512dd0ae 100644 --- a/packages/SystemUI/src/com/android/systemui/recent/RecentsActivity.java +++ b/packages/SystemUI/src/com/android/systemui/recent/RecentsActivity.java @@ -164,13 +164,15 @@ public class RecentsActivity extends Activity { super.onNewIntent(intent); if (TOGGLE_RECENTS_INTENT.equals(intent.getAction())) { - if (mRecentsPanel != null && !mRecentsPanel.isShowing()) { - final SystemUIApplication app = (SystemUIApplication) getApplication(); - final RecentTasksLoader recentTasksLoader = app.getRecentTasksLoader(); - mRecentsPanel.show(true, recentTasksLoader.getLoadedTasks(), - recentTasksLoader.isFirstScreenful()); - } else if ((mRecentsPanel != null && mRecentsPanel.isShowing())) { - dismissAndGoBack(); + if (mRecentsPanel != null) { + if (mRecentsPanel.isShowing() && mForeground) { + dismissAndGoBack(); + } else { + final SystemUIApplication app = (SystemUIApplication) getApplication(); + final RecentTasksLoader recentTasksLoader = app.getRecentTasksLoader(); + mRecentsPanel.show(true, recentTasksLoader.getLoadedTasks(), + recentTasksLoader.isFirstScreenful()); + } } } } diff --git a/packages/SystemUI/src/com/android/systemui/recent/RecentsPanelView.java b/packages/SystemUI/src/com/android/systemui/recent/RecentsPanelView.java index 730d350199b02..04e38a4a7ac33 100644 --- a/packages/SystemUI/src/com/android/systemui/recent/RecentsPanelView.java +++ b/packages/SystemUI/src/com/android/systemui/recent/RecentsPanelView.java @@ -33,6 +33,7 @@ import android.graphics.Shader.TileMode; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.net.Uri; +import android.os.Bundle; import android.os.RemoteException; import android.os.UserHandle; import android.provider.Settings; @@ -581,25 +582,23 @@ public class RecentsPanelView extends FrameLayout implements OnItemClickListener bm = holder.thumbnailViewImage.getDrawingCache(); usingDrawingCache = true; } - - if (bm == null) { - throw new RuntimeException("Recents thumbnail is null"); - } - ActivityOptions opts = ActivityOptions.makeThumbnailScaleUpAnimation( - holder.thumbnailViewImage, bm, 0, 0, null); + Bundle opts = (bm == null) ? + null : + ActivityOptions.makeThumbnailScaleUpAnimation( + holder.thumbnailViewImage, bm, 0, 0, null).toBundle(); show(false); if (ad.taskId >= 0) { // This is an active task; it should just go to the foreground. am.moveTaskToFront(ad.taskId, ActivityManager.MOVE_TASK_WITH_HOME, - opts.toBundle()); + opts); } else { Intent intent = ad.intent; intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY | Intent.FLAG_ACTIVITY_TASK_ON_HOME | Intent.FLAG_ACTIVITY_NEW_TASK); if (DEBUG) Log.v(TAG, "Starting activity " + intent); - context.startActivityAsUser(intent, opts.toBundle(), + context.startActivityAsUser(intent, opts, new UserHandle(UserHandle.USER_CURRENT)); } if (usingDrawingCache) {