From 8da429e80d1778d7bcfbfbd64355c70fb466b3ce Mon Sep 17 00:00:00 2001 From: Dianne Hackborn Date: Sun, 23 Sep 2012 12:52:19 -0700 Subject: [PATCH] Fix issue #7209355, #7214271. Issue #7209355: Intent on the secondary user results in an intent picker in the Primary user. Issue #7214271: Crash in system UI Also fix a bug where I recently broke the removeTask() operation in the activity manager where it would remove the wrong task. Change-Id: I448c73a0e83a78d9d8d96b4629658c169888d275 --- api/current.txt | 1 + core/java/android/content/pm/ResolveInfo.java | 15 +++++++++++++++ .../android/systemui/recent/RecentsPanelView.java | 6 ++++-- .../java/com/android/server/am/ActivityStack.java | 5 ++--- .../android/server/pm/PackageManagerService.java | 11 ++++++++++- 5 files changed, 32 insertions(+), 6 deletions(-) diff --git a/api/current.txt b/api/current.txt index df5429de7bd91..ff1c44e9bf103 100644 --- a/api/current.txt +++ b/api/current.txt @@ -6769,6 +6769,7 @@ package android.content.pm { public class ResolveInfo implements android.os.Parcelable { ctor public ResolveInfo(); + ctor public ResolveInfo(android.content.pm.ResolveInfo); method public int describeContents(); method public void dump(android.util.Printer, java.lang.String); method public final int getIconResource(); diff --git a/core/java/android/content/pm/ResolveInfo.java b/core/java/android/content/pm/ResolveInfo.java index e3749b4410166..07117fe0754e8 100644 --- a/core/java/android/content/pm/ResolveInfo.java +++ b/core/java/android/content/pm/ResolveInfo.java @@ -230,6 +230,21 @@ public class ResolveInfo implements Parcelable { public ResolveInfo() { } + public ResolveInfo(ResolveInfo orig) { + activityInfo = orig.activityInfo; + serviceInfo = orig.serviceInfo; + filter = orig.filter; + priority = orig.priority; + preferredOrder = orig.preferredOrder; + match = orig.match; + specificIndex = orig.specificIndex; + labelRes = orig.labelRes; + nonLocalizedLabel = orig.nonLocalizedLabel; + icon = orig.icon; + resolvePackageName = orig.resolvePackageName; + system = orig.system; + } + public String toString() { ComponentInfo ci = activityInfo != null ? activityInfo : serviceInfo; return "ResolveInfo{" diff --git a/packages/SystemUI/src/com/android/systemui/recent/RecentsPanelView.java b/packages/SystemUI/src/com/android/systemui/recent/RecentsPanelView.java index 0caa6718bab01..5296ae9ef999b 100644 --- a/packages/SystemUI/src/com/android/systemui/recent/RecentsPanelView.java +++ b/packages/SystemUI/src/com/android/systemui/recent/RecentsPanelView.java @@ -538,12 +538,14 @@ public class RecentsPanelView extends FrameLayout implements OnItemClickListener } private void updateUiElements() { - final int items = mRecentTaskDescriptions.size(); + final int items = mRecentTaskDescriptions != null + ? mRecentTaskDescriptions.size() : 0; mRecentsContainer.setVisibility(items > 0 ? View.VISIBLE : View.GONE); // Set description for accessibility - int numRecentApps = mRecentTaskDescriptions.size(); + int numRecentApps = mRecentTaskDescriptions != null + ? mRecentTaskDescriptions.size() : 0; String recentAppsAccessibilityDescription; if (numRecentApps == 0) { recentAppsAccessibilityDescription = diff --git a/services/java/com/android/server/am/ActivityStack.java b/services/java/com/android/server/am/ActivityStack.java index 05ff3798e2794..81c67a38c4d5a 100755 --- a/services/java/com/android/server/am/ActivityStack.java +++ b/services/java/com/android/server/am/ActivityStack.java @@ -4387,6 +4387,8 @@ final class ActivityStack { while (j < NA) { ActivityRecord ar = mHistory.get(j); if (!ar.finishing && ar.task.taskId == taskId) { + thumbs.root = ar; + thumbs.rootIndex = j; holder = ar.thumbHolder; if (holder != null) { thumbs.mainThumbnail = holder.lastThumbnail; @@ -4401,9 +4403,6 @@ final class ActivityStack { return thumbs; } - thumbs.root = mHistory.get(j); - thumbs.rootIndex = j; - ArrayList subtasks = new ArrayList(); thumbs.subtasks = subtasks; while (j < NA) { diff --git a/services/java/com/android/server/pm/PackageManagerService.java b/services/java/com/android/server/pm/PackageManagerService.java index 3f2387b6bca5a..89c0efae15de4 100644 --- a/services/java/com/android/server/pm/PackageManagerService.java +++ b/services/java/com/android/server/pm/PackageManagerService.java @@ -2488,6 +2488,15 @@ public class PackageManagerService extends IPackageManager.Stub { if (ri != null) { return ri; } + if (userId != 0) { + ri = new ResolveInfo(mResolveInfo); + ri.activityInfo = new ActivityInfo(ri.activityInfo); + ri.activityInfo.applicationInfo = new ApplicationInfo( + ri.activityInfo.applicationInfo); + ri.activityInfo.applicationInfo.uid = UserHandle.getUid(userId, + UserHandle.getAppId(ri.activityInfo.applicationInfo.uid)); + return ri; + } return mResolveInfo; } } @@ -3668,7 +3677,7 @@ public class PackageManagerService extends IPackageManager.Stub { mResolveActivity.applicationInfo = mAndroidApplication; mResolveActivity.name = ResolverActivity.class.getName(); mResolveActivity.packageName = mAndroidApplication.packageName; - mResolveActivity.processName = mAndroidApplication.processName; + mResolveActivity.processName = "system:ui"; mResolveActivity.launchMode = ActivityInfo.LAUNCH_MULTIPLE; mResolveActivity.flags = ActivityInfo.FLAG_EXCLUDE_FROM_RECENTS; mResolveActivity.theme = com.android.internal.R.style.Theme_Holo_Dialog_Alert;