blob: f312204e9467a5bb102ebfc5b233a1a19cf9b0a5 [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 Kennedye9910222017-02-21 16:00:11 -080064 * An auxiliary response that may modify the resolved information. This is
65 * only set under certain circumstances; such as when resolving instant apps
66 * or components defined in un-installed splits.
Todd Kennedy7440f172015-12-09 14:31:22 -080067 * @hide
68 */
Todd Kennedye9910222017-02-21 16:00:11 -080069 public AuxiliaryResolveInfo auxiliaryInfo;
Todd Kennedy7440f172015-12-09 14:31:22 -080070
71 /**
Todd Kennedy533c9ff2017-02-27 11:45:13 -080072 * Whether or not an instant app is available for the resolved intent.
73 */
Jeff Sharkeyf29d1962017-05-01 15:09:11 -060074 public boolean isInstantAppAvailable;
75
76 /** @removed */
77 @Deprecated
Todd Kennedy533c9ff2017-02-27 11:45:13 -080078 public boolean instantAppAvailable;
79
80 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080081 * The IntentFilter that was matched for this ResolveInfo.
82 */
83 public IntentFilter filter;
Sudheer Shanka9ded7602015-05-19 21:17:25 +010084
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080085 /**
86 * The declared priority of this match. Comes from the "priority"
87 * attribute or, if not set, defaults to 0. Higher values are a higher
88 * priority.
89 */
90 public int priority;
Sudheer Shanka9ded7602015-05-19 21:17:25 +010091
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080092 /**
93 * Order of result according to the user's preference. If the user
94 * has not set a preference for this result, the value is 0; higher
95 * values are a higher priority.
96 */
97 public int preferredOrder;
Sudheer Shanka9ded7602015-05-19 21:17:25 +010098
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080099 /**
100 * The system's evaluation of how well the activity matches the
101 * IntentFilter. This is a match constant, a combination of
102 * {@link IntentFilter#MATCH_CATEGORY_MASK IntentFilter.MATCH_CATEGORY_MASK}
103 * and {@link IntentFilter#MATCH_ADJUSTMENT_MASK IntentFiler.MATCH_ADJUSTMENT_MASK}.
104 */
105 public int match;
Sudheer Shanka9ded7602015-05-19 21:17:25 +0100106
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800107 /**
108 * Only set when returned by
109 * {@link PackageManager#queryIntentActivityOptions}, this tells you
110 * which of the given specific intents this result came from. 0 is the
111 * first in the list, < 0 means it came from the generic Intent query.
112 */
113 public int specificIndex = -1;
Sudheer Shanka9ded7602015-05-19 21:17:25 +0100114
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800115 /**
116 * This filter has specified the Intent.CATEGORY_DEFAULT, meaning it
117 * would like to be considered a default action that the user can
118 * perform on this data.
119 */
120 public boolean isDefault;
Sudheer Shanka9ded7602015-05-19 21:17:25 +0100121
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800122 /**
123 * A string resource identifier (in the package's resources) of this
124 * match's label. From the "label" attribute or, if not set, 0.
125 */
126 public int labelRes;
Sudheer Shanka9ded7602015-05-19 21:17:25 +0100127
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800128 /**
129 * The actual string retrieve from <var>labelRes</var> or null if none
130 * was provided.
131 */
132 public CharSequence nonLocalizedLabel;
Sudheer Shanka9ded7602015-05-19 21:17:25 +0100133
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800134 /**
135 * A drawable resource identifier (in the package's resources) of this
Sudheer Shanka9ded7602015-05-19 21:17:25 +0100136 * match's icon. From the "icon" attribute or, if not set, 0. It is
137 * set only if the icon can be obtained by resource id alone.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800138 */
139 public int icon;
140
141 /**
Dianne Hackborneb034652009-09-07 00:49:58 -0700142 * Optional -- if non-null, the {@link #labelRes} and {@link #icon}
143 * resources will be loaded from this package, rather than the one
144 * containing the resolved component.
145 */
146 public String resolvePackageName;
Dianne Hackbornd99b2932011-08-18 14:39:58 -0700147
148 /**
Nicolas Prevot88cc3462014-05-14 14:51:48 +0100149 * If not equal to UserHandle.USER_CURRENT, then the intent will be forwarded to this user.
150 * @hide
151 */
152 public int targetUserId;
153
154 /**
Sudheer Shanka9ded7602015-05-19 21:17:25 +0100155 * Set to true if the icon cannot be obtained by resource ids alone.
156 * It is set to true for ResolveInfos from the managed profile: They need to
157 * have their icon badged, so it cannot be obtained by resource ids alone.
Nicolas Prevot88cc3462014-05-14 14:51:48 +0100158 * @hide
159 */
Nicolas Prevot7f7b0c72014-06-23 15:59:38 +0100160 public boolean noResourceId;
Nicolas Prevot88cc3462014-05-14 14:51:48 +0100161
162 /**
Sudheer Shanka9ded7602015-05-19 21:17:25 +0100163 * Same as {@link #icon} but it will always correspond to "icon" attribute
164 * regardless of {@link #noResourceId} value.
165 * @hide
166 */
167 public int iconResourceId;
168
169 /**
Dianne Hackbornd99b2932011-08-18 14:39:58 -0700170 * @hide Target comes from system process?
171 */
172 public boolean system;
173
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -0800174 /**
Fabrice Di Meglio7d014ce2015-04-08 16:17:46 -0700175 * @hide Does the associated IntentFilter comes from a Browser ?
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -0800176 */
Fabrice Di Meglio7d014ce2015-04-08 16:17:46 -0700177 public boolean handleAllWebDataURI;
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -0800178
Jeff Sharkey2a90f6732016-01-06 12:26:11 -0700179 /** {@hide} */
180 public ComponentInfo getComponentInfo() {
Jeff Sharkey85f5f812013-10-07 10:16:12 -0700181 if (activityInfo != null) return activityInfo;
182 if (serviceInfo != null) return serviceInfo;
183 if (providerInfo != null) return providerInfo;
184 throw new IllegalStateException("Missing ComponentInfo!");
185 }
186
Dianne Hackborneb034652009-09-07 00:49:58 -0700187 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800188 * Retrieve the current textual label associated with this resolution. This
189 * will call back on the given PackageManager to load the label from
190 * the application.
Sudheer Shanka9ded7602015-05-19 21:17:25 +0100191 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800192 * @param pm A PackageManager from which the label can be loaded; usually
193 * the PackageManager from which you originally retrieved this item.
Sudheer Shanka9ded7602015-05-19 21:17:25 +0100194 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800195 * @return Returns a CharSequence containing the resolutions's label. If the
196 * item does not have a label, its name is returned.
197 */
198 public CharSequence loadLabel(PackageManager pm) {
199 if (nonLocalizedLabel != null) {
200 return nonLocalizedLabel;
201 }
Dianne Hackborneb034652009-09-07 00:49:58 -0700202 CharSequence label;
203 if (resolvePackageName != null && labelRes != 0) {
204 label = pm.getText(resolvePackageName, labelRes, null);
205 if (label != null) {
Romain Guy2aba11f2010-03-29 16:03:01 -0700206 return label.toString().trim();
Dianne Hackborneb034652009-09-07 00:49:58 -0700207 }
208 }
Jeff Sharkey85f5f812013-10-07 10:16:12 -0700209 ComponentInfo ci = getComponentInfo();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800210 ApplicationInfo ai = ci.applicationInfo;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800211 if (labelRes != 0) {
212 label = pm.getText(ci.packageName, labelRes, ai);
213 if (label != null) {
Romain Guy2aba11f2010-03-29 16:03:01 -0700214 return label.toString().trim();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800215 }
216 }
Romain Guy2aba11f2010-03-29 16:03:01 -0700217
218 CharSequence data = ci.loadLabel(pm);
219 // Make the data safe
220 if (data != null) data = data.toString().trim();
221 return data;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800222 }
Sudheer Shanka9ded7602015-05-19 21:17:25 +0100223
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800224 /**
225 * Retrieve the current graphical icon associated with this resolution. This
226 * will call back on the given PackageManager to load the icon from
227 * the application.
Sudheer Shanka9ded7602015-05-19 21:17:25 +0100228 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800229 * @param pm A PackageManager from which the icon can be loaded; usually
230 * the PackageManager from which you originally retrieved this item.
Sudheer Shanka9ded7602015-05-19 21:17:25 +0100231 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800232 * @return Returns a Drawable containing the resolution's icon. If the
233 * item does not have an icon, the default activity icon is returned.
234 */
235 public Drawable loadIcon(PackageManager pm) {
Sudheer Shanka9ded7602015-05-19 21:17:25 +0100236 Drawable dr = null;
237 if (resolvePackageName != null && iconResourceId != 0) {
238 dr = pm.getDrawable(resolvePackageName, iconResourceId, null);
Dianne Hackborneb034652009-09-07 00:49:58 -0700239 }
Jeff Sharkey85f5f812013-10-07 10:16:12 -0700240 ComponentInfo ci = getComponentInfo();
Sudheer Shanka9ded7602015-05-19 21:17:25 +0100241 if (dr == null && iconResourceId != 0) {
242 ApplicationInfo ai = ci.applicationInfo;
243 dr = pm.getDrawable(ci.packageName, iconResourceId, ai);
244 }
245 if (dr != null) {
246 return pm.getUserBadgedIcon(dr, new UserHandle(UserHandle.myUserId()));
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800247 }
248 return ci.loadIcon(pm);
249 }
Ricky Wai1281b182015-04-29 14:57:04 +0100250
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800251 /**
252 * Return the icon resource identifier to use for this match. If the
253 * match defines an icon, that is used; else if the activity defines
254 * an icon, that is used; else, the application icon is used.
Ricky Wai1281b182015-04-29 14:57:04 +0100255 * This function does not check noResourceId flag.
256 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800257 * @return The icon associated with this match.
258 */
Ricky Wai1281b182015-04-29 14:57:04 +0100259 final int getIconResourceInternal() {
Sudheer Shanka9ded7602015-05-19 21:17:25 +0100260 if (iconResourceId != 0) return iconResourceId;
Jeff Sharkey85f5f812013-10-07 10:16:12 -0700261 final ComponentInfo ci = getComponentInfo();
Nicolas Prevot7f7b0c72014-06-23 15:59:38 +0100262 if (ci != null) {
Nicolas Prevot88cc3462014-05-14 14:51:48 +0100263 return ci.getIconResource();
264 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800265 return 0;
266 }
267
Ricky Wai1281b182015-04-29 14:57:04 +0100268 /**
269 * Return the icon resource identifier to use for this match. If the
270 * match defines an icon, that is used; else if the activity defines
271 * an icon, that is used; else, the application icon is used.
272 *
273 * @return The icon associated with this match.
274 */
275 public final int getIconResource() {
276 if (noResourceId) return 0;
277 return getIconResourceInternal();
278 }
279
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800280 public void dump(Printer pw, String prefix) {
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -0800281 dump(pw, prefix, PackageItemInfo.DUMP_FLAG_ALL);
282 }
283
284 /** @hide */
285 public void dump(Printer pw, String prefix, int flags) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800286 if (filter != null) {
287 pw.println(prefix + "Filter:");
288 filter.dump(pw, prefix + " ");
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800289 }
290 pw.println(prefix + "priority=" + priority
291 + " preferredOrder=" + preferredOrder
292 + " match=0x" + Integer.toHexString(match)
293 + " specificIndex=" + specificIndex
294 + " isDefault=" + isDefault);
Dianne Hackborneb034652009-09-07 00:49:58 -0700295 if (resolvePackageName != null) {
296 pw.println(prefix + "resolvePackageName=" + resolvePackageName);
297 }
298 if (labelRes != 0 || nonLocalizedLabel != null || icon != 0) {
299 pw.println(prefix + "labelRes=0x" + Integer.toHexString(labelRes)
300 + " nonLocalizedLabel=" + nonLocalizedLabel
301 + " icon=0x" + Integer.toHexString(icon));
302 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800303 if (activityInfo != null) {
304 pw.println(prefix + "ActivityInfo:");
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -0800305 activityInfo.dump(pw, prefix + " ", flags);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800306 } else if (serviceInfo != null) {
307 pw.println(prefix + "ServiceInfo:");
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -0800308 serviceInfo.dump(pw, prefix + " ", flags);
Jeff Sharkey85f5f812013-10-07 10:16:12 -0700309 } else if (providerInfo != null) {
310 pw.println(prefix + "ProviderInfo:");
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -0800311 providerInfo.dump(pw, prefix + " ", flags);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800312 }
313 }
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -0800314
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800315 public ResolveInfo() {
Nicolas Prevot88cc3462014-05-14 14:51:48 +0100316 targetUserId = UserHandle.USER_CURRENT;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800317 }
318
Dianne Hackborn8da429e2012-09-23 12:52:19 -0700319 public ResolveInfo(ResolveInfo orig) {
320 activityInfo = orig.activityInfo;
321 serviceInfo = orig.serviceInfo;
Jeff Sharkey85f5f812013-10-07 10:16:12 -0700322 providerInfo = orig.providerInfo;
Dianne Hackborn8da429e2012-09-23 12:52:19 -0700323 filter = orig.filter;
324 priority = orig.priority;
325 preferredOrder = orig.preferredOrder;
326 match = orig.match;
327 specificIndex = orig.specificIndex;
328 labelRes = orig.labelRes;
329 nonLocalizedLabel = orig.nonLocalizedLabel;
330 icon = orig.icon;
331 resolvePackageName = orig.resolvePackageName;
Sudheer Shanka9ded7602015-05-19 21:17:25 +0100332 noResourceId = orig.noResourceId;
333 iconResourceId = orig.iconResourceId;
Dianne Hackborn8da429e2012-09-23 12:52:19 -0700334 system = orig.system;
Nicolas Prevot88cc3462014-05-14 14:51:48 +0100335 targetUserId = orig.targetUserId;
Fabrice Di Meglio7d014ce2015-04-08 16:17:46 -0700336 handleAllWebDataURI = orig.handleAllWebDataURI;
Jeff Sharkeyf29d1962017-05-01 15:09:11 -0600337 isInstantAppAvailable = orig.isInstantAppAvailable;
338 instantAppAvailable = isInstantAppAvailable;
Dianne Hackborn8da429e2012-09-23 12:52:19 -0700339 }
340
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800341 public String toString() {
Jeff Sharkey85f5f812013-10-07 10:16:12 -0700342 final ComponentInfo ci = getComponentInfo();
Dianne Hackborn6d8dfbd2013-09-23 17:38:51 -0700343 StringBuilder sb = new StringBuilder(128);
344 sb.append("ResolveInfo{");
345 sb.append(Integer.toHexString(System.identityHashCode(this)));
346 sb.append(' ');
347 ComponentName.appendShortString(sb, ci.packageName, ci.name);
348 if (priority != 0) {
349 sb.append(" p=");
350 sb.append(priority);
351 }
352 if (preferredOrder != 0) {
353 sb.append(" o=");
354 sb.append(preferredOrder);
355 }
356 sb.append(" m=0x");
357 sb.append(Integer.toHexString(match));
Nicolas Prevot88cc3462014-05-14 14:51:48 +0100358 if (targetUserId != UserHandle.USER_CURRENT) {
359 sb.append(" targetUserId=");
360 sb.append(targetUserId);
361 }
Dianne Hackborn6d8dfbd2013-09-23 17:38:51 -0700362 sb.append('}');
363 return sb.toString();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800364 }
365
366 public int describeContents() {
367 return 0;
368 }
369
370 public void writeToParcel(Parcel dest, int parcelableFlags) {
371 if (activityInfo != null) {
372 dest.writeInt(1);
373 activityInfo.writeToParcel(dest, parcelableFlags);
374 } else if (serviceInfo != null) {
375 dest.writeInt(2);
376 serviceInfo.writeToParcel(dest, parcelableFlags);
Jeff Sharkey85f5f812013-10-07 10:16:12 -0700377 } else if (providerInfo != null) {
378 dest.writeInt(3);
379 providerInfo.writeToParcel(dest, parcelableFlags);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800380 } else {
381 dest.writeInt(0);
382 }
383 if (filter != null) {
384 dest.writeInt(1);
385 filter.writeToParcel(dest, parcelableFlags);
386 } else {
387 dest.writeInt(0);
388 }
389 dest.writeInt(priority);
390 dest.writeInt(preferredOrder);
391 dest.writeInt(match);
392 dest.writeInt(specificIndex);
393 dest.writeInt(labelRes);
394 TextUtils.writeToParcel(nonLocalizedLabel, dest, parcelableFlags);
395 dest.writeInt(icon);
Dianne Hackborneb034652009-09-07 00:49:58 -0700396 dest.writeString(resolvePackageName);
Nicolas Prevot88cc3462014-05-14 14:51:48 +0100397 dest.writeInt(targetUserId);
Dianne Hackbornd99b2932011-08-18 14:39:58 -0700398 dest.writeInt(system ? 1 : 0);
Nicolas Prevot7f7b0c72014-06-23 15:59:38 +0100399 dest.writeInt(noResourceId ? 1 : 0);
Sudheer Shanka9ded7602015-05-19 21:17:25 +0100400 dest.writeInt(iconResourceId);
Fabrice Di Meglio7d014ce2015-04-08 16:17:46 -0700401 dest.writeInt(handleAllWebDataURI ? 1 : 0);
Jeff Sharkeyf29d1962017-05-01 15:09:11 -0600402 dest.writeInt(isInstantAppAvailable ? 1 : 0);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800403 }
404
405 public static final Creator<ResolveInfo> CREATOR
406 = new Creator<ResolveInfo>() {
407 public ResolveInfo createFromParcel(Parcel source) {
408 return new ResolveInfo(source);
409 }
410 public ResolveInfo[] newArray(int size) {
411 return new ResolveInfo[size];
412 }
413 };
414
415 private ResolveInfo(Parcel source) {
Jeff Sharkey85f5f812013-10-07 10:16:12 -0700416 activityInfo = null;
417 serviceInfo = null;
418 providerInfo = null;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800419 switch (source.readInt()) {
420 case 1:
421 activityInfo = ActivityInfo.CREATOR.createFromParcel(source);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800422 break;
423 case 2:
424 serviceInfo = ServiceInfo.CREATOR.createFromParcel(source);
Jeff Sharkey85f5f812013-10-07 10:16:12 -0700425 break;
426 case 3:
427 providerInfo = ProviderInfo.CREATOR.createFromParcel(source);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800428 break;
429 default:
Jeff Sharkey85f5f812013-10-07 10:16:12 -0700430 Slog.w(TAG, "Missing ComponentInfo!");
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800431 break;
432 }
433 if (source.readInt() != 0) {
434 filter = IntentFilter.CREATOR.createFromParcel(source);
435 }
436 priority = source.readInt();
437 preferredOrder = source.readInt();
438 match = source.readInt();
439 specificIndex = source.readInt();
440 labelRes = source.readInt();
441 nonLocalizedLabel
442 = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(source);
443 icon = source.readInt();
Dianne Hackborneb034652009-09-07 00:49:58 -0700444 resolvePackageName = source.readString();
Nicolas Prevot88cc3462014-05-14 14:51:48 +0100445 targetUserId = source.readInt();
Dianne Hackbornd99b2932011-08-18 14:39:58 -0700446 system = source.readInt() != 0;
Nicolas Prevot7f7b0c72014-06-23 15:59:38 +0100447 noResourceId = source.readInt() != 0;
Sudheer Shanka9ded7602015-05-19 21:17:25 +0100448 iconResourceId = source.readInt();
Fabrice Di Meglio7d014ce2015-04-08 16:17:46 -0700449 handleAllWebDataURI = source.readInt() != 0;
Jeff Sharkeyf29d1962017-05-01 15:09:11 -0600450 instantAppAvailable = isInstantAppAvailable = source.readInt() != 0;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800451 }
Sudheer Shanka9ded7602015-05-19 21:17:25 +0100452
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800453 public static class DisplayNameComparator
454 implements Comparator<ResolveInfo> {
455 public DisplayNameComparator(PackageManager pm) {
456 mPM = pm;
Adam Powell0256c6f2013-05-29 16:42:33 -0700457 mCollator.setStrength(Collator.PRIMARY);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800458 }
459
460 public final int compare(ResolveInfo a, ResolveInfo b) {
Nicolas Prevot88cc3462014-05-14 14:51:48 +0100461 // We want to put the one targeted to another user at the end of the dialog.
462 if (a.targetUserId != UserHandle.USER_CURRENT) {
463 return 1;
464 }
465 if (b.targetUserId != UserHandle.USER_CURRENT) {
466 return -1;
467 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800468 CharSequence sa = a.loadLabel(mPM);
469 if (sa == null) sa = a.activityInfo.name;
470 CharSequence sb = b.loadLabel(mPM);
471 if (sb == null) sb = b.activityInfo.name;
472
Adam Powell0256c6f2013-05-29 16:42:33 -0700473 return mCollator.compare(sa.toString(), sb.toString());
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800474 }
475
Adam Powell0256c6f2013-05-29 16:42:33 -0700476 private final Collator mCollator = Collator.getInstance();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800477 private PackageManager mPM;
478 }
479}