blob: a5fb451db61d75b49080ad55bc822ed9b1aa2e01 [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) {
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -0800263 dump(pw, prefix, PackageItemInfo.DUMP_FLAG_ALL);
264 }
265
266 /** @hide */
267 public void dump(Printer pw, String prefix, int flags) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800268 if (filter != null) {
269 pw.println(prefix + "Filter:");
270 filter.dump(pw, prefix + " ");
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800271 }
272 pw.println(prefix + "priority=" + priority
273 + " preferredOrder=" + preferredOrder
274 + " match=0x" + Integer.toHexString(match)
275 + " specificIndex=" + specificIndex
276 + " isDefault=" + isDefault);
Dianne Hackborneb034652009-09-07 00:49:58 -0700277 if (resolvePackageName != null) {
278 pw.println(prefix + "resolvePackageName=" + resolvePackageName);
279 }
280 if (labelRes != 0 || nonLocalizedLabel != null || icon != 0) {
281 pw.println(prefix + "labelRes=0x" + Integer.toHexString(labelRes)
282 + " nonLocalizedLabel=" + nonLocalizedLabel
283 + " icon=0x" + Integer.toHexString(icon));
284 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800285 if (activityInfo != null) {
286 pw.println(prefix + "ActivityInfo:");
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -0800287 activityInfo.dump(pw, prefix + " ", flags);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800288 } else if (serviceInfo != null) {
289 pw.println(prefix + "ServiceInfo:");
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -0800290 serviceInfo.dump(pw, prefix + " ", flags);
Jeff Sharkey85f5f812013-10-07 10:16:12 -0700291 } else if (providerInfo != null) {
292 pw.println(prefix + "ProviderInfo:");
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -0800293 providerInfo.dump(pw, prefix + " ", flags);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800294 }
295 }
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -0800296
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800297 public ResolveInfo() {
Nicolas Prevot88cc3462014-05-14 14:51:48 +0100298 targetUserId = UserHandle.USER_CURRENT;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800299 }
300
Dianne Hackborn8da429e2012-09-23 12:52:19 -0700301 public ResolveInfo(ResolveInfo orig) {
302 activityInfo = orig.activityInfo;
303 serviceInfo = orig.serviceInfo;
Jeff Sharkey85f5f812013-10-07 10:16:12 -0700304 providerInfo = orig.providerInfo;
Dianne Hackborn8da429e2012-09-23 12:52:19 -0700305 filter = orig.filter;
306 priority = orig.priority;
307 preferredOrder = orig.preferredOrder;
308 match = orig.match;
309 specificIndex = orig.specificIndex;
310 labelRes = orig.labelRes;
311 nonLocalizedLabel = orig.nonLocalizedLabel;
312 icon = orig.icon;
313 resolvePackageName = orig.resolvePackageName;
Sudheer Shanka9ded7602015-05-19 21:17:25 +0100314 noResourceId = orig.noResourceId;
315 iconResourceId = orig.iconResourceId;
Dianne Hackborn8da429e2012-09-23 12:52:19 -0700316 system = orig.system;
Nicolas Prevot88cc3462014-05-14 14:51:48 +0100317 targetUserId = orig.targetUserId;
Fabrice Di Meglio7d014ce2015-04-08 16:17:46 -0700318 handleAllWebDataURI = orig.handleAllWebDataURI;
Dianne Hackborn8da429e2012-09-23 12:52:19 -0700319 }
320
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800321 public String toString() {
Jeff Sharkey85f5f812013-10-07 10:16:12 -0700322 final ComponentInfo ci = getComponentInfo();
Dianne Hackborn6d8dfbd2013-09-23 17:38:51 -0700323 StringBuilder sb = new StringBuilder(128);
324 sb.append("ResolveInfo{");
325 sb.append(Integer.toHexString(System.identityHashCode(this)));
326 sb.append(' ');
327 ComponentName.appendShortString(sb, ci.packageName, ci.name);
328 if (priority != 0) {
329 sb.append(" p=");
330 sb.append(priority);
331 }
332 if (preferredOrder != 0) {
333 sb.append(" o=");
334 sb.append(preferredOrder);
335 }
336 sb.append(" m=0x");
337 sb.append(Integer.toHexString(match));
Nicolas Prevot88cc3462014-05-14 14:51:48 +0100338 if (targetUserId != UserHandle.USER_CURRENT) {
339 sb.append(" targetUserId=");
340 sb.append(targetUserId);
341 }
Dianne Hackborn6d8dfbd2013-09-23 17:38:51 -0700342 sb.append('}');
343 return sb.toString();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800344 }
345
346 public int describeContents() {
347 return 0;
348 }
349
350 public void writeToParcel(Parcel dest, int parcelableFlags) {
351 if (activityInfo != null) {
352 dest.writeInt(1);
353 activityInfo.writeToParcel(dest, parcelableFlags);
354 } else if (serviceInfo != null) {
355 dest.writeInt(2);
356 serviceInfo.writeToParcel(dest, parcelableFlags);
Jeff Sharkey85f5f812013-10-07 10:16:12 -0700357 } else if (providerInfo != null) {
358 dest.writeInt(3);
359 providerInfo.writeToParcel(dest, parcelableFlags);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800360 } else {
361 dest.writeInt(0);
362 }
363 if (filter != null) {
364 dest.writeInt(1);
365 filter.writeToParcel(dest, parcelableFlags);
366 } else {
367 dest.writeInt(0);
368 }
369 dest.writeInt(priority);
370 dest.writeInt(preferredOrder);
371 dest.writeInt(match);
372 dest.writeInt(specificIndex);
373 dest.writeInt(labelRes);
374 TextUtils.writeToParcel(nonLocalizedLabel, dest, parcelableFlags);
375 dest.writeInt(icon);
Dianne Hackborneb034652009-09-07 00:49:58 -0700376 dest.writeString(resolvePackageName);
Nicolas Prevot88cc3462014-05-14 14:51:48 +0100377 dest.writeInt(targetUserId);
Dianne Hackbornd99b2932011-08-18 14:39:58 -0700378 dest.writeInt(system ? 1 : 0);
Nicolas Prevot7f7b0c72014-06-23 15:59:38 +0100379 dest.writeInt(noResourceId ? 1 : 0);
Sudheer Shanka9ded7602015-05-19 21:17:25 +0100380 dest.writeInt(iconResourceId);
Fabrice Di Meglio7d014ce2015-04-08 16:17:46 -0700381 dest.writeInt(handleAllWebDataURI ? 1 : 0);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800382 }
383
384 public static final Creator<ResolveInfo> CREATOR
385 = new Creator<ResolveInfo>() {
386 public ResolveInfo createFromParcel(Parcel source) {
387 return new ResolveInfo(source);
388 }
389 public ResolveInfo[] newArray(int size) {
390 return new ResolveInfo[size];
391 }
392 };
393
394 private ResolveInfo(Parcel source) {
Jeff Sharkey85f5f812013-10-07 10:16:12 -0700395 activityInfo = null;
396 serviceInfo = null;
397 providerInfo = null;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800398 switch (source.readInt()) {
399 case 1:
400 activityInfo = ActivityInfo.CREATOR.createFromParcel(source);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800401 break;
402 case 2:
403 serviceInfo = ServiceInfo.CREATOR.createFromParcel(source);
Jeff Sharkey85f5f812013-10-07 10:16:12 -0700404 break;
405 case 3:
406 providerInfo = ProviderInfo.CREATOR.createFromParcel(source);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800407 break;
408 default:
Jeff Sharkey85f5f812013-10-07 10:16:12 -0700409 Slog.w(TAG, "Missing ComponentInfo!");
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800410 break;
411 }
412 if (source.readInt() != 0) {
413 filter = IntentFilter.CREATOR.createFromParcel(source);
414 }
415 priority = source.readInt();
416 preferredOrder = source.readInt();
417 match = source.readInt();
418 specificIndex = source.readInt();
419 labelRes = source.readInt();
420 nonLocalizedLabel
421 = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(source);
422 icon = source.readInt();
Dianne Hackborneb034652009-09-07 00:49:58 -0700423 resolvePackageName = source.readString();
Nicolas Prevot88cc3462014-05-14 14:51:48 +0100424 targetUserId = source.readInt();
Dianne Hackbornd99b2932011-08-18 14:39:58 -0700425 system = source.readInt() != 0;
Nicolas Prevot7f7b0c72014-06-23 15:59:38 +0100426 noResourceId = source.readInt() != 0;
Sudheer Shanka9ded7602015-05-19 21:17:25 +0100427 iconResourceId = source.readInt();
Fabrice Di Meglio7d014ce2015-04-08 16:17:46 -0700428 handleAllWebDataURI = source.readInt() != 0;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800429 }
Sudheer Shanka9ded7602015-05-19 21:17:25 +0100430
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800431 public static class DisplayNameComparator
432 implements Comparator<ResolveInfo> {
433 public DisplayNameComparator(PackageManager pm) {
434 mPM = pm;
Adam Powell0256c6f2013-05-29 16:42:33 -0700435 mCollator.setStrength(Collator.PRIMARY);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800436 }
437
438 public final int compare(ResolveInfo a, ResolveInfo b) {
Nicolas Prevot88cc3462014-05-14 14:51:48 +0100439 // We want to put the one targeted to another user at the end of the dialog.
440 if (a.targetUserId != UserHandle.USER_CURRENT) {
441 return 1;
442 }
443 if (b.targetUserId != UserHandle.USER_CURRENT) {
444 return -1;
445 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800446 CharSequence sa = a.loadLabel(mPM);
447 if (sa == null) sa = a.activityInfo.name;
448 CharSequence sb = b.loadLabel(mPM);
449 if (sb == null) sb = b.activityInfo.name;
450
Adam Powell0256c6f2013-05-29 16:42:33 -0700451 return mCollator.compare(sa.toString(), sb.toString());
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800452 }
453
Adam Powell0256c6f2013-05-29 16:42:33 -0700454 private final Collator mCollator = Collator.getInstance();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800455 private PackageManager mPM;
456 }
457}