blob: d5d300760c8a60101f7864a0847ab3b8f77f6c4e [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 /**
71 * A ResolveInfo that points at the ephemeral installer.
72 * @hide
73 */
74 public ResolveInfo ephemeralInstaller;
75
76 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080077 * The IntentFilter that was matched for this ResolveInfo.
78 */
79 public IntentFilter filter;
Sudheer Shanka9ded7602015-05-19 21:17:25 +010080
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080081 /**
82 * The declared priority of this match. Comes from the "priority"
83 * attribute or, if not set, defaults to 0. Higher values are a higher
84 * priority.
85 */
86 public int priority;
Sudheer Shanka9ded7602015-05-19 21:17:25 +010087
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080088 /**
89 * Order of result according to the user's preference. If the user
90 * has not set a preference for this result, the value is 0; higher
91 * values are a higher priority.
92 */
93 public int preferredOrder;
Sudheer Shanka9ded7602015-05-19 21:17:25 +010094
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080095 /**
96 * The system's evaluation of how well the activity matches the
97 * IntentFilter. This is a match constant, a combination of
98 * {@link IntentFilter#MATCH_CATEGORY_MASK IntentFilter.MATCH_CATEGORY_MASK}
99 * and {@link IntentFilter#MATCH_ADJUSTMENT_MASK IntentFiler.MATCH_ADJUSTMENT_MASK}.
100 */
101 public int match;
Sudheer Shanka9ded7602015-05-19 21:17:25 +0100102
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800103 /**
104 * Only set when returned by
105 * {@link PackageManager#queryIntentActivityOptions}, this tells you
106 * which of the given specific intents this result came from. 0 is the
107 * first in the list, < 0 means it came from the generic Intent query.
108 */
109 public int specificIndex = -1;
Sudheer Shanka9ded7602015-05-19 21:17:25 +0100110
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800111 /**
112 * This filter has specified the Intent.CATEGORY_DEFAULT, meaning it
113 * would like to be considered a default action that the user can
114 * perform on this data.
115 */
116 public boolean isDefault;
Sudheer Shanka9ded7602015-05-19 21:17:25 +0100117
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800118 /**
119 * A string resource identifier (in the package's resources) of this
120 * match's label. From the "label" attribute or, if not set, 0.
121 */
122 public int labelRes;
Sudheer Shanka9ded7602015-05-19 21:17:25 +0100123
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800124 /**
125 * The actual string retrieve from <var>labelRes</var> or null if none
126 * was provided.
127 */
128 public CharSequence nonLocalizedLabel;
Sudheer Shanka9ded7602015-05-19 21:17:25 +0100129
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800130 /**
131 * A drawable resource identifier (in the package's resources) of this
Sudheer Shanka9ded7602015-05-19 21:17:25 +0100132 * match's icon. From the "icon" attribute or, if not set, 0. It is
133 * set only if the icon can be obtained by resource id alone.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800134 */
135 public int icon;
136
137 /**
Dianne Hackborneb034652009-09-07 00:49:58 -0700138 * Optional -- if non-null, the {@link #labelRes} and {@link #icon}
139 * resources will be loaded from this package, rather than the one
140 * containing the resolved component.
141 */
142 public String resolvePackageName;
Dianne Hackbornd99b2932011-08-18 14:39:58 -0700143
144 /**
Nicolas Prevot88cc3462014-05-14 14:51:48 +0100145 * If not equal to UserHandle.USER_CURRENT, then the intent will be forwarded to this user.
146 * @hide
147 */
148 public int targetUserId;
149
150 /**
Sudheer Shanka9ded7602015-05-19 21:17:25 +0100151 * Set to true if the icon cannot be obtained by resource ids alone.
152 * It is set to true for ResolveInfos from the managed profile: They need to
153 * have their icon badged, so it cannot be obtained by resource ids alone.
Nicolas Prevot88cc3462014-05-14 14:51:48 +0100154 * @hide
155 */
Nicolas Prevot7f7b0c72014-06-23 15:59:38 +0100156 public boolean noResourceId;
Nicolas Prevot88cc3462014-05-14 14:51:48 +0100157
158 /**
Sudheer Shanka9ded7602015-05-19 21:17:25 +0100159 * Same as {@link #icon} but it will always correspond to "icon" attribute
160 * regardless of {@link #noResourceId} value.
161 * @hide
162 */
163 public int iconResourceId;
164
165 /**
Dianne Hackbornd99b2932011-08-18 14:39:58 -0700166 * @hide Target comes from system process?
167 */
168 public boolean system;
169
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -0800170 /**
Fabrice Di Meglio7d014ce2015-04-08 16:17:46 -0700171 * @hide Does the associated IntentFilter comes from a Browser ?
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -0800172 */
Fabrice Di Meglio7d014ce2015-04-08 16:17:46 -0700173 public boolean handleAllWebDataURI;
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -0800174
Jeff Sharkey85f5f812013-10-07 10:16:12 -0700175 private ComponentInfo getComponentInfo() {
176 if (activityInfo != null) return activityInfo;
177 if (serviceInfo != null) return serviceInfo;
178 if (providerInfo != null) return providerInfo;
179 throw new IllegalStateException("Missing ComponentInfo!");
180 }
181
Dianne Hackborneb034652009-09-07 00:49:58 -0700182 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800183 * Retrieve the current textual label associated with this resolution. This
184 * will call back on the given PackageManager to load the label from
185 * the application.
Sudheer Shanka9ded7602015-05-19 21:17:25 +0100186 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800187 * @param pm A PackageManager from which the label can be loaded; usually
188 * the PackageManager from which you originally retrieved this item.
Sudheer Shanka9ded7602015-05-19 21:17:25 +0100189 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800190 * @return Returns a CharSequence containing the resolutions's label. If the
191 * item does not have a label, its name is returned.
192 */
193 public CharSequence loadLabel(PackageManager pm) {
194 if (nonLocalizedLabel != null) {
195 return nonLocalizedLabel;
196 }
Dianne Hackborneb034652009-09-07 00:49:58 -0700197 CharSequence label;
198 if (resolvePackageName != null && labelRes != 0) {
199 label = pm.getText(resolvePackageName, labelRes, null);
200 if (label != null) {
Romain Guy2aba11f2010-03-29 16:03:01 -0700201 return label.toString().trim();
Dianne Hackborneb034652009-09-07 00:49:58 -0700202 }
203 }
Jeff Sharkey85f5f812013-10-07 10:16:12 -0700204 ComponentInfo ci = getComponentInfo();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800205 ApplicationInfo ai = ci.applicationInfo;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800206 if (labelRes != 0) {
207 label = pm.getText(ci.packageName, labelRes, ai);
208 if (label != null) {
Romain Guy2aba11f2010-03-29 16:03:01 -0700209 return label.toString().trim();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800210 }
211 }
Romain Guy2aba11f2010-03-29 16:03:01 -0700212
213 CharSequence data = ci.loadLabel(pm);
214 // Make the data safe
215 if (data != null) data = data.toString().trim();
216 return data;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800217 }
Sudheer Shanka9ded7602015-05-19 21:17:25 +0100218
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800219 /**
220 * Retrieve the current graphical icon associated with this resolution. This
221 * will call back on the given PackageManager to load the icon from
222 * the application.
Sudheer Shanka9ded7602015-05-19 21:17:25 +0100223 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800224 * @param pm A PackageManager from which the icon can be loaded; usually
225 * the PackageManager from which you originally retrieved this item.
Sudheer Shanka9ded7602015-05-19 21:17:25 +0100226 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800227 * @return Returns a Drawable containing the resolution's icon. If the
228 * item does not have an icon, the default activity icon is returned.
229 */
230 public Drawable loadIcon(PackageManager pm) {
Sudheer Shanka9ded7602015-05-19 21:17:25 +0100231 Drawable dr = null;
232 if (resolvePackageName != null && iconResourceId != 0) {
233 dr = pm.getDrawable(resolvePackageName, iconResourceId, null);
Dianne Hackborneb034652009-09-07 00:49:58 -0700234 }
Jeff Sharkey85f5f812013-10-07 10:16:12 -0700235 ComponentInfo ci = getComponentInfo();
Sudheer Shanka9ded7602015-05-19 21:17:25 +0100236 if (dr == null && iconResourceId != 0) {
237 ApplicationInfo ai = ci.applicationInfo;
238 dr = pm.getDrawable(ci.packageName, iconResourceId, ai);
239 }
240 if (dr != null) {
241 return pm.getUserBadgedIcon(dr, new UserHandle(UserHandle.myUserId()));
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800242 }
243 return ci.loadIcon(pm);
244 }
Ricky Wai1281b182015-04-29 14:57:04 +0100245
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800246 /**
247 * Return the icon resource identifier to use for this match. If the
248 * match defines an icon, that is used; else if the activity defines
249 * an icon, that is used; else, the application icon is used.
Ricky Wai1281b182015-04-29 14:57:04 +0100250 * This function does not check noResourceId flag.
251 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800252 * @return The icon associated with this match.
253 */
Ricky Wai1281b182015-04-29 14:57:04 +0100254 final int getIconResourceInternal() {
Sudheer Shanka9ded7602015-05-19 21:17:25 +0100255 if (iconResourceId != 0) return iconResourceId;
Jeff Sharkey85f5f812013-10-07 10:16:12 -0700256 final ComponentInfo ci = getComponentInfo();
Nicolas Prevot7f7b0c72014-06-23 15:59:38 +0100257 if (ci != null) {
Nicolas Prevot88cc3462014-05-14 14:51:48 +0100258 return ci.getIconResource();
259 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800260 return 0;
261 }
262
Ricky Wai1281b182015-04-29 14:57:04 +0100263 /**
264 * Return the icon resource identifier to use for this match. If the
265 * match defines an icon, that is used; else if the activity defines
266 * an icon, that is used; else, the application icon is used.
267 *
268 * @return The icon associated with this match.
269 */
270 public final int getIconResource() {
271 if (noResourceId) return 0;
272 return getIconResourceInternal();
273 }
274
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800275 public void dump(Printer pw, String prefix) {
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -0800276 dump(pw, prefix, PackageItemInfo.DUMP_FLAG_ALL);
277 }
278
279 /** @hide */
280 public void dump(Printer pw, String prefix, int flags) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800281 if (filter != null) {
282 pw.println(prefix + "Filter:");
283 filter.dump(pw, prefix + " ");
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800284 }
285 pw.println(prefix + "priority=" + priority
286 + " preferredOrder=" + preferredOrder
287 + " match=0x" + Integer.toHexString(match)
288 + " specificIndex=" + specificIndex
289 + " isDefault=" + isDefault);
Dianne Hackborneb034652009-09-07 00:49:58 -0700290 if (resolvePackageName != null) {
291 pw.println(prefix + "resolvePackageName=" + resolvePackageName);
292 }
293 if (labelRes != 0 || nonLocalizedLabel != null || icon != 0) {
294 pw.println(prefix + "labelRes=0x" + Integer.toHexString(labelRes)
295 + " nonLocalizedLabel=" + nonLocalizedLabel
296 + " icon=0x" + Integer.toHexString(icon));
297 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800298 if (activityInfo != null) {
299 pw.println(prefix + "ActivityInfo:");
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -0800300 activityInfo.dump(pw, prefix + " ", flags);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800301 } else if (serviceInfo != null) {
302 pw.println(prefix + "ServiceInfo:");
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -0800303 serviceInfo.dump(pw, prefix + " ", flags);
Jeff Sharkey85f5f812013-10-07 10:16:12 -0700304 } else if (providerInfo != null) {
305 pw.println(prefix + "ProviderInfo:");
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -0800306 providerInfo.dump(pw, prefix + " ", flags);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800307 }
308 }
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -0800309
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800310 public ResolveInfo() {
Nicolas Prevot88cc3462014-05-14 14:51:48 +0100311 targetUserId = UserHandle.USER_CURRENT;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800312 }
313
Dianne Hackborn8da429e2012-09-23 12:52:19 -0700314 public ResolveInfo(ResolveInfo orig) {
315 activityInfo = orig.activityInfo;
316 serviceInfo = orig.serviceInfo;
Jeff Sharkey85f5f812013-10-07 10:16:12 -0700317 providerInfo = orig.providerInfo;
Dianne Hackborn8da429e2012-09-23 12:52:19 -0700318 filter = orig.filter;
319 priority = orig.priority;
320 preferredOrder = orig.preferredOrder;
321 match = orig.match;
322 specificIndex = orig.specificIndex;
323 labelRes = orig.labelRes;
324 nonLocalizedLabel = orig.nonLocalizedLabel;
325 icon = orig.icon;
326 resolvePackageName = orig.resolvePackageName;
Sudheer Shanka9ded7602015-05-19 21:17:25 +0100327 noResourceId = orig.noResourceId;
328 iconResourceId = orig.iconResourceId;
Dianne Hackborn8da429e2012-09-23 12:52:19 -0700329 system = orig.system;
Nicolas Prevot88cc3462014-05-14 14:51:48 +0100330 targetUserId = orig.targetUserId;
Fabrice Di Meglio7d014ce2015-04-08 16:17:46 -0700331 handleAllWebDataURI = orig.handleAllWebDataURI;
Dianne Hackborn8da429e2012-09-23 12:52:19 -0700332 }
333
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800334 public String toString() {
Jeff Sharkey85f5f812013-10-07 10:16:12 -0700335 final ComponentInfo ci = getComponentInfo();
Dianne Hackborn6d8dfbd2013-09-23 17:38:51 -0700336 StringBuilder sb = new StringBuilder(128);
337 sb.append("ResolveInfo{");
338 sb.append(Integer.toHexString(System.identityHashCode(this)));
339 sb.append(' ');
340 ComponentName.appendShortString(sb, ci.packageName, ci.name);
341 if (priority != 0) {
342 sb.append(" p=");
343 sb.append(priority);
344 }
345 if (preferredOrder != 0) {
346 sb.append(" o=");
347 sb.append(preferredOrder);
348 }
349 sb.append(" m=0x");
350 sb.append(Integer.toHexString(match));
Nicolas Prevot88cc3462014-05-14 14:51:48 +0100351 if (targetUserId != UserHandle.USER_CURRENT) {
352 sb.append(" targetUserId=");
353 sb.append(targetUserId);
354 }
Dianne Hackborn6d8dfbd2013-09-23 17:38:51 -0700355 sb.append('}');
356 return sb.toString();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800357 }
358
359 public int describeContents() {
360 return 0;
361 }
362
363 public void writeToParcel(Parcel dest, int parcelableFlags) {
364 if (activityInfo != null) {
365 dest.writeInt(1);
366 activityInfo.writeToParcel(dest, parcelableFlags);
367 } else if (serviceInfo != null) {
368 dest.writeInt(2);
369 serviceInfo.writeToParcel(dest, parcelableFlags);
Jeff Sharkey85f5f812013-10-07 10:16:12 -0700370 } else if (providerInfo != null) {
371 dest.writeInt(3);
372 providerInfo.writeToParcel(dest, parcelableFlags);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800373 } else {
374 dest.writeInt(0);
375 }
376 if (filter != null) {
377 dest.writeInt(1);
378 filter.writeToParcel(dest, parcelableFlags);
379 } else {
380 dest.writeInt(0);
381 }
382 dest.writeInt(priority);
383 dest.writeInt(preferredOrder);
384 dest.writeInt(match);
385 dest.writeInt(specificIndex);
386 dest.writeInt(labelRes);
387 TextUtils.writeToParcel(nonLocalizedLabel, dest, parcelableFlags);
388 dest.writeInt(icon);
Dianne Hackborneb034652009-09-07 00:49:58 -0700389 dest.writeString(resolvePackageName);
Nicolas Prevot88cc3462014-05-14 14:51:48 +0100390 dest.writeInt(targetUserId);
Dianne Hackbornd99b2932011-08-18 14:39:58 -0700391 dest.writeInt(system ? 1 : 0);
Nicolas Prevot7f7b0c72014-06-23 15:59:38 +0100392 dest.writeInt(noResourceId ? 1 : 0);
Sudheer Shanka9ded7602015-05-19 21:17:25 +0100393 dest.writeInt(iconResourceId);
Fabrice Di Meglio7d014ce2015-04-08 16:17:46 -0700394 dest.writeInt(handleAllWebDataURI ? 1 : 0);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800395 }
396
397 public static final Creator<ResolveInfo> CREATOR
398 = new Creator<ResolveInfo>() {
399 public ResolveInfo createFromParcel(Parcel source) {
400 return new ResolveInfo(source);
401 }
402 public ResolveInfo[] newArray(int size) {
403 return new ResolveInfo[size];
404 }
405 };
406
407 private ResolveInfo(Parcel source) {
Jeff Sharkey85f5f812013-10-07 10:16:12 -0700408 activityInfo = null;
409 serviceInfo = null;
410 providerInfo = null;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800411 switch (source.readInt()) {
412 case 1:
413 activityInfo = ActivityInfo.CREATOR.createFromParcel(source);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800414 break;
415 case 2:
416 serviceInfo = ServiceInfo.CREATOR.createFromParcel(source);
Jeff Sharkey85f5f812013-10-07 10:16:12 -0700417 break;
418 case 3:
419 providerInfo = ProviderInfo.CREATOR.createFromParcel(source);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800420 break;
421 default:
Jeff Sharkey85f5f812013-10-07 10:16:12 -0700422 Slog.w(TAG, "Missing ComponentInfo!");
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800423 break;
424 }
425 if (source.readInt() != 0) {
426 filter = IntentFilter.CREATOR.createFromParcel(source);
427 }
428 priority = source.readInt();
429 preferredOrder = source.readInt();
430 match = source.readInt();
431 specificIndex = source.readInt();
432 labelRes = source.readInt();
433 nonLocalizedLabel
434 = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(source);
435 icon = source.readInt();
Dianne Hackborneb034652009-09-07 00:49:58 -0700436 resolvePackageName = source.readString();
Nicolas Prevot88cc3462014-05-14 14:51:48 +0100437 targetUserId = source.readInt();
Dianne Hackbornd99b2932011-08-18 14:39:58 -0700438 system = source.readInt() != 0;
Nicolas Prevot7f7b0c72014-06-23 15:59:38 +0100439 noResourceId = source.readInt() != 0;
Sudheer Shanka9ded7602015-05-19 21:17:25 +0100440 iconResourceId = source.readInt();
Fabrice Di Meglio7d014ce2015-04-08 16:17:46 -0700441 handleAllWebDataURI = source.readInt() != 0;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800442 }
Sudheer Shanka9ded7602015-05-19 21:17:25 +0100443
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800444 public static class DisplayNameComparator
445 implements Comparator<ResolveInfo> {
446 public DisplayNameComparator(PackageManager pm) {
447 mPM = pm;
Adam Powell0256c6f2013-05-29 16:42:33 -0700448 mCollator.setStrength(Collator.PRIMARY);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800449 }
450
451 public final int compare(ResolveInfo a, ResolveInfo b) {
Nicolas Prevot88cc3462014-05-14 14:51:48 +0100452 // We want to put the one targeted to another user at the end of the dialog.
453 if (a.targetUserId != UserHandle.USER_CURRENT) {
454 return 1;
455 }
456 if (b.targetUserId != UserHandle.USER_CURRENT) {
457 return -1;
458 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800459 CharSequence sa = a.loadLabel(mPM);
460 if (sa == null) sa = a.activityInfo.name;
461 CharSequence sb = b.loadLabel(mPM);
462 if (sb == null) sb = b.activityInfo.name;
463
Adam Powell0256c6f2013-05-29 16:42:33 -0700464 return mCollator.compare(sa.toString(), sb.toString());
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800465 }
466
Adam Powell0256c6f2013-05-29 16:42:33 -0700467 private final Collator mCollator = Collator.getInstance();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800468 private PackageManager mPM;
469 }
470}