blob: b5df4d75a2384a39aec1aefcda047fc6ebd654fa [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 /**
Todd Kennedy7440f172015-12-09 14:31:22 -080064 * The ephemeral application that corresponds to this resolution match. This will
65 * only be set in specific circumstances.
66 * @hide
67 */
68 public EphemeralResolveInfo ephemeralResolveInfo;
69
70 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080071 * The IntentFilter that was matched for this ResolveInfo.
72 */
73 public IntentFilter filter;
Sudheer Shanka9ded7602015-05-19 21:17:25 +010074
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080075 /**
76 * The declared priority of this match. Comes from the "priority"
77 * attribute or, if not set, defaults to 0. Higher values are a higher
78 * priority.
79 */
80 public int priority;
Sudheer Shanka9ded7602015-05-19 21:17:25 +010081
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080082 /**
83 * Order of result according to the user's preference. If the user
84 * has not set a preference for this result, the value is 0; higher
85 * values are a higher priority.
86 */
87 public int preferredOrder;
Sudheer Shanka9ded7602015-05-19 21:17:25 +010088
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080089 /**
90 * The system's evaluation of how well the activity matches the
91 * IntentFilter. This is a match constant, a combination of
92 * {@link IntentFilter#MATCH_CATEGORY_MASK IntentFilter.MATCH_CATEGORY_MASK}
93 * and {@link IntentFilter#MATCH_ADJUSTMENT_MASK IntentFiler.MATCH_ADJUSTMENT_MASK}.
94 */
95 public int match;
Sudheer Shanka9ded7602015-05-19 21:17:25 +010096
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080097 /**
98 * Only set when returned by
99 * {@link PackageManager#queryIntentActivityOptions}, this tells you
100 * which of the given specific intents this result came from. 0 is the
101 * first in the list, < 0 means it came from the generic Intent query.
102 */
103 public int specificIndex = -1;
Sudheer Shanka9ded7602015-05-19 21:17:25 +0100104
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800105 /**
106 * This filter has specified the Intent.CATEGORY_DEFAULT, meaning it
107 * would like to be considered a default action that the user can
108 * perform on this data.
109 */
110 public boolean isDefault;
Sudheer Shanka9ded7602015-05-19 21:17:25 +0100111
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800112 /**
113 * A string resource identifier (in the package's resources) of this
114 * match's label. From the "label" attribute or, if not set, 0.
115 */
116 public int labelRes;
Sudheer Shanka9ded7602015-05-19 21:17:25 +0100117
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800118 /**
119 * The actual string retrieve from <var>labelRes</var> or null if none
120 * was provided.
121 */
122 public CharSequence nonLocalizedLabel;
Sudheer Shanka9ded7602015-05-19 21:17:25 +0100123
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800124 /**
125 * A drawable resource identifier (in the package's resources) of this
Sudheer Shanka9ded7602015-05-19 21:17:25 +0100126 * match's icon. From the "icon" attribute or, if not set, 0. It is
127 * set only if the icon can be obtained by resource id alone.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800128 */
129 public int icon;
130
131 /**
Dianne Hackborneb034652009-09-07 00:49:58 -0700132 * Optional -- if non-null, the {@link #labelRes} and {@link #icon}
133 * resources will be loaded from this package, rather than the one
134 * containing the resolved component.
135 */
136 public String resolvePackageName;
Dianne Hackbornd99b2932011-08-18 14:39:58 -0700137
138 /**
Nicolas Prevot88cc3462014-05-14 14:51:48 +0100139 * If not equal to UserHandle.USER_CURRENT, then the intent will be forwarded to this user.
140 * @hide
141 */
142 public int targetUserId;
143
144 /**
Sudheer Shanka9ded7602015-05-19 21:17:25 +0100145 * Set to true if the icon cannot be obtained by resource ids alone.
146 * It is set to true for ResolveInfos from the managed profile: They need to
147 * have their icon badged, so it cannot be obtained by resource ids alone.
Nicolas Prevot88cc3462014-05-14 14:51:48 +0100148 * @hide
149 */
Nicolas Prevot7f7b0c72014-06-23 15:59:38 +0100150 public boolean noResourceId;
Nicolas Prevot88cc3462014-05-14 14:51:48 +0100151
152 /**
Sudheer Shanka9ded7602015-05-19 21:17:25 +0100153 * Same as {@link #icon} but it will always correspond to "icon" attribute
154 * regardless of {@link #noResourceId} value.
155 * @hide
156 */
157 public int iconResourceId;
158
159 /**
Dianne Hackbornd99b2932011-08-18 14:39:58 -0700160 * @hide Target comes from system process?
161 */
162 public boolean system;
163
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -0800164 /**
Fabrice Di Meglio7d014ce2015-04-08 16:17:46 -0700165 * @hide Does the associated IntentFilter comes from a Browser ?
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -0800166 */
Fabrice Di Meglio7d014ce2015-04-08 16:17:46 -0700167 public boolean handleAllWebDataURI;
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -0800168
Jeff Sharkey2a90f6732016-01-06 12:26:11 -0700169 /** {@hide} */
170 public ComponentInfo getComponentInfo() {
Jeff Sharkey85f5f812013-10-07 10:16:12 -0700171 if (activityInfo != null) return activityInfo;
172 if (serviceInfo != null) return serviceInfo;
173 if (providerInfo != null) return providerInfo;
174 throw new IllegalStateException("Missing ComponentInfo!");
175 }
176
Dianne Hackborneb034652009-09-07 00:49:58 -0700177 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800178 * Retrieve the current textual label associated with this resolution. This
179 * will call back on the given PackageManager to load the label from
180 * the application.
Sudheer Shanka9ded7602015-05-19 21:17:25 +0100181 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800182 * @param pm A PackageManager from which the label can be loaded; usually
183 * the PackageManager from which you originally retrieved this item.
Sudheer Shanka9ded7602015-05-19 21:17:25 +0100184 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800185 * @return Returns a CharSequence containing the resolutions's label. If the
186 * item does not have a label, its name is returned.
187 */
188 public CharSequence loadLabel(PackageManager pm) {
189 if (nonLocalizedLabel != null) {
190 return nonLocalizedLabel;
191 }
Dianne Hackborneb034652009-09-07 00:49:58 -0700192 CharSequence label;
193 if (resolvePackageName != null && labelRes != 0) {
194 label = pm.getText(resolvePackageName, labelRes, null);
195 if (label != null) {
Romain Guy2aba11f2010-03-29 16:03:01 -0700196 return label.toString().trim();
Dianne Hackborneb034652009-09-07 00:49:58 -0700197 }
198 }
Jeff Sharkey85f5f812013-10-07 10:16:12 -0700199 ComponentInfo ci = getComponentInfo();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800200 ApplicationInfo ai = ci.applicationInfo;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800201 if (labelRes != 0) {
202 label = pm.getText(ci.packageName, labelRes, ai);
203 if (label != null) {
Romain Guy2aba11f2010-03-29 16:03:01 -0700204 return label.toString().trim();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800205 }
206 }
Romain Guy2aba11f2010-03-29 16:03:01 -0700207
208 CharSequence data = ci.loadLabel(pm);
209 // Make the data safe
210 if (data != null) data = data.toString().trim();
211 return data;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800212 }
Sudheer Shanka9ded7602015-05-19 21:17:25 +0100213
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800214 /**
215 * Retrieve the current graphical icon associated with this resolution. This
216 * will call back on the given PackageManager to load the icon from
217 * the application.
Sudheer Shanka9ded7602015-05-19 21:17:25 +0100218 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800219 * @param pm A PackageManager from which the icon can be loaded; usually
220 * the PackageManager from which you originally retrieved this item.
Sudheer Shanka9ded7602015-05-19 21:17:25 +0100221 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800222 * @return Returns a Drawable containing the resolution's icon. If the
223 * item does not have an icon, the default activity icon is returned.
224 */
225 public Drawable loadIcon(PackageManager pm) {
Sudheer Shanka9ded7602015-05-19 21:17:25 +0100226 Drawable dr = null;
227 if (resolvePackageName != null && iconResourceId != 0) {
228 dr = pm.getDrawable(resolvePackageName, iconResourceId, null);
Dianne Hackborneb034652009-09-07 00:49:58 -0700229 }
Jeff Sharkey85f5f812013-10-07 10:16:12 -0700230 ComponentInfo ci = getComponentInfo();
Sudheer Shanka9ded7602015-05-19 21:17:25 +0100231 if (dr == null && iconResourceId != 0) {
232 ApplicationInfo ai = ci.applicationInfo;
233 dr = pm.getDrawable(ci.packageName, iconResourceId, ai);
234 }
235 if (dr != null) {
236 return pm.getUserBadgedIcon(dr, new UserHandle(UserHandle.myUserId()));
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800237 }
238 return ci.loadIcon(pm);
239 }
Ricky Wai1281b182015-04-29 14:57:04 +0100240
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800241 /**
242 * Return the icon resource identifier to use for this match. If the
243 * match defines an icon, that is used; else if the activity defines
244 * an icon, that is used; else, the application icon is used.
Ricky Wai1281b182015-04-29 14:57:04 +0100245 * This function does not check noResourceId flag.
246 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800247 * @return The icon associated with this match.
248 */
Ricky Wai1281b182015-04-29 14:57:04 +0100249 final int getIconResourceInternal() {
Sudheer Shanka9ded7602015-05-19 21:17:25 +0100250 if (iconResourceId != 0) return iconResourceId;
Jeff Sharkey85f5f812013-10-07 10:16:12 -0700251 final ComponentInfo ci = getComponentInfo();
Nicolas Prevot7f7b0c72014-06-23 15:59:38 +0100252 if (ci != null) {
Nicolas Prevot88cc3462014-05-14 14:51:48 +0100253 return ci.getIconResource();
254 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800255 return 0;
256 }
257
Ricky Wai1281b182015-04-29 14:57:04 +0100258 /**
259 * Return the icon resource identifier to use for this match. If the
260 * match defines an icon, that is used; else if the activity defines
261 * an icon, that is used; else, the application icon is used.
262 *
263 * @return The icon associated with this match.
264 */
265 public final int getIconResource() {
266 if (noResourceId) return 0;
267 return getIconResourceInternal();
268 }
269
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800270 public void dump(Printer pw, String prefix) {
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -0800271 dump(pw, prefix, PackageItemInfo.DUMP_FLAG_ALL);
272 }
273
274 /** @hide */
275 public void dump(Printer pw, String prefix, int flags) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800276 if (filter != null) {
277 pw.println(prefix + "Filter:");
278 filter.dump(pw, prefix + " ");
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800279 }
280 pw.println(prefix + "priority=" + priority
281 + " preferredOrder=" + preferredOrder
282 + " match=0x" + Integer.toHexString(match)
283 + " specificIndex=" + specificIndex
284 + " isDefault=" + isDefault);
Dianne Hackborneb034652009-09-07 00:49:58 -0700285 if (resolvePackageName != null) {
286 pw.println(prefix + "resolvePackageName=" + resolvePackageName);
287 }
288 if (labelRes != 0 || nonLocalizedLabel != null || icon != 0) {
289 pw.println(prefix + "labelRes=0x" + Integer.toHexString(labelRes)
290 + " nonLocalizedLabel=" + nonLocalizedLabel
291 + " icon=0x" + Integer.toHexString(icon));
292 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800293 if (activityInfo != null) {
294 pw.println(prefix + "ActivityInfo:");
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -0800295 activityInfo.dump(pw, prefix + " ", flags);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800296 } else if (serviceInfo != null) {
297 pw.println(prefix + "ServiceInfo:");
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -0800298 serviceInfo.dump(pw, prefix + " ", flags);
Jeff Sharkey85f5f812013-10-07 10:16:12 -0700299 } else if (providerInfo != null) {
300 pw.println(prefix + "ProviderInfo:");
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -0800301 providerInfo.dump(pw, prefix + " ", flags);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800302 }
303 }
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -0800304
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800305 public ResolveInfo() {
Nicolas Prevot88cc3462014-05-14 14:51:48 +0100306 targetUserId = UserHandle.USER_CURRENT;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800307 }
308
Dianne Hackborn8da429e2012-09-23 12:52:19 -0700309 public ResolveInfo(ResolveInfo orig) {
310 activityInfo = orig.activityInfo;
311 serviceInfo = orig.serviceInfo;
Jeff Sharkey85f5f812013-10-07 10:16:12 -0700312 providerInfo = orig.providerInfo;
Dianne Hackborn8da429e2012-09-23 12:52:19 -0700313 filter = orig.filter;
314 priority = orig.priority;
315 preferredOrder = orig.preferredOrder;
316 match = orig.match;
317 specificIndex = orig.specificIndex;
318 labelRes = orig.labelRes;
319 nonLocalizedLabel = orig.nonLocalizedLabel;
320 icon = orig.icon;
321 resolvePackageName = orig.resolvePackageName;
Sudheer Shanka9ded7602015-05-19 21:17:25 +0100322 noResourceId = orig.noResourceId;
323 iconResourceId = orig.iconResourceId;
Dianne Hackborn8da429e2012-09-23 12:52:19 -0700324 system = orig.system;
Nicolas Prevot88cc3462014-05-14 14:51:48 +0100325 targetUserId = orig.targetUserId;
Fabrice Di Meglio7d014ce2015-04-08 16:17:46 -0700326 handleAllWebDataURI = orig.handleAllWebDataURI;
Dianne Hackborn8da429e2012-09-23 12:52:19 -0700327 }
328
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800329 public String toString() {
Jeff Sharkey85f5f812013-10-07 10:16:12 -0700330 final ComponentInfo ci = getComponentInfo();
Dianne Hackborn6d8dfbd2013-09-23 17:38:51 -0700331 StringBuilder sb = new StringBuilder(128);
332 sb.append("ResolveInfo{");
333 sb.append(Integer.toHexString(System.identityHashCode(this)));
334 sb.append(' ');
335 ComponentName.appendShortString(sb, ci.packageName, ci.name);
336 if (priority != 0) {
337 sb.append(" p=");
338 sb.append(priority);
339 }
340 if (preferredOrder != 0) {
341 sb.append(" o=");
342 sb.append(preferredOrder);
343 }
344 sb.append(" m=0x");
345 sb.append(Integer.toHexString(match));
Nicolas Prevot88cc3462014-05-14 14:51:48 +0100346 if (targetUserId != UserHandle.USER_CURRENT) {
347 sb.append(" targetUserId=");
348 sb.append(targetUserId);
349 }
Dianne Hackborn6d8dfbd2013-09-23 17:38:51 -0700350 sb.append('}');
351 return sb.toString();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800352 }
353
354 public int describeContents() {
355 return 0;
356 }
357
358 public void writeToParcel(Parcel dest, int parcelableFlags) {
359 if (activityInfo != null) {
360 dest.writeInt(1);
361 activityInfo.writeToParcel(dest, parcelableFlags);
362 } else if (serviceInfo != null) {
363 dest.writeInt(2);
364 serviceInfo.writeToParcel(dest, parcelableFlags);
Jeff Sharkey85f5f812013-10-07 10:16:12 -0700365 } else if (providerInfo != null) {
366 dest.writeInt(3);
367 providerInfo.writeToParcel(dest, parcelableFlags);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800368 } else {
369 dest.writeInt(0);
370 }
371 if (filter != null) {
372 dest.writeInt(1);
373 filter.writeToParcel(dest, parcelableFlags);
374 } else {
375 dest.writeInt(0);
376 }
377 dest.writeInt(priority);
378 dest.writeInt(preferredOrder);
379 dest.writeInt(match);
380 dest.writeInt(specificIndex);
381 dest.writeInt(labelRes);
382 TextUtils.writeToParcel(nonLocalizedLabel, dest, parcelableFlags);
383 dest.writeInt(icon);
Dianne Hackborneb034652009-09-07 00:49:58 -0700384 dest.writeString(resolvePackageName);
Nicolas Prevot88cc3462014-05-14 14:51:48 +0100385 dest.writeInt(targetUserId);
Dianne Hackbornd99b2932011-08-18 14:39:58 -0700386 dest.writeInt(system ? 1 : 0);
Nicolas Prevot7f7b0c72014-06-23 15:59:38 +0100387 dest.writeInt(noResourceId ? 1 : 0);
Sudheer Shanka9ded7602015-05-19 21:17:25 +0100388 dest.writeInt(iconResourceId);
Fabrice Di Meglio7d014ce2015-04-08 16:17:46 -0700389 dest.writeInt(handleAllWebDataURI ? 1 : 0);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800390 }
391
392 public static final Creator<ResolveInfo> CREATOR
393 = new Creator<ResolveInfo>() {
394 public ResolveInfo createFromParcel(Parcel source) {
395 return new ResolveInfo(source);
396 }
397 public ResolveInfo[] newArray(int size) {
398 return new ResolveInfo[size];
399 }
400 };
401
402 private ResolveInfo(Parcel source) {
Jeff Sharkey85f5f812013-10-07 10:16:12 -0700403 activityInfo = null;
404 serviceInfo = null;
405 providerInfo = null;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800406 switch (source.readInt()) {
407 case 1:
408 activityInfo = ActivityInfo.CREATOR.createFromParcel(source);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800409 break;
410 case 2:
411 serviceInfo = ServiceInfo.CREATOR.createFromParcel(source);
Jeff Sharkey85f5f812013-10-07 10:16:12 -0700412 break;
413 case 3:
414 providerInfo = ProviderInfo.CREATOR.createFromParcel(source);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800415 break;
416 default:
Jeff Sharkey85f5f812013-10-07 10:16:12 -0700417 Slog.w(TAG, "Missing ComponentInfo!");
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800418 break;
419 }
420 if (source.readInt() != 0) {
421 filter = IntentFilter.CREATOR.createFromParcel(source);
422 }
423 priority = source.readInt();
424 preferredOrder = source.readInt();
425 match = source.readInt();
426 specificIndex = source.readInt();
427 labelRes = source.readInt();
428 nonLocalizedLabel
429 = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(source);
430 icon = source.readInt();
Dianne Hackborneb034652009-09-07 00:49:58 -0700431 resolvePackageName = source.readString();
Nicolas Prevot88cc3462014-05-14 14:51:48 +0100432 targetUserId = source.readInt();
Dianne Hackbornd99b2932011-08-18 14:39:58 -0700433 system = source.readInt() != 0;
Nicolas Prevot7f7b0c72014-06-23 15:59:38 +0100434 noResourceId = source.readInt() != 0;
Sudheer Shanka9ded7602015-05-19 21:17:25 +0100435 iconResourceId = source.readInt();
Fabrice Di Meglio7d014ce2015-04-08 16:17:46 -0700436 handleAllWebDataURI = source.readInt() != 0;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800437 }
Sudheer Shanka9ded7602015-05-19 21:17:25 +0100438
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800439 public static class DisplayNameComparator
440 implements Comparator<ResolveInfo> {
441 public DisplayNameComparator(PackageManager pm) {
442 mPM = pm;
Adam Powell0256c6f2013-05-29 16:42:33 -0700443 mCollator.setStrength(Collator.PRIMARY);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800444 }
445
446 public final int compare(ResolveInfo a, ResolveInfo b) {
Nicolas Prevot88cc3462014-05-14 14:51:48 +0100447 // We want to put the one targeted to another user at the end of the dialog.
448 if (a.targetUserId != UserHandle.USER_CURRENT) {
449 return 1;
450 }
451 if (b.targetUserId != UserHandle.USER_CURRENT) {
452 return -1;
453 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800454 CharSequence sa = a.loadLabel(mPM);
455 if (sa == null) sa = a.activityInfo.name;
456 CharSequence sb = b.loadLabel(mPM);
457 if (sb == null) sb = b.activityInfo.name;
458
Adam Powell0256c6f2013-05-29 16:42:33 -0700459 return mCollator.compare(sa.toString(), sb.toString());
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800460 }
461
Adam Powell0256c6f2013-05-29 16:42:33 -0700462 private final Collator mCollator = Collator.getInstance();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800463 private PackageManager mPM;
464 }
465}