summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorAdam Powell <adamp@android.com>2012-12-03 11:04:21 -0800
committerGerrit Code Review <noreply-gerritcodereview@google.com>2012-12-03 11:04:21 -0800
commit05c8f17f05ca83573f7670191e6dec91497dc742 (patch)
tree44f2e772279ac48927d843b5f97fdc0db16a074e /core
parent5046ae56675b5e81bd7160f12709d609d8b4c19c (diff)
parent43a5070e06802734a1e5ea30eb5185dc7a581905 (diff)
downloadframeworks_base-05c8f17f05ca83573f7670191e6dec91497dc742.zip
frameworks_base-05c8f17f05ca83573f7670191e6dec91497dc742.tar.gz
frameworks_base-05c8f17f05ca83573f7670191e6dec91497dc742.tar.bz2
Merge "resolver list is not cleared on rebuild"
Diffstat (limited to 'core')
-rw-r--r--core/java/com/android/internal/app/ResolverActivity.java68
1 files changed, 29 insertions, 39 deletions
diff --git a/core/java/com/android/internal/app/ResolverActivity.java b/core/java/com/android/internal/app/ResolverActivity.java
index e63c57f..c22cd26 100644
--- a/core/java/com/android/internal/app/ResolverActivity.java
+++ b/core/java/com/android/internal/app/ResolverActivity.java
@@ -35,7 +35,6 @@ import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
import android.os.PatternMatcher;
-import android.os.Process;
import android.os.RemoteException;
import android.os.UserHandle;
import android.util.Log;
@@ -64,6 +63,7 @@ import java.util.Set;
*/
public class ResolverActivity extends AlertActivity implements AdapterView.OnItemClickListener {
private static final String TAG = "ResolverActivity";
+ private static final boolean DEBUG = false;
private int mLaunchedFromUid;
private ResolveListAdapter mAdapter;
@@ -323,7 +323,7 @@ public class ResolverActivity extends AlertActivity implements AdapterView.OnIte
|| (!"file".equals(data.getScheme())
&& !"content".equals(data.getScheme()))) {
filter.addDataScheme(data.getScheme());
-
+
// Look through the resolved filter to determine which part
// of it matched the original Intent.
Iterator<IntentFilter.AuthorityEntry> aIt = ri.filter.authoritiesIterator();
@@ -402,7 +402,6 @@ public class ResolverActivity extends AlertActivity implements AdapterView.OnIte
private final int mLaunchedFromUid;
private final LayoutInflater mInflater;
- private List<ResolveInfo> mCurrentResolveList;
private List<DisplayResolveInfo> mList;
public ResolveListAdapter(Context context, Intent intent,
@@ -413,6 +412,7 @@ public class ResolverActivity extends AlertActivity implements AdapterView.OnIte
mBaseResolveList = rList;
mLaunchedFromUid = launchedFromUid;
mInflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ mList = new ArrayList<DisplayResolveInfo>();
rebuildList();
}
@@ -420,22 +420,23 @@ public class ResolverActivity extends AlertActivity implements AdapterView.OnIte
final int oldItemCount = getCount();
rebuildList();
notifyDataSetChanged();
- if (mList.size() <= 0) {
+ final int newItemCount = getCount();
+ if (newItemCount == 0) {
// We no longer have any items... just finish the activity.
finish();
- }
-
- final int newItemCount = getCount();
- if (newItemCount != oldItemCount) {
+ } else if (newItemCount != oldItemCount) {
resizeGrid();
}
}
private void rebuildList() {
+ List<ResolveInfo> currentResolveList;
+
+ mList.clear();
if (mBaseResolveList != null) {
- mCurrentResolveList = mBaseResolveList;
+ currentResolveList = mBaseResolveList;
} else {
- mCurrentResolveList = mPm.queryIntentActivities(
+ currentResolveList = mPm.queryIntentActivities(
mIntent, PackageManager.MATCH_DEFAULT_ONLY
| (mAlwaysUseOption ? PackageManager.GET_RESOLVED_FILTER : 0));
// Filter out any activities that the launched uid does not
@@ -443,36 +444,36 @@ public class ResolverActivity extends AlertActivity implements AdapterView.OnIte
// list of resolved activities, because that only happens when
// we are being subclassed, so we can safely launch whatever
// they gave us.
- if (mCurrentResolveList != null) {
- for (int i=mCurrentResolveList.size()-1; i >= 0; i--) {
- ActivityInfo ai = mCurrentResolveList.get(i).activityInfo;
+ if (currentResolveList != null) {
+ for (int i=currentResolveList.size()-1; i >= 0; i--) {
+ ActivityInfo ai = currentResolveList.get(i).activityInfo;
int granted = ActivityManager.checkComponentPermission(
ai.permission, mLaunchedFromUid,
ai.applicationInfo.uid, ai.exported);
if (granted != PackageManager.PERMISSION_GRANTED) {
// Access not allowed!
- mCurrentResolveList.remove(i);
+ currentResolveList.remove(i);
}
}
}
}
int N;
- if ((mCurrentResolveList != null) && ((N = mCurrentResolveList.size()) > 0)) {
+ if ((currentResolveList != null) && ((N = currentResolveList.size()) > 0)) {
// Only display the first matches that are either of equal
// priority or have asked to be default options.
- ResolveInfo r0 = mCurrentResolveList.get(0);
+ ResolveInfo r0 = currentResolveList.get(0);
for (int i=1; i<N; i++) {
- ResolveInfo ri = mCurrentResolveList.get(i);
- if (false) Log.v(
+ ResolveInfo ri = currentResolveList.get(i);
+ if (DEBUG) Log.v(
"ResolveListActivity",
r0.activityInfo.name + "=" +
r0.priority + "/" + r0.isDefault + " vs " +
ri.activityInfo.name + "=" +
ri.priority + "/" + ri.isDefault);
- if (r0.priority != ri.priority ||
+ if (r0.priority != ri.priority ||
r0.isDefault != ri.isDefault) {
while (i < N) {
- mCurrentResolveList.remove(i);
+ currentResolveList.remove(i);
N--;
}
}
@@ -480,11 +481,8 @@ public class ResolverActivity extends AlertActivity implements AdapterView.OnIte
if (N > 1) {
ResolveInfo.DisplayNameComparator rComparator =
new ResolveInfo.DisplayNameComparator(mPm);
- Collections.sort(mCurrentResolveList, rComparator);
+ Collections.sort(currentResolveList, rComparator);
}
-
- mList = new ArrayList<DisplayResolveInfo>();
-
// First put the initial items at the top.
if (mInitialIntents != null) {
for (int i=0; i<mInitialIntents.length; i++) {
@@ -512,10 +510,10 @@ public class ResolverActivity extends AlertActivity implements AdapterView.OnIte
ri.loadLabel(getPackageManager()), null, ii));
}
}
-
+
// Check for applications with same name and use application name or
// package name if necessary
- r0 = mCurrentResolveList.get(0);
+ r0 = currentResolveList.get(0);
int start = 0;
CharSequence r0Label = r0.loadLabel(mPm);
mShowExtended = false;
@@ -523,7 +521,7 @@ public class ResolverActivity extends AlertActivity implements AdapterView.OnIte
if (r0Label == null) {
r0Label = r0.activityInfo.packageName;
}
- ResolveInfo ri = mCurrentResolveList.get(i);
+ ResolveInfo ri = currentResolveList.get(i);
CharSequence riLabel = ri.loadLabel(mPm);
if (riLabel == null) {
riLabel = ri.activityInfo.packageName;
@@ -531,13 +529,13 @@ public class ResolverActivity extends AlertActivity implements AdapterView.OnIte
if (riLabel.equals(r0Label)) {
continue;
}
- processGroup(mCurrentResolveList, start, (i-1), r0, r0Label);
+ processGroup(currentResolveList, start, (i-1), r0, r0Label);
r0 = ri;
r0Label = riLabel;
start = i;
}
// Process last group
- processGroup(mCurrentResolveList, start, (N-1), r0, r0Label);
+ processGroup(currentResolveList, start, (N-1), r0, r0Label);
}
}
@@ -589,18 +587,10 @@ public class ResolverActivity extends AlertActivity implements AdapterView.OnIte
}
public ResolveInfo resolveInfoForPosition(int position) {
- if (mList == null) {
- return null;
- }
-
return mList.get(position).ri;
}
public Intent intentForPosition(int position) {
- if (mList == null) {
- return null;
- }
-
DisplayResolveInfo dri = mList.get(position);
Intent intent = new Intent(dri.origIntent != null
@@ -614,11 +604,11 @@ public class ResolverActivity extends AlertActivity implements AdapterView.OnIte
}
public int getCount() {
- return mList != null ? mList.size() : 0;
+ return mList.size();
}
public Object getItem(int position) {
- return position;
+ return mList.get(position);
}
public long getItemId(int position) {