blob: 7bab35ce7e8e5c43da9eb0393623f2ad9f035f59 [file] [log] [blame]
Kenny Root15a4d2f2010-03-11 18:20:12 -08001/*
2 * Copyright (C) 2007 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080017package android.content.pm;
18
Dianne Hackborn6d8dfbd2013-09-23 17:38:51 -070019import android.content.ComponentName;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080020import android.content.IntentFilter;
21import android.graphics.drawable.Drawable;
22import android.os.Parcel;
23import android.os.Parcelable;
Nicolas Prevot88cc3462014-05-14 14:51:48 +010024import android.os.UserHandle;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080025import android.text.TextUtils;
26import android.util.Printer;
Jeff Sharkey85f5f812013-10-07 10:16:12 -070027import android.util.Slog;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080028
29import java.text.Collator;
30import java.util.Comparator;
31
32/**
33 * Information that is returned from resolving an intent
34 * against an IntentFilter. This partially corresponds to
35 * information collected from the AndroidManifest.xml's
36 * <intent> tags.
37 */
38public class ResolveInfo implements Parcelable {
Jeff Sharkey85f5f812013-10-07 10:16:12 -070039 private static final String TAG = "ResolveInfo";
40
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080041 /**
Jeff Sharkey85f5f812013-10-07 10:16:12 -070042 * The activity or broadcast receiver that corresponds to this resolution
43 * match, if this resolution is for an activity or broadcast receiver.
44 * Exactly one of {@link #activityInfo}, {@link #serviceInfo}, or
45 * {@link #providerInfo} will be non-null.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080046 */
47 public ActivityInfo activityInfo;
Sudheer Shanka9ded7602015-05-19 21:17:25 +010048
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080049 /**
Jeff Sharkey85f5f812013-10-07 10:16:12 -070050 * The service that corresponds to this resolution match, if this resolution
51 * is for a service. Exactly one of {@link #activityInfo},
52 * {@link #serviceInfo}, or {@link #providerInfo} will be non-null.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080053 */
54 public ServiceInfo serviceInfo;
Jeff Sharkey85f5f812013-10-07 10:16:12 -070055
56 /**
57 * The provider that corresponds to this resolution match, if this
58 * resolution is for a provider. Exactly one of {@link #activityInfo},
59 * {@link #serviceInfo}, or {@link #providerInfo} will be non-null.
60 */
61 public ProviderInfo providerInfo;
62
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080063 /**
64 * The IntentFilter that was matched for this ResolveInfo.
65 */
66 public IntentFilter filter;
Sudheer Shanka9ded7602015-05-19 21:17:25 +010067
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080068 /**
69 * The declared priority of this match. Comes from the "priority"
70 * attribute or, if not set, defaults to 0. Higher values are a higher
71 * priority.
72 */
73 public int priority;
Sudheer Shanka9ded7602015-05-19 21:17:25 +010074
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080075 /**
76 * Order of result according to the user's preference. If the user
77 * has not set a preference for this result, the value is 0; higher
78 * values are a higher priority.
79 */
80 public int preferredOrder;
Sudheer Shanka9ded7602015-05-19 21:17:25 +010081
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080082 /**
83 * The system's evaluation of how well the activity matches the
84 * IntentFilter. This is a match constant, a combination of
85 * {@link IntentFilter#MATCH_CATEGORY_MASK IntentFilter.MATCH_CATEGORY_MASK}
86 * and {@link IntentFilter#MATCH_ADJUSTMENT_MASK IntentFiler.MATCH_ADJUSTMENT_MASK}.
87 */
88 public int match;
Sudheer Shanka9ded7602015-05-19 21:17:25 +010089
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080090 /**
91 * Only set when returned by
92 * {@link PackageManager#queryIntentActivityOptions}, this tells you
93 * which of the given specific intents this result came from. 0 is the
94 * first in the list, < 0 means it came from the generic Intent query.
95 */
96 public int specificIndex = -1;
Sudheer Shanka9ded7602015-05-19 21:17:25 +010097
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080098 /**
99 * This filter has specified the Intent.CATEGORY_DEFAULT, meaning it
100 * would like to be considered a default action that the user can
101 * perform on this data.
102 */
103 public boolean isDefault;
Sudheer Shanka9ded7602015-05-19 21:17:25 +0100104
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800105 /**
106 * A string resource identifier (in the package's resources) of this
107 * match's label. From the "label" attribute or, if not set, 0.
108 */
109 public int labelRes;
Sudheer Shanka9ded7602015-05-19 21:17:25 +0100110
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800111 /**
112 * The actual string retrieve from <var>labelRes</var> or null if none
113 * was provided.
114 */
115 public CharSequence nonLocalizedLabel;
Sudheer Shanka9ded7602015-05-19 21:17:25 +0100116
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800117 /**
118 * A drawable resource identifier (in the package's resources) of this
Sudheer Shanka9ded7602015-05-19 21:17:25 +0100119 * match's icon. From the "icon" attribute or, if not set, 0. It is
120 * set only if the icon can be obtained by resource id alone.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800121 */
122 public int icon;
123
124 /**
Dianne Hackborneb034652009-09-07 00:49:58 -0700125 * Optional -- if non-null, the {@link #labelRes} and {@link #icon}
126 * resources will be loaded from this package, rather than the one
127 * containing the resolved component.
128 */
129 public String resolvePackageName;
Dianne Hackbornd99b2932011-08-18 14:39:58 -0700130
131 /**
Nicolas Prevot88cc3462014-05-14 14:51:48 +0100132 * If not equal to UserHandle.USER_CURRENT, then the intent will be forwarded to this user.
133 * @hide
134 */
135 public int targetUserId;
136
137 /**
Sudheer Shanka9ded7602015-05-19 21:17:25 +0100138 * Set to true if the icon cannot be obtained by resource ids alone.
139 * It is set to true for ResolveInfos from the managed profile: They need to
140 * have their icon badged, so it cannot be obtained by resource ids alone.
Nicolas Prevot88cc3462014-05-14 14:51:48 +0100141 * @hide
142 */
Nicolas Prevot7f7b0c72014-06-23 15:59:38 +0100143 public boolean noResourceId;
Nicolas Prevot88cc3462014-05-14 14:51:48 +0100144
145 /**
Sudheer Shanka9ded7602015-05-19 21:17:25 +0100146 * Same as {@link #icon} but it will always correspond to "icon" attribute
147 * regardless of {@link #noResourceId} value.
148 * @hide
149 */
150 public int iconResourceId;
151
152 /**
Dianne Hackbornd99b2932011-08-18 14:39:58 -0700153 * @hide Target comes from system process?
154 */
155 public boolean system;
156
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -0800157 /**
Fabrice Di Meglio7d014ce2015-04-08 16:17:46 -0700158 * @hide Does the associated IntentFilter comes from a Browser ?
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -0800159 */
Fabrice Di Meglio7d014ce2015-04-08 16:17:46 -0700160 public boolean handleAllWebDataURI;
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -0800161
Jeff Sharkey85f5f812013-10-07 10:16:12 -0700162 private ComponentInfo getComponentInfo() {
163 if (activityInfo != null) return activityInfo;
164 if (serviceInfo != null) return serviceInfo;
165 if (providerInfo != null) return providerInfo;
166 throw new IllegalStateException("Missing ComponentInfo!");
167 }
168
Dianne Hackborneb034652009-09-07 00:49:58 -0700169 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800170 * Retrieve the current textual label associated with this resolution. This
171 * will call back on the given PackageManager to load the label from
172 * the application.
Sudheer Shanka9ded7602015-05-19 21:17:25 +0100173 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800174 * @param pm A PackageManager from which the label can be loaded; usually
175 * the PackageManager from which you originally retrieved this item.
Sudheer Shanka9ded7602015-05-19 21:17:25 +0100176 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800177 * @return Returns a CharSequence containing the resolutions's label. If the
178 * item does not have a label, its name is returned.
179 */
180 public CharSequence loadLabel(PackageManager pm) {
181 if (nonLocalizedLabel != null) {
182 return nonLocalizedLabel;
183 }
Dianne Hackborneb034652009-09-07 00:49:58 -0700184 CharSequence label;
185 if (resolvePackageName != null && labelRes != 0) {
186 label = pm.getText(resolvePackageName, labelRes, null);
187 if (label != null) {
Romain Guy2aba11f2010-03-29 16:03:01 -0700188 return label.toString().trim();
Dianne Hackborneb034652009-09-07 00:49:58 -0700189 }
190 }
Jeff Sharkey85f5f812013-10-07 10:16:12 -0700191 ComponentInfo ci = getComponentInfo();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800192 ApplicationInfo ai = ci.applicationInfo;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800193 if (labelRes != 0) {
194 label = pm.getText(ci.packageName, labelRes, ai);
195 if (label != null) {
Romain Guy2aba11f2010-03-29 16:03:01 -0700196 return label.toString().trim();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800197 }
198 }
Romain Guy2aba11f2010-03-29 16:03:01 -0700199
200 CharSequence data = ci.loadLabel(pm);
201 // Make the data safe
202 if (data != null) data = data.toString().trim();
203 return data;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800204 }
Sudheer Shanka9ded7602015-05-19 21:17:25 +0100205
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800206 /**
207 * Retrieve the current graphical icon associated with this resolution. This
208 * will call back on the given PackageManager to load the icon from
209 * the application.
Sudheer Shanka9ded7602015-05-19 21:17:25 +0100210 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800211 * @param pm A PackageManager from which the icon can be loaded; usually
212 * the PackageManager from which you originally retrieved this item.
Sudheer Shanka9ded7602015-05-19 21:17:25 +0100213 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800214 * @return Returns a Drawable containing the resolution's icon. If the
215 * item does not have an icon, the default activity icon is returned.
216 */
217 public Drawable loadIcon(PackageManager pm) {
Sudheer Shanka9ded7602015-05-19 21:17:25 +0100218 Drawable dr = null;
219 if (resolvePackageName != null && iconResourceId != 0) {
220 dr = pm.getDrawable(resolvePackageName, iconResourceId, null);
Dianne Hackborneb034652009-09-07 00:49:58 -0700221 }
Jeff Sharkey85f5f812013-10-07 10:16:12 -0700222 ComponentInfo ci = getComponentInfo();
Sudheer Shanka9ded7602015-05-19 21:17:25 +0100223 if (dr == null && iconResourceId != 0) {
224 ApplicationInfo ai = ci.applicationInfo;
225 dr = pm.getDrawable(ci.packageName, iconResourceId, ai);
226 }
227 if (dr != null) {
228 return pm.getUserBadgedIcon(dr, new UserHandle(UserHandle.myUserId()));
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800229 }
230 return ci.loadIcon(pm);
231 }
Ricky Wai1281b182015-04-29 14:57:04 +0100232
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800233 /**
234 * Return the icon resource identifier to use for this match. If the
235 * match defines an icon, that is used; else if the activity defines
236 * an icon, that is used; else, the application icon is used.
Ricky Wai1281b182015-04-29 14:57:04 +0100237 * This function does not check noResourceId flag.
238 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800239 * @return The icon associated with this match.
240 */
Ricky Wai1281b182015-04-29 14:57:04 +0100241 final int getIconResourceInternal() {
Sudheer Shanka9ded7602015-05-19 21:17:25 +0100242 if (iconResourceId != 0) return iconResourceId;
Jeff Sharkey85f5f812013-10-07 10:16:12 -0700243 final ComponentInfo ci = getComponentInfo();
Nicolas Prevot7f7b0c72014-06-23 15:59:38 +0100244 if (ci != null) {
Nicolas Prevot88cc3462014-05-14 14:51:48 +0100245 return ci.getIconResource();
246 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800247 return 0;
248 }
249
Ricky Wai1281b182015-04-29 14:57:04 +0100250 /**
251 * Return the icon resource identifier to use for this match. If the
252 * match defines an icon, that is used; else if the activity defines
253 * an icon, that is used; else, the application icon is used.
254 *
255 * @return The icon associated with this match.
256 */
257 public final int getIconResource() {
258 if (noResourceId) return 0;
259 return getIconResourceInternal();
260 }
261
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800262 public void dump(Printer pw, String prefix) {
263 if (filter != null) {
264 pw.println(prefix + "Filter:");
265 filter.dump(pw, prefix + " ");
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800266 }
267 pw.println(prefix + "priority=" + priority
268 + " preferredOrder=" + preferredOrder
269 + " match=0x" + Integer.toHexString(match)
270 + " specificIndex=" + specificIndex
271 + " isDefault=" + isDefault);
Dianne Hackborneb034652009-09-07 00:49:58 -0700272 if (resolvePackageName != null) {
273 pw.println(prefix + "resolvePackageName=" + resolvePackageName);
274 }
275 if (labelRes != 0 || nonLocalizedLabel != null || icon != 0) {
276 pw.println(prefix + "labelRes=0x" + Integer.toHexString(labelRes)
277 + " nonLocalizedLabel=" + nonLocalizedLabel
278 + " icon=0x" + Integer.toHexString(icon));
279 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800280 if (activityInfo != null) {
281 pw.println(prefix + "ActivityInfo:");
282 activityInfo.dump(pw, prefix + " ");
283 } else if (serviceInfo != null) {
284 pw.println(prefix + "ServiceInfo:");
Dianne Hackborneb034652009-09-07 00:49:58 -0700285 serviceInfo.dump(pw, prefix + " ");
Jeff Sharkey85f5f812013-10-07 10:16:12 -0700286 } else if (providerInfo != null) {
287 pw.println(prefix + "ProviderInfo:");
288 providerInfo.dump(pw, prefix + " ");
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800289 }
290 }
291
292 public ResolveInfo() {
Nicolas Prevot88cc3462014-05-14 14:51:48 +0100293 targetUserId = UserHandle.USER_CURRENT;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800294 }
295
Dianne Hackborn8da429e2012-09-23 12:52:19 -0700296 public ResolveInfo(ResolveInfo orig) {
297 activityInfo = orig.activityInfo;
298 serviceInfo = orig.serviceInfo;
Jeff Sharkey85f5f812013-10-07 10:16:12 -0700299 providerInfo = orig.providerInfo;
Dianne Hackborn8da429e2012-09-23 12:52:19 -0700300 filter = orig.filter;
301 priority = orig.priority;
302 preferredOrder = orig.preferredOrder;
303 match = orig.match;
304 specificIndex = orig.specificIndex;
305 labelRes = orig.labelRes;
306 nonLocalizedLabel = orig.nonLocalizedLabel;
307 icon = orig.icon;
308 resolvePackageName = orig.resolvePackageName;
Sudheer Shanka9ded7602015-05-19 21:17:25 +0100309 noResourceId = orig.noResourceId;
310 iconResourceId = orig.iconResourceId;
Dianne Hackborn8da429e2012-09-23 12:52:19 -0700311 system = orig.system;
Nicolas Prevot88cc3462014-05-14 14:51:48 +0100312 targetUserId = orig.targetUserId;
Fabrice Di Meglio7d014ce2015-04-08 16:17:46 -0700313 handleAllWebDataURI = orig.handleAllWebDataURI;
Dianne Hackborn8da429e2012-09-23 12:52:19 -0700314 }
315
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800316 public String toString() {
Jeff Sharkey85f5f812013-10-07 10:16:12 -0700317 final ComponentInfo ci = getComponentInfo();
Dianne Hackborn6d8dfbd2013-09-23 17:38:51 -0700318 StringBuilder sb = new StringBuilder(128);
319 sb.append("ResolveInfo{");
320 sb.append(Integer.toHexString(System.identityHashCode(this)));
321 sb.append(' ');
322 ComponentName.appendShortString(sb, ci.packageName, ci.name);
323 if (priority != 0) {
324 sb.append(" p=");
325 sb.append(priority);
326 }
327 if (preferredOrder != 0) {
328 sb.append(" o=");
329 sb.append(preferredOrder);
330 }
331 sb.append(" m=0x");
332 sb.append(Integer.toHexString(match));
Nicolas Prevot88cc3462014-05-14 14:51:48 +0100333 if (targetUserId != UserHandle.USER_CURRENT) {
334 sb.append(" targetUserId=");
335 sb.append(targetUserId);
336 }
Dianne Hackborn6d8dfbd2013-09-23 17:38:51 -0700337 sb.append('}');
338 return sb.toString();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800339 }
340
341 public int describeContents() {
342 return 0;
343 }
344
345 public void writeToParcel(Parcel dest, int parcelableFlags) {
346 if (activityInfo != null) {
347 dest.writeInt(1);
348 activityInfo.writeToParcel(dest, parcelableFlags);
349 } else if (serviceInfo != null) {
350 dest.writeInt(2);
351 serviceInfo.writeToParcel(dest, parcelableFlags);
Jeff Sharkey85f5f812013-10-07 10:16:12 -0700352 } else if (providerInfo != null) {
353 dest.writeInt(3);
354 providerInfo.writeToParcel(dest, parcelableFlags);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800355 } else {
356 dest.writeInt(0);
357 }
358 if (filter != null) {
359 dest.writeInt(1);
360 filter.writeToParcel(dest, parcelableFlags);
361 } else {
362 dest.writeInt(0);
363 }
364 dest.writeInt(priority);
365 dest.writeInt(preferredOrder);
366 dest.writeInt(match);
367 dest.writeInt(specificIndex);
368 dest.writeInt(labelRes);
369 TextUtils.writeToParcel(nonLocalizedLabel, dest, parcelableFlags);
370 dest.writeInt(icon);
Dianne Hackborneb034652009-09-07 00:49:58 -0700371 dest.writeString(resolvePackageName);
Nicolas Prevot88cc3462014-05-14 14:51:48 +0100372 dest.writeInt(targetUserId);
Dianne Hackbornd99b2932011-08-18 14:39:58 -0700373 dest.writeInt(system ? 1 : 0);
Nicolas Prevot7f7b0c72014-06-23 15:59:38 +0100374 dest.writeInt(noResourceId ? 1 : 0);
Sudheer Shanka9ded7602015-05-19 21:17:25 +0100375 dest.writeInt(iconResourceId);
Fabrice Di Meglio7d014ce2015-04-08 16:17:46 -0700376 dest.writeInt(handleAllWebDataURI ? 1 : 0);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800377 }
378
379 public static final Creator<ResolveInfo> CREATOR
380 = new Creator<ResolveInfo>() {
381 public ResolveInfo createFromParcel(Parcel source) {
382 return new ResolveInfo(source);
383 }
384 public ResolveInfo[] newArray(int size) {
385 return new ResolveInfo[size];
386 }
387 };
388
389 private ResolveInfo(Parcel source) {
Jeff Sharkey85f5f812013-10-07 10:16:12 -0700390 activityInfo = null;
391 serviceInfo = null;
392 providerInfo = null;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800393 switch (source.readInt()) {
394 case 1:
395 activityInfo = ActivityInfo.CREATOR.createFromParcel(source);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800396 break;
397 case 2:
398 serviceInfo = ServiceInfo.CREATOR.createFromParcel(source);
Jeff Sharkey85f5f812013-10-07 10:16:12 -0700399 break;
400 case 3:
401 providerInfo = ProviderInfo.CREATOR.createFromParcel(source);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800402 break;
403 default:
Jeff Sharkey85f5f812013-10-07 10:16:12 -0700404 Slog.w(TAG, "Missing ComponentInfo!");
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800405 break;
406 }
407 if (source.readInt() != 0) {
408 filter = IntentFilter.CREATOR.createFromParcel(source);
409 }
410 priority = source.readInt();
411 preferredOrder = source.readInt();
412 match = source.readInt();
413 specificIndex = source.readInt();
414 labelRes = source.readInt();
415 nonLocalizedLabel
416 = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(source);
417 icon = source.readInt();
Dianne Hackborneb034652009-09-07 00:49:58 -0700418 resolvePackageName = source.readString();
Nicolas Prevot88cc3462014-05-14 14:51:48 +0100419 targetUserId = source.readInt();
Dianne Hackbornd99b2932011-08-18 14:39:58 -0700420 system = source.readInt() != 0;
Nicolas Prevot7f7b0c72014-06-23 15:59:38 +0100421 noResourceId = source.readInt() != 0;
Sudheer Shanka9ded7602015-05-19 21:17:25 +0100422 iconResourceId = source.readInt();
Fabrice Di Meglio7d014ce2015-04-08 16:17:46 -0700423 handleAllWebDataURI = source.readInt() != 0;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800424 }
Sudheer Shanka9ded7602015-05-19 21:17:25 +0100425
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800426 public static class DisplayNameComparator
427 implements Comparator<ResolveInfo> {
428 public DisplayNameComparator(PackageManager pm) {
429 mPM = pm;
Adam Powell0256c6f2013-05-29 16:42:33 -0700430 mCollator.setStrength(Collator.PRIMARY);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800431 }
432
433 public final int compare(ResolveInfo a, ResolveInfo b) {
Nicolas Prevot88cc3462014-05-14 14:51:48 +0100434 // We want to put the one targeted to another user at the end of the dialog.
435 if (a.targetUserId != UserHandle.USER_CURRENT) {
436 return 1;
437 }
438 if (b.targetUserId != UserHandle.USER_CURRENT) {
439 return -1;
440 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800441 CharSequence sa = a.loadLabel(mPM);
442 if (sa == null) sa = a.activityInfo.name;
443 CharSequence sb = b.loadLabel(mPM);
444 if (sb == null) sb = b.activityInfo.name;
445
Adam Powell0256c6f2013-05-29 16:42:33 -0700446 return mCollator.compare(sa.toString(), sb.toString());
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800447 }
448
Adam Powell0256c6f2013-05-29 16:42:33 -0700449 private final Collator mCollator = Collator.getInstance();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800450 private PackageManager mPM;
451 }
452}