Loading core/java/com/android/internal/app/ResolverActivity.java +29 −39 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; Loading Loading @@ -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, Loading @@ -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(); } Loading @@ -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 Loading @@ -443,27 +444,27 @@ 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 " + Loading @@ -472,7 +473,7 @@ public class ResolverActivity extends AlertActivity implements AdapterView.OnIte if (r0.priority != ri.priority || r0.isDefault != ri.isDefault) { while (i < N) { mCurrentResolveList.remove(i); currentResolveList.remove(i); N--; } } Loading @@ -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++) { Loading Loading @@ -515,7 +513,7 @@ public class ResolverActivity extends AlertActivity implements AdapterView.OnIte // 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; Loading @@ -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; Loading @@ -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); } } Loading Loading @@ -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 Loading @@ -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) { Loading Loading
core/java/com/android/internal/app/ResolverActivity.java +29 −39 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; Loading Loading @@ -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, Loading @@ -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(); } Loading @@ -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 Loading @@ -443,27 +444,27 @@ 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 " + Loading @@ -472,7 +473,7 @@ public class ResolverActivity extends AlertActivity implements AdapterView.OnIte if (r0.priority != ri.priority || r0.isDefault != ri.isDefault) { while (i < N) { mCurrentResolveList.remove(i); currentResolveList.remove(i); N--; } } Loading @@ -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++) { Loading Loading @@ -515,7 +513,7 @@ public class ResolverActivity extends AlertActivity implements AdapterView.OnIte // 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; Loading @@ -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; Loading @@ -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); } } Loading Loading @@ -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 Loading @@ -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) { Loading