Debian Codegraph @

core/java/android/content/pm/PackageManager.java

raw symbols SCIP
1 /*
2 * Copyright (C) 2006 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
17 package android.content.pm;
18
19 import android.Manifest;
20 import android.annotation.CallbackExecutor;
21 import android.annotation.CheckResult;
22 import android.annotation.DrawableRes;
23 import android.annotation.IntDef;
24 import android.annotation.IntRange;
25 import android.annotation.LongDef;
26 import android.annotation.NonNull;
27 import android.annotation.Nullable;
28 import android.annotation.RequiresPermission;
29 import android.annotation.SdkConstant;
30 import android.annotation.SdkConstant.SdkConstantType;
31 import android.annotation.StringRes;
32 import android.annotation.SystemApi;
33 import android.annotation.TestApi;
34 import android.annotation.UserIdInt;
35 import android.annotation.XmlRes;
36 import android.app.ActivityManager;
37 import android.app.ActivityThread;
38 import android.app.AppDetailsActivity;
39 import android.app.PackageDeleteObserver;
40 import android.app.PackageInstallObserver;
41 import android.app.PropertyInvalidatedCache;
42 import android.app.admin.DevicePolicyManager;
43 import android.app.usage.StorageStatsManager;
44 import android.compat.annotation.ChangeId;
45 import android.compat.annotation.EnabledSince;
46 import android.compat.annotation.UnsupportedAppUsage;
47 import android.content.ComponentName;
48 import android.content.Context;
49 import android.content.Intent;
50 import android.content.IntentFilter;
51 import android.content.IntentSender;
52 import android.content.pm.dex.ArtManager;
53 import android.content.pm.pkg.FrameworkPackageUserState;
54 import android.content.pm.verify.domain.DomainVerificationManager;
55 import android.content.res.Configuration;
56 import android.content.res.Resources;
57 import android.content.res.XmlResourceParser;
58 import android.graphics.Rect;
59 import android.graphics.drawable.AdaptiveIconDrawable;
60 import android.graphics.drawable.Drawable;
61 import android.net.ConnectivityManager;
62 import android.net.wifi.WifiManager;
63 import android.os.Build;
64 import android.os.Bundle;
65 import android.os.Handler;
66 import android.os.IBinder;
67 import android.os.Parcel;
68 import android.os.Parcelable;
69 import android.os.PersistableBundle;
70 import android.os.RemoteException;
71 import android.os.UserHandle;
72 import android.os.UserManager;
73 import android.os.incremental.IncrementalManager;
74 import android.os.storage.StorageManager;
75 import android.os.storage.VolumeInfo;
76 import android.permission.PermissionManager;
77 import android.telephony.TelephonyManager;
78 import android.telephony.UiccCardInfo;
79 import android.telephony.gba.GbaService;
80 import android.telephony.ims.ImsService;
81 import android.telephony.ims.ProvisioningManager;
82 import android.telephony.ims.RcsUceAdapter;
83 import android.telephony.ims.SipDelegateManager;
84 import android.util.AndroidException;
85 import android.util.Log;
86
87 import com.android.internal.annotations.VisibleForTesting;
88 import com.android.internal.util.ArrayUtils;
89 import com.android.internal.util.DataClass;
90
91 import dalvik.system.VMRuntime;
92
93 import java.io.File;
94 import java.lang.annotation.Retention;
95 import java.lang.annotation.RetentionPolicy;
96 import java.security.cert.Certificate;
97 import java.security.cert.CertificateEncodingException;
98 import java.util.Collections;
99 import java.util.List;
100 import java.util.Locale;
101 import java.util.Objects;
102 import java.util.Set;
103 import java.util.UUID;
104 import java.util.concurrent.Executor;
105 import java.util.function.Consumer;
106
107 /**
108 * Class for retrieving various kinds of information related to the application
109 * packages that are currently installed on the device.
110 *
111 * You can find this class through {@link Context#getPackageManager}.
112 *
113 * <p class="note"><strong>Note: </strong>If your app targets Android 11 (API level 30) or
114 * higher, the methods in this class each return a filtered list of apps. Learn more about how to
115 * <a href="/training/basics/intents/package-visibility">manage package visibility</a>.
116 * </p>
117 */
118 public abstract class PackageManager {
119 private static final String TAG = "PackageManager";
120
121 /** {@hide} */
122 public static final boolean APPLY_DEFAULT_TO_DEVICE_PROTECTED_STORAGE = true;
123
124 /** {@hide} */
125 public static final boolean ENABLE_SHARED_UID_MIGRATION = true;
126
127 /**
128 * This exception is thrown when a given package, application, or component
129 * name cannot be found.
130 */
131 public static class NameNotFoundException extends AndroidException {
132 public NameNotFoundException() {
133 }
134
135 public NameNotFoundException(String name) {
136 super(name);
137 }
138 }
139
140 /**
141 * &lt;application&gt; level {@link android.content.pm.PackageManager.Property} tag specifying
142 * the XML resource ID containing an application's media capabilities XML file
143 *
144 * For example:
145 * &lt;application&gt;
146 * &lt;property android:name="android.media.PROPERTY_MEDIA_CAPABILITIES"
147 * android:resource="@xml/media_capabilities"&gt;
148 * &lt;application&gt;
149 */
150 public static final String PROPERTY_MEDIA_CAPABILITIES =
151 "android.media.PROPERTY_MEDIA_CAPABILITIES";
152
153 /**
154 * &lt;application&gt; level {@link android.content.pm.PackageManager.Property} tag
155 * specifying the XML resource ID containing the declaration of the self-certified network
156 * capabilities used by the application.
157 *
158 * <p> Starting from Android 14, usage of some network capabilities in
159 * {@link android.net.ConnectivityManager#requestNetwork} require the application to
160 * declare its usage of that particular capability in this resource. Only some capabilities
161 * require a declaration. Please look up the specific capability you want to use in
162 * {@link android.net.NetworkCapabilities} to see if it needs declaration in this property.
163 *
164 * For example:
165 * &lt;application&gt;
166 * &lt;property android:name="android.net.PROPERTY_SELF_CERTIFIED_NETWORK_CAPABILITIES"
167 * android:resource="@xml/self_certified_network_capabilities"&gt;
168 * &lt;application&gt;
169 *
170 * <p> The detail format of self_certified_network_capabilities.xml is described in
171 * {@link android.net.NetworkRequest}
172 */
173 public static final String PROPERTY_SELF_CERTIFIED_NETWORK_CAPABILITIES =
174 "android.net.PROPERTY_SELF_CERTIFIED_NETWORK_CAPABILITIES";
175
176 /**
177 * Application level property that an app can specify to opt-out from having private data
178 * directories both on the internal and external storages.
179 *
180 * <p>Changing the value of this property during app update is not supported, and such updates
181 * will be rejected.
182 *
183 * <p>This should only be set by platform apps that know what they are doing.
184 *
185 * @hide
186 */
187 public static final String PROPERTY_NO_APP_DATA_STORAGE =
188 "android.internal.PROPERTY_NO_APP_DATA_STORAGE";
189
190 /**
191 * A property value set within the manifest.
192 * <p>
193 * The value of a property will only have a single type, as defined by
194 * the property itself.
195 */
196 public static final class Property implements Parcelable {
197 private static final int TYPE_BOOLEAN = 1;
198 private static final int TYPE_FLOAT = 2;
199 private static final int TYPE_INTEGER = 3;
200 private static final int TYPE_RESOURCE = 4;
201 private static final int TYPE_STRING = 5;
202 private final String mName;
203 private final int mType;
204 private final String mClassName;
205 private final String mPackageName;
206 private boolean mBooleanValue;
207 private float mFloatValue;
208 private int mIntegerValue;
209 private String mStringValue;
210
211 /** @hide */
212 @VisibleForTesting
213 public Property(@NonNull String name, int type,
214 @NonNull String packageName, @Nullable String className) {
215 if (type < TYPE_BOOLEAN || type > TYPE_STRING) {
216 throw new IllegalArgumentException("Invalid type");
217 }
218 this.mName = Objects.requireNonNull(name);
219 this.mType = type;
220 this.mPackageName = Objects.requireNonNull(packageName);
221 this.mClassName = className;
222 }
223 /** @hide */
224 public Property(@NonNull String name, boolean value,
225 String packageName, String className) {
226 this(name, TYPE_BOOLEAN, packageName, className);
227 mBooleanValue = value;
228 }
229 /** @hide */
230 public Property(@NonNull String name, float value,
231 String packageName, String className) {
232 this(name, TYPE_FLOAT, packageName, className);
233 mFloatValue = value;
234 }
235 /** @hide */
236 public Property(@NonNull String name, int value, boolean isResource,
237 String packageName, String className) {
238 this(name, isResource ? TYPE_RESOURCE : TYPE_INTEGER, packageName, className);
239 mIntegerValue = value;
240 }
241 /** @hide */
242 public Property(@NonNull String name, String value,
243 String packageName, String className) {
244 this(name, TYPE_STRING, packageName, className);
245 mStringValue = value;
246 }
247
248 /** @hide */
249 @VisibleForTesting
250 public int getType() {
251 return mType;
252 }
253
254 /**
255 * Returns the name of the property.
256 */
257 @NonNull public String getName() {
258 return mName;
259 }
260
261 /**
262 * Returns the name of the package where this this property was defined.
263 */
264 @NonNull public String getPackageName() {
265 return mPackageName;
266 }
267
268 /**
269 * Returns the classname of the component where this property was defined.
270 * <p>If the property was defined within and &lt;application&gt; tag, retutrns
271 * {@code null}
272 */
273 @Nullable public String getClassName() {
274 return mClassName;
275 }
276
277 /**
278 * Returns the boolean value set for the property.
279 * <p>If the property is not of a boolean type, returns {@code false}.
280 */
281 public boolean getBoolean() {
282 return mBooleanValue;
283 }
284
285 /**
286 * Returns {@code true} if the property is a boolean type. Otherwise {@code false}.
287 */
288 public boolean isBoolean() {
289 return mType == TYPE_BOOLEAN;
290 }
291
292 /**
293 * Returns the float value set for the property.
294 * <p>If the property is not of a float type, returns {@code 0.0}.
295 */
296 public float getFloat() {
297 return mFloatValue;
298 }
299
300 /**
301 * Returns {@code true} if the property is a float type. Otherwise {@code false}.
302 */
303 public boolean isFloat() {
304 return mType == TYPE_FLOAT;
305 }
306
307 /**
308 * Returns the integer value set for the property.
309 * <p>If the property is not of an integer type, returns {@code 0}.
310 */
311 public int getInteger() {
312 return mType == TYPE_INTEGER ? mIntegerValue : 0;
313 }
314
315 /**
316 * Returns {@code true} if the property is an integer type. Otherwise {@code false}.
317 */
318 public boolean isInteger() {
319 return mType == TYPE_INTEGER;
320 }
321
322 /**
323 * Returns the a resource id set for the property.
324 * <p>If the property is not of a resource id type, returns {@code 0}.
325 */
326 public int getResourceId() {
327 return mType == TYPE_RESOURCE ? mIntegerValue : 0;
328 }
329
330 /**
331 * Returns {@code true} if the property is a resource id type. Otherwise {@code false}.
332 */
333 public boolean isResourceId() {
334 return mType == TYPE_RESOURCE;
335 }
336
337 /**
338 * Returns the a String value set for the property.
339 * <p>If the property is not a String type, returns {@code null}.
340 */
341 @Nullable public String getString() {
342 return mStringValue;
343 }
344
345 /**
346 * Returns {@code true} if the property is a String type. Otherwise {@code false}.
347 */
348 public boolean isString() {
349 return mType == TYPE_STRING;
350 }
351
352 /**
353 * Adds a mapping from the given key to this property's value in the provided
354 * {@link android.os.Bundle}. If the provided {@link android.os.Bundle} is
355 * {@code null}, creates a new {@link android.os.Bundle}.
356 * @hide
357 */
358 public Bundle toBundle(Bundle outBundle) {
359 final Bundle b = outBundle == null || outBundle == Bundle.EMPTY
360 ? new Bundle() : outBundle;
361 if (mType == TYPE_BOOLEAN) {
362 b.putBoolean(mName, mBooleanValue);
363 } else if (mType == TYPE_FLOAT) {
364 b.putFloat(mName, mFloatValue);
365 } else if (mType == TYPE_INTEGER) {
366 b.putInt(mName, mIntegerValue);
367 } else if (mType == TYPE_RESOURCE) {
368 b.putInt(mName, mIntegerValue);
369 } else if (mType == TYPE_STRING) {
370 b.putString(mName, mStringValue);
371 }
372 return b;
373 }
374
375 @Override
376 public int describeContents() {
377 return 0;
378 }
379
380 @Override
381 public void writeToParcel(@NonNull Parcel dest, int flags) {
382 dest.writeString(mName);
383 dest.writeInt(mType);
384 dest.writeString(mPackageName);
385 dest.writeString(mClassName);
386 if (mType == TYPE_BOOLEAN) {
387 dest.writeBoolean(mBooleanValue);
388 } else if (mType == TYPE_FLOAT) {
389 dest.writeFloat(mFloatValue);
390 } else if (mType == TYPE_INTEGER) {
391 dest.writeInt(mIntegerValue);
392 } else if (mType == TYPE_RESOURCE) {
393 dest.writeInt(mIntegerValue);
394 } else if (mType == TYPE_STRING) {
395 dest.writeString(mStringValue);
396 }
397 }
398
399 @NonNull
400 public static final Creator<Property> CREATOR = new Creator<Property>() {
401 @Override
402 public Property createFromParcel(@NonNull Parcel source) {
403 final String name = source.readString();
404 final int type = source.readInt();
405 final String packageName = source.readString();
406 final String className = source.readString();
407 if (type == TYPE_BOOLEAN) {
408 return new Property(name, source.readBoolean(), packageName, className);
409 } else if (type == TYPE_FLOAT) {
410 return new Property(name, source.readFloat(), packageName, className);
411 } else if (type == TYPE_INTEGER) {
412 return new Property(name, source.readInt(), false, packageName, className);
413 } else if (type == TYPE_RESOURCE) {
414 return new Property(name, source.readInt(), true, packageName, className);
415 } else if (type == TYPE_STRING) {
416 return new Property(name, source.readString(), packageName, className);
417 }
418 return null;
419 }
420
421 @Override
422 public Property[] newArray(int size) {
423 return new Property[size];
424 }
425 };
426 }
427
428 /**
429 * The class containing the enabled setting of a package component.
430 * <p>
431 * This is used by the {@link #setComponentEnabledSettings(List)} to support the batch updates
432 * of the enabled settings of components.
433 *
434 * @see #setComponentEnabledSettings(List)
435 */
436 @DataClass(genConstructor = false)
437 public static final class ComponentEnabledSetting implements Parcelable {
438 /**
439 * The package name of the application to enable the setting.
440 */
441 private final @Nullable String mPackageName;
442
443 /**
444 * The component name of the application to enable the setting.
445 */
446 private final @Nullable ComponentName mComponentName;
447
448 /**
449 * The new enabled state
450 */
451 private final @EnabledState int mEnabledState;
452
453 /**
454 * The optional behavior flag
455 */
456 private final @EnabledFlags int mEnabledFlags;
457
458 /**
459 * Create an instance of the ComponentEnabledSetting for the component level's enabled
460 * setting update.
461 *
462 * @param componentName The component name to update the enabled setting.
463 * @param newState The new enabled state.
464 * @param flags The optional behavior flags.
465 */
466 public ComponentEnabledSetting(@NonNull ComponentName componentName,
467 @EnabledState int newState, @EnabledFlags int flags) {
468 mPackageName = null;
469 mComponentName = Objects.requireNonNull(componentName);
470 mEnabledState = newState;
471 mEnabledFlags = flags;
472 }
473
474 /**
475 * Create an instance of the ComponentEnabledSetting for the application level's enabled
476 * setting update.
477 *
478 * @param packageName The package name to update the enabled setting.
479 * @param newState The new enabled state.
480 * @param flags The optional behavior flags.
481 * @hide
482 */
483 public ComponentEnabledSetting(@NonNull String packageName,
484 @EnabledState int newState, @EnabledFlags int flags) {
485 mPackageName = Objects.requireNonNull(packageName);
486 mComponentName = null;
487 mEnabledState = newState;
488 mEnabledFlags = flags;
489 }
490
491 /**
492 * Returns the package name of the setting.
493 *
494 * @return the package name.
495 * @hide
496 */
497 public @NonNull String getPackageName() {
498 if (isComponent()) {
499 return mComponentName.getPackageName();
500 }
501 return mPackageName;
502 }
503
504 /**
505 * Returns the component class name of the setting.
506 *
507 * @return the class name.
508 * @hide
509 */
510 public @Nullable String getClassName() {
511 if (isComponent()) {
512 return mComponentName.getClassName();
513 }
514 return null;
515 }
516
517 /**
518 * Whether or not this is for the component level's enabled setting update.
519 *
520 * @return {@code true} if it's the component level enabled setting update.
521 * @hide
522 */
523 public boolean isComponent() {
524 return mComponentName != null;
525 }
526
527
528
529 // Code below generated by codegen v1.0.23.
530 //
531 // DO NOT MODIFY!
532 // CHECKSTYLE:OFF Generated code
533 //
534 // To regenerate run:
535 // $ codegen $ANDROID_BUILD_TOP/frameworks/base/core/java/android/content/pm/PackageManager.java
536 //
537 // To exclude the generated code from IntelliJ auto-formatting enable (one-time):
538 // Settings > Editor > Code Style > Formatter Control
539 //@formatter:off
540
541
542 /**
543 * The component name of the application to enable the setting.
544 */
545 @DataClass.Generated.Member
546 public @Nullable ComponentName getComponentName() {
547 return mComponentName;
548 }
549
550 /**
551 * The new enabled state
552 */
553 @DataClass.Generated.Member
554 public @EnabledState int getEnabledState() {
555 return mEnabledState;
556 }
557
558 /**
559 * The optional behavior flag
560 */
561 @DataClass.Generated.Member
562 public @EnabledFlags int getEnabledFlags() {
563 return mEnabledFlags;
564 }
565
566 @Override
567 @DataClass.Generated.Member
568 public void writeToParcel(@NonNull Parcel dest, int flags) {
569 // You can override field parcelling by defining methods like:
570 // void parcelFieldName(Parcel dest, int flags) { ... }
571
572 byte flg = 0;
573 if (mPackageName != null) flg |= 0x1;
574 if (mComponentName != null) flg |= 0x2;
575 dest.writeByte(flg);
576 if (mPackageName != null) dest.writeString(mPackageName);
577 if (mComponentName != null) dest.writeTypedObject(mComponentName, flags);
578 dest.writeInt(mEnabledState);
579 dest.writeInt(mEnabledFlags);
580 }
581
582 @Override
583 @DataClass.Generated.Member
584 public int describeContents() { return 0; }
585
586 /** @hide */
587 @SuppressWarnings({"unchecked", "RedundantCast"})
588 @DataClass.Generated.Member
589 /* package-private */ ComponentEnabledSetting(@NonNull Parcel in) {
590 // You can override field unparcelling by defining methods like:
591 // static FieldType unparcelFieldName(Parcel in) { ... }
592
593 byte flg = in.readByte();
594 String packageName = (flg & 0x1) == 0 ? null : in.readString();
595 ComponentName componentName = (flg & 0x2) == 0 ? null : (ComponentName) in.readTypedObject(ComponentName.CREATOR);
596 int enabledState = in.readInt();
597 int enabledFlags = in.readInt();
598
599 this.mPackageName = packageName;
600 this.mComponentName = componentName;
601 this.mEnabledState = enabledState;
602 com.android.internal.util.AnnotationValidations.validate(
603 EnabledState.class, null, mEnabledState);
604 this.mEnabledFlags = enabledFlags;
605 com.android.internal.util.AnnotationValidations.validate(
606 EnabledFlags.class, null, mEnabledFlags);
607
608 // onConstructed(); // You can define this method to get a callback
609 }
610
611 @DataClass.Generated.Member
612 public static final @NonNull Parcelable.Creator<ComponentEnabledSetting> CREATOR
613 = new Parcelable.Creator<ComponentEnabledSetting>() {
614 @Override
615 public ComponentEnabledSetting[] newArray(int size) {
616 return new ComponentEnabledSetting[size];
617 }
618
619 @Override
620 public ComponentEnabledSetting createFromParcel(@NonNull Parcel in) {
621 return new ComponentEnabledSetting(in);
622 }
623 };
624
625 @DataClass.Generated(
626 time = 1628668290863L,
627 codegenVersion = "1.0.23",
628 sourceFile = "frameworks/base/core/java/android/content/pm/PackageManager.java",
629 inputSignatures = "private final @android.annotation.Nullable java.lang.String mPackageName\nprivate final @android.annotation.Nullable android.content.ComponentName mComponentName\nprivate final @android.content.pm.PackageManager.EnabledState int mEnabledState\nprivate final @android.content.pm.PackageManager.EnabledFlags int mEnabledFlags\npublic @android.annotation.NonNull java.lang.String getPackageName()\npublic @android.annotation.Nullable java.lang.String getClassName()\npublic boolean isComponent()\nclass ComponentEnabledSetting extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genConstructor=false)")
630 @Deprecated
631 private void __metadata() {}
632
633
634 //@formatter:on
635 // End of generated code
636
637 }
638
639 /**
640 * Listener for changes in permissions granted to a UID.
641 *
642 * @hide
643 */
644 @SystemApi
645 public interface OnPermissionsChangedListener {
646
647 /**
648 * Called when the permissions for a UID change.
649 * @param uid The UID with a change.
650 */
651 public void onPermissionsChanged(int uid);
652 }
653
654 /** @hide */
655 public static final int TYPE_UNKNOWN = 0;
656 /** @hide */
657 public static final int TYPE_ACTIVITY = 1;
658 /** @hide */
659 public static final int TYPE_RECEIVER = 2;
660 /** @hide */
661 public static final int TYPE_SERVICE = 3;
662 /** @hide */
663 public static final int TYPE_PROVIDER = 4;
664 /** @hide */
665 public static final int TYPE_APPLICATION = 5;
666 /** @hide */
667 @IntDef(prefix = { "TYPE_" }, value = {
668 TYPE_UNKNOWN,
669 TYPE_ACTIVITY,
670 TYPE_RECEIVER,
671 TYPE_SERVICE,
672 TYPE_PROVIDER,
673 })
674 @Retention(RetentionPolicy.SOURCE)
675 public @interface ComponentType {}
676
677 /** @hide */
678 @IntDef(prefix = { "TYPE_" }, value = {
679 TYPE_UNKNOWN,
680 TYPE_ACTIVITY,
681 TYPE_RECEIVER,
682 TYPE_SERVICE,
683 TYPE_PROVIDER,
684 TYPE_APPLICATION,
685 })
686 @Retention(RetentionPolicy.SOURCE)
687 public @interface PropertyLocation {}
688
689 /**
690 * As a guiding principle:
691 * <p>
692 * {@code GET_} flags are used to request additional data that may have been
693 * elided to save wire space.
694 * <p>
695 * {@code MATCH_} flags are used to include components or packages that
696 * would have otherwise been omitted from a result set by current system
697 * state.
698 */
699
700 /** @hide */
701 @LongDef(flag = true, prefix = { "GET_", "MATCH_" }, value = {
702 GET_ACTIVITIES,
703 GET_CONFIGURATIONS,
704 GET_GIDS,
705 GET_INSTRUMENTATION,
706 GET_INTENT_FILTERS,
707 GET_META_DATA,
708 GET_PERMISSIONS,
709 GET_PROVIDERS,
710 GET_RECEIVERS,
711 GET_SERVICES,
712 GET_SHARED_LIBRARY_FILES,
713 GET_SIGNATURES,
714 GET_SIGNING_CERTIFICATES,
715 GET_URI_PERMISSION_PATTERNS,
716 MATCH_UNINSTALLED_PACKAGES,
717 MATCH_DISABLED_COMPONENTS,
718 MATCH_DISABLED_UNTIL_USED_COMPONENTS,
719 MATCH_SYSTEM_ONLY,
720 MATCH_FACTORY_ONLY,
721 MATCH_DEBUG_TRIAGED_MISSING,
722 MATCH_INSTANT,
723 MATCH_APEX,
724 GET_DISABLED_COMPONENTS,
725 GET_DISABLED_UNTIL_USED_COMPONENTS,
726 GET_UNINSTALLED_PACKAGES,
727 MATCH_HIDDEN_UNTIL_INSTALLED_COMPONENTS,
728 GET_ATTRIBUTIONS,
729 })
730 @Retention(RetentionPolicy.SOURCE)
731 public @interface PackageInfoFlagsBits {}
732
733 /** @hide */
734 @LongDef(flag = true, prefix = { "GET_", "MATCH_" }, value = {
735 GET_META_DATA,
736 GET_SHARED_LIBRARY_FILES,
737 MATCH_UNINSTALLED_PACKAGES,
738 MATCH_SYSTEM_ONLY,
739 MATCH_DEBUG_TRIAGED_MISSING,
740 MATCH_DISABLED_COMPONENTS,
741 MATCH_DISABLED_UNTIL_USED_COMPONENTS,
742 MATCH_INSTANT,
743 MATCH_STATIC_SHARED_AND_SDK_LIBRARIES,
744 GET_DISABLED_UNTIL_USED_COMPONENTS,
745 GET_UNINSTALLED_PACKAGES,
746 MATCH_HIDDEN_UNTIL_INSTALLED_COMPONENTS,
747 MATCH_APEX,
748 })
749 @Retention(RetentionPolicy.SOURCE)
750 public @interface ApplicationInfoFlagsBits {}
751
752 /** @hide */
753 @LongDef(flag = true, prefix = { "GET_", "MATCH_" }, value = {
754 GET_META_DATA,
755 GET_SHARED_LIBRARY_FILES,
756 MATCH_ALL,
757 MATCH_DEBUG_TRIAGED_MISSING,
758 MATCH_DEFAULT_ONLY,
759 MATCH_DISABLED_COMPONENTS,
760 MATCH_DISABLED_UNTIL_USED_COMPONENTS,
761 MATCH_DIRECT_BOOT_AUTO,
762 MATCH_DIRECT_BOOT_AWARE,
763 MATCH_DIRECT_BOOT_UNAWARE,
764 MATCH_SYSTEM_ONLY,
765 MATCH_UNINSTALLED_PACKAGES,
766 MATCH_INSTANT,
767 MATCH_STATIC_SHARED_AND_SDK_LIBRARIES,
768 GET_DISABLED_COMPONENTS,
769 GET_DISABLED_UNTIL_USED_COMPONENTS,
770 GET_UNINSTALLED_PACKAGES,
771 })
772 @Retention(RetentionPolicy.SOURCE)
773 public @interface ComponentInfoFlagsBits {}
774
775 /** @hide */
776 @LongDef(flag = true, prefix = { "GET_", "MATCH_" }, value = {
777 GET_META_DATA,
778 GET_RESOLVED_FILTER,
779 GET_SHARED_LIBRARY_FILES,
780 MATCH_ALL,
781 MATCH_DEBUG_TRIAGED_MISSING,
782 MATCH_DISABLED_COMPONENTS,
783 MATCH_DISABLED_UNTIL_USED_COMPONENTS,
784 MATCH_DEFAULT_ONLY,
785 MATCH_DIRECT_BOOT_AUTO,
786 MATCH_DIRECT_BOOT_AWARE,
787 MATCH_DIRECT_BOOT_UNAWARE,
788 MATCH_SYSTEM_ONLY,
789 MATCH_UNINSTALLED_PACKAGES,
790 MATCH_INSTANT,
791 GET_DISABLED_COMPONENTS,
792 GET_DISABLED_UNTIL_USED_COMPONENTS,
793 GET_UNINSTALLED_PACKAGES,
794 })
795 @Retention(RetentionPolicy.SOURCE)
796 public @interface ResolveInfoFlagsBits {}
797
798 /** @hide */
799 @IntDef(flag = true, prefix = { "GET_", "MATCH_" }, value = {
800 MATCH_ALL,
801 })
802 @Retention(RetentionPolicy.SOURCE)
803 public @interface InstalledModulesFlags {}
804
805 /** @hide */
806 @IntDef(flag = true, prefix = { "GET_", "MATCH_" }, value = {
807 GET_META_DATA,
808 })
809 @Retention(RetentionPolicy.SOURCE)
810 public @interface PermissionInfoFlags {}
811
812 /** @hide */
813 @IntDef(flag = true, prefix = { "GET_", "MATCH_" }, value = {
814 GET_META_DATA,
815 })
816 @Retention(RetentionPolicy.SOURCE)
817 public @interface PermissionGroupInfoFlags {}
818
819 /** @hide */
820 @IntDef(flag = true, prefix = { "GET_", "MATCH_" }, value = {
821 GET_META_DATA,
822 })
823 @Retention(RetentionPolicy.SOURCE)
824 public @interface InstrumentationInfoFlags {}
825
826 /**
827 * {@link PackageInfo} flag: return information about
828 * activities in the package in {@link PackageInfo#activities}.
829 */
830 public static final int GET_ACTIVITIES = 0x00000001;
831
832 /**
833 * {@link PackageInfo} flag: return information about
834 * intent receivers in the package in
835 * {@link PackageInfo#receivers}.
836 */
837 public static final int GET_RECEIVERS = 0x00000002;
838
839 /**
840 * {@link PackageInfo} flag: return information about
841 * services in the package in {@link PackageInfo#services}.
842 */
843 public static final int GET_SERVICES = 0x00000004;
844
845 /**
846 * {@link PackageInfo} flag: return information about
847 * content providers in the package in
848 * {@link PackageInfo#providers}.
849 */
850 public static final int GET_PROVIDERS = 0x00000008;
851
852 /**
853 * {@link PackageInfo} flag: return information about
854 * instrumentation in the package in
855 * {@link PackageInfo#instrumentation}.
856 */
857 public static final int GET_INSTRUMENTATION = 0x00000010;
858
859 /**
860 * {@link PackageInfo} flag: return information about the
861 * intent filters supported by the activity.
862 *
863 * @deprecated The platform does not support getting {@link IntentFilter}s for the package.
864 */
865 @Deprecated
866 public static final int GET_INTENT_FILTERS = 0x00000020;
867
868 /**
869 * {@link PackageInfo} flag: return information about the
870 * signatures included in the package.
871 *
872 * @deprecated use {@code GET_SIGNING_CERTIFICATES} instead
873 */
874 @Deprecated
875 public static final int GET_SIGNATURES = 0x00000040;
876
877 /**
878 * {@link ResolveInfo} flag: return the IntentFilter that
879 * was matched for a particular ResolveInfo in
880 * {@link ResolveInfo#filter}.
881 */
882 public static final int GET_RESOLVED_FILTER = 0x00000040;
883
884 /**
885 * {@link ComponentInfo} flag: return the {@link ComponentInfo#metaData}
886 * data {@link android.os.Bundle}s that are associated with a component.
887 * This applies for any API returning a ComponentInfo subclass.
888 */
889 public static final int GET_META_DATA = 0x00000080;
890
891 /**
892 * {@link PackageInfo} flag: return the
893 * {@link PackageInfo#gids group ids} that are associated with an
894 * application.
895 * This applies for any API returning a PackageInfo class, either
896 * directly or nested inside of another.
897 */
898 public static final int GET_GIDS = 0x00000100;
899
900 /**
901 * @deprecated replaced with {@link #MATCH_DISABLED_COMPONENTS}
902 */
903 @Deprecated
904 public static final int GET_DISABLED_COMPONENTS = 0x00000200;
905
906 /**
907 * {@link PackageInfo} flag: include disabled components in the returned info.
908 */
909 public static final int MATCH_DISABLED_COMPONENTS = 0x00000200;
910
911 /**
912 * {@link ApplicationInfo} flag: return the
913 * {@link ApplicationInfo#sharedLibraryFiles paths to the shared libraries}
914 * that are associated with an application.
915 * This applies for any API returning an ApplicationInfo class, either
916 * directly or nested inside of another.
917 */
918 public static final int GET_SHARED_LIBRARY_FILES = 0x00000400;
919
920 /**
921 * {@link ProviderInfo} flag: return the
922 * {@link ProviderInfo#uriPermissionPatterns URI permission patterns}
923 * that are associated with a content provider.
924 * This applies for any API returning a ProviderInfo class, either
925 * directly or nested inside of another.
926 */
927 public static final int GET_URI_PERMISSION_PATTERNS = 0x00000800;
928 /**
929 * {@link PackageInfo} flag: return information about
930 * permissions in the package in
931 * {@link PackageInfo#permissions}.
932 */
933 public static final int GET_PERMISSIONS = 0x00001000;
934
935 /**
936 * @deprecated replaced with {@link #MATCH_UNINSTALLED_PACKAGES}
937 */
938 @Deprecated
939 public static final int GET_UNINSTALLED_PACKAGES = 0x00002000;
940
941 /**
942 * Flag parameter to retrieve some information about all applications (even
943 * uninstalled ones) which have data directories. This state could have
944 * resulted if applications have been deleted with flag
945 * {@code DELETE_KEEP_DATA} with a possibility of being replaced or
946 * reinstalled in future.
947 * <p>
948 * Note: this flag may cause less information about currently installed
949 * applications to be returned.
950 * <p>
951 * Note: use of this flag requires the android.permission.QUERY_ALL_PACKAGES
952 * permission to see uninstalled packages.
953 */
954 public static final int MATCH_UNINSTALLED_PACKAGES = 0x00002000;
955
956 /**
957 * {@link PackageInfo} flag: return information about
958 * hardware preferences in
959 * {@link PackageInfo#configPreferences PackageInfo.configPreferences},
960 * and requested features in {@link PackageInfo#reqFeatures} and
961 * {@link PackageInfo#featureGroups}.
962 */
963 public static final int GET_CONFIGURATIONS = 0x00004000;
964
965 /**
966 * @deprecated replaced with {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}.
967 */
968 @Deprecated
969 public static final int GET_DISABLED_UNTIL_USED_COMPONENTS = 0x00008000;
970
971 /**
972 * {@link PackageInfo} flag: include disabled components which are in
973 * that state only because of {@link #COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED}
974 * in the returned info. Note that if you set this flag, applications
975 * that are in this disabled state will be reported as enabled.
976 */
977 public static final int MATCH_DISABLED_UNTIL_USED_COMPONENTS = 0x00008000;
978
979 /**
980 * Resolution and querying flag: if set, only filters that support the
981 * {@link android.content.Intent#CATEGORY_DEFAULT} will be considered for
982 * matching. This is a synonym for including the CATEGORY_DEFAULT in your
983 * supplied Intent.
984 */
985 public static final int MATCH_DEFAULT_ONLY = 0x00010000;
986
987 /**
988 * Querying flag: if set and if the platform is doing any filtering of the
989 * results, then the filtering will not happen. This is a synonym for saying
990 * that all results should be returned.
991 * <p>
992 * <em>This flag should be used with extreme care.</em>
993 */
994 public static final int MATCH_ALL = 0x00020000;
995
996 /**
997 * Querying flag: match components which are direct boot <em>unaware</em> in
998 * the returned info, regardless of the current user state.
999 * <p>
1000 * When neither {@link #MATCH_DIRECT_BOOT_AWARE} nor
1001 * {@link #MATCH_DIRECT_BOOT_UNAWARE} are specified, the default behavior is
1002 * to match only runnable components based on the user state. For example,
1003 * when a user is started but credentials have not been presented yet, the
1004 * user is running "locked" and only {@link #MATCH_DIRECT_BOOT_AWARE}
1005 * components are returned. Once the user credentials have been presented,
1006 * the user is running "unlocked" and both {@link #MATCH_DIRECT_BOOT_AWARE}
1007 * and {@link #MATCH_DIRECT_BOOT_UNAWARE} components are returned.
1008 *
1009 * @see UserManager#isUserUnlocked()
1010 */
1011 public static final int MATCH_DIRECT_BOOT_UNAWARE = 0x00040000;
1012
1013 /**
1014 * Querying flag: match components which are direct boot <em>aware</em> in
1015 * the returned info, regardless of the current user state.
1016 * <p>
1017 * When neither {@link #MATCH_DIRECT_BOOT_AWARE} nor
1018 * {@link #MATCH_DIRECT_BOOT_UNAWARE} are specified, the default behavior is
1019 * to match only runnable components based on the user state. For example,
1020 * when a user is started but credentials have not been presented yet, the
1021 * user is running "locked" and only {@link #MATCH_DIRECT_BOOT_AWARE}
1022 * components are returned. Once the user credentials have been presented,
1023 * the user is running "unlocked" and both {@link #MATCH_DIRECT_BOOT_AWARE}
1024 * and {@link #MATCH_DIRECT_BOOT_UNAWARE} components are returned.
1025 *
1026 * @see UserManager#isUserUnlocked()
1027 */
1028 public static final int MATCH_DIRECT_BOOT_AWARE = 0x00080000;
1029
1030 /**
1031 * Querying flag: include only components from applications that are marked
1032 * with {@link ApplicationInfo#FLAG_SYSTEM}.
1033 */
1034 public static final int MATCH_SYSTEM_ONLY = 0x00100000;
1035
1036 /**
1037 * Internal {@link PackageInfo} flag: include only components on the system image.
1038 * This will not return information on any unbundled update to system components.
1039 * @hide
1040 */
1041 @SystemApi
1042 public static final int MATCH_FACTORY_ONLY = 0x00200000;
1043
1044 /**
1045 * Allows querying of packages installed for any user, not just the specific one. This flag
1046 * is only meant for use by apps that have INTERACT_ACROSS_USERS permission.
1047 * @hide
1048 */
1049 @SystemApi
1050 public static final int MATCH_ANY_USER = 0x00400000;
1051
1052 /**
1053 * Combination of MATCH_ANY_USER and MATCH_UNINSTALLED_PACKAGES to mean any known
1054 * package.
1055 * @hide
1056 */
1057 @TestApi
1058 public static final int MATCH_KNOWN_PACKAGES = MATCH_UNINSTALLED_PACKAGES | MATCH_ANY_USER;
1059
1060 /**
1061 * Internal {@link PackageInfo} flag: include components that are part of an
1062 * instant app. By default, instant app components are not matched.
1063 * @hide
1064 */
1065 @SystemApi
1066 public static final int MATCH_INSTANT = 0x00800000;
1067
1068 /**
1069 * Internal {@link PackageInfo} flag: include only components that are exposed to
1070 * instant apps. Matched components may have been either explicitly or implicitly
1071 * exposed.
1072 * @hide
1073 */
1074 public static final int MATCH_VISIBLE_TO_INSTANT_APP_ONLY = 0x01000000;
1075
1076 /**
1077 * Internal {@link PackageInfo} flag: include only components that have been
1078 * explicitly exposed to instant apps.
1079 * @hide
1080 */
1081 public static final int MATCH_EXPLICITLY_VISIBLE_ONLY = 0x02000000;
1082
1083 /**
1084 * Internal {@link PackageInfo} flag: include static shared and SDK libraries.
1085 * Apps that depend on static shared/SDK libs can always access the version
1086 * of the lib they depend on. System/shell/root can access all shared
1087 * libs regardless of dependency but need to explicitly ask for them
1088 * via this flag.
1089 * @hide
1090 */
1091 @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
1092 public static final int MATCH_STATIC_SHARED_AND_SDK_LIBRARIES = 0x04000000;
1093
1094 /**
1095 * {@link PackageInfo} flag: return the signing certificates associated with
1096 * this package. Each entry is a signing certificate that the package
1097 * has proven it is authorized to use, usually a past signing certificate from
1098 * which it has rotated.
1099 */
1100 public static final int GET_SIGNING_CERTIFICATES = 0x08000000;
1101
1102 /**
1103 * Querying flag: automatically match components based on their Direct Boot
1104 * awareness and the current user state.
1105 * <p>
1106 * Since the default behavior is to automatically apply the current user
1107 * state, this is effectively a sentinel value that doesn't change the
1108 * output of any queries based on its presence or absence.
1109 * <p>
1110 * Instead, this value can be useful in conjunction with
1111 * {@link android.os.StrictMode.VmPolicy.Builder#detectImplicitDirectBoot()}
1112 * to detect when a caller is relying on implicit automatic matching,
1113 * instead of confirming the explicit behavior they want, using a
1114 * combination of these flags:
1115 * <ul>
1116 * <li>{@link #MATCH_DIRECT_BOOT_AWARE}
1117 * <li>{@link #MATCH_DIRECT_BOOT_UNAWARE}
1118 * <li>{@link #MATCH_DIRECT_BOOT_AUTO}
1119 * </ul>
1120 */
1121 public static final int MATCH_DIRECT_BOOT_AUTO = 0x10000000;
1122
1123 /**
1124 * {@link PackageInfo} flag: return all attributions declared in the package manifest
1125 */
1126 public static final int GET_ATTRIBUTIONS = 0x80000000;
1127
1128 /** @hide */
1129 @Deprecated
1130 public static final int MATCH_DEBUG_TRIAGED_MISSING = MATCH_DIRECT_BOOT_AUTO;
1131
1132 /**
1133 * {@link PackageInfo} flag: include system apps that are in the uninstalled state and have
1134 * been set to be hidden until installed via {@link #setSystemAppState}.
1135 * @hide
1136 */
1137 @SystemApi
1138 public static final int MATCH_HIDDEN_UNTIL_INSTALLED_COMPONENTS = 0x20000000;
1139
1140 /**
1141 * {@link PackageInfo} flag: include APEX packages that are currently
1142 * installed. In APEX terminology, this corresponds to packages that are
1143 * currently active, i.e. mounted and available to other processes of the OS.
1144 * In particular, this flag alone will not match APEX files that are staged
1145 * for activation at next reboot.
1146 */
1147 public static final int MATCH_APEX = 0x40000000;
1148
1149 /**
1150 * Flag for {@link #addCrossProfileIntentFilter}: if this flag is set: when
1151 * resolving an intent that matches the {@code CrossProfileIntentFilter},
1152 * the current profile will be skipped. Only activities in the target user
1153 * can respond to the intent.
1154 *
1155 * @hide
1156 */
1157 public static final int SKIP_CURRENT_PROFILE = 0x00000002;
1158
1159 /**
1160 * Flag for {@link #addCrossProfileIntentFilter}: if this flag is set:
1161 * activities in the other profiles can respond to the intent only if no activity with
1162 * non-negative priority in current profile can respond to the intent.
1163 * @hide
1164 */
1165 public static final int ONLY_IF_NO_MATCH_FOUND = 0x00000004;
1166
1167 /** @hide */
1168 @IntDef(flag = true, prefix = { "MODULE_" }, value = {
1169 MODULE_APEX_NAME,
1170 })
1171 @Retention(RetentionPolicy.SOURCE)
1172 public @interface ModuleInfoFlags {}
1173
1174 /**
1175 * Flag for {@link #getModuleInfo}: allow ModuleInfo to be retrieved using the apex module
1176 * name, rather than the package name.
1177 *
1178 * @hide
1179 */
1180 @SystemApi
1181 public static final int MODULE_APEX_NAME = 0x00000001;
1182
1183 /** @hide */
1184 @IntDef(prefix = { "PERMISSION_" }, value = {
1185 PERMISSION_GRANTED,
1186 PERMISSION_DENIED
1187 })
1188 @Retention(RetentionPolicy.SOURCE)
1189 public @interface PermissionResult {}
1190
1191 /**
1192 * Permission check result: this is returned by {@link #checkPermission}
1193 * if the permission has been granted to the given package.
1194 */
1195 public static final int PERMISSION_GRANTED = 0;
1196
1197 /**
1198 * Permission check result: this is returned by {@link #checkPermission}
1199 * if the permission has not been granted to the given package.
1200 */
1201 public static final int PERMISSION_DENIED = -1;
1202
1203 /** @hide */
1204 @IntDef(prefix = { "SIGNATURE_" }, value = {
1205 SIGNATURE_MATCH,
1206 SIGNATURE_NEITHER_SIGNED,
1207 SIGNATURE_FIRST_NOT_SIGNED,
1208 SIGNATURE_SECOND_NOT_SIGNED,
1209 SIGNATURE_NO_MATCH,
1210 SIGNATURE_UNKNOWN_PACKAGE,
1211 })
1212 @Retention(RetentionPolicy.SOURCE)
1213 public @interface SignatureResult {}
1214
1215 /**
1216 * Signature check result: this is returned by {@link #checkSignatures}
1217 * if all signatures on the two packages match.
1218 */
1219 public static final int SIGNATURE_MATCH = 0;
1220
1221 /**
1222 * Signature check result: this is returned by {@link #checkSignatures}
1223 * if neither of the two packages is signed.
1224 */
1225 public static final int SIGNATURE_NEITHER_SIGNED = 1;
1226
1227 /**
1228 * Signature check result: this is returned by {@link #checkSignatures}
1229 * if the first package is not signed but the second is.
1230 */
1231 public static final int SIGNATURE_FIRST_NOT_SIGNED = -1;
1232
1233 /**
1234 * Signature check result: this is returned by {@link #checkSignatures}
1235 * if the second package is not signed but the first is.
1236 */
1237 public static final int SIGNATURE_SECOND_NOT_SIGNED = -2;
1238
1239 /**
1240 * Signature check result: this is returned by {@link #checkSignatures}
1241 * if not all signatures on both packages match.
1242 */
1243 public static final int SIGNATURE_NO_MATCH = -3;
1244
1245 /**
1246 * Signature check result: this is returned by {@link #checkSignatures}
1247 * if either of the packages are not valid.
1248 */
1249 public static final int SIGNATURE_UNKNOWN_PACKAGE = -4;
1250
1251 /** @hide */
1252 @IntDef(prefix = { "COMPONENT_ENABLED_STATE_" }, value = {
1253 COMPONENT_ENABLED_STATE_DEFAULT,
1254 COMPONENT_ENABLED_STATE_ENABLED,
1255 COMPONENT_ENABLED_STATE_DISABLED,
1256 COMPONENT_ENABLED_STATE_DISABLED_USER,
1257 COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED,
1258 })
1259 @Retention(RetentionPolicy.SOURCE)
1260 public @interface EnabledState {}
1261
1262 /**
1263 * Flag for {@link #setApplicationEnabledSetting(String, int, int)} and
1264 * {@link #setComponentEnabledSetting(ComponentName, int, int)}: This
1265 * component or application is in its default enabled state (as specified in
1266 * its manifest).
1267 * <p>
1268 * Explicitly setting the component state to this value restores it's
1269 * enabled state to whatever is set in the manifest.
1270 */
1271 public static final int COMPONENT_ENABLED_STATE_DEFAULT = 0;
1272
1273 /**
1274 * Flag for {@link #setApplicationEnabledSetting(String, int, int)}
1275 * and {@link #setComponentEnabledSetting(ComponentName, int, int)}: This
1276 * component or application has been explictily enabled, regardless of
1277 * what it has specified in its manifest.
1278 */
1279 public static final int COMPONENT_ENABLED_STATE_ENABLED = 1;
1280
1281 /**
1282 * Flag for {@link #setApplicationEnabledSetting(String, int, int)}
1283 * and {@link #setComponentEnabledSetting(ComponentName, int, int)}: This
1284 * component or application has been explicitly disabled, regardless of
1285 * what it has specified in its manifest.
1286 */
1287 public static final int COMPONENT_ENABLED_STATE_DISABLED = 2;
1288
1289 /**
1290 * Flag for {@link #setApplicationEnabledSetting(String, int, int)} only: The
1291 * user has explicitly disabled the application, regardless of what it has
1292 * specified in its manifest. Because this is due to the user's request,
1293 * they may re-enable it if desired through the appropriate system UI. This
1294 * option currently <strong>cannot</strong> be used with
1295 * {@link #setComponentEnabledSetting(ComponentName, int, int)}.
1296 */
1297 public static final int COMPONENT_ENABLED_STATE_DISABLED_USER = 3;
1298
1299 /**
1300 * Flag for {@link #setApplicationEnabledSetting(String, int, int)} only: This
1301 * application should be considered, until the point where the user actually
1302 * wants to use it. This means that it will not normally show up to the user
1303 * (such as in the launcher), but various parts of the user interface can
1304 * use {@link #GET_DISABLED_UNTIL_USED_COMPONENTS} to still see it and allow
1305 * the user to select it (as for example an IME, device admin, etc). Such code,
1306 * once the user has selected the app, should at that point also make it enabled.
1307 * This option currently <strong>can not</strong> be used with
1308 * {@link #setComponentEnabledSetting(ComponentName, int, int)}.
1309 */
1310 public static final int COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED = 4;
1311
1312 /** @hide */
1313 @Retention(RetentionPolicy.SOURCE)
1314 @IntDef(prefix = { "ROLLBACK_DATA_POLICY_" }, value = {
1315 ROLLBACK_DATA_POLICY_RESTORE,
1316 ROLLBACK_DATA_POLICY_WIPE,
1317 ROLLBACK_DATA_POLICY_RETAIN
1318 })
1319 public @interface RollbackDataPolicy {}
1320
1321 /**
1322 * User data will be backed up during install and restored during rollback.
1323 *
1324 * @hide
1325 */
1326 @SystemApi
1327 public static final int ROLLBACK_DATA_POLICY_RESTORE = 0;
1328
1329 /**
1330 * User data won't be backed up during install but will be wiped out during rollback.
1331 *
1332 * @hide
1333 */
1334 @SystemApi
1335 public static final int ROLLBACK_DATA_POLICY_WIPE = 1;
1336
1337 /**
1338 * User data won't be backed up during install and will remain unchanged during rollback.
1339 *
1340 * @hide
1341 */
1342 @SystemApi
1343 public static final int ROLLBACK_DATA_POLICY_RETAIN = 2;
1344
1345 /** @hide */
1346 @IntDef(flag = true, prefix = { "INSTALL_" }, value = {
1347 INSTALL_REPLACE_EXISTING,
1348 INSTALL_ALLOW_TEST,
1349 INSTALL_INTERNAL,
1350 INSTALL_FROM_ADB,
1351 INSTALL_ALL_USERS,
1352 INSTALL_REQUEST_DOWNGRADE,
1353 INSTALL_GRANT_RUNTIME_PERMISSIONS,
1354 INSTALL_ALL_WHITELIST_RESTRICTED_PERMISSIONS,
1355 INSTALL_FORCE_VOLUME_UUID,
1356 INSTALL_FORCE_PERMISSION_PROMPT,
1357 INSTALL_INSTANT_APP,
1358 INSTALL_DONT_KILL_APP,
1359 INSTALL_FULL_APP,
1360 INSTALL_ALLOCATE_AGGRESSIVE,
1361 INSTALL_VIRTUAL_PRELOAD,
1362 INSTALL_APEX,
1363 INSTALL_ENABLE_ROLLBACK,
1364 INSTALL_ALLOW_DOWNGRADE,
1365 INSTALL_STAGED,
1366 })
1367 @Retention(RetentionPolicy.SOURCE)
1368 public @interface InstallFlags {}
1369
1370 /**
1371 * Flag parameter for {@link #installPackage} to indicate that you want to
1372 * replace an already installed package, if one exists.
1373 *
1374 * @hide
1375 */
1376 @UnsupportedAppUsage
1377 public static final int INSTALL_REPLACE_EXISTING = 0x00000002;
1378
1379 /**
1380 * Flag parameter for {@link #installPackage} to indicate that you want to
1381 * allow test packages (those that have set android:testOnly in their
1382 * manifest) to be installed.
1383 * @hide
1384 */
1385 public static final int INSTALL_ALLOW_TEST = 0x00000004;
1386
1387 /**
1388 * Flag parameter for {@link #installPackage} to indicate that this package
1389 * must be installed to internal storage.
1390 *
1391 * @hide
1392 */
1393 public static final int INSTALL_INTERNAL = 0x00000010;
1394
1395 /**
1396 * Flag parameter for {@link #installPackage} to indicate that this install
1397 * was initiated via ADB.
1398 *
1399 * @hide
1400 */
1401 public static final int INSTALL_FROM_ADB = 0x00000020;
1402
1403 /**
1404 * Flag parameter for {@link #installPackage} to indicate that this install
1405 * should immediately be visible to all users.
1406 *
1407 * @hide
1408 */
1409 public static final int INSTALL_ALL_USERS = 0x00000040;
1410
1411 /**
1412 * Flag parameter for {@link #installPackage} to indicate that an upgrade to a lower version
1413 * of a package than currently installed has been requested.
1414 *
1415 * <p>Note that this flag doesn't guarantee that downgrade will be performed. That decision
1416 * depends
1417 * on whenever:
1418 * <ul>
1419 * <li>An app is debuggable.
1420 * <li>Or a build is debuggable.
1421 * <li>Or {@link #INSTALL_ALLOW_DOWNGRADE} is set.
1422 * </ul>
1423 *
1424 * @hide
1425 */
1426 public static final int INSTALL_REQUEST_DOWNGRADE = 0x00000080;
1427
1428 /**
1429 * Flag parameter for {@link #installPackage} to indicate that all runtime
1430 * permissions should be granted to the package. If {@link #INSTALL_ALL_USERS}
1431 * is set the runtime permissions will be granted to all users, otherwise
1432 * only to the owner.
1433 *
1434 * @hide
1435 */
1436 public static final int INSTALL_GRANT_RUNTIME_PERMISSIONS = 0x00000100;
1437
1438 /**
1439 * Flag parameter for {@link #installPackage} to indicate that all restricted
1440 * permissions should be whitelisted. If {@link #INSTALL_ALL_USERS}
1441 * is set the restricted permissions will be whitelisted for all users, otherwise
1442 * only to the owner.
1443 *
1444 * <p>
1445 * <strong>Note: </strong>In retrospect it would have been preferred to use
1446 * more inclusive terminology when naming this API. Similar APIs added will
1447 * refrain from using the term "whitelist".
1448 * </p>
1449 *
1450 * @hide
1451 */
1452 public static final int INSTALL_ALL_WHITELIST_RESTRICTED_PERMISSIONS = 0x00400000;
1453
1454 /** {@hide} */
1455 public static final int INSTALL_FORCE_VOLUME_UUID = 0x00000200;
1456
1457 /**
1458 * Flag parameter for {@link #installPackage} to indicate that we always want to force
1459 * the prompt for permission approval. This overrides any special behaviour for internal
1460 * components.
1461 *
1462 * @hide
1463 */
1464 public static final int INSTALL_FORCE_PERMISSION_PROMPT = 0x00000400;
1465
1466 /**
1467 * Flag parameter for {@link #installPackage} to indicate that this package is
1468 * to be installed as a lightweight "ephemeral" app.
1469 *
1470 * @hide
1471 */
1472 public static final int INSTALL_INSTANT_APP = 0x00000800;
1473
1474 /**
1475 * Flag parameter for {@link #installPackage} to indicate that this package contains
1476 * a feature split to an existing application and the existing application should not
1477 * be killed during the installation process.
1478 *
1479 * @hide
1480 */
1481 public static final int INSTALL_DONT_KILL_APP = 0x00001000;
1482
1483 /**
1484 * Flag parameter for {@link #installPackage} to indicate that this package is
1485 * to be installed as a heavy weight app. This is fundamentally the opposite of
1486 * {@link #INSTALL_INSTANT_APP}.
1487 *
1488 * @hide
1489 */
1490 public static final int INSTALL_FULL_APP = 0x00004000;
1491
1492 /**
1493 * Flag parameter for {@link #installPackage} to indicate that this package
1494 * is critical to system health or security, meaning the system should use
1495 * {@link StorageManager#FLAG_ALLOCATE_AGGRESSIVE} internally.
1496 *
1497 * @hide
1498 */
1499 public static final int INSTALL_ALLOCATE_AGGRESSIVE = 0x00008000;
1500
1501 /**
1502 * Flag parameter for {@link #installPackage} to indicate that this package
1503 * is a virtual preload.
1504 *
1505 * @hide
1506 */
1507 public static final int INSTALL_VIRTUAL_PRELOAD = 0x00010000;
1508
1509 /**
1510 * Flag parameter for {@link #installPackage} to indicate that this package
1511 * is an APEX package
1512 *
1513 * @hide
1514 */
1515 public static final int INSTALL_APEX = 0x00020000;
1516
1517 /**
1518 * Flag parameter for {@link #installPackage} to indicate that rollback
1519 * should be enabled for this install.
1520 *
1521 * @hide
1522 */
1523 public static final int INSTALL_ENABLE_ROLLBACK = 0x00040000;
1524
1525 /**
1526 * Flag parameter for {@link #installPackage} to indicate that package verification should be
1527 * disabled for this package.
1528 *
1529 * @hide
1530 */
1531 public static final int INSTALL_DISABLE_VERIFICATION = 0x00080000;
1532
1533 /**
1534 * Flag parameter for {@link #installPackage} to indicate that
1535 * {@link #INSTALL_REQUEST_DOWNGRADE} should be allowed.
1536 *
1537 * @hide
1538 */
1539 public static final int INSTALL_ALLOW_DOWNGRADE = 0x00100000;
1540
1541 /**
1542 * Flag parameter for {@link #installPackage} to indicate that this package
1543 * is being installed as part of a staged install.
1544 *
1545 * @hide
1546 */
1547 public static final int INSTALL_STAGED = 0x00200000;
1548
1549 /**
1550 * Flag parameter for {@link #installPackage} to indicate that check whether given APEX can be
1551 * updated should be disabled for this install.
1552 * @hide
1553 */
1554 public static final int INSTALL_DISABLE_ALLOWED_APEX_UPDATE_CHECK = 0x00400000;
1555
1556 /**
1557 * Flag parameter for {@link #installPackage} to bypass the low target sdk version block
1558 * for this install.
1559 *
1560 * @hide
1561 */
1562 public static final int INSTALL_BYPASS_LOW_TARGET_SDK_BLOCK = 0x01000000;
1563
1564 /** @hide */
1565 @IntDef(flag = true, value = {
1566 DONT_KILL_APP,
1567 SYNCHRONOUS
1568 })
1569 @Retention(RetentionPolicy.SOURCE)
1570 public @interface EnabledFlags {}
1571
1572 /**
1573 * Flag parameter for
1574 * {@link #setComponentEnabledSetting(android.content.ComponentName, int, int)} to indicate
1575 * that you don't want to kill the app containing the component. Be careful when you set this
1576 * since changing component states can make the containing application's behavior unpredictable.
1577 */
1578 public static final int DONT_KILL_APP = 0x00000001;
1579
1580 /**
1581 * Flag parameter for
1582 * {@link #setComponentEnabledSetting(android.content.ComponentName, int, int)} to indicate
1583 * that the given user's package restrictions state will be serialised to disk after the
1584 * component state has been updated. Note that this is synchronous disk access, so calls using
1585 * this flag should be run on a background thread.
1586 */
1587 public static final int SYNCHRONOUS = 0x00000002;
1588
1589 /** @hide */
1590 @IntDef(prefix = { "INSTALL_REASON_" }, value = {
1591 INSTALL_REASON_UNKNOWN,
1592 INSTALL_REASON_POLICY,
1593 INSTALL_REASON_DEVICE_RESTORE,
1594 INSTALL_REASON_DEVICE_SETUP,
1595 INSTALL_REASON_USER,
1596 INSTALL_REASON_ROLLBACK
1597 })
1598 @Retention(RetentionPolicy.SOURCE)
1599 public @interface InstallReason {}
1600
1601 /**
1602 * Code indicating that the reason for installing this package is unknown.
1603 */
1604 public static final int INSTALL_REASON_UNKNOWN = 0;
1605
1606 /**
1607 * Code indicating that this package was installed due to enterprise policy.
1608 */
1609 public static final int INSTALL_REASON_POLICY = 1;
1610
1611 /**
1612 * Code indicating that this package was installed as part of restoring from another device.
1613 */
1614 public static final int INSTALL_REASON_DEVICE_RESTORE = 2;
1615
1616 /**
1617 * Code indicating that this package was installed as part of device setup.
1618 */
1619 public static final int INSTALL_REASON_DEVICE_SETUP = 3;
1620
1621 /**
1622 * Code indicating that the package installation was initiated by the user.
1623 */
1624 public static final int INSTALL_REASON_USER = 4;
1625
1626 /**
1627 * Code indicating that the package installation was a rollback initiated by RollbackManager.
1628 *
1629 * @hide
1630 */
1631 public static final int INSTALL_REASON_ROLLBACK = 5;
1632
1633 /** @hide */
1634 @IntDef(prefix = { "INSTALL_SCENARIO_" }, value = {
1635 INSTALL_SCENARIO_DEFAULT,
1636 INSTALL_SCENARIO_FAST,
1637 INSTALL_SCENARIO_BULK,
1638 INSTALL_SCENARIO_BULK_SECONDARY,
1639 })
1640 @Retention(RetentionPolicy.SOURCE)
1641 public @interface InstallScenario {}
1642
1643 /**
1644 * A value to indicate the lack of CUJ information, disabling all installation scenario logic.
1645 */
1646 public static final int INSTALL_SCENARIO_DEFAULT = 0;
1647
1648 /**
1649 * Installation scenario providing the fastest “install button to launch" experience possible.
1650 */
1651 public static final int INSTALL_SCENARIO_FAST = 1;
1652
1653 /**
1654 * Installation scenario indicating a bulk operation with the desired result of a fully
1655 * optimized application. If the system is busy or resources are scarce the system will
1656 * perform less work to avoid impacting system health.
1657 *
1658 * Examples of bulk installation scenarios might include device restore, background updates of
1659 * multiple applications, or user-triggered updates for all applications.
1660 *
1661 * The decision to use BULK or BULK_SECONDARY should be based on the desired user experience.
1662 * BULK_SECONDARY operations may take less time to complete but, when they do, will produce
1663 * less optimized applications. The device state (e.g. memory usage or battery status) should
1664 * not be considered when making this decision as those factors are taken into account by the
1665 * Package Manager when acting on the installation scenario.
1666 */
1667 public static final int INSTALL_SCENARIO_BULK = 2;
1668
1669 /**
1670 * Installation scenario indicating a bulk operation that prioritizes minimal system health
1671 * impact over application optimization. The application may undergo additional optimization
1672 * if the system is idle and system resources are abundant. The more elements of a bulk
1673 * operation that are marked BULK_SECONDARY, the faster the entire bulk operation will be.
1674 *
1675 * See the comments for INSTALL_SCENARIO_BULK for more information.
1676 */
1677 public static final int INSTALL_SCENARIO_BULK_SECONDARY = 3;
1678
1679 /** @hide */
1680 @IntDef(prefix = { "UNINSTALL_REASON_" }, value = {
1681 UNINSTALL_REASON_UNKNOWN,
1682 UNINSTALL_REASON_USER_TYPE,
1683 })
1684 @Retention(RetentionPolicy.SOURCE)
1685 public @interface UninstallReason {}
1686
1687 /**
1688 * Code indicating that the reason for uninstalling this package is unknown.
1689 * @hide
1690 */
1691 public static final int UNINSTALL_REASON_UNKNOWN = 0;
1692
1693 /**
1694 * Code indicating that this package was uninstalled due to the type of user.
1695 * See UserSystemPackageInstaller
1696 * @hide
1697 */
1698 public static final int UNINSTALL_REASON_USER_TYPE = 1;
1699
1700 /**
1701 * @hide
1702 */
1703 public static final int INSTALL_UNKNOWN = 0;
1704
1705 /**
1706 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
1707 * on success.
1708 *
1709 * @hide
1710 */
1711 @SystemApi
1712 public static final int INSTALL_SUCCEEDED = 1;
1713
1714 /**
1715 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
1716 * if the package is already installed.
1717 *
1718 * @hide
1719 */
1720 @SystemApi
1721 public static final int INSTALL_FAILED_ALREADY_EXISTS = -1;
1722
1723 /**
1724 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
1725 * if the package archive file is invalid.
1726 *
1727 * @hide
1728 */
1729 @SystemApi
1730 public static final int INSTALL_FAILED_INVALID_APK = -2;
1731
1732 /**
1733 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
1734 * if the URI passed in is invalid.
1735 *
1736 * @hide
1737 */
1738 @SystemApi
1739 public static final int INSTALL_FAILED_INVALID_URI = -3;
1740
1741 /**
1742 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
1743 * if the package manager service found that the device didn't have enough storage space to
1744 * install the app.
1745 *
1746 * @hide
1747 */
1748 @SystemApi
1749 public static final int INSTALL_FAILED_INSUFFICIENT_STORAGE = -4;
1750
1751 /**
1752 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
1753 * if a package is already installed with the same name.
1754 *
1755 * @hide
1756 */
1757 @SystemApi
1758 public static final int INSTALL_FAILED_DUPLICATE_PACKAGE = -5;
1759
1760 /**
1761 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
1762 * if the requested shared user does not exist.
1763 *
1764 * @hide
1765 */
1766 @SystemApi
1767 public static final int INSTALL_FAILED_NO_SHARED_USER = -6;
1768
1769 /**
1770 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
1771 * if a previously installed package of the same name has a different signature than the new
1772 * package (and the old package's data was not removed).
1773 *
1774 * @hide
1775 */
1776 @SystemApi
1777 public static final int INSTALL_FAILED_UPDATE_INCOMPATIBLE = -7;
1778
1779 /**
1780 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
1781 * if the new package is requested a shared user which is already installed on the device and
1782 * does not have matching signature.
1783 *
1784 * @hide
1785 */
1786 @SystemApi
1787 public static final int INSTALL_FAILED_SHARED_USER_INCOMPATIBLE = -8;
1788
1789 /**
1790 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
1791 * if the new package uses a shared library that is not available.
1792 *
1793 * @hide
1794 */
1795 @SystemApi
1796 public static final int INSTALL_FAILED_MISSING_SHARED_LIBRARY = -9;
1797
1798 /**
1799 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
1800 * when the package being replaced is a system app and the caller didn't provide the
1801 * {@link #DELETE_SYSTEM_APP} flag.
1802 *
1803 * @hide
1804 */
1805 @SystemApi
1806 public static final int INSTALL_FAILED_REPLACE_COULDNT_DELETE = -10;
1807
1808 /**
1809 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
1810 * if the new package failed while optimizing and validating its dex files, either because there
1811 * was not enough storage or the validation failed.
1812 *
1813 * @hide
1814 */
1815 @SystemApi
1816 public static final int INSTALL_FAILED_DEXOPT = -11;
1817
1818 /**
1819 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
1820 * if the new package failed because the current SDK version is older than that required by the
1821 * package.
1822 *
1823 * @hide
1824 */
1825 @SystemApi
1826 public static final int INSTALL_FAILED_OLDER_SDK = -12;
1827
1828 /**
1829 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
1830 * if the new package failed because it contains a content provider with the same authority as a
1831 * provider already installed in the system.
1832 *
1833 * @hide
1834 */
1835 @SystemApi
1836 public static final int INSTALL_FAILED_CONFLICTING_PROVIDER = -13;
1837
1838 /**
1839 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
1840 * if the new package failed because the current SDK version is newer than that required by the
1841 * package.
1842 *
1843 * @hide
1844 */
1845 @SystemApi
1846 public static final int INSTALL_FAILED_NEWER_SDK = -14;
1847
1848 /**
1849 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
1850 * if the new package failed because it has specified that it is a test-only package and the
1851 * caller has not supplied the {@link #INSTALL_ALLOW_TEST} flag.
1852 *
1853 * @hide
1854 */
1855 @SystemApi
1856 public static final int INSTALL_FAILED_TEST_ONLY = -15;
1857
1858 /**
1859 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
1860 * if the package being installed contains native code, but none that is compatible with the
1861 * device's CPU_ABI.
1862 *
1863 * @hide
1864 */
1865 @SystemApi
1866 public static final int INSTALL_FAILED_CPU_ABI_INCOMPATIBLE = -16;
1867
1868 /**
1869 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
1870 * if the new package uses a feature that is not available.
1871 *
1872 * @hide
1873 */
1874 @SystemApi
1875 public static final int INSTALL_FAILED_MISSING_FEATURE = -17;
1876
1877 // ------ Errors related to sdcard
1878 /**
1879 * Installation return code: this is passed in the
1880 * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if a secure container mount point couldn't be
1881 * accessed on external media.
1882 *
1883 * @hide
1884 */
1885 @SystemApi
1886 public static final int INSTALL_FAILED_CONTAINER_ERROR = -18;
1887
1888 /**
1889 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
1890 * if the new package couldn't be installed in the specified install location.
1891 *
1892 * @hide
1893 */
1894 @SystemApi
1895 public static final int INSTALL_FAILED_INVALID_INSTALL_LOCATION = -19;
1896
1897 /**
1898 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
1899 * if the new package couldn't be installed in the specified install location because the media
1900 * is not available.
1901 *
1902 * @hide
1903 */
1904 @SystemApi
1905 public static final int INSTALL_FAILED_MEDIA_UNAVAILABLE = -20;
1906
1907 /**
1908 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
1909 * if the new package couldn't be installed because the verification timed out.
1910 *
1911 * @hide
1912 */
1913 @SystemApi
1914 public static final int INSTALL_FAILED_VERIFICATION_TIMEOUT = -21;
1915
1916 /**
1917 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
1918 * if the new package couldn't be installed because the verification did not succeed.
1919 *
1920 * @hide
1921 */
1922 @SystemApi
1923 public static final int INSTALL_FAILED_VERIFICATION_FAILURE = -22;
1924
1925 /**
1926 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
1927 * if the package changed from what the calling program expected.
1928 *
1929 * @hide
1930 */
1931 @SystemApi
1932 public static final int INSTALL_FAILED_PACKAGE_CHANGED = -23;
1933
1934 /**
1935 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
1936 * if the new package is assigned a different UID than it previously held.
1937 *
1938 * @hide
1939 */
1940 public static final int INSTALL_FAILED_UID_CHANGED = -24;
1941
1942 /**
1943 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
1944 * if the new package has an older version code than the currently installed package.
1945 *
1946 * @hide
1947 */
1948 public static final int INSTALL_FAILED_VERSION_DOWNGRADE = -25;
1949
1950 /**
1951 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
1952 * if the old package has target SDK high enough to support runtime permission and the new
1953 * package has target SDK low enough to not support runtime permissions.
1954 *
1955 * @hide
1956 */
1957 @SystemApi
1958 public static final int INSTALL_FAILED_PERMISSION_MODEL_DOWNGRADE = -26;
1959
1960 /**
1961 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
1962 * if the new package attempts to downgrade the target sandbox version of the app.
1963 *
1964 * @hide
1965 */
1966 @SystemApi
1967 public static final int INSTALL_FAILED_SANDBOX_VERSION_DOWNGRADE = -27;
1968
1969 /**
1970 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
1971 * if the new package requires at least one split and it was not provided.
1972 *
1973 * @hide
1974 */
1975 public static final int INSTALL_FAILED_MISSING_SPLIT = -28;
1976
1977 /**
1978 * Installation parse return code: this is passed in the
1979 * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the parser was given a path that is not a
1980 * file, or does not end with the expected '.apk' extension.
1981 *
1982 * @hide
1983 */
1984 @SystemApi
1985 public static final int INSTALL_PARSE_FAILED_NOT_APK = -100;
1986
1987 /**
1988 * Installation parse return code: this is passed in the
1989 * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the parser was unable to retrieve the
1990 * AndroidManifest.xml file.
1991 *
1992 * @hide
1993 */
1994 @SystemApi
1995 public static final int INSTALL_PARSE_FAILED_BAD_MANIFEST = -101;
1996
1997 /**
1998 * Installation parse return code: this is passed in the
1999 * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the parser encountered an unexpected
2000 * exception.
2001 *
2002 * @hide
2003 */
2004 @SystemApi
2005 public static final int INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION = -102;
2006
2007 /**
2008 * Installation parse return code: this is passed in the
2009 * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the parser did not find any certificates in
2010 * the .apk.
2011 *
2012 * @hide
2013 */
2014 @SystemApi
2015 public static final int INSTALL_PARSE_FAILED_NO_CERTIFICATES = -103;
2016
2017 /**
2018 * Installation parse return code: this is passed in the
2019 * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the parser found inconsistent certificates on
2020 * the files in the .apk.
2021 *
2022 * @hide
2023 */
2024 @SystemApi
2025 public static final int INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES = -104;
2026
2027 /**
2028 * Installation parse return code: this is passed in the
2029 * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the parser encountered a
2030 * CertificateEncodingException in one of the files in the .apk.
2031 *
2032 * @hide
2033 */
2034 @SystemApi
2035 public static final int INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING = -105;
2036
2037 /**
2038 * Installation parse return code: this is passed in the
2039 * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the parser encountered a bad or missing
2040 * package name in the manifest.
2041 *
2042 * @hide
2043 */
2044 @SystemApi
2045 public static final int INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME = -106;
2046
2047 /**
2048 * Installation parse return code: tthis is passed in the
2049 * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the parser encountered a bad shared user id
2050 * name in the manifest.
2051 *
2052 * @hide
2053 */
2054 @SystemApi
2055 public static final int INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID = -107;
2056
2057 /**
2058 * Installation parse return code: this is passed in the
2059 * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the parser encountered some structural
2060 * problem in the manifest.
2061 *
2062 * @hide
2063 */
2064 @SystemApi
2065 public static final int INSTALL_PARSE_FAILED_MANIFEST_MALFORMED = -108;
2066
2067 /**
2068 * Installation parse return code: this is passed in the
2069 * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the parser did not find any actionable tags
2070 * (instrumentation or application) in the manifest.
2071 *
2072 * @hide
2073 */
2074 @SystemApi
2075 public static final int INSTALL_PARSE_FAILED_MANIFEST_EMPTY = -109;
2076
2077 /**
2078 * Installation failed return code: this is passed in the
2079 * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the system failed to install the package
2080 * because of system issues.
2081 *
2082 * @hide
2083 */
2084 @SystemApi
2085 public static final int INSTALL_FAILED_INTERNAL_ERROR = -110;
2086
2087 /**
2088 * Installation failed return code: this is passed in the
2089 * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the system failed to install the package
2090 * because the user is restricted from installing apps.
2091 *
2092 * @hide
2093 */
2094 public static final int INSTALL_FAILED_USER_RESTRICTED = -111;
2095
2096 /**
2097 * Installation failed return code: this is passed in the
2098 * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the system failed to install the package
2099 * because it is attempting to define a permission that is already defined by some existing
2100 * package.
2101 * <p>
2102 * The package name of the app which has already defined the permission is passed to a
2103 * {@link PackageInstallObserver}, if any, as the {@link #EXTRA_FAILURE_EXISTING_PACKAGE} string
2104 * extra; and the name of the permission being redefined is passed in the
2105 * {@link #EXTRA_FAILURE_EXISTING_PERMISSION} string extra.
2106 *
2107 * @hide
2108 */
2109 public static final int INSTALL_FAILED_DUPLICATE_PERMISSION = -112;
2110
2111 /**
2112 * Installation failed return code: this is passed in the
2113 * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the system failed to install the package
2114 * because its packaged native code did not match any of the ABIs supported by the system.
2115 *
2116 * @hide
2117 */
2118 public static final int INSTALL_FAILED_NO_MATCHING_ABIS = -113;
2119
2120 /**
2121 * Internal return code for NativeLibraryHelper methods to indicate that the package
2122 * being processed did not contain any native code. This is placed here only so that
2123 * it can belong to the same value space as the other install failure codes.
2124 *
2125 * @hide
2126 */
2127 @UnsupportedAppUsage
2128 public static final int NO_NATIVE_LIBRARIES = -114;
2129
2130 /** {@hide} */
2131 public static final int INSTALL_FAILED_ABORTED = -115;
2132
2133 /**
2134 * Installation failed return code: install type is incompatible with some other
2135 * installation flags supplied for the operation; or other circumstances such as trying
2136 * to upgrade a system app via an Incremental or instant app install.
2137 * @hide
2138 */
2139 public static final int INSTALL_FAILED_SESSION_INVALID = -116;
2140
2141 /**
2142 * Installation parse return code: this is passed in the
2143 * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the dex metadata file is invalid or
2144 * if there was no matching apk file for a dex metadata file.
2145 *
2146 * @hide
2147 */
2148 public static final int INSTALL_FAILED_BAD_DEX_METADATA = -117;
2149
2150 /**
2151 * Installation parse return code: this is passed in the
2152 * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if there is any signature problem.
2153 *
2154 * @hide
2155 */
2156 public static final int INSTALL_FAILED_BAD_SIGNATURE = -118;
2157
2158 /**
2159 * Installation failed return code: a new staged session was attempted to be committed while
2160 * there is already one in-progress or new session has package that is already staged.
2161 *
2162 * @hide
2163 */
2164 public static final int INSTALL_FAILED_OTHER_STAGED_SESSION_IN_PROGRESS = -119;
2165
2166 /**
2167 * Installation failed return code: one of the child sessions does not match the parent session
2168 * in respect to staged or rollback enabled parameters.
2169 *
2170 * @hide
2171 */
2172 public static final int INSTALL_FAILED_MULTIPACKAGE_INCONSISTENCY = -120;
2173
2174 /**
2175 * Installation failed return code: the required installed version code
2176 * does not match the currently installed package version code.
2177 *
2178 * @hide
2179 */
2180 public static final int INSTALL_FAILED_WRONG_INSTALLED_VERSION = -121;
2181
2182 /**
2183 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
2184 * if the new package failed because it contains a request to use a process that was not
2185 * explicitly defined as part of its &lt;processes&gt; tag.
2186 *
2187 * @hide
2188 */
2189 public static final int INSTALL_FAILED_PROCESS_NOT_DEFINED = -122;
2190
2191 /**
2192 * Installation parse return code: system is in a minimal boot state, and the parser only
2193 * allows the package with {@code coreApp} manifest attribute to be a valid application.
2194 *
2195 * @hide
2196 */
2197 public static final int INSTALL_PARSE_FAILED_ONLY_COREAPP_ALLOWED = -123;
2198
2199 /**
2200 * Installation failed return code: the {@code resources.arsc} of one of the APKs being
2201 * installed is compressed or not aligned on a 4-byte boundary. Resource tables that cannot be
2202 * memory mapped exert excess memory pressure on the system and drastically slow down
2203 * construction of {@link Resources} objects.
2204 *
2205 * @hide
2206 */
2207 public static final int INSTALL_PARSE_FAILED_RESOURCES_ARSC_COMPRESSED = -124;
2208
2209 /**
2210 * Installation failed return code: the package was skipped and should be ignored.
2211 *
2212 * The reason for the skip is undefined.
2213 * @hide
2214 */
2215 public static final int INSTALL_PARSE_FAILED_SKIPPED = -125;
2216
2217 /**
2218 * Installation failed return code: this is passed in the
2219 * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the system failed to install the package
2220 * because it is attempting to define a permission group that is already defined by some
2221 * existing package.
2222 *
2223 * @hide
2224 */
2225 public static final int INSTALL_FAILED_DUPLICATE_PERMISSION_GROUP = -126;
2226
2227 /**
2228 * Installation failed return code: this is passed in the
2229 * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the system failed to install the package
2230 * because it is attempting to define a permission in a group that does not exists or that is
2231 * defined by an packages with an incompatible certificate.
2232 *
2233 * @hide
2234 */
2235 public static final int INSTALL_FAILED_BAD_PERMISSION_GROUP = -127;
2236
2237 /**
2238 * Installation failed return code: an error occurred during the activation phase of this
2239 * session.
2240 *
2241 * @hide
2242 */
2243 public static final int INSTALL_ACTIVATION_FAILED = -128;
2244
2245 /** @hide */
2246 @IntDef(flag = true, prefix = { "DELETE_" }, value = {
2247 DELETE_KEEP_DATA,
2248 DELETE_ALL_USERS,
2249 DELETE_SYSTEM_APP,
2250 DELETE_DONT_KILL_APP,
2251 DELETE_CHATTY,
2252 })
2253 @Retention(RetentionPolicy.SOURCE)
2254 public @interface DeleteFlags {}
2255
2256 /**
2257 * Flag parameter for {@link #deletePackage} to indicate that you don't want to delete the
2258 * package's data directory.
2259 *
2260 * @hide
2261 */
2262 public static final int DELETE_KEEP_DATA = 0x00000001;
2263
2264 /**
2265 * Flag parameter for {@link #deletePackage} to indicate that you want the
2266 * package deleted for all users.
2267 *
2268 * @hide
2269 */
2270 public static final int DELETE_ALL_USERS = 0x00000002;
2271
2272 /**
2273 * Flag parameter for {@link #deletePackage} to indicate that, if you are calling
2274 * uninstall on a system that has been updated, then don't do the normal process
2275 * of uninstalling the update and rolling back to the older system version (which
2276 * needs to happen for all users); instead, just mark the app as uninstalled for
2277 * the current user.
2278 *
2279 * @hide
2280 */
2281 public static final int DELETE_SYSTEM_APP = 0x00000004;
2282
2283 /**
2284 * Flag parameter for {@link #deletePackage} to indicate that, if you are calling
2285 * uninstall on a package that is replaced to provide new feature splits, the
2286 * existing application should not be killed during the removal process.
2287 *
2288 * @hide
2289 */
2290 public static final int DELETE_DONT_KILL_APP = 0x00000008;
2291
2292 /**
2293 * Flag parameter for {@link #deletePackage} to indicate that package deletion
2294 * should be chatty.
2295 *
2296 * @hide
2297 */
2298 public static final int DELETE_CHATTY = 0x80000000;
2299
2300 /**
2301 * Return code for when package deletion succeeds. This is passed to the
2302 * {@link IPackageDeleteObserver} if the system succeeded in deleting the
2303 * package.
2304 *
2305 * @hide
2306 */
2307 public static final int DELETE_SUCCEEDED = 1;
2308
2309 /**
2310 * Deletion failed return code: this is passed to the
2311 * {@link IPackageDeleteObserver} if the system failed to delete the package
2312 * for an unspecified reason.
2313 *
2314 * @hide
2315 */
2316 public static final int DELETE_FAILED_INTERNAL_ERROR = -1;
2317
2318 /**
2319 * Deletion failed return code: this is passed to the
2320 * {@link IPackageDeleteObserver} if the system failed to delete the package
2321 * because it is the active DevicePolicy manager.
2322 *
2323 * @hide
2324 */
2325 public static final int DELETE_FAILED_DEVICE_POLICY_MANAGER = -2;
2326
2327 /**
2328 * Deletion failed return code: this is passed to the
2329 * {@link IPackageDeleteObserver} if the system failed to delete the package
2330 * since the user is restricted.
2331 *
2332 * @hide
2333 */
2334 public static final int DELETE_FAILED_USER_RESTRICTED = -3;
2335
2336 /**
2337 * Deletion failed return code: this is passed to the
2338 * {@link IPackageDeleteObserver} if the system failed to delete the package
2339 * because a profile or device owner has marked the package as
2340 * uninstallable.
2341 *
2342 * @hide
2343 */
2344 public static final int DELETE_FAILED_OWNER_BLOCKED = -4;
2345
2346 /** {@hide} */
2347 public static final int DELETE_FAILED_ABORTED = -5;
2348
2349 /**
2350 * Deletion failed return code: this is passed to the
2351 * {@link IPackageDeleteObserver} if the system failed to delete the package
2352 * because the packge is a shared library used by other installed packages.
2353 * {@hide} */
2354 public static final int DELETE_FAILED_USED_SHARED_LIBRARY = -6;
2355
2356 /**
2357 * Deletion failed return code: this is passed to the
2358 * {@link IPackageDeleteObserver} if the system failed to delete the package
2359 * because there is an app pinned.
2360 *
2361 * @hide
2362 */
2363 public static final int DELETE_FAILED_APP_PINNED = -7;
2364
2365 /**
2366 * Return code that is passed to the {@link IPackageMoveObserver} when the
2367 * package has been successfully moved by the system.
2368 *
2369 * @hide
2370 */
2371 public static final int MOVE_SUCCEEDED = -100;
2372
2373 /**
2374 * Error code that is passed to the {@link IPackageMoveObserver} when the
2375 * package hasn't been successfully moved by the system because of
2376 * insufficient memory on specified media.
2377 *
2378 * @hide
2379 */
2380 public static final int MOVE_FAILED_INSUFFICIENT_STORAGE = -1;
2381
2382 /**
2383 * Error code that is passed to the {@link IPackageMoveObserver} if the
2384 * specified package doesn't exist.
2385 *
2386 * @hide
2387 */
2388 public static final int MOVE_FAILED_DOESNT_EXIST = -2;
2389
2390 /**
2391 * Error code that is passed to the {@link IPackageMoveObserver} if the
2392 * specified package cannot be moved since its a system package.
2393 *
2394 * @hide
2395 */
2396 public static final int MOVE_FAILED_SYSTEM_PACKAGE = -3;
2397
2398 /**
2399 * Error code that is passed to the {@link IPackageMoveObserver} if the
2400 * specified package cannot be moved to the specified location.
2401 *
2402 * @hide
2403 */
2404 public static final int MOVE_FAILED_INVALID_LOCATION = -5;
2405
2406 /**
2407 * Error code that is passed to the {@link IPackageMoveObserver} if the
2408 * specified package cannot be moved to the specified location.
2409 *
2410 * @hide
2411 */
2412 public static final int MOVE_FAILED_INTERNAL_ERROR = -6;
2413
2414 /**
2415 * Error code that is passed to the {@link IPackageMoveObserver} if the
2416 * specified package already has an operation pending in the queue.
2417 *
2418 * @hide
2419 */
2420 public static final int MOVE_FAILED_OPERATION_PENDING = -7;
2421
2422 /**
2423 * Error code that is passed to the {@link IPackageMoveObserver} if the
2424 * specified package cannot be moved since it contains a device admin.
2425 *
2426 * @hide
2427 */
2428 public static final int MOVE_FAILED_DEVICE_ADMIN = -8;
2429
2430 /**
2431 * Error code that is passed to the {@link IPackageMoveObserver} if system does not allow
2432 * non-system apps to be moved to internal storage.
2433 *
2434 * @hide
2435 */
2436 public static final int MOVE_FAILED_3RD_PARTY_NOT_ALLOWED_ON_INTERNAL = -9;
2437
2438 /** @hide */
2439 public static final int MOVE_FAILED_LOCKED_USER = -10;
2440
2441 /**
2442 * Flag parameter for {@link #movePackage} to indicate that
2443 * the package should be moved to internal storage if its
2444 * been installed on external media.
2445 * @hide
2446 */
2447 @Deprecated
2448 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
2449 public static final int MOVE_INTERNAL = 0x00000001;
2450
2451 /**
2452 * Flag parameter for {@link #movePackage} to indicate that
2453 * the package should be moved to external media.
2454 * @hide
2455 */
2456 @Deprecated
2457 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
2458 public static final int MOVE_EXTERNAL_MEDIA = 0x00000002;
2459
2460 /** {@hide} */
2461 public static final String EXTRA_MOVE_ID = "android.content.pm.extra.MOVE_ID";
2462
2463 /**
2464 * Usable by the required verifier as the {@code verificationCode} argument
2465 * for {@link PackageManager#verifyPendingInstall} to indicate that it will
2466 * allow the installation to proceed without any of the optional verifiers
2467 * needing to vote.
2468 *
2469 * @hide
2470 */
2471 public static final int VERIFICATION_ALLOW_WITHOUT_SUFFICIENT = 2;
2472
2473 /**
2474 * Used as the {@code verificationCode} argument for
2475 * {@link PackageManager#verifyPendingInstall} to indicate that the calling
2476 * package verifier allows the installation to proceed.
2477 */
2478 public static final int VERIFICATION_ALLOW = 1;
2479
2480 /**
2481 * Used as the {@code verificationCode} argument for
2482 * {@link PackageManager#verifyPendingInstall} to indicate the calling
2483 * package verifier does not vote to allow the installation to proceed.
2484 */
2485 public static final int VERIFICATION_REJECT = -1;
2486
2487 /**
2488 * Used as the {@code verificationCode} argument for
2489 * {@link PackageManager#verifyIntentFilter} to indicate that the calling
2490 * IntentFilter Verifier confirms that the IntentFilter is verified.
2491 *
2492 * @deprecated Use {@link DomainVerificationManager} APIs.
2493 * @hide
2494 */
2495 @Deprecated
2496 @SystemApi
2497 public static final int INTENT_FILTER_VERIFICATION_SUCCESS = 1;
2498
2499 /**
2500 * Used as the {@code verificationCode} argument for
2501 * {@link PackageManager#verifyIntentFilter} to indicate that the calling
2502 * IntentFilter Verifier confirms that the IntentFilter is NOT verified.
2503 *
2504 * @deprecated Use {@link DomainVerificationManager} APIs.
2505 * @hide
2506 */
2507 @Deprecated
2508 @SystemApi
2509 public static final int INTENT_FILTER_VERIFICATION_FAILURE = -1;
2510
2511 /**
2512 * Internal status code to indicate that an IntentFilter verification result is not specified.
2513 *
2514 * @deprecated Use {@link DomainVerificationManager} APIs.
2515 * @hide
2516 */
2517 @Deprecated
2518 @SystemApi
2519 public static final int INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_UNDEFINED = 0;
2520
2521 /**
2522 * Used as the {@code status} argument for
2523 * {@link #updateIntentVerificationStatusAsUser} to indicate that the User
2524 * will always be prompted the Intent Disambiguation Dialog if there are two
2525 * or more Intent resolved for the IntentFilter's domain(s).
2526 *
2527 * @deprecated Use {@link DomainVerificationManager} APIs.
2528 * @hide
2529 */
2530 @Deprecated
2531 @SystemApi
2532 public static final int INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK = 1;
2533
2534 /**
2535 * Used as the {@code status} argument for
2536 * {@link #updateIntentVerificationStatusAsUser} to indicate that the User
2537 * will never be prompted the Intent Disambiguation Dialog if there are two
2538 * or more resolution of the Intent. The default App for the domain(s)
2539 * specified in the IntentFilter will also ALWAYS be used.
2540 *
2541 * @deprecated Use {@link DomainVerificationManager} APIs.
2542 * @hide
2543 */
2544 @Deprecated
2545 @SystemApi
2546 public static final int INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS = 2;
2547
2548 /**
2549 * Used as the {@code status} argument for
2550 * {@link #updateIntentVerificationStatusAsUser} to indicate that the User
2551 * may be prompted the Intent Disambiguation Dialog if there are two or more
2552 * Intent resolved. The default App for the domain(s) specified in the
2553 * IntentFilter will also NEVER be presented to the User.
2554 *
2555 * @deprecated Use {@link DomainVerificationManager} APIs.
2556 * @hide
2557 */
2558 @Deprecated
2559 @SystemApi
2560 public static final int INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER = 3;
2561
2562 /**
2563 * Used as the {@code status} argument for
2564 * {@link #updateIntentVerificationStatusAsUser} to indicate that this app
2565 * should always be considered as an ambiguous candidate for handling the
2566 * matching Intent even if there are other candidate apps in the "always"
2567 * state. Put another way: if there are any 'always ask' apps in a set of
2568 * more than one candidate app, then a disambiguation is *always* presented
2569 * even if there is another candidate app with the 'always' state.
2570 *
2571 * @deprecated Use {@link DomainVerificationManager} APIs.
2572 * @hide
2573 */
2574 @Deprecated
2575 @SystemApi
2576 public static final int INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS_ASK = 4;
2577
2578 /**
2579 * Can be used as the {@code millisecondsToDelay} argument for
2580 * {@link PackageManager#extendVerificationTimeout}. This is the
2581 * maximum time {@code PackageManager} waits for the verification
2582 * agent to return (in milliseconds).
2583 */
2584 public static final long MAXIMUM_VERIFICATION_TIMEOUT = 60*60*1000;
2585
2586 /**
2587 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device's
2588 * audio pipeline is low-latency, more suitable for audio applications sensitive to delays or
2589 * lag in sound input or output.
2590 */
2591 @SdkConstant(SdkConstantType.FEATURE)
2592 public static final String FEATURE_AUDIO_LOW_LATENCY = "android.hardware.audio.low_latency";
2593
2594 /**
2595 * Feature for {@link #getSystemAvailableFeatures} and
2596 * {@link #hasSystemFeature}: The device includes at least one form of audio
2597 * output, as defined in the Android Compatibility Definition Document (CDD)
2598 * <a href="https://source.android.com/compatibility/android-cdd#7_8_audio">section 7.8 Audio</a>.
2599 */
2600 @SdkConstant(SdkConstantType.FEATURE)
2601 public static final String FEATURE_AUDIO_OUTPUT = "android.hardware.audio.output";
2602
2603 /**
2604 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
2605 * The device has professional audio level of functionality and performance.
2606 */
2607 @SdkConstant(SdkConstantType.FEATURE)
2608 public static final String FEATURE_AUDIO_PRO = "android.hardware.audio.pro";
2609
2610 /**
2611 * Feature for {@link #getSystemAvailableFeatures} and
2612 * {@link #hasSystemFeature}: The device is capable of communicating with
2613 * other devices via Bluetooth.
2614 */
2615 @SdkConstant(SdkConstantType.FEATURE)
2616 public static final String FEATURE_BLUETOOTH = "android.hardware.bluetooth";
2617
2618 /**
2619 * Feature for {@link #getSystemAvailableFeatures} and
2620 * {@link #hasSystemFeature}: The device is capable of communicating with
2621 * other devices via Bluetooth Low Energy radio.
2622 */
2623 @SdkConstant(SdkConstantType.FEATURE)
2624 public static final String FEATURE_BLUETOOTH_LE = "android.hardware.bluetooth_le";
2625
2626 /**
2627 * Feature for {@link #getSystemAvailableFeatures} and
2628 * {@link #hasSystemFeature}: The device has a camera facing away
2629 * from the screen.
2630 */
2631 @SdkConstant(SdkConstantType.FEATURE)
2632 public static final String FEATURE_CAMERA = "android.hardware.camera";
2633
2634 /**
2635 * Feature for {@link #getSystemAvailableFeatures} and
2636 * {@link #hasSystemFeature}: The device's camera supports auto-focus.
2637 */
2638 @SdkConstant(SdkConstantType.FEATURE)
2639 public static final String FEATURE_CAMERA_AUTOFOCUS = "android.hardware.camera.autofocus";
2640
2641 /**
2642 * Feature for {@link #getSystemAvailableFeatures} and
2643 * {@link #hasSystemFeature}: The device has at least one camera pointing in
2644 * some direction, or can support an external camera being connected to it.
2645 */
2646 @SdkConstant(SdkConstantType.FEATURE)
2647 public static final String FEATURE_CAMERA_ANY = "android.hardware.camera.any";
2648
2649 /**
2650 * Feature for {@link #getSystemAvailableFeatures} and
2651 * {@link #hasSystemFeature}: The device can support having an external camera connected to it.
2652 * The external camera may not always be connected or available to applications to use.
2653 */
2654 @SdkConstant(SdkConstantType.FEATURE)
2655 public static final String FEATURE_CAMERA_EXTERNAL = "android.hardware.camera.external";
2656
2657 /**
2658 * Feature for {@link #getSystemAvailableFeatures} and
2659 * {@link #hasSystemFeature}: The device's camera supports flash.
2660 */
2661 @SdkConstant(SdkConstantType.FEATURE)
2662 public static final String FEATURE_CAMERA_FLASH = "android.hardware.camera.flash";
2663
2664 /**
2665 * Feature for {@link #getSystemAvailableFeatures} and
2666 * {@link #hasSystemFeature}: The device has a front facing camera.
2667 */
2668 @SdkConstant(SdkConstantType.FEATURE)
2669 public static final String FEATURE_CAMERA_FRONT = "android.hardware.camera.front";
2670
2671 /**
2672 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: At least one
2673 * of the cameras on the device supports the
2674 * {@link android.hardware.camera2.CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL full hardware}
2675 * capability level.
2676 */
2677 @SdkConstant(SdkConstantType.FEATURE)
2678 public static final String FEATURE_CAMERA_LEVEL_FULL = "android.hardware.camera.level.full";
2679
2680 /**
2681 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: At least one
2682 * of the cameras on the device supports the
2683 * {@link android.hardware.camera2.CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_MANUAL_SENSOR manual sensor}
2684 * capability level.
2685 */
2686 @SdkConstant(SdkConstantType.FEATURE)
2687 public static final String FEATURE_CAMERA_CAPABILITY_MANUAL_SENSOR =
2688 "android.hardware.camera.capability.manual_sensor";
2689
2690 /**
2691 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: At least one
2692 * of the cameras on the device supports the
2693 * {@link android.hardware.camera2.CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_MANUAL_POST_PROCESSING manual post-processing}
2694 * capability level.
2695 */
2696 @SdkConstant(SdkConstantType.FEATURE)
2697 public static final String FEATURE_CAMERA_CAPABILITY_MANUAL_POST_PROCESSING =
2698 "android.hardware.camera.capability.manual_post_processing";
2699
2700 /**
2701 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: At least one
2702 * of the cameras on the device supports the
2703 * {@link android.hardware.camera2.CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_RAW RAW}
2704 * capability level.
2705 */
2706 @SdkConstant(SdkConstantType.FEATURE)
2707 public static final String FEATURE_CAMERA_CAPABILITY_RAW =
2708 "android.hardware.camera.capability.raw";
2709
2710 /**
2711 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: At least one
2712 * of the cameras on the device supports the
2713 * {@link android.hardware.camera2.CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_MOTION_TRACKING
2714 * MOTION_TRACKING} capability level.
2715 */
2716 @SdkConstant(SdkConstantType.FEATURE)
2717 public static final String FEATURE_CAMERA_AR =
2718 "android.hardware.camera.ar";
2719
2720 /**
2721 * Feature for {@link #getSystemAvailableFeatures} and
2722 * {@link #hasSystemFeature}: The device's main front and back cameras can stream
2723 * concurrently as described in {@link
2724 * android.hardware.camera2.CameraManager#getConcurrentCameraIds()}.
2725 * </p>
2726 * <p>While {@link android.hardware.camera2.CameraManager#getConcurrentCameraIds()} and
2727 * associated APIs are only available on API level 30 or newer, this feature flag may be
2728 * advertised by devices on API levels below 30. If present on such a device, the same
2729 * guarantees hold: The main front and main back camera can be used at the same time, with
2730 * guaranteed stream configurations as defined in the table for concurrent streaming at
2731 * {@link android.hardware.camera2.CameraDevice#createCaptureSession(android.hardware.camera2.params.SessionConfiguration)}.
2732 * </p>
2733 */
2734 @SdkConstant(SdkConstantType.FEATURE)
2735 public static final String FEATURE_CAMERA_CONCURRENT = "android.hardware.camera.concurrent";
2736
2737 /**
2738 * Feature for {@link #getSystemAvailableFeatures} and
2739 * {@link #hasSystemFeature}: The device is capable of communicating with
2740 * consumer IR devices.
2741 */
2742 @SdkConstant(SdkConstantType.FEATURE)
2743 public static final String FEATURE_CONSUMER_IR = "android.hardware.consumerir";
2744
2745 /**
2746 * Feature for {@link #getSystemAvailableFeatures} and
2747 * {@link #hasSystemFeature}: The device supports a Context Hub, used to expose the
2748 * functionalities in {@link android.hardware.location.ContextHubManager}.
2749 *
2750 * @hide
2751 */
2752 @SystemApi
2753 @SdkConstant(SdkConstantType.FEATURE)
2754 public static final String FEATURE_CONTEXT_HUB = "android.hardware.context_hub";
2755
2756 /** {@hide} */
2757 @SdkConstant(SdkConstantType.FEATURE)
2758 public static final String FEATURE_CTS = "android.software.cts";
2759
2760 /**
2761 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device
2762 * is opted-in to render the application using Automotive App Host
2763 *
2764 * @hide
2765 */
2766 @SdkConstant(SdkConstantType.FEATURE)
2767 public static final String FEATURE_CAR_TEMPLATES_HOST =
2768 "android.software.car.templates_host";
2769
2770 /**
2771 * Feature for {@link #getSystemAvailableFeatures} and
2772 * {@link #hasSystemFeature(String, int)}: If this feature is supported, the device supports
2773 * {@link android.security.identity.IdentityCredentialStore} implemented in secure hardware
2774 * at the given feature version.
2775 *
2776 * <p>Known feature versions include:
2777 * <ul>
2778 * <li><code>202009</code>: corresponds to the features included in the Identity Credential
2779 * API shipped in Android 11.
2780 * <li><code>202101</code>: corresponds to the features included in the Identity Credential
2781 * API shipped in Android 12.
2782 * <li><code>202201</code>: corresponds to the features included in the Identity Credential
2783 * API shipped in Android 13.
2784 * </ul>
2785 */
2786 @SdkConstant(SdkConstantType.FEATURE)
2787 public static final String FEATURE_IDENTITY_CREDENTIAL_HARDWARE =
2788 "android.hardware.identity_credential";
2789
2790 /**
2791 * Feature for {@link #getSystemAvailableFeatures} and
2792 * {@link #hasSystemFeature(String, int)}: If this feature is supported, the device supports
2793 * {@link android.security.identity.IdentityCredentialStore} implemented in secure hardware
2794 * with direct access at the given feature version.
2795 * See {@link #FEATURE_IDENTITY_CREDENTIAL_HARDWARE} for known feature versions.
2796 */
2797 @SdkConstant(SdkConstantType.FEATURE)
2798 public static final String FEATURE_IDENTITY_CREDENTIAL_HARDWARE_DIRECT_ACCESS =
2799 "android.hardware.identity_credential_direct_access";
2800
2801 /**
2802 * Feature for {@link #getSystemAvailableFeatures} and
2803 * {@link #hasSystemFeature}: The device supports one or more methods of
2804 * reporting current location.
2805 */
2806 @SdkConstant(SdkConstantType.FEATURE)
2807 public static final String FEATURE_LOCATION = "android.hardware.location";
2808
2809 /**
2810 * Feature for {@link #getSystemAvailableFeatures} and
2811 * {@link #hasSystemFeature}: The device has a Global Positioning System
2812 * receiver and can report precise location.
2813 */
2814 @SdkConstant(SdkConstantType.FEATURE)
2815 public static final String FEATURE_LOCATION_GPS = "android.hardware.location.gps";
2816
2817 /**
2818 * Feature for {@link #getSystemAvailableFeatures} and
2819 * {@link #hasSystemFeature}: The device can report location with coarse
2820 * accuracy using a network-based geolocation system.
2821 */
2822 @SdkConstant(SdkConstantType.FEATURE)
2823 public static final String FEATURE_LOCATION_NETWORK = "android.hardware.location.network";
2824
2825 /**
2826 * Feature for {@link #getSystemAvailableFeatures} and
2827 * {@link #hasSystemFeature}: The device supports FeliCa communication, which is based on
2828 * ISO/IEC 18092 and JIS X 6319-4.
2829 *
2830 * @hide
2831 */
2832 @SdkConstant(SdkConstantType.FEATURE)
2833 public static final String FEATURE_FELICA = "android.hardware.felica";
2834
2835 /**
2836 * Feature for {@link #getSystemAvailableFeatures} and
2837 * {@link #hasSystemFeature}: The device's
2838 * {@link ActivityManager#isLowRamDevice() ActivityManager.isLowRamDevice()} method returns
2839 * true.
2840 */
2841 @SdkConstant(SdkConstantType.FEATURE)
2842 public static final String FEATURE_RAM_LOW = "android.hardware.ram.low";
2843
2844 /**
2845 * Feature for {@link #getSystemAvailableFeatures} and
2846 * {@link #hasSystemFeature}: The device's
2847 * {@link ActivityManager#isLowRamDevice() ActivityManager.isLowRamDevice()} method returns
2848 * false.
2849 */
2850 @SdkConstant(SdkConstantType.FEATURE)
2851 public static final String FEATURE_RAM_NORMAL = "android.hardware.ram.normal";
2852
2853 /**
2854 * Feature for {@link #getSystemAvailableFeatures} and
2855 * {@link #hasSystemFeature}: The device can record audio via a
2856 * microphone.
2857 */
2858 @SdkConstant(SdkConstantType.FEATURE)
2859 public static final String FEATURE_MICROPHONE = "android.hardware.microphone";
2860
2861 /**
2862 * Feature for {@link #getSystemAvailableFeatures} and
2863 * {@link #hasSystemFeature}: The device can communicate using Near-Field
2864 * Communications (NFC).
2865 */
2866 @SdkConstant(SdkConstantType.FEATURE)
2867 public static final String FEATURE_NFC = "android.hardware.nfc";
2868
2869 /**
2870 * Feature for {@link #getSystemAvailableFeatures} and
2871 * {@link #hasSystemFeature}: The device supports host-
2872 * based NFC card emulation.
2873 *
2874 * TODO remove when depending apps have moved to new constant.
2875 * @hide
2876 * @deprecated
2877 */
2878 @Deprecated
2879 @SdkConstant(SdkConstantType.FEATURE)
2880 public static final String FEATURE_NFC_HCE = "android.hardware.nfc.hce";
2881
2882 /**
2883 * Feature for {@link #getSystemAvailableFeatures} and
2884 * {@link #hasSystemFeature}: The device supports host-
2885 * based NFC card emulation.
2886 */
2887 @SdkConstant(SdkConstantType.FEATURE)
2888 public static final String FEATURE_NFC_HOST_CARD_EMULATION = "android.hardware.nfc.hce";
2889
2890 /**
2891 * Feature for {@link #getSystemAvailableFeatures} and
2892 * {@link #hasSystemFeature}: The device supports host-
2893 * based NFC-F card emulation.
2894 */
2895 @SdkConstant(SdkConstantType.FEATURE)
2896 public static final String FEATURE_NFC_HOST_CARD_EMULATION_NFCF = "android.hardware.nfc.hcef";
2897
2898 /**
2899 * Feature for {@link #getSystemAvailableFeatures} and
2900 * {@link #hasSystemFeature}: The device supports uicc-
2901 * based NFC card emulation.
2902 */
2903 @SdkConstant(SdkConstantType.FEATURE)
2904 public static final String FEATURE_NFC_OFF_HOST_CARD_EMULATION_UICC =
2905 "android.hardware.nfc.uicc";
2906
2907 /**
2908 * Feature for {@link #getSystemAvailableFeatures} and
2909 * {@link #hasSystemFeature}: The device supports eSE-
2910 * based NFC card emulation.
2911 */
2912 @SdkConstant(SdkConstantType.FEATURE)
2913 public static final String FEATURE_NFC_OFF_HOST_CARD_EMULATION_ESE = "android.hardware.nfc.ese";
2914
2915 /**
2916 * Feature for {@link #getSystemAvailableFeatures} and
2917 * {@link #hasSystemFeature}: The Beam API is enabled on the device.
2918 */
2919 @SdkConstant(SdkConstantType.FEATURE)
2920 public static final String FEATURE_NFC_BEAM = "android.sofware.nfc.beam";
2921
2922 /**
2923 * Feature for {@link #getSystemAvailableFeatures} and
2924 * {@link #hasSystemFeature}: The device supports any
2925 * one of the {@link #FEATURE_NFC}, {@link #FEATURE_NFC_HOST_CARD_EMULATION},
2926 * or {@link #FEATURE_NFC_HOST_CARD_EMULATION_NFCF} features.
2927 *
2928 * @hide
2929 */
2930 @SdkConstant(SdkConstantType.FEATURE)
2931 public static final String FEATURE_NFC_ANY = "android.hardware.nfc.any";
2932
2933 /**
2934 * Feature for {@link #getSystemAvailableFeatures} and
2935 * {@link #hasSystemFeature}: The device supports Open Mobile API capable UICC-based secure
2936 * elements.
2937 */
2938 @SdkConstant(SdkConstantType.FEATURE)
2939 public static final String FEATURE_SE_OMAPI_UICC = "android.hardware.se.omapi.uicc";
2940
2941 /**
2942 * Feature for {@link #getSystemAvailableFeatures} and
2943 * {@link #hasSystemFeature}: The device supports Open Mobile API capable eSE-based secure
2944 * elements.
2945 */
2946 @SdkConstant(SdkConstantType.FEATURE)
2947 public static final String FEATURE_SE_OMAPI_ESE = "android.hardware.se.omapi.ese";
2948
2949 /**
2950 * Feature for {@link #getSystemAvailableFeatures} and
2951 * {@link #hasSystemFeature}: The device supports Open Mobile API capable SD-based secure
2952 * elements.
2953 */
2954 @SdkConstant(SdkConstantType.FEATURE)
2955 public static final String FEATURE_SE_OMAPI_SD = "android.hardware.se.omapi.sd";
2956
2957 /**
2958 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device is
2959 * compatible with Android’s security model.
2960 *
2961 * <p>See sections 2 and 9 in the
2962 * <a href="https://source.android.com/compatibility/android-cdd">Android CDD</a> for more
2963 * details.
2964 */
2965 @SdkConstant(SdkConstantType.FEATURE)
2966 public static final String FEATURE_SECURITY_MODEL_COMPATIBLE =
2967 "android.hardware.security.model.compatible";
2968
2969 /**
2970 * Feature for {@link #getSystemAvailableFeatures} and
2971 * {@link #hasSystemFeature}: The device supports the OpenGL ES
2972 * <a href="http://www.khronos.org/registry/gles/extensions/ANDROID/ANDROID_extension_pack_es31a.txt">
2973 * Android Extension Pack</a>.
2974 */
2975 @SdkConstant(SdkConstantType.FEATURE)
2976 public static final String FEATURE_OPENGLES_EXTENSION_PACK = "android.hardware.opengles.aep";
2977
2978 /**
2979 * Feature for {@link #getSystemAvailableFeatures()} and {@link #hasSystemFeature(String)}.
2980 * This feature indicates whether device supports
2981 * <a href="https://source.android.com/docs/core/virtualization">Android Virtualization Framework</a>.
2982 *
2983 * @hide
2984 */
2985 @SystemApi
2986 @SdkConstant(SdkConstantType.FEATURE)
2987 public static final String FEATURE_VIRTUALIZATION_FRAMEWORK =
2988 "android.software.virtualization_framework";
2989
2990 /**
2991 * Feature for {@link #getSystemAvailableFeatures} and
2992 * {@link #hasSystemFeature(String, int)}: If this feature is supported, the Vulkan
2993 * implementation on this device is hardware accelerated, and the Vulkan native API will
2994 * enumerate at least one {@code VkPhysicalDevice}, and the feature version will indicate what
2995 * level of optional hardware features limits it supports.
2996 * <p>
2997 * Level 0 includes the base Vulkan requirements as well as:
2998 * <ul><li>{@code VkPhysicalDeviceFeatures::textureCompressionETC2}</li></ul>
2999 * <p>
3000 * Level 1 additionally includes:
3001 * <ul>
3002 * <li>{@code VkPhysicalDeviceFeatures::fullDrawIndexUint32}</li>
3003 * <li>{@code VkPhysicalDeviceFeatures::imageCubeArray}</li>
3004 * <li>{@code VkPhysicalDeviceFeatures::independentBlend}</li>
3005 * <li>{@code VkPhysicalDeviceFeatures::geometryShader}</li>
3006 * <li>{@code VkPhysicalDeviceFeatures::tessellationShader}</li>
3007 * <li>{@code VkPhysicalDeviceFeatures::sampleRateShading}</li>
3008 * <li>{@code VkPhysicalDeviceFeatures::textureCompressionASTC_LDR}</li>
3009 * <li>{@code VkPhysicalDeviceFeatures::fragmentStoresAndAtomics}</li>
3010 * <li>{@code VkPhysicalDeviceFeatures::shaderImageGatherExtended}</li>
3011 * <li>{@code VkPhysicalDeviceFeatures::shaderUniformBufferArrayDynamicIndexing}</li>
3012 * <li>{@code VkPhysicalDeviceFeatures::shaderSampledImageArrayDynamicIndexing}</li>
3013 * </ul>
3014 */
3015 @SdkConstant(SdkConstantType.FEATURE)
3016 public static final String FEATURE_VULKAN_HARDWARE_LEVEL = "android.hardware.vulkan.level";
3017
3018 /**
3019 * Feature for {@link #getSystemAvailableFeatures} and
3020 * {@link #hasSystemFeature(String, int)}: If this feature is supported, the Vulkan
3021 * implementation on this device is hardware accelerated, and the Vulkan native API will
3022 * enumerate at least one {@code VkPhysicalDevice}, and the feature version will indicate what
3023 * level of optional compute features that device supports beyond the Vulkan 1.0 requirements.
3024 * <p>
3025 * Compute level 0 indicates:
3026 * <ul>
3027 * <li>The {@code VK_KHR_variable_pointers} extension and
3028 * {@code VkPhysicalDeviceVariablePointerFeaturesKHR::variablePointers} feature are
3029 supported.</li>
3030 * <li>{@code VkPhysicalDeviceLimits::maxPerStageDescriptorStorageBuffers} is at least 16.</li>
3031 * </ul>
3032 */
3033 @SdkConstant(SdkConstantType.FEATURE)
3034 public static final String FEATURE_VULKAN_HARDWARE_COMPUTE = "android.hardware.vulkan.compute";
3035
3036 /**
3037 * Feature for {@link #getSystemAvailableFeatures} and
3038 * {@link #hasSystemFeature(String, int)}: If this feature is supported, the Vulkan
3039 * implementation on this device is hardware accelerated, and the feature version will indicate
3040 * the highest {@code VkPhysicalDeviceProperties::apiVersion} supported by the physical devices
3041 * that support the hardware level indicated by {@link #FEATURE_VULKAN_HARDWARE_LEVEL}. The
3042 * feature version uses the same encoding as Vulkan version numbers:
3043 * <ul>
3044 * <li>Major version number in bits 31-22</li>
3045 * <li>Minor version number in bits 21-12</li>
3046 * <li>Patch version number in bits 11-0</li>
3047 * </ul>
3048 * A version of 1.1.0 or higher also indicates:
3049 * <ul>
3050 * <li>The {@code VK_ANDROID_external_memory_android_hardware_buffer} extension is
3051 * supported.</li>
3052 * <li>{@code SYNC_FD} external semaphore and fence handles are supported.</li>
3053 * <li>{@code VkPhysicalDeviceSamplerYcbcrConversionFeatures::samplerYcbcrConversion} is
3054 * supported.</li>
3055 * </ul>
3056 * A subset of devices that support Vulkan 1.1 do so via software emulation. For more
3057 * information, see
3058 * <a href="{@docRoot}ndk/guides/graphics/design-notes">Vulkan Design Guidelines</a>.
3059 */
3060 @SdkConstant(SdkConstantType.FEATURE)
3061 public static final String FEATURE_VULKAN_HARDWARE_VERSION = "android.hardware.vulkan.version";
3062
3063 /**
3064 * Feature for {@link #getSystemAvailableFeatures} and
3065 * {@link #hasSystemFeature(String, int)}: If this feature is supported, the feature version
3066 * specifies a date such that the device is known to pass the Vulkan dEQP test suite associated
3067 * with that date. The date is encoded as follows:
3068 * <ul>
3069 * <li>Year in bits 31-16</li>
3070 * <li>Month in bits 15-8</li>
3071 * <li>Day in bits 7-0</li>
3072 * </ul>
3073 * <p>
3074 * Example: 2019-03-01 is encoded as 0x07E30301, and would indicate that the device passes the
3075 * Vulkan dEQP test suite version that was current on 2019-03-01.
3076 */
3077 @SdkConstant(SdkConstantType.FEATURE)
3078 public static final String FEATURE_VULKAN_DEQP_LEVEL = "android.software.vulkan.deqp.level";
3079
3080 /**
3081 * Feature for {@link #getSystemAvailableFeatures} and
3082 * {@link #hasSystemFeature(String, int)}: If this feature is supported, the feature version
3083 * specifies a date such that the device is known to pass the OpenGLES dEQP test suite
3084 * associated with that date. The date is encoded as follows:
3085 * <ul>
3086 * <li>Year in bits 31-16</li>
3087 * <li>Month in bits 15-8</li>
3088 * <li>Day in bits 7-0</li>
3089 * </ul>
3090 * <p>
3091 * Example: 2021-03-01 is encoded as 0x07E50301, and would indicate that the device passes the
3092 * OpenGL ES dEQP test suite version that was current on 2021-03-01.
3093 */
3094 @SdkConstant(SdkConstantType.FEATURE)
3095 public static final String FEATURE_OPENGLES_DEQP_LEVEL = "android.software.opengles.deqp.level";
3096
3097 /**
3098 * Feature for {@link #getSystemAvailableFeatures} and
3099 * {@link #hasSystemFeature}: The device includes broadcast radio tuner.
3100 * @hide
3101 */
3102 @SystemApi
3103 @SdkConstant(SdkConstantType.FEATURE)
3104 public static final String FEATURE_BROADCAST_RADIO = "android.hardware.broadcastradio";
3105
3106 /**
3107 * Feature for {@link #getSystemAvailableFeatures} and
3108 * {@link #hasSystemFeature}: The device has a secure implementation of keyguard, meaning the
3109 * device supports PIN, pattern and password as defined in Android CDD
3110 */
3111 @SdkConstant(SdkConstantType.FEATURE)
3112 public static final String FEATURE_SECURE_LOCK_SCREEN = "android.software.secure_lock_screen";
3113
3114 /**
3115 * Feature for {@link #getSystemAvailableFeatures} and
3116 * {@link #hasSystemFeature}: The device includes an accelerometer.
3117 */
3118 @SdkConstant(SdkConstantType.FEATURE)
3119 public static final String FEATURE_SENSOR_ACCELEROMETER = "android.hardware.sensor.accelerometer";
3120
3121 /**
3122 * Feature for {@link #getSystemAvailableFeatures} and
3123 * {@link #hasSystemFeature}: The device includes a barometer (air
3124 * pressure sensor.)
3125 */
3126 @SdkConstant(SdkConstantType.FEATURE)
3127 public static final String FEATURE_SENSOR_BAROMETER = "android.hardware.sensor.barometer";
3128
3129 /**
3130 * Feature for {@link #getSystemAvailableFeatures} and
3131 * {@link #hasSystemFeature}: The device includes a magnetometer (compass).
3132 */
3133 @SdkConstant(SdkConstantType.FEATURE)
3134 public static final String FEATURE_SENSOR_COMPASS = "android.hardware.sensor.compass";
3135
3136 /**
3137 * Feature for {@link #getSystemAvailableFeatures} and
3138 * {@link #hasSystemFeature}: The device includes a gyroscope.
3139 */
3140 @SdkConstant(SdkConstantType.FEATURE)
3141 public static final String FEATURE_SENSOR_GYROSCOPE = "android.hardware.sensor.gyroscope";
3142
3143 /**
3144 * Feature for {@link #getSystemAvailableFeatures} and
3145 * {@link #hasSystemFeature}: The device includes a limited axes accelerometer.
3146 */
3147 @SdkConstant(SdkConstantType.FEATURE)
3148 public static final String FEATURE_SENSOR_ACCELEROMETER_LIMITED_AXES =
3149 "android.hardware.sensor.accelerometer_limited_axes";
3150
3151 /**
3152 * Feature for {@link #getSystemAvailableFeatures} and
3153 * {@link #hasSystemFeature}: The device includes a limited axes gyroscope.
3154 */
3155 @SdkConstant(SdkConstantType.FEATURE)
3156 public static final String FEATURE_SENSOR_GYROSCOPE_LIMITED_AXES =
3157 "android.hardware.sensor.gyroscope_limited_axes";
3158
3159 /**
3160 * Feature for {@link #getSystemAvailableFeatures} and
3161 * {@link #hasSystemFeature}: The device includes an uncalibrated limited axes accelerometer.
3162 */
3163 @SdkConstant(SdkConstantType.FEATURE)
3164 public static final String FEATURE_SENSOR_ACCELEROMETER_LIMITED_AXES_UNCALIBRATED =
3165 "android.hardware.sensor.accelerometer_limited_axes_uncalibrated";
3166
3167 /**
3168 * Feature for {@link #getSystemAvailableFeatures} and
3169 * {@link #hasSystemFeature}: The device includes an uncalibrated limited axes gyroscope.
3170 */
3171 @SdkConstant(SdkConstantType.FEATURE)
3172 public static final String FEATURE_SENSOR_GYROSCOPE_LIMITED_AXES_UNCALIBRATED =
3173 "android.hardware.sensor.gyroscope_limited_axes_uncalibrated";
3174
3175 /**
3176 * Feature for {@link #getSystemAvailableFeatures} and
3177 * {@link #hasSystemFeature}: The device includes a light sensor.
3178 */
3179 @SdkConstant(SdkConstantType.FEATURE)
3180 public static final String FEATURE_SENSOR_LIGHT = "android.hardware.sensor.light";
3181
3182 /**
3183 * Feature for {@link #getSystemAvailableFeatures} and
3184 * {@link #hasSystemFeature}: The device includes a proximity sensor.
3185 */
3186 @SdkConstant(SdkConstantType.FEATURE)
3187 public static final String FEATURE_SENSOR_PROXIMITY = "android.hardware.sensor.proximity";
3188
3189 /**
3190 * Feature for {@link #getSystemAvailableFeatures} and
3191 * {@link #hasSystemFeature}: The device includes a hardware step counter.
3192 */
3193 @SdkConstant(SdkConstantType.FEATURE)
3194 public static final String FEATURE_SENSOR_STEP_COUNTER = "android.hardware.sensor.stepcounter";
3195
3196 /**
3197 * Feature for {@link #getSystemAvailableFeatures} and
3198 * {@link #hasSystemFeature}: The device includes a hardware step detector.
3199 */
3200 @SdkConstant(SdkConstantType.FEATURE)
3201 public static final String FEATURE_SENSOR_STEP_DETECTOR = "android.hardware.sensor.stepdetector";
3202
3203 /**
3204 * Feature for {@link #getSystemAvailableFeatures} and
3205 * {@link #hasSystemFeature}: The device includes a heart rate monitor.
3206 */
3207 @SdkConstant(SdkConstantType.FEATURE)
3208 public static final String FEATURE_SENSOR_HEART_RATE = "android.hardware.sensor.heartrate";
3209
3210 /**
3211 * Feature for {@link #getSystemAvailableFeatures} and
3212 * {@link #hasSystemFeature}: The heart rate sensor on this device is an Electrocardiogram.
3213 */
3214 @SdkConstant(SdkConstantType.FEATURE)
3215 public static final String FEATURE_SENSOR_HEART_RATE_ECG =
3216 "android.hardware.sensor.heartrate.ecg";
3217
3218 /**
3219 * Feature for {@link #getSystemAvailableFeatures} and
3220 * {@link #hasSystemFeature}: The device includes a relative humidity sensor.
3221 */
3222 @SdkConstant(SdkConstantType.FEATURE)
3223 public static final String FEATURE_SENSOR_RELATIVE_HUMIDITY =
3224 "android.hardware.sensor.relative_humidity";
3225
3226 /**
3227 * Feature for {@link #getSystemAvailableFeatures} and
3228 * {@link #hasSystemFeature}: The device includes an ambient temperature sensor.
3229 */
3230 @SdkConstant(SdkConstantType.FEATURE)
3231 public static final String FEATURE_SENSOR_AMBIENT_TEMPERATURE =
3232 "android.hardware.sensor.ambient_temperature";
3233
3234 /**
3235 * Feature for {@link #getSystemAvailableFeatures} and
3236 * {@link #hasSystemFeature}: The device includes a hinge angle sensor.
3237 */
3238 @SdkConstant(SdkConstantType.FEATURE)
3239 public static final String FEATURE_SENSOR_HINGE_ANGLE = "android.hardware.sensor.hinge_angle";
3240
3241 /**
3242 * Feature for {@link #getSystemAvailableFeatures} and
3243 * {@link #hasSystemFeature}: The device includes a heading sensor.
3244 */
3245 @SdkConstant(SdkConstantType.FEATURE)
3246 public static final String FEATURE_SENSOR_HEADING = "android.hardware.sensor.heading";
3247
3248 /**
3249 * Feature for {@link #getSystemAvailableFeatures} and
3250 * {@link #hasSystemFeature}: The device supports exposing head tracker sensors from peripheral
3251 * devices via the dynamic sensors API.
3252 */
3253 @SdkConstant(SdkConstantType.FEATURE)
3254 public static final String FEATURE_SENSOR_DYNAMIC_HEAD_TRACKER = "android.hardware.sensor.dynamic.head_tracker";
3255
3256 /**
3257 * Feature for {@link #getSystemAvailableFeatures} and
3258 * {@link #hasSystemFeature}: The device supports high fidelity sensor processing
3259 * capabilities.
3260 */
3261 @SdkConstant(SdkConstantType.FEATURE)
3262 public static final String FEATURE_HIFI_SENSORS =
3263 "android.hardware.sensor.hifi_sensors";
3264
3265 /**
3266 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
3267 * The device supports a hardware mechanism for invoking an assist gesture.
3268 * @see android.provider.Settings.Secure#ASSIST_GESTURE_ENABLED
3269 * @hide
3270 */
3271 @SdkConstant(SdkConstantType.FEATURE)
3272 public static final String FEATURE_ASSIST_GESTURE = "android.hardware.sensor.assist";
3273
3274 /**
3275 * Feature for {@link #getSystemAvailableFeatures} and
3276 * {@link #hasSystemFeature}: The device has a telephony radio with data
3277 * communication support.
3278 */
3279 @SdkConstant(SdkConstantType.FEATURE)
3280 public static final String FEATURE_TELEPHONY = "android.hardware.telephony";
3281
3282 /**
3283 * Feature for {@link #getSystemAvailableFeatures} and
3284 * {@link #hasSystemFeature}: The device has a CDMA telephony stack.
3285 *
3286 * <p>This feature should only be defined if {@link #FEATURE_TELEPHONY} has been defined.
3287 */
3288 @SdkConstant(SdkConstantType.FEATURE)
3289 public static final String FEATURE_TELEPHONY_CDMA = "android.hardware.telephony.cdma";
3290
3291 /**
3292 * Feature for {@link #getSystemAvailableFeatures} and
3293 * {@link #hasSystemFeature}: The device has a GSM telephony stack.
3294 *
3295 * <p>This feature should only be defined if {@link #FEATURE_TELEPHONY} has been defined.
3296 */
3297 @SdkConstant(SdkConstantType.FEATURE)
3298 public static final String FEATURE_TELEPHONY_GSM = "android.hardware.telephony.gsm";
3299
3300 /**
3301 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
3302 * The device supports telephony carrier restriction mechanism.
3303 *
3304 * <p>Devices declaring this feature must have an implementation of the
3305 * {@link android.telephony.TelephonyManager#getAllowedCarriers} and
3306 * {@link android.telephony.TelephonyManager#setAllowedCarriers}.
3307 *
3308 * This feature should only be defined if {@link #FEATURE_TELEPHONY_SUBSCRIPTION}
3309 * has been defined.
3310 * @hide
3311 */
3312 @SystemApi
3313 @SdkConstant(SdkConstantType.FEATURE)
3314 public static final String FEATURE_TELEPHONY_CARRIERLOCK =
3315 "android.hardware.telephony.carrierlock";
3316
3317 /**
3318 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device
3319 * supports embedded subscriptions on eUICCs.
3320 *
3321 * This feature should only be defined if {@link #FEATURE_TELEPHONY_SUBSCRIPTION}
3322 * has been defined.
3323 */
3324 @SdkConstant(SdkConstantType.FEATURE)
3325 public static final String FEATURE_TELEPHONY_EUICC = "android.hardware.telephony.euicc";
3326
3327 /**
3328 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device
3329 * supports multiple enabled profiles on eUICCs.
3330 *
3331 * <p>Devices declaring this feature must have an implementation of the
3332 * {@link UiccCardInfo#getPorts},
3333 * {@link UiccCardInfo#isMultipleEnabledProfilesSupported} and
3334 * {@link android.telephony.euicc.EuiccManager#switchToSubscription (with portIndex)}.
3335 *
3336 * This feature should only be defined if {@link #FEATURE_TELEPHONY_EUICC} have been defined.
3337 */
3338 @SdkConstant(SdkConstantType.FEATURE)
3339 public static final String FEATURE_TELEPHONY_EUICC_MEP = "android.hardware.telephony.euicc.mep";
3340
3341 /**
3342 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device
3343 * supports cell-broadcast reception using the MBMS APIs.
3344 *
3345 * <p>This feature should only be defined if both {@link #FEATURE_TELEPHONY_SUBSCRIPTION}
3346 * and {@link #FEATURE_TELEPHONY_RADIO_ACCESS} have been defined.
3347 */
3348 @SdkConstant(SdkConstantType.FEATURE)
3349 public static final String FEATURE_TELEPHONY_MBMS = "android.hardware.telephony.mbms";
3350
3351 /**
3352 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device
3353 * supports attaching to IMS implementations using the ImsService API in telephony.
3354 *
3355 * <p>This feature should only be defined if {@link #FEATURE_TELEPHONY_DATA} has been defined.
3356 */
3357 @SdkConstant(SdkConstantType.FEATURE)
3358 public static final String FEATURE_TELEPHONY_IMS = "android.hardware.telephony.ims";
3359
3360 /**
3361 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device
3362 * supports a single IMS registration as defined by carrier networks in the IMS service
3363 * implementation using the {@link ImsService} API, {@link GbaService} API, and IRadio 1.6 HAL.
3364 * <p>
3365 * When set, the device must fully support the following APIs for an application to implement
3366 * IMS single registration:
3367 * <ul>
3368 * <li> Updating RCS provisioning status using the {@link ProvisioningManager} API to supply an
3369 * RCC.14 defined XML and notify IMS applications of Auto Configuration Server (ACS) or
3370 * proprietary server provisioning updates.</li>
3371 * <li>Opening a delegate in the device IMS service to forward SIP traffic to the carrier's
3372 * network using the {@link SipDelegateManager} API</li>
3373 * <li>Listening to EPS dedicated bearer establishment via the
3374 * {@link ConnectivityManager#registerQosCallback}
3375 * API to indicate to the application when to start/stop media traffic.</li>
3376 * <li>Implementing Generic Bootstrapping Architecture (GBA) and providing the associated
3377 * authentication keys to applications
3378 * requesting this information via the {@link TelephonyManager#bootstrapAuthenticationRequest}
3379 * API</li>
3380 * <li>Implementing RCS User Capability Exchange using the {@link RcsUceAdapter} API</li>
3381 * </ul>
3382 * <p>
3383 * This feature should only be defined if {@link #FEATURE_TELEPHONY_IMS} is also defined.
3384 * @hide
3385 */
3386 @SystemApi
3387 @SdkConstant(SdkConstantType.FEATURE)
3388 public static final String FEATURE_TELEPHONY_IMS_SINGLE_REGISTRATION =
3389 "android.hardware.telephony.ims.singlereg";
3390
3391 /**
3392 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
3393 * The device supports Telecom Service APIs.
3394 */
3395 @SdkConstant(SdkConstantType.FEATURE)
3396 public static final String FEATURE_TELECOM = "android.software.telecom";
3397
3398 /**
3399 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
3400 * The device supports Telephony APIs for calling service.
3401 *
3402 * <p>This feature should only be defined if {@link #FEATURE_TELEPHONY_RADIO_ACCESS},
3403 * {@link #FEATURE_TELEPHONY_SUBSCRIPTION}, and {@link #FEATURE_TELECOM} have been defined.
3404 */
3405 @SdkConstant(SdkConstantType.FEATURE)
3406 public static final String FEATURE_TELEPHONY_CALLING = "android.hardware.telephony.calling";
3407
3408 /**
3409 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
3410 * The device supports Telephony APIs for data service.
3411 *
3412 * <p>This feature should only be defined if both {@link #FEATURE_TELEPHONY_SUBSCRIPTION}
3413 * and {@link #FEATURE_TELEPHONY_RADIO_ACCESS} have been defined.
3414 */
3415 @SdkConstant(SdkConstantType.FEATURE)
3416 public static final String FEATURE_TELEPHONY_DATA = "android.hardware.telephony.data";
3417
3418 /**
3419 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
3420 * The device supports Telephony APIs for SMS and MMS.
3421 *
3422 * <p>This feature should only be defined if both {@link #FEATURE_TELEPHONY_SUBSCRIPTION}
3423 * and {@link #FEATURE_TELEPHONY_RADIO_ACCESS} have been defined.
3424 */
3425 @SdkConstant(SdkConstantType.FEATURE)
3426 public static final String FEATURE_TELEPHONY_MESSAGING = "android.hardware.telephony.messaging";
3427
3428 /**
3429 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
3430 * The device supports Telephony APIs for the radio access.
3431 *
3432 * <p>This feature should only be defined if {@link #FEATURE_TELEPHONY} has been defined.
3433 */
3434 @SdkConstant(SdkConstantType.FEATURE)
3435 public static final String FEATURE_TELEPHONY_RADIO_ACCESS =
3436 "android.hardware.telephony.radio.access";
3437
3438 /**
3439 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
3440 * The device supports Telephony APIs for the subscription.
3441 *
3442 * <p>This feature should only be defined if {@link #FEATURE_TELEPHONY} has been defined.
3443 */
3444 @SdkConstant(SdkConstantType.FEATURE)
3445 public static final String FEATURE_TELEPHONY_SUBSCRIPTION =
3446 "android.hardware.telephony.subscription";
3447
3448 /**
3449 * Feature for {@link #getSystemAvailableFeatures} and
3450 * {@link #hasSystemFeature}: The device is capable of communicating with
3451 * other devices via ultra wideband.
3452 * @hide
3453 */
3454 @SdkConstant(SdkConstantType.FEATURE)
3455 public static final String FEATURE_UWB = "android.hardware.uwb";
3456
3457 /**
3458 * Feature for {@link #getSystemAvailableFeatures} and
3459 * {@link #hasSystemFeature}: The device supports connecting to USB devices
3460 * as the USB host.
3461 */
3462 @SdkConstant(SdkConstantType.FEATURE)
3463 public static final String FEATURE_USB_HOST = "android.hardware.usb.host";
3464
3465 /**
3466 * Feature for {@link #getSystemAvailableFeatures} and
3467 * {@link #hasSystemFeature}: The device supports connecting to USB accessories.
3468 */
3469 @SdkConstant(SdkConstantType.FEATURE)
3470 public static final String FEATURE_USB_ACCESSORY = "android.hardware.usb.accessory";
3471
3472 /**
3473 * Feature for {@link #getSystemAvailableFeatures} and
3474 * {@link #hasSystemFeature}: The SIP API is enabled on the device.
3475 */
3476 @SdkConstant(SdkConstantType.FEATURE)
3477 public static final String FEATURE_SIP = "android.software.sip";
3478
3479 /**
3480 * Feature for {@link #getSystemAvailableFeatures} and
3481 * {@link #hasSystemFeature}: The device supports SIP-based VOIP.
3482 */
3483 @SdkConstant(SdkConstantType.FEATURE)
3484 public static final String FEATURE_SIP_VOIP = "android.software.sip.voip";
3485
3486 /**
3487 * Feature for {@link #getSystemAvailableFeatures} and
3488 * {@link #hasSystemFeature}: The Connection Service API is enabled on the device.
3489 * @deprecated use {@link #FEATURE_TELECOM} instead.
3490 */
3491 @Deprecated
3492 @SdkConstant(SdkConstantType.FEATURE)
3493 public static final String FEATURE_CONNECTION_SERVICE = "android.software.connectionservice";
3494
3495 /**
3496 * Feature for {@link #getSystemAvailableFeatures} and
3497 * {@link #hasSystemFeature}: The device's display has a touch screen.
3498 */
3499 @SdkConstant(SdkConstantType.FEATURE)
3500 public static final String FEATURE_TOUCHSCREEN = "android.hardware.touchscreen";
3501
3502 /**
3503 * Feature for {@link #getSystemAvailableFeatures} and
3504 * {@link #hasSystemFeature}: The device's touch screen supports
3505 * multitouch sufficient for basic two-finger gesture detection.
3506 */
3507 @SdkConstant(SdkConstantType.FEATURE)
3508 public static final String FEATURE_TOUCHSCREEN_MULTITOUCH = "android.hardware.touchscreen.multitouch";
3509
3510 /**
3511 * Feature for {@link #getSystemAvailableFeatures} and
3512 * {@link #hasSystemFeature}: The device's touch screen is capable of
3513 * tracking two or more fingers fully independently.
3514 */
3515 @SdkConstant(SdkConstantType.FEATURE)
3516 public static final String FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT = "android.hardware.touchscreen.multitouch.distinct";
3517
3518 /**
3519 * Feature for {@link #getSystemAvailableFeatures} and
3520 * {@link #hasSystemFeature}: The device's touch screen is capable of
3521 * tracking a full hand of fingers fully independently -- that is, 5 or
3522 * more simultaneous independent pointers.
3523 */
3524 @SdkConstant(SdkConstantType.FEATURE)
3525 public static final String FEATURE_TOUCHSCREEN_MULTITOUCH_JAZZHAND = "android.hardware.touchscreen.multitouch.jazzhand";
3526
3527 /**
3528 * Feature for {@link #getSystemAvailableFeatures} and
3529 * {@link #hasSystemFeature}: The device does not have a touch screen, but
3530 * does support touch emulation for basic events. For instance, the
3531 * device might use a mouse or remote control to drive a cursor, and
3532 * emulate basic touch pointer events like down, up, drag, etc. All
3533 * devices that support android.hardware.touchscreen or a sub-feature are
3534 * presumed to also support faketouch.
3535 */
3536 @SdkConstant(SdkConstantType.FEATURE)
3537 public static final String FEATURE_FAKETOUCH = "android.hardware.faketouch";
3538
3539 /**
3540 * Feature for {@link #getSystemAvailableFeatures} and
3541 * {@link #hasSystemFeature}: The device does not have a touch screen, but
3542 * does support touch emulation for basic events that supports distinct
3543 * tracking of two or more fingers. This is an extension of
3544 * {@link #FEATURE_FAKETOUCH} for input devices with this capability. Note
3545 * that unlike a distinct multitouch screen as defined by
3546 * {@link #FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT}, these kinds of input
3547 * devices will not actually provide full two-finger gestures since the
3548 * input is being transformed to cursor movement on the screen. That is,
3549 * single finger gestures will move a cursor; two-finger swipes will
3550 * result in single-finger touch events; other two-finger gestures will
3551 * result in the corresponding two-finger touch event.
3552 */
3553 @SdkConstant(SdkConstantType.FEATURE)
3554 public static final String FEATURE_FAKETOUCH_MULTITOUCH_DISTINCT = "android.hardware.faketouch.multitouch.distinct";
3555
3556 /**
3557 * Feature for {@link #getSystemAvailableFeatures} and
3558 * {@link #hasSystemFeature}: The device does not have a touch screen, but
3559 * does support touch emulation for basic events that supports tracking
3560 * a hand of fingers (5 or more fingers) fully independently.
3561 * This is an extension of
3562 * {@link #FEATURE_FAKETOUCH} for input devices with this capability. Note
3563 * that unlike a multitouch screen as defined by
3564 * {@link #FEATURE_TOUCHSCREEN_MULTITOUCH_JAZZHAND}, not all two finger
3565 * gestures can be detected due to the limitations described for
3566 * {@link #FEATURE_FAKETOUCH_MULTITOUCH_DISTINCT}.
3567 */
3568 @SdkConstant(SdkConstantType.FEATURE)
3569 public static final String FEATURE_FAKETOUCH_MULTITOUCH_JAZZHAND = "android.hardware.faketouch.multitouch.jazzhand";
3570
3571 /**
3572 * Feature for {@link #getSystemAvailableFeatures} and
3573 * {@link #hasSystemFeature}: The device has biometric hardware to detect a fingerprint.
3574 */
3575 @SdkConstant(SdkConstantType.FEATURE)
3576 public static final String FEATURE_FINGERPRINT = "android.hardware.fingerprint";
3577
3578 /**
3579 * Feature for {@link #getSystemAvailableFeatures} and
3580 * {@link #hasSystemFeature}: The device has biometric hardware to perform face authentication.
3581 */
3582 @SdkConstant(SdkConstantType.FEATURE)
3583 public static final String FEATURE_FACE = "android.hardware.biometrics.face";
3584
3585 /**
3586 * Feature for {@link #getSystemAvailableFeatures} and
3587 * {@link #hasSystemFeature}: The device has biometric hardware to perform iris authentication.
3588 */
3589 @SdkConstant(SdkConstantType.FEATURE)
3590 public static final String FEATURE_IRIS = "android.hardware.biometrics.iris";
3591
3592 /**
3593 * Feature for {@link #getSystemAvailableFeatures} and
3594 * {@link #hasSystemFeature}: The device supports portrait orientation
3595 * screens. For backwards compatibility, you can assume that if neither
3596 * this nor {@link #FEATURE_SCREEN_LANDSCAPE} is set then the device supports
3597 * both portrait and landscape.
3598 */
3599 @SdkConstant(SdkConstantType.FEATURE)
3600 public static final String FEATURE_SCREEN_PORTRAIT = "android.hardware.screen.portrait";
3601
3602 /**
3603 * Feature for {@link #getSystemAvailableFeatures} and
3604 * {@link #hasSystemFeature}: The device supports landscape orientation
3605 * screens. For backwards compatibility, you can assume that if neither
3606 * this nor {@link #FEATURE_SCREEN_PORTRAIT} is set then the device supports
3607 * both portrait and landscape.
3608 */
3609 @SdkConstant(SdkConstantType.FEATURE)
3610 public static final String FEATURE_SCREEN_LANDSCAPE = "android.hardware.screen.landscape";
3611
3612 /**
3613 * Feature for {@link #getSystemAvailableFeatures} and
3614 * {@link #hasSystemFeature}: The device supports live wallpapers.
3615 */
3616 @SdkConstant(SdkConstantType.FEATURE)
3617 public static final String FEATURE_LIVE_WALLPAPER = "android.software.live_wallpaper";
3618 /**
3619 * Feature for {@link #getSystemAvailableFeatures} and
3620 * {@link #hasSystemFeature}: The device supports app widgets.
3621 */
3622 @SdkConstant(SdkConstantType.FEATURE)
3623 public static final String FEATURE_APP_WIDGETS = "android.software.app_widgets";
3624 /**
3625 * Feature for {@link #getSystemAvailableFeatures} and
3626 * {@link #hasSystemFeature}: The device supports the
3627 * {@link android.R.attr#cantSaveState} API.
3628 */
3629 @SdkConstant(SdkConstantType.FEATURE)
3630 public static final String FEATURE_CANT_SAVE_STATE = "android.software.cant_save_state";
3631
3632 /**
3633 * @hide
3634 * Feature for {@link #getSystemAvailableFeatures} and
3635 * {@link #hasSystemFeature}: The device supports
3636 * {@link android.service.games.GameService}.
3637 *
3638 * @hide
3639 */
3640 @SdkConstant(SdkConstantType.FEATURE)
3641 @SystemApi
3642 public static final String FEATURE_GAME_SERVICE = "android.software.game_service";
3643
3644 /**
3645 * @hide
3646 * Feature for {@link #getSystemAvailableFeatures} and
3647 * {@link #hasSystemFeature}: The device supports
3648 * {@link android.service.voice.VoiceInteractionService} and
3649 * {@link android.app.VoiceInteractor}.
3650 */
3651 @SdkConstant(SdkConstantType.FEATURE)
3652 public static final String FEATURE_VOICE_RECOGNIZERS = "android.software.voice_recognizers";
3653
3654
3655 /**
3656 * Feature for {@link #getSystemAvailableFeatures} and
3657 * {@link #hasSystemFeature}: The device supports a home screen that is replaceable
3658 * by third party applications.
3659 */
3660 @SdkConstant(SdkConstantType.FEATURE)
3661 public static final String FEATURE_HOME_SCREEN = "android.software.home_screen";
3662
3663 /**
3664 * Feature for {@link #getSystemAvailableFeatures} and
3665 * {@link #hasSystemFeature}: The device supports adding new input methods implemented
3666 * with the {@link android.inputmethodservice.InputMethodService} API.
3667 */
3668 @SdkConstant(SdkConstantType.FEATURE)
3669 public static final String FEATURE_INPUT_METHODS = "android.software.input_methods";
3670
3671 /**
3672 * Feature for {@link #getSystemAvailableFeatures} and
3673 * {@link #hasSystemFeature}: The device supports device policy enforcement via device admins.
3674 */
3675 @SdkConstant(SdkConstantType.FEATURE)
3676 public static final String FEATURE_DEVICE_ADMIN = "android.software.device_admin";
3677
3678 /**
3679 * Feature for {@link #getSystemAvailableFeatures} and
3680 * {@link #hasSystemFeature}: The device supports leanback UI. This is
3681 * typically used in a living room television experience, but is a software
3682 * feature unlike {@link #FEATURE_TELEVISION}. Devices running with this
3683 * feature will use resources associated with the "television" UI mode.
3684 */
3685 @SdkConstant(SdkConstantType.FEATURE)
3686 public static final String FEATURE_LEANBACK = "android.software.leanback";
3687
3688 /**
3689 * Feature for {@link #getSystemAvailableFeatures} and
3690 * {@link #hasSystemFeature}: The device supports only leanback UI. Only
3691 * applications designed for this experience should be run, though this is
3692 * not enforced by the system.
3693 */
3694 @SdkConstant(SdkConstantType.FEATURE)
3695 public static final String FEATURE_LEANBACK_ONLY = "android.software.leanback_only";
3696
3697 /**
3698 * Feature for {@link #getSystemAvailableFeatures} and
3699 * {@link #hasSystemFeature}: The device supports live TV and can display
3700 * contents from TV inputs implemented with the
3701 * {@link android.media.tv.TvInputService} API.
3702 */
3703 @SdkConstant(SdkConstantType.FEATURE)
3704 public static final String FEATURE_LIVE_TV = "android.software.live_tv";
3705
3706 /**
3707 * Feature for {@link #getSystemAvailableFeatures} and
3708 * {@link #hasSystemFeature}: The device supports WiFi (802.11) networking.
3709 */
3710 @SdkConstant(SdkConstantType.FEATURE)
3711 public static final String FEATURE_WIFI = "android.hardware.wifi";
3712
3713 /**
3714 * Feature for {@link #getSystemAvailableFeatures} and
3715 * {@link #hasSystemFeature}: The device supports Wi-Fi Direct networking.
3716 */
3717 @SdkConstant(SdkConstantType.FEATURE)
3718 public static final String FEATURE_WIFI_DIRECT = "android.hardware.wifi.direct";
3719
3720 /**
3721 * Feature for {@link #getSystemAvailableFeatures} and
3722 * {@link #hasSystemFeature}: The device supports Wi-Fi Aware.
3723 */
3724 @SdkConstant(SdkConstantType.FEATURE)
3725 public static final String FEATURE_WIFI_AWARE = "android.hardware.wifi.aware";
3726
3727 /**
3728 * Feature for {@link #getSystemAvailableFeatures} and
3729 * {@link #hasSystemFeature}: The device supports Wi-Fi Passpoint and all
3730 * Passpoint related APIs in {@link WifiManager} are supported. Refer to
3731 * {@link WifiManager#addOrUpdatePasspointConfiguration} for more info.
3732 */
3733 @SdkConstant(SdkConstantType.FEATURE)
3734 public static final String FEATURE_WIFI_PASSPOINT = "android.hardware.wifi.passpoint";
3735
3736 /**
3737 * Feature for {@link #getSystemAvailableFeatures} and
3738 * {@link #hasSystemFeature}: The device supports Wi-Fi RTT (IEEE 802.11mc).
3739 */
3740 @SdkConstant(SdkConstantType.FEATURE)
3741 public static final String FEATURE_WIFI_RTT = "android.hardware.wifi.rtt";
3742
3743
3744 /**
3745 * Feature for {@link #getSystemAvailableFeatures} and
3746 * {@link #hasSystemFeature}: The device supports LoWPAN networking.
3747 * @hide
3748 */
3749 @SdkConstant(SdkConstantType.FEATURE)
3750 public static final String FEATURE_LOWPAN = "android.hardware.lowpan";
3751
3752 /**
3753 * Feature for {@link #getSystemAvailableFeatures} and
3754 * {@link #hasSystemFeature}: This is a device dedicated to showing UI
3755 * on a vehicle headunit. A headunit here is defined to be inside a
3756 * vehicle that may or may not be moving. A headunit uses either a
3757 * primary display in the center console and/or additional displays in
3758 * the instrument cluster or elsewhere in the vehicle. Headunit display(s)
3759 * have limited size and resolution. The user will likely be focused on
3760 * driving so limiting driver distraction is a primary concern. User input
3761 * can be a variety of hard buttons, touch, rotary controllers and even mouse-
3762 * like interfaces.
3763 */
3764 @SdkConstant(SdkConstantType.FEATURE)
3765 public static final String FEATURE_AUTOMOTIVE = "android.hardware.type.automotive";
3766
3767 /**
3768 * Feature for {@link #getSystemAvailableFeatures} and
3769 * {@link #hasSystemFeature}: This is a device dedicated to showing UI
3770 * on a television. Television here is defined to be a typical living
3771 * room television experience: displayed on a big screen, where the user
3772 * is sitting far away from it, and the dominant form of input will be
3773 * something like a DPAD, not through touch or mouse.
3774 * @deprecated use {@link #FEATURE_LEANBACK} instead.
3775 */
3776 @Deprecated
3777 @SdkConstant(SdkConstantType.FEATURE)
3778 public static final String FEATURE_TELEVISION = "android.hardware.type.television";
3779
3780 /**
3781 * Feature for {@link #getSystemAvailableFeatures} and
3782 * {@link #hasSystemFeature}: This is a device dedicated to showing UI
3783 * on a watch. A watch here is defined to be a device worn on the body, perhaps on
3784 * the wrist. The user is very close when interacting with the device.
3785 */
3786 @SdkConstant(SdkConstantType.FEATURE)
3787 public static final String FEATURE_WATCH = "android.hardware.type.watch";
3788
3789 /**
3790 * Feature for {@link #getSystemAvailableFeatures} and
3791 * {@link #hasSystemFeature}: This is a device for IoT and may not have an UI. An embedded
3792 * device is defined as a full stack Android device with or without a display and no
3793 * user-installable apps.
3794 */
3795 @SdkConstant(SdkConstantType.FEATURE)
3796 public static final String FEATURE_EMBEDDED = "android.hardware.type.embedded";
3797
3798 /**
3799 * Feature for {@link #getSystemAvailableFeatures} and
3800 * {@link #hasSystemFeature}: This is a device dedicated to be primarily used
3801 * with keyboard, mouse or touchpad. This includes traditional desktop
3802 * computers, laptops and variants such as convertibles or detachables.
3803 * Due to the larger screen, the device will most likely use the
3804 * {@link #FEATURE_FREEFORM_WINDOW_MANAGEMENT} feature as well.
3805 */
3806 @SdkConstant(SdkConstantType.FEATURE)
3807 public static final String FEATURE_PC = "android.hardware.type.pc";
3808
3809 /**
3810 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
3811 * The device supports printing.
3812 */
3813 @SdkConstant(SdkConstantType.FEATURE)
3814 public static final String FEATURE_PRINTING = "android.software.print";
3815
3816 /**
3817 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
3818 * The device supports {@link android.companion.CompanionDeviceManager#associate associating}
3819 * with devices via {@link android.companion.CompanionDeviceManager}.
3820 */
3821 @SdkConstant(SdkConstantType.FEATURE)
3822 public static final String FEATURE_COMPANION_DEVICE_SETUP
3823 = "android.software.companion_device_setup";
3824
3825 /**
3826 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
3827 * The device can perform backup and restore operations on installed applications.
3828 */
3829 @SdkConstant(SdkConstantType.FEATURE)
3830 public static final String FEATURE_BACKUP = "android.software.backup";
3831
3832 /**
3833 * Feature for {@link #getSystemAvailableFeatures} and
3834 * {@link #hasSystemFeature}: The device supports freeform window management.
3835 * Windows have title bars and can be moved and resized.
3836 */
3837 // If this feature is present, you also need to set
3838 // com.android.internal.R.config_freeformWindowManagement to true in your configuration overlay.
3839 @SdkConstant(SdkConstantType.FEATURE)
3840 public static final String FEATURE_FREEFORM_WINDOW_MANAGEMENT
3841 = "android.software.freeform_window_management";
3842
3843 /**
3844 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
3845 * The device supports picture-in-picture multi-window mode.
3846 */
3847 @SdkConstant(SdkConstantType.FEATURE)
3848 public static final String FEATURE_PICTURE_IN_PICTURE = "android.software.picture_in_picture";
3849
3850 /**
3851 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
3852 * The device supports expanded picture-in-picture multi-window mode.
3853 *
3854 * @see android.app.PictureInPictureParams.Builder#setExpandedAspectRatio
3855 */
3856 @SdkConstant(SdkConstantType.FEATURE)
3857 public static final String FEATURE_EXPANDED_PICTURE_IN_PICTURE
3858 = "android.software.expanded_picture_in_picture";
3859
3860 /**
3861 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
3862 * The device supports running activities on secondary displays.
3863 */
3864 @SdkConstant(SdkConstantType.FEATURE)
3865 public static final String FEATURE_ACTIVITIES_ON_SECONDARY_DISPLAYS
3866 = "android.software.activities_on_secondary_displays";
3867
3868 /**
3869 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
3870 * The device supports creating secondary users and managed profiles via
3871 * {@link DevicePolicyManager}.
3872 */
3873 @SdkConstant(SdkConstantType.FEATURE)
3874 public static final String FEATURE_MANAGED_USERS = "android.software.managed_users";
3875
3876 /**
3877 * @hide
3878 * TODO: Remove after dependencies updated b/17392243
3879 */
3880 public static final String FEATURE_MANAGED_PROFILES = "android.software.managed_users";
3881
3882 /**
3883 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
3884 * The device supports verified boot.
3885 */
3886 @SdkConstant(SdkConstantType.FEATURE)
3887 public static final String FEATURE_VERIFIED_BOOT = "android.software.verified_boot";
3888
3889 /**
3890 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
3891 * The device supports secure removal of users. When a user is deleted the data associated
3892 * with that user is securely deleted and no longer available.
3893 */
3894 @SdkConstant(SdkConstantType.FEATURE)
3895 public static final String FEATURE_SECURELY_REMOVES_USERS
3896 = "android.software.securely_removes_users";
3897
3898 /** {@hide} */
3899 @TestApi
3900 @SdkConstant(SdkConstantType.FEATURE)
3901 public static final String FEATURE_FILE_BASED_ENCRYPTION
3902 = "android.software.file_based_encryption";
3903
3904 /** {@hide} */
3905 @TestApi
3906 @SdkConstant(SdkConstantType.FEATURE)
3907 public static final String FEATURE_ADOPTABLE_STORAGE
3908 = "android.software.adoptable_storage";
3909
3910 /**
3911 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
3912 * The device has a full implementation of the android.webkit.* APIs. Devices
3913 * lacking this feature will not have a functioning WebView implementation.
3914 */
3915 @SdkConstant(SdkConstantType.FEATURE)
3916 public static final String FEATURE_WEBVIEW = "android.software.webview";
3917
3918 /**
3919 * Feature for {@link #getSystemAvailableFeatures} and
3920 * {@link #hasSystemFeature}: This device supports ethernet.
3921 */
3922 @SdkConstant(SdkConstantType.FEATURE)
3923 public static final String FEATURE_ETHERNET = "android.hardware.ethernet";
3924
3925 /**
3926 * Feature for {@link #getSystemAvailableFeatures} and
3927 * {@link #hasSystemFeature}: This device supports HDMI-CEC.
3928 * @hide
3929 */
3930 @TestApi
3931 @SdkConstant(SdkConstantType.FEATURE)
3932 public static final String FEATURE_HDMI_CEC = "android.hardware.hdmi.cec";
3933
3934 /**
3935 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
3936 * The device has all of the inputs necessary to be considered a compatible game controller, or
3937 * includes a compatible game controller in the box.
3938 */
3939 @SdkConstant(SdkConstantType.FEATURE)
3940 public static final String FEATURE_GAMEPAD = "android.hardware.gamepad";
3941
3942 /**
3943 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
3944 * The device has a full implementation of the android.media.midi.* APIs.
3945 */
3946 @SdkConstant(SdkConstantType.FEATURE)
3947 public static final String FEATURE_MIDI = "android.software.midi";
3948
3949 /**
3950 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
3951 * The device implements an optimized mode for virtual reality (VR) applications that handles
3952 * stereoscopic rendering of notifications, and disables most monocular system UI components
3953 * while a VR application has user focus.
3954 * Devices declaring this feature must include an application implementing a
3955 * {@link android.service.vr.VrListenerService} that can be targeted by VR applications via
3956 * {@link android.app.Activity#setVrModeEnabled}.
3957 * @deprecated use {@link #FEATURE_VR_MODE_HIGH_PERFORMANCE} instead.
3958 */
3959 @Deprecated
3960 @SdkConstant(SdkConstantType.FEATURE)
3961 public static final String FEATURE_VR_MODE = "android.software.vr.mode";
3962
3963 /**
3964 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
3965 * The device implements an optimized mode for virtual reality (VR) applications that handles
3966 * stereoscopic rendering of notifications, disables most monocular system UI components
3967 * while a VR application has user focus and meets extra CDD requirements to provide a
3968 * high-quality VR experience.
3969 * Devices declaring this feature must include an application implementing a
3970 * {@link android.service.vr.VrListenerService} that can be targeted by VR applications via
3971 * {@link android.app.Activity#setVrModeEnabled}.
3972 * and must meet CDD requirements to provide a high-quality VR experience.
3973 */
3974 @SdkConstant(SdkConstantType.FEATURE)
3975 public static final String FEATURE_VR_MODE_HIGH_PERFORMANCE
3976 = "android.hardware.vr.high_performance";
3977
3978 /**
3979 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
3980 * The device supports autofill of user credentials, addresses, credit cards, etc
3981 * via integration with {@link android.service.autofill.AutofillService autofill
3982 * providers}.
3983 */
3984 @SdkConstant(SdkConstantType.FEATURE)
3985 public static final String FEATURE_AUTOFILL = "android.software.autofill";
3986
3987 /**
3988 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
3989 * The device implements headtracking suitable for a VR device.
3990 */
3991 @SdkConstant(SdkConstantType.FEATURE)
3992 public static final String FEATURE_VR_HEADTRACKING = "android.hardware.vr.headtracking";
3993
3994 /**
3995 * Feature for {@link #getSystemAvailableFeatures} and
3996 * {@link #hasSystemFeature(String, int)}: If this feature is supported, the device implements
3997 * the Android Keystore backed by an isolated execution environment. The version indicates
3998 * which features are implemented in the isolated execution environment:
3999 * <ul>
4000 * <li>100: Hardware support for ECDH (see {@link javax.crypto.KeyAgreement}) and support
4001 * for app-generated attestation keys (see {@link
4002 * android.security.keystore.KeyGenParameterSpec.Builder#setAttestKeyAlias(String)}).
4003 * <li>41: Hardware enforcement of device-unlocked keys (see {@link
4004 * android.security.keystore.KeyGenParameterSpec.Builder#setUnlockedDeviceRequired(boolean)}).
4005 * <li>40: Support for wrapped key import (see {@link
4006 * android.security.keystore.WrappedKeyEntry}), optional support for ID attestation (see {@link
4007 * android.security.keystore.KeyGenParameterSpec.Builder#setDevicePropertiesAttestationIncluded(boolean)}),
4008 * attestation (see {@link
4009 * android.security.keystore.KeyGenParameterSpec.Builder#setAttestationChallenge(byte[])}),
4010 * AES, HMAC, ECDSA and RSA support where the secret or private key never leaves secure
4011 * hardware, and support for requiring user authentication before a key can be used.
4012 * </ul>
4013 * This feature version is guaranteed to be set for all devices launching with Android 12 and
4014 * may be set on devices launching with an earlier version. If the feature version is set, it
4015 * will at least have the value 40. If it's not set the device may have a version of
4016 * hardware-backed keystore but it may not support all features listed above.
4017 */
4018 @SdkConstant(SdkConstantType.FEATURE)
4019 public static final String FEATURE_HARDWARE_KEYSTORE = "android.hardware.hardware_keystore";
4020
4021 /**
4022 * Feature for {@link #getSystemAvailableFeatures}, {@link #hasSystemFeature(String)}, and
4023 * {@link #hasSystemFeature(String, int)}: If this feature is supported, the device implements
4024 * the Android Keystore backed by a dedicated secure processor referred to as
4025 * <a href="https://source.android.com/security/best-practices/hardware#strongbox-keymaster">
4026 * StrongBox</a>. If this feature has a version, the version number indicates which features are
4027 * implemented in StrongBox:
4028 * <ul>
4029 * <li>100: Hardware support for ECDH (see {@link javax.crypto.KeyAgreement}) and support
4030 * for app-generated attestation keys (see {@link
4031 * android.security.keystore.KeyGenParameterSpec.Builder#setAttestKeyAlias(String)}).
4032 * <li>41: Hardware enforcement of device-unlocked keys (see {@link
4033 * android.security.keystore.KeyGenParameterSpec.Builder#setUnlockedDeviceRequired(boolean)}).
4034 * <li>40: Support for wrapped key import (see {@link
4035 * android.security.keystore.WrappedKeyEntry}), optional support for ID attestation (see {@link
4036 * android.security.keystore.KeyGenParameterSpec.Builder#setDevicePropertiesAttestationIncluded(boolean)}),
4037 * attestation (see {@link
4038 * android.security.keystore.KeyGenParameterSpec.Builder#setAttestationChallenge(byte[])}),
4039 * AES, HMAC, ECDSA and RSA support where the secret or private key never leaves secure
4040 * hardware, and support for requiring user authentication before a key can be used.
4041 * </ul>
4042 * If a device has StrongBox, this feature version number is guaranteed to be set for all
4043 * devices launching with Android 12 and may be set on devices launching with an earlier
4044 * version. If the feature version is set, it will at least have the value 40. If it's not
4045 * set the device may have StrongBox but it may not support all features listed above.
4046 */
4047 @SdkConstant(SdkConstantType.FEATURE)
4048 public static final String FEATURE_STRONGBOX_KEYSTORE =
4049 "android.hardware.strongbox_keystore";
4050
4051 /**
4052 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
4053 * The device does not have slices implementation.
4054 * @hide
4055 */
4056 @SdkConstant(SdkConstantType.FEATURE)
4057 public static final String FEATURE_SLICES_DISABLED = "android.software.slices_disabled";
4058
4059 /**
4060 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
4061 * The device supports device-unique Keystore attestations. Only available on devices that
4062 * also support {@link #FEATURE_STRONGBOX_KEYSTORE}, and can only be used by device owner
4063 * apps (see {@link android.app.admin.DevicePolicyManager#generateKeyPair}).
4064 * @hide
4065 */
4066 @SdkConstant(SdkConstantType.FEATURE)
4067 public static final String FEATURE_DEVICE_UNIQUE_ATTESTATION =
4068 "android.hardware.device_unique_attestation";
4069
4070 /**
4071 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
4072 * The device has a Keymaster implementation that supports Device ID attestation.
4073 *
4074 * @see DevicePolicyManager#isDeviceIdAttestationSupported
4075 * @hide
4076 */
4077 @SdkConstant(SdkConstantType.FEATURE)
4078 public static final String FEATURE_DEVICE_ID_ATTESTATION =
4079 "android.software.device_id_attestation";
4080
4081 /**
4082 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device has
4083 * the requisite kernel support for multinetworking-capable IPsec tunnels.
4084 *
4085 * <p>This feature implies that the device supports XFRM Interfaces (CONFIG_XFRM_INTERFACE), or
4086 * VTIs with kernel patches allowing updates of output/set mark via UPDSA.
4087 */
4088 @SdkConstant(SdkConstantType.FEATURE)
4089 public static final String FEATURE_IPSEC_TUNNELS = "android.software.ipsec_tunnels";
4090
4091 /**
4092 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device has
4093 * the requisite kernel support for migrating IPsec tunnels to new source/destination addresses.
4094 *
4095 * <p>This feature implies that the device supports XFRM Migration (CONFIG_XFRM_MIGRATE) and has
4096 * the kernel fixes to support cross-address-family IPsec tunnel migration
4097 */
4098 @SdkConstant(SdkConstantType.FEATURE)
4099 public static final String FEATURE_IPSEC_TUNNEL_MIGRATION =
4100 "android.software.ipsec_tunnel_migration";
4101
4102 /**
4103 * Feature for {@link #getSystemAvailableFeatures} and
4104 * {@link #hasSystemFeature}: The device supports a system interface for the user to select
4105 * and bind device control services provided by applications.
4106 *
4107 * @see android.service.controls.ControlsProviderService
4108 */
4109 @SdkConstant(SdkConstantType.FEATURE)
4110 public static final String FEATURE_CONTROLS = "android.software.controls";
4111
4112 /**
4113 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device has
4114 * the requisite hardware support to support reboot escrow of synthetic password for updates.
4115 *
4116 * <p>This feature implies that the device has the RebootEscrow HAL implementation.
4117 *
4118 * @hide
4119 */
4120 @SystemApi
4121 @SdkConstant(SdkConstantType.FEATURE)
4122 public static final String FEATURE_REBOOT_ESCROW = "android.hardware.reboot_escrow";
4123
4124 /**
4125 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device has
4126 * the requisite kernel support to support incremental delivery aka Incremental FileSystem.
4127 *
4128 * feature not present - IncFs is not present on the device.
4129 * 1 - IncFs v1, core features, no PerUid support. Optional in R.
4130 * 2 - IncFs v2, PerUid support, fs-verity support. Required in S.
4131 *
4132 * @see IncrementalManager#isFeatureEnabled
4133 * @see IncrementalManager#getVersion()
4134 * @hide
4135 */
4136 @SystemApi
4137 @SdkConstant(SdkConstantType.FEATURE)
4138 public static final String FEATURE_INCREMENTAL_DELIVERY =
4139 "android.software.incremental_delivery";
4140
4141 /**
4142 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device
4143 * has the requisite kernel support for the EROFS filesystem present in 4.19 kernels as a
4144 * staging driver, which lacks 0padding and big pcluster support.
4145 *
4146 * @hide
4147 */
4148 @SystemApi
4149 @SdkConstant(SdkConstantType.FEATURE)
4150 public static final String FEATURE_EROFS_LEGACY = "android.software.erofs_legacy";
4151
4152 /**
4153 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device
4154 * has the requisite kernel support for the EROFS filesystem present in 5.10 kernels, which
4155 * has 0padding, big pcluster, and chunked index support.
4156 *
4157 * @hide
4158 */
4159 @SystemApi
4160 @SdkConstant(SdkConstantType.FEATURE)
4161 public static final String FEATURE_EROFS = "android.software.erofs";
4162
4163 /**
4164 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
4165 * The device has tuner hardware to support tuner operations.
4166 *
4167 * <p>This feature implies that the device has the tuner HAL implementation.
4168 *
4169 * @hide
4170 */
4171 @SdkConstant(SdkConstantType.FEATURE)
4172 public static final String FEATURE_TUNER = "android.hardware.tv.tuner";
4173
4174 /**
4175 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device has
4176 * the necessary changes to support app enumeration.
4177 *
4178 * @hide
4179 */
4180 @SdkConstant(SdkConstantType.FEATURE)
4181 public static final String FEATURE_APP_ENUMERATION = "android.software.app_enumeration";
4182
4183 /**
4184 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device has
4185 * a Keystore implementation that can only enforce limited use key in hardware with max usage
4186 * count equals to 1.
4187 */
4188 @SdkConstant(SdkConstantType.FEATURE)
4189 public static final String FEATURE_KEYSTORE_SINGLE_USE_KEY =
4190 "android.hardware.keystore.single_use_key";
4191
4192 /**
4193 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device has
4194 * a Keystore implementation that can enforce limited use key in hardware with any max usage
4195 * count (including count equals to 1).
4196 */
4197 @SdkConstant(SdkConstantType.FEATURE)
4198 public static final String FEATURE_KEYSTORE_LIMITED_USE_KEY =
4199 "android.hardware.keystore.limited_use_key";
4200
4201 /**
4202 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device has
4203 * a Keystore implementation that can create application-specific attestation keys.
4204 * See {@link android.security.keystore.KeyGenParameterSpec.Builder#setAttestKeyAlias}.
4205 */
4206 @SdkConstant(SdkConstantType.FEATURE)
4207 public static final String FEATURE_KEYSTORE_APP_ATTEST_KEY =
4208 "android.hardware.keystore.app_attest_key";
4209
4210 /**
4211 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device
4212 * is opted-in to receive per-app compatibility overrides that are applied in
4213 * {@link com.android.server.compat.overrides.AppCompatOverridesService}.
4214 *
4215 * @hide
4216 */
4217 @SdkConstant(SdkConstantType.FEATURE)
4218 public static final String FEATURE_APP_COMPAT_OVERRIDES =
4219 "android.software.app_compat_overrides";
4220
4221 /**
4222 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device
4223 * supports communal mode,
4224 *
4225 * @hide
4226 */
4227 @SdkConstant(SdkConstantType.FEATURE)
4228 @TestApi
4229 public static final String FEATURE_COMMUNAL_MODE = "android.software.communal_mode";
4230
4231 /**
4232 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device
4233 * supports dream overlay feature, which is an informational layer shown on top of dreams.
4234 *
4235 * @hide
4236 */
4237 @SdkConstant(SdkConstantType.FEATURE)
4238 public static final String FEATURE_DREAM_OVERLAY = "android.software.dream_overlay";
4239
4240 /**
4241 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device
4242 * supports window magnification.
4243 *
4244 * @see android.accessibilityservice.MagnificationConfig#MAGNIFICATION_MODE_WINDOW
4245 */
4246 @SdkConstant(SdkConstantType.FEATURE)
4247 public static final String FEATURE_WINDOW_MAGNIFICATION =
4248 "android.software.window_magnification";
4249
4250 /** @hide */
4251 public static final boolean APP_ENUMERATION_ENABLED_BY_DEFAULT = true;
4252
4253 /**
4254 * Extra field name for the URI to a verification file. Passed to a package
4255 * verifier.
4256 *
4257 * @hide
4258 */
4259 public static final String EXTRA_VERIFICATION_URI = "android.content.pm.extra.VERIFICATION_URI";
4260
4261 /**
4262 * Extra field name for the ID of a package pending verification. Passed to
4263 * a package verifier and is used to call back to
4264 * {@link PackageManager#verifyPendingInstall(int, int)}
4265 */
4266 public static final String EXTRA_VERIFICATION_ID = "android.content.pm.extra.VERIFICATION_ID";
4267
4268 /**
4269 * Extra field name for the package identifier which is trying to install
4270 * the package.
4271 *
4272 * @hide
4273 */
4274 public static final String EXTRA_VERIFICATION_INSTALLER_PACKAGE
4275 = "android.content.pm.extra.VERIFICATION_INSTALLER_PACKAGE";
4276
4277 /**
4278 * Extra field name for the requested install flags for a package pending
4279 * verification. Passed to a package verifier.
4280 *
4281 * @hide
4282 */
4283 public static final String EXTRA_VERIFICATION_INSTALL_FLAGS
4284 = "android.content.pm.extra.VERIFICATION_INSTALL_FLAGS";
4285
4286 /**
4287 * Extra field name for the uid of who is requesting to install
4288 * the package.
4289 *
4290 * @hide
4291 */
4292 public static final String EXTRA_VERIFICATION_INSTALLER_UID
4293 = "android.content.pm.extra.VERIFICATION_INSTALLER_UID";
4294
4295 /**
4296 * Extra field name for the package name of a package pending verification.
4297 *
4298 * @hide
4299 */
4300 public static final String EXTRA_VERIFICATION_PACKAGE_NAME
4301 = "android.content.pm.extra.VERIFICATION_PACKAGE_NAME";
4302 /**
4303 * Extra field name for the result of a verification, either
4304 * {@link #VERIFICATION_ALLOW}, or {@link #VERIFICATION_REJECT}.
4305 * Passed to package verifiers after a package is verified.
4306 */
4307 public static final String EXTRA_VERIFICATION_RESULT
4308 = "android.content.pm.extra.VERIFICATION_RESULT";
4309
4310 /**
4311 * Extra field name for the version code of a package pending verification.
4312 * @deprecated Use {@link #EXTRA_VERIFICATION_LONG_VERSION_CODE} instead.
4313 * @hide
4314 */
4315 @Deprecated
4316 public static final String EXTRA_VERIFICATION_VERSION_CODE
4317 = "android.content.pm.extra.VERIFICATION_VERSION_CODE";
4318
4319 /**
4320 * Extra field name for the long version code of a package pending verification.
4321 *
4322 * @hide
4323 */
4324 public static final String EXTRA_VERIFICATION_LONG_VERSION_CODE =
4325 "android.content.pm.extra.VERIFICATION_LONG_VERSION_CODE";
4326
4327 /**
4328 * Extra field name for the Merkle tree root hash of a package.
4329 * <p>Passed to a package verifier both prior to verification and as a result
4330 * of verification.
4331 * <p>The value of the extra is a specially formatted list:
4332 * {@code filename1:HASH_1;filename2:HASH_2;...;filenameN:HASH_N}
4333 * <p>The extra must include an entry for every APK within an installation. If
4334 * a hash is not physically present, a hash value of {@code 0} will be used.
4335 * <p>The root hash is generated using SHA-256, no salt with a 4096 byte block
4336 * size. See the description of the
4337 * <a href="https://www.kernel.org/doc/html/latest/filesystems/fsverity.html#merkle-tree">fs-verity merkle-tree</a>
4338 * for more details.
4339 * @hide
4340 */
4341 @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
4342 public static final String EXTRA_VERIFICATION_ROOT_HASH =
4343 "android.content.pm.extra.VERIFICATION_ROOT_HASH";
4344
4345 /**
4346 * Extra field name for the ID of a intent filter pending verification.
4347 * Passed to an intent filter verifier and is used to call back to
4348 * {@link #verifyIntentFilter}
4349 *
4350 * @deprecated Use DomainVerificationManager APIs.
4351 * @hide
4352 */
4353 @Deprecated
4354 public static final String EXTRA_INTENT_FILTER_VERIFICATION_ID
4355 = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_ID";
4356
4357 /**
4358 * Extra field name for the scheme used for an intent filter pending verification. Passed to
4359 * an intent filter verifier and is used to construct the URI to verify against.
4360 *
4361 * Usually this is "https"
4362 *
4363 * @deprecated Use DomainVerificationManager APIs.
4364 * @hide
4365 */
4366 @Deprecated
4367 public static final String EXTRA_INTENT_FILTER_VERIFICATION_URI_SCHEME
4368 = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_URI_SCHEME";
4369
4370 /**
4371 * Extra field name for the host names to be used for an intent filter pending verification.
4372 * Passed to an intent filter verifier and is used to construct the URI to verify the
4373 * intent filter.
4374 *
4375 * This is a space delimited list of hosts.
4376 *
4377 * @deprecated Use DomainVerificationManager APIs.
4378 * @hide
4379 */
4380 @Deprecated
4381 public static final String EXTRA_INTENT_FILTER_VERIFICATION_HOSTS
4382 = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_HOSTS";
4383
4384 /**
4385 * Extra field name for the package name to be used for an intent filter pending verification.
4386 * Passed to an intent filter verifier and is used to check the verification responses coming
4387 * from the hosts. Each host response will need to include the package name of APK containing
4388 * the intent filter.
4389 *
4390 * @deprecated Use DomainVerificationManager APIs.
4391 * @hide
4392 */
4393 @Deprecated
4394 public static final String EXTRA_INTENT_FILTER_VERIFICATION_PACKAGE_NAME
4395 = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_PACKAGE_NAME";
4396
4397 /**
4398 * The action used to request that the user approve a permission request
4399 * from the application.
4400 *
4401 * @hide
4402 */
4403 @SystemApi
4404 public static final String ACTION_REQUEST_PERMISSIONS =
4405 "android.content.pm.action.REQUEST_PERMISSIONS";
4406
4407 /**
4408 * The action used to request that the user approve a permission request
4409 * from the application. Sent from an application other than the one whose permissions
4410 * will be granted. Can only be used by the system server.
4411 *
4412 * @hide
4413 */
4414 @SystemApi
4415 public static final String ACTION_REQUEST_PERMISSIONS_FOR_OTHER =
4416 "android.content.pm.action.REQUEST_PERMISSIONS_FOR_OTHER";
4417
4418 /**
4419 * The names of the requested permissions.
4420 * <p>
4421 * <strong>Type:</strong> String[]
4422 * </p>
4423 *
4424 * @hide
4425 */
4426 @SystemApi
4427 public static final String EXTRA_REQUEST_PERMISSIONS_NAMES =
4428 "android.content.pm.extra.REQUEST_PERMISSIONS_NAMES";
4429
4430 /**
4431 * The results from the permissions request.
4432 * <p>
4433 * <strong>Type:</strong> int[] of #PermissionResult
4434 * </p>
4435 *
4436 * @hide
4437 */
4438 @SystemApi
4439 public static final String EXTRA_REQUEST_PERMISSIONS_RESULTS
4440 = "android.content.pm.extra.REQUEST_PERMISSIONS_RESULTS";
4441
4442 /**
4443 * Indicates that the package requesting permissions has legacy access for some permissions,
4444 * or had it, but it was recently revoked. These request dialogs may show different text,
4445 * indicating that the app is requesting continued access to a permission. Will be cleared
4446 * from any permission request intent, if set by a non-system server app.
4447 * <p>
4448 * <strong>Type:</strong> String[]
4449 * </p>
4450 *
4451 * @hide
4452 */
4453 @SystemApi
4454 public static final String EXTRA_REQUEST_PERMISSIONS_LEGACY_ACCESS_PERMISSION_NAMES
4455 = "android.content.pm.extra.REQUEST_PERMISSIONS_LEGACY_ACCESS_PERMISSION_NAMES";
4456
4457 /**
4458 * String extra for {@link PackageInstallObserver} in the 'extras' Bundle in case of
4459 * {@link #INSTALL_FAILED_DUPLICATE_PERMISSION}. This extra names the package which provides
4460 * the existing definition for the permission.
4461 * @hide
4462 */
4463 public static final String EXTRA_FAILURE_EXISTING_PACKAGE
4464 = "android.content.pm.extra.FAILURE_EXISTING_PACKAGE";
4465
4466 /**
4467 * String extra for {@link PackageInstallObserver} in the 'extras' Bundle in case of
4468 * {@link #INSTALL_FAILED_DUPLICATE_PERMISSION}. This extra names the permission that is
4469 * being redundantly defined by the package being installed.
4470 * @hide
4471 */
4472 public static final String EXTRA_FAILURE_EXISTING_PERMISSION
4473 = "android.content.pm.extra.FAILURE_EXISTING_PERMISSION";
4474
4475 /**
4476 * Permission flag: The permission is set in its current state
4477 * by the user and apps can still request it at runtime.
4478 *
4479 * @hide
4480 */
4481 @SystemApi
4482 public static final int FLAG_PERMISSION_USER_SET = 1 << 0;
4483
4484 /**
4485 * Permission flag: The permission is set in its current state
4486 * by the user and it is fixed, i.e. apps can no longer request
4487 * this permission.
4488 *
4489 * @hide
4490 */
4491 @SystemApi
4492 public static final int FLAG_PERMISSION_USER_FIXED = 1 << 1;
4493
4494 /**
4495 * Permission flag: The permission is set in its current state
4496 * by device policy and neither apps nor the user can change
4497 * its state.
4498 *
4499 * @hide
4500 */
4501 @SystemApi
4502 public static final int FLAG_PERMISSION_POLICY_FIXED = 1 << 2;
4503
4504 /**
4505 * Permission flag: The permission is set in a granted state but
4506 * access to resources it guards is restricted by other means to
4507 * enable revoking a permission on legacy apps that do not support
4508 * runtime permissions. If this permission is upgraded to runtime
4509 * because the app was updated to support runtime permissions, the
4510 * the permission will be revoked in the upgrade process.
4511 *
4512 * @deprecated Renamed to {@link #FLAG_PERMISSION_REVOKED_COMPAT}.
4513 *
4514 * @hide
4515 */
4516 @Deprecated
4517 @SystemApi
4518 public static final int FLAG_PERMISSION_REVOKE_ON_UPGRADE = 1 << 3;
4519
4520 /**
4521 * Permission flag: The permission is set in its current state
4522 * because the app is a component that is a part of the system.
4523 *
4524 * @hide
4525 */
4526 @SystemApi
4527 public static final int FLAG_PERMISSION_SYSTEM_FIXED = 1 << 4;
4528
4529 /**
4530 * Permission flag: The permission is granted by default because it
4531 * enables app functionality that is expected to work out-of-the-box
4532 * for providing a smooth user experience. For example, the phone app
4533 * is expected to have the phone permission.
4534 *
4535 * @hide
4536 */
4537 @SystemApi
4538 public static final int FLAG_PERMISSION_GRANTED_BY_DEFAULT = 1 << 5;
4539
4540 /**
4541 * Permission flag: If app targetSDK < M, then the permission has to be reviewed before any of
4542 * the app components can run. If app targetSDK >= M, then the system might need to show a
4543 * request dialog for this permission on behalf of an app.
4544 *
4545 * @hide
4546 */
4547 @SystemApi
4548 public static final int FLAG_PERMISSION_REVIEW_REQUIRED = 1 << 6;
4549
4550 /**
4551 * Permission flag: The permission has not been explicitly requested by
4552 * the app but has been added automatically by the system. Revoke once
4553 * the app does explicitly request it.
4554 *
4555 * @hide
4556 */
4557 @TestApi
4558 @SystemApi
4559 public static final int FLAG_PERMISSION_REVOKE_WHEN_REQUESTED = 1 << 7;
4560
4561 /**
4562 * Permission flag: The permission's usage should be made highly visible to the user
4563 * when granted.
4564 *
4565 * @hide
4566 */
4567 @SystemApi
4568 public static final int FLAG_PERMISSION_USER_SENSITIVE_WHEN_GRANTED = 1 << 8;
4569
4570 /**
4571 * Permission flag: The permission's usage should be made highly visible to the user
4572 * when denied.
4573 *
4574 * @hide
4575 */
4576 @SystemApi
4577 public static final int FLAG_PERMISSION_USER_SENSITIVE_WHEN_DENIED = 1 << 9;
4578
4579 /**
4580 * Permission flag: The permission is restricted but the app is exempt
4581 * from the restriction and is allowed to hold this permission in its
4582 * full form and the exemption is provided by the installer on record.
4583 *
4584 * @hide
4585 */
4586 @SystemApi
4587 public static final int FLAG_PERMISSION_RESTRICTION_INSTALLER_EXEMPT = 1 << 11;
4588
4589 /**
4590 * Permission flag: The permission is restricted but the app is exempt
4591 * from the restriction and is allowed to hold this permission in its
4592 * full form and the exemption is provided by the system due to its
4593 * permission policy.
4594 *
4595 * @hide
4596 */
4597 @SystemApi
4598 public static final int FLAG_PERMISSION_RESTRICTION_SYSTEM_EXEMPT = 1 << 12;
4599
4600 /**
4601 * Permission flag: The permission is restricted but the app is exempt
4602 * from the restriction and is allowed to hold this permission and the
4603 * exemption is provided by the system when upgrading from an OS version
4604 * where the permission was not restricted to an OS version where the
4605 * permission is restricted.
4606 *
4607 * @hide
4608 */
4609 @SystemApi
4610 public static final int FLAG_PERMISSION_RESTRICTION_UPGRADE_EXEMPT = 1 << 13;
4611
4612
4613 /**
4614 * Permission flag: The permission is disabled but may be granted. If
4615 * disabled the data protected by the permission should be protected
4616 * by a no-op (empty list, default error, etc) instead of crashing the
4617 * client.
4618 *
4619 * @hide
4620 */
4621 @SystemApi
4622 public static final int FLAG_PERMISSION_APPLY_RESTRICTION = 1 << 14;
4623
4624 /**
4625 * Permission flag: The permission is granted because the application holds a role.
4626 *
4627 * @hide
4628 */
4629 @SystemApi
4630 public static final int FLAG_PERMISSION_GRANTED_BY_ROLE = 1 << 15;
4631
4632 /**
4633 * Permission flag: The permission should have been revoked but is kept granted for
4634 * compatibility. The data protected by the permission should be protected by a no-op (empty
4635 * list, default error, etc) instead of crashing the client. The permission will be revoked if
4636 * the app is upgraded to supports it.
4637 *
4638 * @hide
4639 */
4640 @SystemApi
4641 public static final int FLAG_PERMISSION_REVOKED_COMPAT = FLAG_PERMISSION_REVOKE_ON_UPGRADE;
4642
4643 /**
4644 * Permission flag: The permission is one-time and should be revoked automatically on app
4645 * inactivity
4646 *
4647 * @hide
4648 */
4649 @SystemApi
4650 public static final int FLAG_PERMISSION_ONE_TIME = 1 << 16;
4651
4652 /**
4653 * Permission flag: Whether permission was revoked by auto-revoke.
4654 *
4655 * @hide
4656 */
4657 @SystemApi
4658 public static final int FLAG_PERMISSION_AUTO_REVOKED = 1 << 17;
4659
4660 /**
4661 * Permission flag: This location permission is selected as the level of granularity of
4662 * location accuracy.
4663 * Example: If this flag is set for ACCESS_FINE_LOCATION, FINE location is the selected location
4664 * accuracy for location permissions.
4665 *
4666 * @hide
4667 */
4668 @SystemApi
4669 public static final int FLAG_PERMISSION_SELECTED_LOCATION_ACCURACY = 1 << 19;
4670
4671 /**
4672 * Permission flags: Reserved for use by the permission controller. The platform and any
4673 * packages besides the permission controller should not assume any definition about these
4674 * flags.
4675 * @hide
4676 */
4677 @SystemApi
4678 public static final int FLAGS_PERMISSION_RESERVED_PERMISSION_CONTROLLER = 1 << 28 | 1 << 29
4679 | 1 << 30 | 1 << 31;
4680
4681 /**
4682 * Permission flags: Bitwise or of all permission flags allowing an
4683 * exemption for a restricted permission.
4684 * @hide
4685 */
4686 public static final int FLAGS_PERMISSION_RESTRICTION_ANY_EXEMPT =
4687 FLAG_PERMISSION_RESTRICTION_INSTALLER_EXEMPT
4688 | FLAG_PERMISSION_RESTRICTION_SYSTEM_EXEMPT
4689 | FLAG_PERMISSION_RESTRICTION_UPGRADE_EXEMPT;
4690
4691 /**
4692 * Mask for all permission flags.
4693 *
4694 * @hide
4695 *
4696 * @deprecated Don't use - does not capture all flags.
4697 */
4698 @Deprecated
4699 @SystemApi
4700 public static final int MASK_PERMISSION_FLAGS = 0xFF;
4701
4702 /**
4703 * Mask for all permission flags.
4704 *
4705 * @hide
4706 */
4707 public static final int MASK_PERMISSION_FLAGS_ALL = FLAG_PERMISSION_USER_SET
4708 | FLAG_PERMISSION_USER_FIXED
4709 | FLAG_PERMISSION_POLICY_FIXED
4710 | FLAG_PERMISSION_REVOKE_ON_UPGRADE
4711 | FLAG_PERMISSION_SYSTEM_FIXED
4712 | FLAG_PERMISSION_GRANTED_BY_DEFAULT
4713 | FLAG_PERMISSION_REVIEW_REQUIRED
4714 | FLAG_PERMISSION_REVOKE_WHEN_REQUESTED
4715 | FLAG_PERMISSION_USER_SENSITIVE_WHEN_GRANTED
4716 | FLAG_PERMISSION_USER_SENSITIVE_WHEN_DENIED
4717 | FLAG_PERMISSION_RESTRICTION_INSTALLER_EXEMPT
4718 | FLAG_PERMISSION_RESTRICTION_SYSTEM_EXEMPT
4719 | FLAG_PERMISSION_RESTRICTION_UPGRADE_EXEMPT
4720 | FLAG_PERMISSION_APPLY_RESTRICTION
4721 | FLAG_PERMISSION_GRANTED_BY_ROLE
4722 | FLAG_PERMISSION_REVOKED_COMPAT
4723 | FLAG_PERMISSION_ONE_TIME
4724 | FLAG_PERMISSION_AUTO_REVOKED;
4725
4726 /**
4727 * Injected activity in app that forwards user to setting activity of that app.
4728 *
4729 * @hide
4730 */
4731 public static final String APP_DETAILS_ACTIVITY_CLASS_NAME = AppDetailsActivity.class.getName();
4732
4733 /**
4734 * Permission whitelist flag: permissions whitelisted by the system.
4735 * Permissions can also be whitelisted by the installer, on upgrade, or on
4736 * role grant.
4737 *
4738 * <p>
4739 * <strong>Note: </strong>In retrospect it would have been preferred to use
4740 * more inclusive terminology when naming this API. Similar APIs added will
4741 * refrain from using the term "whitelist".
4742 * </p>
4743 */
4744 public static final int FLAG_PERMISSION_WHITELIST_SYSTEM = 1 << 0;
4745
4746 /**
4747 * Permission whitelist flag: permissions whitelisted by the installer.
4748 * Permissions can also be whitelisted by the system, on upgrade, or on role
4749 * grant.
4750 *
4751 * <p>
4752 * <strong>Note: </strong>In retrospect it would have been preferred to use
4753 * more inclusive terminology when naming this API. Similar APIs added will
4754 * refrain from using the term "whitelist".
4755 * </p>
4756 */
4757 public static final int FLAG_PERMISSION_WHITELIST_INSTALLER = 1 << 1;
4758
4759 /**
4760 * Permission whitelist flag: permissions whitelisted by the system
4761 * when upgrading from an OS version where the permission was not
4762 * restricted to an OS version where the permission is restricted.
4763 * Permissions can also be whitelisted by the installer, the system, or on
4764 * role grant.
4765 *
4766 * <p>
4767 * <strong>Note: </strong>In retrospect it would have been preferred to use
4768 * more inclusive terminology when naming this API. Similar APIs added will
4769 * refrain from using the term "whitelist".
4770 * </p>
4771 */
4772 public static final int FLAG_PERMISSION_WHITELIST_UPGRADE = 1 << 2;
4773
4774 /** @hide */
4775 @IntDef(flag = true, prefix = {"FLAG_PERMISSION_WHITELIST_"}, value = {
4776 FLAG_PERMISSION_WHITELIST_SYSTEM,
4777 FLAG_PERMISSION_WHITELIST_INSTALLER,
4778 FLAG_PERMISSION_WHITELIST_UPGRADE
4779 })
4780 @Retention(RetentionPolicy.SOURCE)
4781 public @interface PermissionWhitelistFlags {}
4782
4783 /**
4784 * This is a library that contains components apps can invoke. For
4785 * example, a services for apps to bind to, or standard chooser UI,
4786 * etc. This library is versioned and backwards compatible. Clients
4787 * should check its version via {@link android.ext.services.Version
4788 * #getVersionCode()} and avoid calling APIs added in later versions.
4789 * <p>
4790 * This shared library no longer exists since Android R.
4791 *
4792 * @see #getServicesSystemSharedLibraryPackageName()
4793 *
4794 * @hide
4795 */
4796 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
4797 @TestApi
4798 public static final String SYSTEM_SHARED_LIBRARY_SERVICES = "android.ext.services";
4799
4800 /**
4801 * This is a library that contains components apps can dynamically
4802 * load. For example, new widgets, helper classes, etc. This library
4803 * is versioned and backwards compatible. Clients should check its
4804 * version via {@link android.ext.shared.Version#getVersionCode()}
4805 * and avoid calling APIs added in later versions.
4806 *
4807 * @hide
4808 */
4809 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
4810 @TestApi
4811 public static final String SYSTEM_SHARED_LIBRARY_SHARED = "android.ext.shared";
4812
4813 /** @hide */
4814 @IntDef({
4815 NOTIFY_PACKAGE_USE_ACTIVITY,
4816 NOTIFY_PACKAGE_USE_SERVICE,
4817 NOTIFY_PACKAGE_USE_FOREGROUND_SERVICE,
4818 NOTIFY_PACKAGE_USE_BROADCAST_RECEIVER,
4819 NOTIFY_PACKAGE_USE_CONTENT_PROVIDER,
4820 NOTIFY_PACKAGE_USE_BACKUP,
4821 NOTIFY_PACKAGE_USE_CROSS_PACKAGE,
4822 NOTIFY_PACKAGE_USE_INSTRUMENTATION,
4823 })
4824 public @interface NotifyReason {
4825 }
4826
4827 /**
4828 * Used when starting a process for an Activity.
4829 *
4830 * @hide
4831 */
4832 public static final int NOTIFY_PACKAGE_USE_ACTIVITY = 0;
4833
4834 /**
4835 * Used when starting a process for a Service.
4836 *
4837 * @hide
4838 */
4839 public static final int NOTIFY_PACKAGE_USE_SERVICE = 1;
4840
4841 /**
4842 * Used when moving a Service to the foreground.
4843 *
4844 * @hide
4845 */
4846 public static final int NOTIFY_PACKAGE_USE_FOREGROUND_SERVICE = 2;
4847
4848 /**
4849 * Used when starting a process for a BroadcastReceiver.
4850 *
4851 * @hide
4852 */
4853 public static final int NOTIFY_PACKAGE_USE_BROADCAST_RECEIVER = 3;
4854
4855 /**
4856 * Used when starting a process for a ContentProvider.
4857 *
4858 * @hide
4859 */
4860 public static final int NOTIFY_PACKAGE_USE_CONTENT_PROVIDER = 4;
4861
4862 /**
4863 * Used when starting a process for a BroadcastReceiver.
4864 *
4865 * @hide
4866 */
4867 public static final int NOTIFY_PACKAGE_USE_BACKUP = 5;
4868
4869 /**
4870 * Used with Context.getClassLoader() across Android packages.
4871 *
4872 * @hide
4873 */
4874 public static final int NOTIFY_PACKAGE_USE_CROSS_PACKAGE = 6;
4875
4876 /**
4877 * Used when starting a package within a process for Instrumentation.
4878 *
4879 * @hide
4880 */
4881 public static final int NOTIFY_PACKAGE_USE_INSTRUMENTATION = 7;
4882
4883 /**
4884 * Total number of usage reasons.
4885 *
4886 * @hide
4887 */
4888 public static final int NOTIFY_PACKAGE_USE_REASONS_COUNT = 8;
4889
4890 /**
4891 * Constant for specifying the highest installed package version code.
4892 */
4893 public static final int VERSION_CODE_HIGHEST = -1;
4894
4895 /**
4896 * Apps targeting Android R and above will need to declare the packages and intents they intend
4897 * to use to get details about other apps on a device. Such declarations must be made via the
4898 * {@code <queries>} tag in the manifest.
4899 *
4900 * @hide
4901 */
4902 @ChangeId
4903 @EnabledSince(targetSdkVersion = Build.VERSION_CODES.R)
4904 public static final long FILTER_APPLICATION_QUERY = 135549675L;
4905
4906 /** {@hide} */
4907 @IntDef(prefix = {"SYSTEM_APP_STATE_"}, value = {
4908 SYSTEM_APP_STATE_HIDDEN_UNTIL_INSTALLED_HIDDEN,
4909 SYSTEM_APP_STATE_HIDDEN_UNTIL_INSTALLED_VISIBLE,
4910 SYSTEM_APP_STATE_INSTALLED,
4911 SYSTEM_APP_STATE_UNINSTALLED
4912 })
4913 @Retention(RetentionPolicy.SOURCE)
4914 public @interface SystemAppState {}
4915
4916 /**
4917 * Constant for use with {@link #setSystemAppState} to mark a system app as hidden until
4918 * installation.
4919 * @hide
4920 */
4921 @SystemApi
4922 public static final int SYSTEM_APP_STATE_HIDDEN_UNTIL_INSTALLED_HIDDEN = 0;
4923
4924 /**
4925 * Constant for use with {@link #setSystemAppState} to mark a system app as not hidden until
4926 * installation.
4927 * @hide
4928 */
4929 @SystemApi
4930 public static final int SYSTEM_APP_STATE_HIDDEN_UNTIL_INSTALLED_VISIBLE = 1;
4931
4932 /**
4933 * Constant for use with {@link #setSystemAppState} to change a system app's state to installed.
4934 * @hide
4935 */
4936 @SystemApi
4937 public static final int SYSTEM_APP_STATE_INSTALLED = 2;
4938
4939 /**
4940 * Constant for use with {@link #setSystemAppState} to change a system app's state to
4941 * uninstalled.
4942 * @hide
4943 */
4944 @SystemApi
4945 public static final int SYSTEM_APP_STATE_UNINSTALLED = 3;
4946
4947 /**
4948 * A manifest property to control app's participation in {@code adb backup}. Should only
4949 * be used by system / privileged apps.
4950 *
4951 * @hide
4952 */
4953 public static final String PROPERTY_ALLOW_ADB_BACKUP = "android.backup.ALLOW_ADB_BACKUP";
4954
4955 /**
4956 * Flags class that wraps around the bitmask flags used in methods that retrieve package or
4957 * application info.
4958 * @hide
4959 */
4960 public static class Flags {
4961 final long mValue;
4962 protected Flags(long value) {
4963 mValue = value;
4964 }
4965 public long getValue() {
4966 return mValue;
4967 }
4968 }
4969
4970 /**
4971 * Specific flags used for retrieving package info. Example:
4972 * {@code PackageManager.getPackageInfo(packageName, PackageInfoFlags.of(0)}
4973 */
4974 public final static class PackageInfoFlags extends Flags {
4975 private PackageInfoFlags(@PackageInfoFlagsBits long value) {
4976 super(value);
4977 }
4978 @NonNull
4979 public static PackageInfoFlags of(@PackageInfoFlagsBits long value) {
4980 return new PackageInfoFlags(value);
4981 }
4982 }
4983
4984 /**
4985 * Specific flags used for retrieving application info.
4986 */
4987 public final static class ApplicationInfoFlags extends Flags {
4988 private ApplicationInfoFlags(@ApplicationInfoFlagsBits long value) {
4989 super(value);
4990 }
4991 @NonNull
4992 public static ApplicationInfoFlags of(@ApplicationInfoFlagsBits long value) {
4993 return new ApplicationInfoFlags(value);
4994 }
4995 }
4996
4997 /**
4998 * Specific flags used for retrieving component info.
4999 */
5000 public final static class ComponentInfoFlags extends Flags {
5001 private ComponentInfoFlags(@ComponentInfoFlagsBits long value) {
5002 super(value);
5003 }
5004 @NonNull
5005 public static ComponentInfoFlags of(@ComponentInfoFlagsBits long value) {
5006 return new ComponentInfoFlags(value);
5007 }
5008 }
5009
5010 /**
5011 * Specific flags used for retrieving resolve info.
5012 */
5013 public final static class ResolveInfoFlags extends Flags {
5014 private ResolveInfoFlags(@ResolveInfoFlagsBits long value) {
5015 super(value);
5016 }
5017 @NonNull
5018 public static ResolveInfoFlags of(@ResolveInfoFlagsBits long value) {
5019 return new ResolveInfoFlags(value);
5020 }
5021 }
5022
5023 /** {@hide} */
5024 public int getUserId() {
5025 return UserHandle.myUserId();
5026 }
5027
5028 /**
5029 * @deprecated Do not instantiate or subclass - obtain an instance from
5030 * {@link Context#getPackageManager}
5031 */
5032 @Deprecated
5033 public PackageManager() {}
5034
5035 /**
5036 * Retrieve overall information about an application package that is
5037 * installed on the system.
5038 *
5039 * @param packageName The full name (i.e. com.google.apps.contacts) of the
5040 * desired package.
5041 * @param flags Additional option flags to modify the data returned.
5042 * @return A PackageInfo object containing information about the package. If
5043 * flag {@code MATCH_UNINSTALLED_PACKAGES} is set and if the package
5044 * is not found in the list of installed applications, the package
5045 * information is retrieved from the list of uninstalled
5046 * applications (which includes installed applications as well as
5047 * applications with data directory i.e. applications which had been
5048 * deleted with {@code DELETE_KEEP_DATA} flag set).
5049 * @throws NameNotFoundException if no such package is available to the
5050 * caller.
5051 * @deprecated Use {@link #getPackageInfo(String, PackageInfoFlags)} instead.
5052 */
5053 @Deprecated
5054 public abstract PackageInfo getPackageInfo(@NonNull String packageName, int flags)
5055 throws NameNotFoundException;
5056
5057 /**
5058 * See {@link #getPackageInfo(String, int)}
5059 */
5060 @NonNull
5061 public PackageInfo getPackageInfo(@NonNull String packageName, @NonNull PackageInfoFlags flags)
5062 throws NameNotFoundException {
5063 throw new UnsupportedOperationException(
5064 "getPackageInfo not implemented in subclass");
5065 }
5066
5067 /**
5068 * Retrieve overall information about an application package that is
5069 * installed on the system. This method can be used for retrieving
5070 * information about packages for which multiple versions can be installed
5071 * at the time. Currently only packages hosting static shared libraries can
5072 * have multiple installed versions. The method can also be used to get info
5073 * for a package that has a single version installed by passing
5074 * {@link #VERSION_CODE_HIGHEST} in the {@link VersionedPackage}
5075 * constructor.
5076 *
5077 * @param versionedPackage The versioned package for which to query.
5078 * @param flags Additional option flags to modify the data returned.
5079 * @return A PackageInfo object containing information about the package. If
5080 * flag {@code MATCH_UNINSTALLED_PACKAGES} is set and if the package
5081 * is not found in the list of installed applications, the package
5082 * information is retrieved from the list of uninstalled
5083 * applications (which includes installed applications as well as
5084 * applications with data directory i.e. applications which had been
5085 * deleted with {@code DELETE_KEEP_DATA} flag set).
5086 * @throws NameNotFoundException if no such package is available to the
5087 * caller.
5088 * @deprecated Use {@link #getPackageInfo(VersionedPackage, PackageInfoFlags)} instead.
5089 */
5090 @Deprecated
5091 public abstract PackageInfo getPackageInfo(@NonNull VersionedPackage versionedPackage,
5092 int flags) throws NameNotFoundException;
5093
5094 /**
5095 * See {@link #getPackageInfo(VersionedPackage, int)}
5096 */
5097 @NonNull
5098 public PackageInfo getPackageInfo(@NonNull VersionedPackage versionedPackage,
5099 @NonNull PackageInfoFlags flags) throws NameNotFoundException {
5100 throw new UnsupportedOperationException(
5101 "getPackageInfo not implemented in subclass");
5102 }
5103
5104 /**
5105 * Retrieve overall information about an application package that is
5106 * installed on the system.
5107 *
5108 * @param packageName The full name (i.e. com.google.apps.contacts) of the
5109 * desired package.
5110 * @param flags Additional option flags to modify the data returned.
5111 * @param userId The user id.
5112 * @return A PackageInfo object containing information about the package. If
5113 * flag {@code MATCH_UNINSTALLED_PACKAGES} is set and if the package
5114 * is not found in the list of installed applications, the package
5115 * information is retrieved from the list of uninstalled
5116 * applications (which includes installed applications as well as
5117 * applications with data directory i.e. applications which had been
5118 * deleted with {@code DELETE_KEEP_DATA} flag set).
5119 * @throws NameNotFoundException if no such package is available to the
5120 * caller.
5121 * @deprecated Use {@link #getPackageInfoAsUser(String, PackageInfoFlags, int)} instead.
5122 * @hide
5123 */
5124 @Deprecated
5125 @SuppressWarnings("HiddenAbstractMethod")
5126 @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS)
5127 @UnsupportedAppUsage
5128 public abstract PackageInfo getPackageInfoAsUser(@NonNull String packageName,
5129 int flags, @UserIdInt int userId) throws NameNotFoundException;
5130
5131 /**
5132 * See {@link #getPackageInfoAsUser(String, int, int)}
5133 * @hide
5134 */
5135 @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS)
5136 @NonNull
5137 public PackageInfo getPackageInfoAsUser(@NonNull String packageName,
5138 @NonNull PackageInfoFlags flags, @UserIdInt int userId) throws NameNotFoundException {
5139 throw new UnsupportedOperationException(
5140 "getPackageInfoAsUser not implemented in subclass");
5141 }
5142
5143 /**
5144 * Map from the current package names in use on the device to whatever
5145 * the current canonical name of that package is.
5146 * @param packageNames Array of current names to be mapped.
5147 * @return Returns an array of the same size as the original, containing
5148 * the canonical name for each package.
5149 */
5150 public abstract String[] currentToCanonicalPackageNames(@NonNull String[] packageNames);
5151
5152 /**
5153 * Map from a packages canonical name to the current name in use on the device.
5154 * @param packageNames Array of new names to be mapped.
5155 * @return Returns an array of the same size as the original, containing
5156 * the current name for each package.
5157 */
5158 public abstract String[] canonicalToCurrentPackageNames(@NonNull String[] packageNames);
5159
5160 /**
5161 * Returns a "good" intent to launch a front-door activity in a package.
5162 * This is used, for example, to implement an "open" button when browsing
5163 * through packages. The current implementation looks first for a main
5164 * activity in the category {@link Intent#CATEGORY_INFO}, and next for a
5165 * main activity in the category {@link Intent#CATEGORY_LAUNCHER}. Returns
5166 * <code>null</code> if neither are found.
5167 *
5168 * <p>Consider using {@link #getLaunchIntentSenderForPackage(String)} if
5169 * the caller is not allowed to query for the <code>packageName</code>.
5170 *
5171 * @param packageName The name of the package to inspect.
5172 *
5173 * @return A fully-qualified {@link Intent} that can be used to launch the
5174 * main activity in the package. Returns <code>null</code> if the package
5175 * does not contain such an activity, or if <em>packageName</em> is not
5176 * recognized.
5177 *
5178 * @see #getLaunchIntentSenderForPackage(String)
5179 */
5180 public abstract @Nullable Intent getLaunchIntentForPackage(@NonNull String packageName);
5181
5182 /**
5183 * Return a "good" intent to launch a front-door Leanback activity in a
5184 * package, for use for example to implement an "open" button when browsing
5185 * through packages. The current implementation will look for a main
5186 * activity in the category {@link Intent#CATEGORY_LEANBACK_LAUNCHER}, or
5187 * return null if no main leanback activities are found.
5188 *
5189 * @param packageName The name of the package to inspect.
5190 * @return Returns either a fully-qualified Intent that can be used to launch
5191 * the main Leanback activity in the package, or null if the package
5192 * does not contain such an activity.
5193 */
5194 public abstract @Nullable Intent getLeanbackLaunchIntentForPackage(@NonNull String packageName);
5195
5196 /**
5197 * Return a "good" intent to launch a front-door Car activity in a
5198 * package, for use for example to implement an "open" button when browsing
5199 * through packages. The current implementation will look for a main
5200 * activity in the category {@link Intent#CATEGORY_CAR_LAUNCHER}, or
5201 * return null if no main car activities are found.
5202 *
5203 * @param packageName The name of the package to inspect.
5204 * @return Returns either a fully-qualified Intent that can be used to launch
5205 * the main Car activity in the package, or null if the package
5206 * does not contain such an activity.
5207 * @hide
5208 */
5209 @SuppressWarnings("HiddenAbstractMethod")
5210 public abstract @Nullable Intent getCarLaunchIntentForPackage(@NonNull String packageName);
5211
5212 /**
5213 * Returns an {@link IntentSender} that can be used to launch a front-door activity in a
5214 * package. This is used, for example, to implement an "open" button when browsing through
5215 * packages. The current implementation is the same with
5216 * {@link #getLaunchIntentForPackage(String)}. Instead of returning the {@link Intent}, it
5217 * returns the {@link IntentSender} which is not restricted by the package visibility.
5218 *
5219 * <p>The caller can invoke
5220 * {@link IntentSender#sendIntent(Context, int, Intent, IntentSender.OnFinished, Handler)}
5221 * to launch the activity. An {@link IntentSender.SendIntentException} is thrown if the
5222 * package does not contain such an activity, or if <em>packageName</em> is not recognized.
5223 *
5224 * @param packageName The name of the package to inspect.
5225 * @return Returns a {@link IntentSender} to launch the activity.
5226 *
5227 * @see #getLaunchIntentForPackage(String)
5228 */
5229 public @NonNull IntentSender getLaunchIntentSenderForPackage(@NonNull String packageName) {
5230 throw new UnsupportedOperationException("getLaunchIntentSenderForPackage not implemented"
5231 + "in subclass");
5232 }
5233
5234 /**
5235 * Return an array of all of the POSIX secondary group IDs that have been
5236 * assigned to the given package.
5237 * <p>
5238 * Note that the same package may have different GIDs under different
5239 * {@link UserHandle} on the same device.
5240 *
5241 * @param packageName The full name (i.e. com.google.apps.contacts) of the
5242 * desired package.
5243 * @return Returns an int array of the assigned GIDs, or null if there are
5244 * none.
5245 * @throws NameNotFoundException if no such package is available to the
5246 * caller.
5247 */
5248 public abstract int[] getPackageGids(@NonNull String packageName)
5249 throws NameNotFoundException;
5250
5251 /**
5252 * Return an array of all of the POSIX secondary group IDs that have been
5253 * assigned to the given package.
5254 * <p>
5255 * Note that the same package may have different GIDs under different
5256 * {@link UserHandle} on the same device.
5257 *
5258 * @param packageName The full name (i.e. com.google.apps.contacts) of the
5259 * desired package.
5260 * @return Returns an int array of the assigned gids, or null if there are
5261 * none.
5262 * @throws NameNotFoundException if no such package is available to the
5263 * caller.
5264 * @deprecated Use {@link #getPackageGids(String, PackageInfoFlags)} instead.
5265 */
5266 @Deprecated
5267 public abstract int[] getPackageGids(@NonNull String packageName, int flags)
5268 throws NameNotFoundException;
5269
5270 /**
5271 * See {@link #getPackageGids(String, int)}.
5272 */
5273 @Nullable
5274 public int[] getPackageGids(@NonNull String packageName, @NonNull PackageInfoFlags flags)
5275 throws NameNotFoundException {
5276 throw new UnsupportedOperationException(
5277 "getPackageGids not implemented in subclass");
5278 }
5279
5280 /**
5281 * Return the UID associated with the given package name.
5282 * <p>
5283 * Note that the same package will have different UIDs under different
5284 * {@link UserHandle} on the same device.
5285 *
5286 * @param packageName The full name (i.e. com.google.apps.contacts) of the
5287 * desired package.
5288 * @return Returns an integer UID who owns the given package name.
5289 * @throws NameNotFoundException if no such package is available to the
5290 * caller.
5291 * @deprecated Use {@link #getPackageUid(String, PackageInfoFlags)} instead.
5292 */
5293 @Deprecated
5294 public abstract int getPackageUid(@NonNull String packageName, int flags)
5295 throws NameNotFoundException;
5296
5297 /**
5298 * See {@link #getPackageUid(String, int)}.
5299 */
5300 public int getPackageUid(@NonNull String packageName, @NonNull PackageInfoFlags flags)
5301 throws NameNotFoundException {
5302 throw new UnsupportedOperationException(
5303 "getPackageUid not implemented in subclass");
5304 }
5305
5306 /**
5307 * Return the UID associated with the given package name.
5308 * <p>
5309 * Note that the same package will have different UIDs under different
5310 * {@link UserHandle} on the same device.
5311 *
5312 * @param packageName The full name (i.e. com.google.apps.contacts) of the
5313 * desired package.
5314 * @param userId The user handle identifier to look up the package under.
5315 * @return Returns an integer UID who owns the given package name.
5316 * @throws NameNotFoundException if no such package is available to the
5317 * caller.
5318 * @hide
5319 */
5320 @SuppressWarnings("HiddenAbstractMethod")
5321 @UnsupportedAppUsage
5322 public abstract int getPackageUidAsUser(@NonNull String packageName, @UserIdInt int userId)
5323 throws NameNotFoundException;
5324
5325 /**
5326 * Return the UID associated with the given package name.
5327 * <p>
5328 * Note that the same package will have different UIDs under different
5329 * {@link UserHandle} on the same device.
5330 *
5331 * @param packageName The full name (i.e. com.google.apps.contacts) of the
5332 * desired package.
5333 * @param userId The user handle identifier to look up the package under.
5334 * @return Returns an integer UID who owns the given package name.
5335 * @throws NameNotFoundException if no such package is available to the
5336 * caller.
5337 * @deprecated Use {@link #getPackageUidAsUser(String, PackageInfoFlags, int)} instead.
5338 * @hide
5339 */
5340 @Deprecated
5341 @SuppressWarnings("HiddenAbstractMethod")
5342 @UnsupportedAppUsage
5343 public abstract int getPackageUidAsUser(@NonNull String packageName,
5344 int flags, @UserIdInt int userId) throws NameNotFoundException;
5345
5346 /**
5347 * See {@link #getPackageUidAsUser(String, int, int)}.
5348 * @hide
5349 */
5350 public int getPackageUidAsUser(@NonNull String packageName, @NonNull PackageInfoFlags flags,
5351 @UserIdInt int userId) throws NameNotFoundException {
5352 throw new UnsupportedOperationException(
5353 "getPackageUidAsUser not implemented in subclass");
5354 }
5355
5356 /**
5357 * Retrieve all of the information we know about a particular permission.
5358 *
5359 * @param permName The fully qualified name (i.e. com.google.permission.LOGIN)
5360 * of the permission you are interested in.
5361 * @param flags Additional option flags to modify the data returned.
5362 * @return Returns a {@link PermissionInfo} containing information about the
5363 * permission.
5364 * @throws NameNotFoundException if a package with the given name cannot be
5365 * found on the system.
5366 */
5367 //@Deprecated
5368 public abstract PermissionInfo getPermissionInfo(@NonNull String permName,
5369 @PermissionInfoFlags int flags) throws NameNotFoundException;
5370
5371 /**
5372 * Query for all of the permissions associated with a particular group.
5373 *
5374 * @param permissionGroup The fully qualified name (i.e. com.google.permission.LOGIN)
5375 * of the permission group you are interested in. Use {@code null} to
5376 * find all of the permissions not associated with a group.
5377 * @param flags Additional option flags to modify the data returned.
5378 * @return Returns a list of {@link PermissionInfo} containing information
5379 * about all of the permissions in the given group.
5380 * @throws NameNotFoundException if a group with the given name cannot be
5381 * found on the system.
5382 */
5383 //@Deprecated
5384 @NonNull
5385 public abstract List<PermissionInfo> queryPermissionsByGroup(@Nullable String permissionGroup,
5386 @PermissionInfoFlags int flags) throws NameNotFoundException;
5387
5388 /**
5389 * Returns true if some permissions are individually controlled.
5390 *
5391 * <p>The user usually grants and revokes permission-groups. If this option is set some
5392 * dangerous system permissions can be revoked/granted by the user separately from their group.
5393 *
5394 * @hide
5395 */
5396 @SuppressWarnings("HiddenAbstractMethod")
5397 @SystemApi
5398 public abstract boolean arePermissionsIndividuallyControlled();
5399
5400 /**
5401 * Returns true if wireless consent mode is enabled
5402 *
5403 * @hide
5404 */
5405 @SuppressWarnings("HiddenAbstractMethod")
5406 public abstract boolean isWirelessConsentModeEnabled();
5407
5408 /**
5409 * Retrieve all of the information we know about a particular group of
5410 * permissions.
5411 *
5412 * @param groupName The fully qualified name (i.e.
5413 * com.google.permission_group.APPS) of the permission you are
5414 * interested in.
5415 * @param flags Additional option flags to modify the data returned.
5416 * @return Returns a {@link PermissionGroupInfo} containing information
5417 * about the permission.
5418 * @throws NameNotFoundException if a package with the given name cannot be
5419 * found on the system.
5420 */
5421 //@Deprecated
5422 @NonNull
5423 public abstract PermissionGroupInfo getPermissionGroupInfo(@NonNull String groupName,
5424 @PermissionGroupInfoFlags int flags) throws NameNotFoundException;
5425
5426 /**
5427 * Retrieve all of the known permission groups in the system.
5428 *
5429 * @param flags Additional option flags to modify the data returned.
5430 * @return Returns a list of {@link PermissionGroupInfo} containing
5431 * information about all of the known permission groups.
5432 */
5433 //@Deprecated
5434 @NonNull
5435 public abstract List<PermissionGroupInfo> getAllPermissionGroups(
5436 @PermissionGroupInfoFlags int flags);
5437
5438 /**
5439 * Get the platform-defined permissions which belong to a particular permission group.
5440 *
5441 * @param permissionGroupName the permission group whose permissions are desired
5442 * @param executor the {@link Executor} on which to invoke the callback
5443 * @param callback the callback which will receive a list of the platform-defined permissions in
5444 * the group, or empty if the group is not a valid platform-defined permission
5445 * group, or there was an exception
5446 */
5447 public void getPlatformPermissionsForGroup(@NonNull String permissionGroupName,
5448 @NonNull @CallbackExecutor Executor executor,
5449 @NonNull Consumer<List<String>> callback) {}
5450
5451 /**
5452 * Get the platform-defined permission group of a particular permission, if the permission is a
5453 * platform-defined permission.
5454 *
5455 * @param permissionName the permission whose group is desired
5456 * @param executor the {@link Executor} on which to invoke the callback
5457 * @param callback the callback which will receive the name of the permission group this
5458 * permission belongs to, or {@code null} if it has no group, is not a
5459 * platform-defined permission, or there was an exception
5460 */
5461 public void getGroupOfPlatformPermission(@NonNull String permissionName,
5462 @NonNull @CallbackExecutor Executor executor, @NonNull Consumer<String> callback) {}
5463
5464 /**
5465 * Retrieve all of the information we know about a particular
5466 * package/application.
5467 *
5468 * @param packageName The full name (i.e. com.google.apps.contacts) of an
5469 * application.
5470 * @param flags Additional option flags to modify the data returned.
5471 * @return An {@link ApplicationInfo} containing information about the
5472 * package. If flag {@code MATCH_UNINSTALLED_PACKAGES} is set and if
5473 * the package is not found in the list of installed applications,
5474 * the application information is retrieved from the list of
5475 * uninstalled applications (which includes installed applications
5476 * as well as applications with data directory i.e. applications
5477 * which had been deleted with {@code DELETE_KEEP_DATA} flag set).
5478 * @throws NameNotFoundException if a package with the given name cannot be
5479 * found on the system.
5480 * @deprecated Use {@link #getApplicationInfo(String, ApplicationInfoFlags)} instead.
5481 */
5482 @NonNull
5483 @Deprecated
5484 public abstract ApplicationInfo getApplicationInfo(@NonNull String packageName,
5485 int flags) throws NameNotFoundException;
5486
5487 /**
5488 * See {@link #getApplicationInfo(String, int)}.
5489 */
5490 @NonNull
5491 public ApplicationInfo getApplicationInfo(@NonNull String packageName,
5492 @NonNull ApplicationInfoFlags flags) throws NameNotFoundException {
5493 throw new UnsupportedOperationException(
5494 "getApplicationInfo not implemented in subclass");
5495 }
5496
5497 /**
5498 * @deprecated Use {@link #getApplicationInfoAsUser(String, ApplicationInfoFlags, int)} instead.
5499 * {@hide}
5500 */
5501 @SuppressWarnings("HiddenAbstractMethod")
5502 @NonNull
5503 @UnsupportedAppUsage
5504 @Deprecated
5505 public abstract ApplicationInfo getApplicationInfoAsUser(@NonNull String packageName,
5506 int flags, @UserIdInt int userId) throws NameNotFoundException;
5507
5508 /** {@hide} */
5509 @NonNull
5510 public ApplicationInfo getApplicationInfoAsUser(@NonNull String packageName,
5511 @NonNull ApplicationInfoFlags flags, @UserIdInt int userId)
5512 throws NameNotFoundException {
5513 throw new UnsupportedOperationException(
5514 "getApplicationInfoAsUser not implemented in subclass");
5515 }
5516
5517 /**
5518 * Retrieve all of the information we know about a particular
5519 * package/application, for a specific user.
5520 *
5521 * @param packageName The full name (i.e. com.google.apps.contacts) of an
5522 * application.
5523 * @param flags Additional option flags to modify the data returned.
5524 * @return An {@link ApplicationInfo} containing information about the
5525 * package. If flag {@code MATCH_UNINSTALLED_PACKAGES} is set and if
5526 * the package is not found in the list of installed applications,
5527 * the application information is retrieved from the list of
5528 * uninstalled applications (which includes installed applications
5529 * as well as applications with data directory i.e. applications
5530 * which had been deleted with {@code DELETE_KEEP_DATA} flag set).
5531 * @throws NameNotFoundException if a package with the given name cannot be
5532 * found on the system.
5533 * @deprecated Use {@link #getApplicationInfoAsUser(String, ApplicationInfoFlags, UserHandle)}
5534 * instead.
5535 * @hide
5536 */
5537 @NonNull
5538 @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS)
5539 @SystemApi
5540 @Deprecated
5541 public ApplicationInfo getApplicationInfoAsUser(@NonNull String packageName,
5542 int flags, @NonNull UserHandle user)
5543 throws NameNotFoundException {
5544 return getApplicationInfoAsUser(packageName, flags, user.getIdentifier());
5545 }
5546
5547 /**
5548 * See {@link #getApplicationInfoAsUser(String, int, UserHandle)}.
5549 * @hide
5550 */
5551 @NonNull
5552 @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS)
5553 @SystemApi
5554 public ApplicationInfo getApplicationInfoAsUser(@NonNull String packageName,
5555 @NonNull ApplicationInfoFlags flags, @NonNull UserHandle user)
5556 throws NameNotFoundException {
5557 return getApplicationInfoAsUser(packageName, flags, user.getIdentifier());
5558 }
5559
5560 /**
5561 * @return The target SDK version for the given package name.
5562 * @throws NameNotFoundException if a package with the given name cannot be found on the system.
5563 */
5564 @IntRange(from = 0)
5565 public int getTargetSdkVersion(@NonNull String packageName) throws NameNotFoundException {
5566 throw new UnsupportedOperationException();
5567 }
5568
5569 /**
5570 * Retrieve all of the information we know about a particular activity
5571 * class.
5572 *
5573 * @param component The full component name (i.e.
5574 * com.google.apps.contacts/com.google.apps.contacts.
5575 * ContactsList) of an Activity class.
5576 * @param flags Additional option flags to modify the data returned.
5577 * @return An {@link ActivityInfo} containing information about the
5578 * activity.
5579 * @throws NameNotFoundException if a package with the given name cannot be
5580 * found on the system.
5581 * @deprecated Use {@link #getActivityInfo(ComponentName, ComponentInfoFlags)} instead.
5582 */
5583 @Deprecated
5584 @NonNull
5585 public abstract ActivityInfo getActivityInfo(@NonNull ComponentName component,
5586 int flags) throws NameNotFoundException;
5587
5588 /**
5589 * See {@link #getActivityInfo(ComponentName, int)}.
5590 */
5591 @NonNull
5592 public ActivityInfo getActivityInfo(@NonNull ComponentName component,
5593 @NonNull ComponentInfoFlags flags) throws NameNotFoundException {
5594 throw new UnsupportedOperationException(
5595 "getActivityInfo not implemented in subclass");
5596 }
5597
5598 /**
5599 * Retrieve all of the information we know about a particular receiver
5600 * class.
5601 *
5602 * @param component The full component name (i.e.
5603 * com.google.apps.calendar/com.google.apps.calendar.
5604 * CalendarAlarm) of a Receiver class.
5605 * @param flags Additional option flags to modify the data returned.
5606 * @return An {@link ActivityInfo} containing information about the
5607 * receiver.
5608 * @throws NameNotFoundException if a package with the given name cannot be
5609 * found on the system.
5610 * @deprecated Use {@link #getReceiverInfo(ComponentName, ComponentInfoFlags)} instead.
5611 */
5612 @Deprecated
5613 @NonNull
5614 public abstract ActivityInfo getReceiverInfo(@NonNull ComponentName component,
5615 int flags) throws NameNotFoundException;
5616
5617 /**
5618 * See {@link #getReceiverInfo(ComponentName, int)}.
5619 */
5620 @NonNull
5621 public ActivityInfo getReceiverInfo(@NonNull ComponentName component,
5622 @NonNull ComponentInfoFlags flags) throws NameNotFoundException {
5623 throw new UnsupportedOperationException(
5624 "getReceiverInfo not implemented in subclass");
5625 }
5626
5627 /**
5628 * Retrieve all of the information we know about a particular service class.
5629 *
5630 * @param component The full component name (i.e.
5631 * com.google.apps.media/com.google.apps.media.
5632 * BackgroundPlayback) of a Service class.
5633 * @param flags Additional option flags to modify the data returned.
5634 * @return A {@link ServiceInfo} object containing information about the
5635 * service.
5636 * @throws NameNotFoundException if the component cannot be found on the system.
5637 * @deprecated Use {@link #getServiceInfo(ComponentName, ComponentInfoFlags)} instead.
5638 */
5639 @Deprecated
5640 @NonNull
5641 public abstract ServiceInfo getServiceInfo(@NonNull ComponentName component,
5642 int flags) throws NameNotFoundException;
5643
5644 /**
5645 * See {@link #getServiceInfo(ComponentName, int)}.
5646 */
5647 @NonNull
5648 public ServiceInfo getServiceInfo(@NonNull ComponentName component,
5649 @NonNull ComponentInfoFlags flags) throws NameNotFoundException {
5650 throw new UnsupportedOperationException(
5651 "getServiceInfo not implemented in subclass");
5652 }
5653
5654 /**
5655 * Retrieve all of the information we know about a particular content
5656 * provider class.
5657 *
5658 * @param component The full component name (i.e.
5659 * com.google.providers.media/com.google.providers.media.
5660 * MediaProvider) of a ContentProvider class.
5661 * @param flags Additional option flags to modify the data returned.
5662 * @return A {@link ProviderInfo} object containing information about the
5663 * provider.
5664 * @throws NameNotFoundException if a package with the given name cannot be
5665 * found on the system.
5666 * @deprecated Use {@link #getProviderInfo(ComponentName, ComponentInfoFlags)} instead.
5667 */
5668 @Deprecated
5669 @NonNull
5670 public abstract ProviderInfo getProviderInfo(@NonNull ComponentName component,
5671 int flags) throws NameNotFoundException;
5672
5673 /**
5674 * See {@link #getProviderInfo(ComponentName, int)}.
5675 */
5676 @NonNull
5677 public ProviderInfo getProviderInfo(@NonNull ComponentName component,
5678 @NonNull ComponentInfoFlags flags) throws NameNotFoundException {
5679 throw new UnsupportedOperationException(
5680 "getProviderInfo not implemented in subclass");
5681 }
5682
5683 /**
5684 * Retrieve information for a particular module.
5685 *
5686 * @param packageName The name of the module.
5687 * @param flags Additional option flags to modify the data returned.
5688 * @return A {@link ModuleInfo} object containing information about the
5689 * module.
5690 * @throws NameNotFoundException if a module with the given name cannot be
5691 * found on the system.
5692 */
5693 @NonNull
5694 public ModuleInfo getModuleInfo(@NonNull String packageName, @ModuleInfoFlags int flags)
5695 throws NameNotFoundException {
5696 throw new UnsupportedOperationException(
5697 "getModuleInfo not implemented in subclass");
5698 }
5699
5700 /**
5701 * Return a List of all modules that are installed.
5702 *
5703 * @param flags Additional option flags to modify the data returned.
5704 * @return A {@link List} of {@link ModuleInfo} objects, one for each installed
5705 * module, containing information about the module. In the unlikely case
5706 * there are no installed modules, an empty list is returned.
5707 */
5708 @NonNull
5709 public List<ModuleInfo> getInstalledModules(@InstalledModulesFlags int flags) {
5710 throw new UnsupportedOperationException(
5711 "getInstalledModules not implemented in subclass");
5712 }
5713
5714 /**
5715 * Return a List of all packages that are installed for the current user.
5716 *
5717 * @param flags Additional option flags to modify the data returned.
5718 * @return A List of PackageInfo objects, one for each installed package,
5719 * containing information about the package. In the unlikely case
5720 * there are no installed packages, an empty list is returned. If
5721 * flag {@code MATCH_UNINSTALLED_PACKAGES} is set, the package
5722 * information is retrieved from the list of uninstalled
5723 * applications (which includes installed applications as well as
5724 * applications with data directory i.e. applications which had been
5725 * deleted with {@code DELETE_KEEP_DATA} flag set).
5726 * @deprecated Use {@link #getInstalledPackages(PackageInfoFlags)} instead.
5727 */
5728 @Deprecated
5729 @NonNull
5730 public abstract List<PackageInfo> getInstalledPackages(int flags);
5731
5732 /**
5733 * See {@link #getInstalledPackages(int)}.
5734 * @param flags
5735 */
5736 @NonNull
5737 public List<PackageInfo> getInstalledPackages(@NonNull PackageInfoFlags flags) {
5738 throw new UnsupportedOperationException(
5739 "getInstalledPackages not implemented in subclass");
5740 }
5741
5742 /**
5743 * Return a List of all installed packages that are currently holding any of
5744 * the given permissions.
5745 *
5746 * @param flags Additional option flags to modify the data returned.
5747 * @return A List of PackageInfo objects, one for each installed package
5748 * that holds any of the permissions that were provided, containing
5749 * information about the package. If no installed packages hold any
5750 * of the permissions, an empty list is returned. If flag
5751 * {@code MATCH_UNINSTALLED_PACKAGES} is set, the package
5752 * information is retrieved from the list of uninstalled
5753 * applications (which includes installed applications as well as
5754 * applications with data directory i.e. applications which had been
5755 * deleted with {@code DELETE_KEEP_DATA} flag set).
5756 * @deprecated Use {@link #getPackagesHoldingPermissions(String[], PackageInfoFlags)} instead.
5757 */
5758 @Deprecated
5759 @NonNull
5760 public abstract List<PackageInfo> getPackagesHoldingPermissions(
5761 @NonNull String[] permissions, int flags);
5762
5763 /**
5764 * See {@link #getPackagesHoldingPermissions(String[], int)}.
5765 */
5766 @NonNull
5767 public List<PackageInfo> getPackagesHoldingPermissions(
5768 @NonNull String[] permissions, @NonNull PackageInfoFlags flags) {
5769 throw new UnsupportedOperationException(
5770 "getPackagesHoldingPermissions not implemented in subclass");
5771 }
5772
5773 /**
5774 * Return a List of all packages that are installed on the device, for a
5775 * specific user.
5776 *
5777 * @param flags Additional option flags to modify the data returned.
5778 * @param userId The user for whom the installed packages are to be listed
5779 * @return A List of PackageInfo objects, one for each installed package,
5780 * containing information about the package. In the unlikely case
5781 * there are no installed packages, an empty list is returned. If
5782 * flag {@code MATCH_UNINSTALLED_PACKAGES} is set, the package
5783 * information is retrieved from the list of uninstalled
5784 * applications (which includes installed applications as well as
5785 * applications with data directory i.e. applications which had been
5786 * deleted with {@code DELETE_KEEP_DATA} flag set).
5787 * @deprecated Use {@link #getInstalledPackagesAsUser(PackageInfoFlags, int)} instead.
5788 * @hide
5789 */
5790 @Deprecated
5791 @SuppressWarnings("HiddenAbstractMethod")
5792 @NonNull
5793 @SystemApi
5794 @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS_FULL)
5795 public abstract List<PackageInfo> getInstalledPackagesAsUser(int flags,
5796 @UserIdInt int userId);
5797
5798 /**
5799 * See {@link #getInstalledPackagesAsUser(int, int)}.
5800 * @hide
5801 */
5802 @NonNull
5803 @SystemApi
5804 @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS_FULL)
5805 public List<PackageInfo> getInstalledPackagesAsUser(@NonNull PackageInfoFlags flags,
5806 @UserIdInt int userId) {
5807 throw new UnsupportedOperationException(
5808 "getApplicationInfoAsUser not implemented in subclass");
5809 }
5810
5811 /**
5812 * Check whether a particular package has been granted a particular
5813 * permission.
5814 *
5815 * @param permName The name of the permission you are checking for.
5816 * @param packageName The name of the package you are checking against.
5817 *
5818 * @return If the package has the permission, PERMISSION_GRANTED is
5819 * returned. If it does not have the permission, PERMISSION_DENIED
5820 * is returned.
5821 *
5822 * @see #PERMISSION_GRANTED
5823 * @see #PERMISSION_DENIED
5824 */
5825 @CheckResult
5826 @PermissionResult
5827 public abstract int checkPermission(@NonNull String permName,
5828 @NonNull String packageName);
5829
5830 /**
5831 * Checks whether a particular permissions has been revoked for a
5832 * package by policy. Typically the device owner or the profile owner
5833 * may apply such a policy. The user cannot grant policy revoked
5834 * permissions, hence the only way for an app to get such a permission
5835 * is by a policy change.
5836 *
5837 * @param permName The name of the permission you are checking for.
5838 * @param packageName The name of the package you are checking against.
5839 *
5840 * @return Whether the permission is restricted by policy.
5841 */
5842 @CheckResult
5843 //@Deprecated
5844 public abstract boolean isPermissionRevokedByPolicy(@NonNull String permName,
5845 @NonNull String packageName);
5846
5847 /**
5848 * Gets the package name of the component controlling runtime permissions.
5849 *
5850 * @return the package name of the component controlling runtime permissions
5851 *
5852 * @hide
5853 */
5854 @NonNull
5855 @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
5856 @TestApi
5857 @UnsupportedAppUsage
5858 public String getPermissionControllerPackageName() {
5859 throw new RuntimeException("Not implemented. Must override in a subclass.");
5860 }
5861
5862 /**
5863 * Returns the package name of the component implementing sdk sandbox service.
5864 *
5865 * @return the package name of the component implementing sdk sandbox service
5866 *
5867 * @hide
5868 */
5869 @NonNull
5870 @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
5871 @TestApi
5872 public String getSdkSandboxPackageName() {
5873 throw new RuntimeException("Not implemented. Must override in a subclass.");
5874 }
5875
5876 /**
5877 * Add a new dynamic permission to the system. For this to work, your
5878 * package must have defined a permission tree through the
5879 * {@link android.R.styleable#AndroidManifestPermissionTree
5880 * &lt;permission-tree&gt;} tag in its manifest. A package can only add
5881 * permissions to trees that were defined by either its own package or
5882 * another with the same user id; a permission is in a tree if it
5883 * matches the name of the permission tree + ".": for example,
5884 * "com.foo.bar" is a member of the permission tree "com.foo".
5885 *
5886 * <p>It is good to make your permission tree name descriptive, because you
5887 * are taking possession of that entire set of permission names. Thus, it
5888 * must be under a domain you control, with a suffix that will not match
5889 * any normal permissions that may be declared in any applications that
5890 * are part of that domain.
5891 *
5892 * <p>New permissions must be added before
5893 * any .apks are installed that use those permissions. Permissions you
5894 * add through this method are remembered across reboots of the device.
5895 * If the given permission already exists, the info you supply here
5896 * will be used to update it.
5897 *
5898 * @param info Description of the permission to be added.
5899 *
5900 * @return Returns true if a new permission was created, false if an
5901 * existing one was updated.
5902 *
5903 * @throws SecurityException if you are not allowed to add the
5904 * given permission name.
5905 *
5906 * @see #removePermission(String)
5907 */
5908 //@Deprecated
5909 public abstract boolean addPermission(@NonNull PermissionInfo info);
5910
5911 /**
5912 * Like {@link #addPermission(PermissionInfo)} but asynchronously
5913 * persists the package manager state after returning from the call,
5914 * allowing it to return quicker and batch a series of adds at the
5915 * expense of no guarantee the added permission will be retained if
5916 * the device is rebooted before it is written.
5917 */
5918 //@Deprecated
5919 public abstract boolean addPermissionAsync(@NonNull PermissionInfo info);
5920
5921 /**
5922 * Removes a permission that was previously added with
5923 * {@link #addPermission(PermissionInfo)}. The same ownership rules apply
5924 * -- you are only allowed to remove permissions that you are allowed
5925 * to add.
5926 *
5927 * @param permName The name of the permission to remove.
5928 *
5929 * @throws SecurityException if you are not allowed to remove the
5930 * given permission name.
5931 *
5932 * @see #addPermission(PermissionInfo)
5933 */
5934 //@Deprecated
5935 public abstract void removePermission(@NonNull String permName);
5936
5937 /**
5938 * Permission flags set when granting or revoking a permission.
5939 *
5940 * @hide
5941 */
5942 @SystemApi
5943 @IntDef(prefix = { "FLAG_PERMISSION_" }, value = {
5944 FLAG_PERMISSION_USER_SET,
5945 FLAG_PERMISSION_USER_FIXED,
5946 FLAG_PERMISSION_POLICY_FIXED,
5947 FLAG_PERMISSION_REVOKE_ON_UPGRADE,
5948 FLAG_PERMISSION_SYSTEM_FIXED,
5949 FLAG_PERMISSION_GRANTED_BY_DEFAULT,
5950 FLAG_PERMISSION_USER_SENSITIVE_WHEN_GRANTED,
5951 FLAG_PERMISSION_USER_SENSITIVE_WHEN_DENIED,
5952 /*
5953 FLAG_PERMISSION_REVOKE_WHEN_REQUESED
5954 */
5955 FLAG_PERMISSION_RESTRICTION_UPGRADE_EXEMPT,
5956 FLAG_PERMISSION_RESTRICTION_SYSTEM_EXEMPT,
5957 FLAG_PERMISSION_RESTRICTION_INSTALLER_EXEMPT,
5958 FLAG_PERMISSION_APPLY_RESTRICTION,
5959 FLAG_PERMISSION_GRANTED_BY_ROLE,
5960 FLAG_PERMISSION_REVOKED_COMPAT,
5961 FLAG_PERMISSION_ONE_TIME,
5962 FLAG_PERMISSION_AUTO_REVOKED
5963 })
5964 @Retention(RetentionPolicy.SOURCE)
5965 public @interface PermissionFlags {}
5966
5967 /**
5968 * Grant a runtime permission to an application which the application does not
5969 * already have. The permission must have been requested by the application.
5970 * If the application is not allowed to hold the permission, a {@link
5971 * java.lang.SecurityException} is thrown. If the package or permission is
5972 * invalid, a {@link java.lang.IllegalArgumentException} is thrown.
5973 * <p>
5974 * <strong>Note: </strong>Using this API requires holding
5975 * android.permission.GRANT_RUNTIME_PERMISSIONS and if the user id is
5976 * not the current user android.permission.INTERACT_ACROSS_USERS_FULL.
5977 * </p>
5978 *
5979 * @param packageName The package to which to grant the permission.
5980 * @param permName The permission name to grant.
5981 * @param user The user for which to grant the permission.
5982 *
5983 * @see #revokeRuntimePermission(String, String, android.os.UserHandle)
5984 *
5985 * @hide
5986 */
5987 //@Deprecated
5988 @SuppressWarnings("HiddenAbstractMethod")
5989 @SystemApi
5990 @RequiresPermission(android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS)
5991 public abstract void grantRuntimePermission(@NonNull String packageName,
5992 @NonNull String permName, @NonNull UserHandle user);
5993
5994 /**
5995 * Revoke a runtime permission that was previously granted by {@link
5996 * #grantRuntimePermission(String, String, android.os.UserHandle)}. The
5997 * permission must have been requested by and granted to the application.
5998 * If the application is not allowed to hold the permission, a {@link
5999 * java.lang.SecurityException} is thrown. If the package or permission is
6000 * invalid, a {@link java.lang.IllegalArgumentException} is thrown.
6001 * <p>
6002 * <strong>Note: </strong>Using this API requires holding
6003 * android.permission.REVOKE_RUNTIME_PERMISSIONS and if the user id is
6004 * not the current user android.permission.INTERACT_ACROSS_USERS_FULL.
6005 * </p>
6006 *
6007 * @param packageName The package from which to revoke the permission.
6008 * @param permName The permission name to revoke.
6009 * @param user The user for which to revoke the permission.
6010 *
6011 * @see #grantRuntimePermission(String, String, android.os.UserHandle)
6012 *
6013 * @hide
6014 */
6015 //@Deprecated
6016 @SuppressWarnings("HiddenAbstractMethod")
6017 @SystemApi
6018 @RequiresPermission(android.Manifest.permission.REVOKE_RUNTIME_PERMISSIONS)
6019 public abstract void revokeRuntimePermission(@NonNull String packageName,
6020 @NonNull String permName, @NonNull UserHandle user);
6021
6022 /**
6023 * Revoke a runtime permission that was previously granted by {@link
6024 * #grantRuntimePermission(String, String, android.os.UserHandle)}. The
6025 * permission must have been requested by and granted to the application.
6026 * If the application is not allowed to hold the permission, a {@link
6027 * java.lang.SecurityException} is thrown. If the package or permission is
6028 * invalid, a {@link java.lang.IllegalArgumentException} is thrown.
6029 * <p>
6030 * <strong>Note: </strong>Using this API requires holding
6031 * android.permission.REVOKE_RUNTIME_PERMISSIONS and if the user id is
6032 * not the current user android.permission.INTERACT_ACROSS_USERS_FULL.
6033 * </p>
6034 *
6035 * @param packageName The package from which to revoke the permission.
6036 * @param permName The permission name to revoke.
6037 * @param user The user for which to revoke the permission.
6038 * @param reason The reason for the revoke.
6039 *
6040 * @see #grantRuntimePermission(String, String, android.os.UserHandle)
6041 *
6042 * @hide
6043 */
6044 //@Deprecated
6045 @SystemApi
6046 @RequiresPermission(android.Manifest.permission.REVOKE_RUNTIME_PERMISSIONS)
6047 public void revokeRuntimePermission(@NonNull String packageName,
6048 @NonNull String permName, @NonNull UserHandle user, @NonNull String reason) {
6049 revokeRuntimePermission(packageName, permName, user);
6050 }
6051
6052 /**
6053 * Gets the state flags associated with a permission.
6054 *
6055 * @param permName The permission for which to get the flags.
6056 * @param packageName The package name for which to get the flags.
6057 * @param user The user for which to get permission flags.
6058 * @return The permission flags.
6059 *
6060 * @hide
6061 */
6062 //@Deprecated
6063 @SuppressWarnings("HiddenAbstractMethod")
6064 @SystemApi
6065 @RequiresPermission(anyOf = {
6066 android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS,
6067 android.Manifest.permission.REVOKE_RUNTIME_PERMISSIONS,
6068 android.Manifest.permission.GET_RUNTIME_PERMISSIONS
6069 })
6070 @PermissionFlags
6071 public abstract int getPermissionFlags(@NonNull String permName,
6072 @NonNull String packageName, @NonNull UserHandle user);
6073
6074 /**
6075 * Updates the flags associated with a permission by replacing the flags in
6076 * the specified mask with the provided flag values.
6077 *
6078 * @param permName The permission for which to update the flags.
6079 * @param packageName The package name for which to update the flags.
6080 * @param flagMask The flags which to replace.
6081 * @param flagValues The flags with which to replace.
6082 * @param user The user for which to update the permission flags.
6083 *
6084 * @hide
6085 */
6086 //@Deprecated
6087 @SuppressWarnings("HiddenAbstractMethod")
6088 @SystemApi
6089 @RequiresPermission(anyOf = {
6090 android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS,
6091 android.Manifest.permission.REVOKE_RUNTIME_PERMISSIONS
6092 })
6093 public abstract void updatePermissionFlags(@NonNull String permName,
6094 @NonNull String packageName, @PermissionFlags int flagMask,
6095 @PermissionFlags int flagValues, @NonNull UserHandle user);
6096
6097 /**
6098 * Gets the restricted permissions that have been whitelisted and the app
6099 * is allowed to have them granted in their full form.
6100 *
6101 * <p> Permissions can be hard restricted which means that the app cannot hold
6102 * them or soft restricted where the app can hold the permission but in a weaker
6103 * form. Whether a permission is {@link PermissionInfo#FLAG_HARD_RESTRICTED hard
6104 * restricted} or {@link PermissionInfo#FLAG_SOFT_RESTRICTED soft restricted}
6105 * depends on the permission declaration. Whitelisting a hard restricted permission
6106 * allows for the to hold that permission and whitelisting a soft restricted
6107 * permission allows the app to hold the permission in its full, unrestricted form.
6108 *
6109 * <p><ol>There are four allowlists:
6110 *
6111 * <li>one for cases where the system permission policy whitelists a permission
6112 * This list corresponds to the{@link #FLAG_PERMISSION_WHITELIST_SYSTEM} flag.
6113 * Can only be accessed by pre-installed holders of a dedicated permission.
6114 *
6115 * <li>one for cases where the system whitelists the permission when upgrading
6116 * from an OS version in which the permission was not restricted to an OS version
6117 * in which the permission is restricted. This list corresponds to the {@link
6118 * #FLAG_PERMISSION_WHITELIST_UPGRADE} flag. Can be accessed by pre-installed
6119 * holders of a dedicated permission or the installer on record.
6120 *
6121 * <li>one for cases where the installer of the package whitelists a permission.
6122 * This list corresponds to the {@link #FLAG_PERMISSION_WHITELIST_INSTALLER} flag.
6123 * Can be accessed by pre-installed holders of a dedicated permission or the
6124 * installer on record.
6125 * </ol>
6126 *
6127 * <p>
6128 * <strong>Note: </strong>In retrospect it would have been preferred to use
6129 * more inclusive terminology when naming this API. Similar APIs added will
6130 * refrain from using the term "whitelist".
6131 * </p>
6132 *
6133 * @param packageName The app for which to get whitelisted permissions.
6134 * @param whitelistFlag The flag to determine which whitelist to query. Only one flag
6135 * can be passed.s
6136 * @return The whitelisted permissions that are on any of the whitelists you query for.
6137 *
6138 * @see #addWhitelistedRestrictedPermission(String, String, int)
6139 * @see #removeWhitelistedRestrictedPermission(String, String, int)
6140 * @see #FLAG_PERMISSION_WHITELIST_SYSTEM
6141 * @see #FLAG_PERMISSION_WHITELIST_UPGRADE
6142 * @see #FLAG_PERMISSION_WHITELIST_INSTALLER
6143 *
6144 * @throws SecurityException if you try to access a whitelist that you have no access to.
6145 */
6146 //@Deprecated
6147 @RequiresPermission(value = Manifest.permission.WHITELIST_RESTRICTED_PERMISSIONS,
6148 conditional = true)
6149 public @NonNull Set<String> getWhitelistedRestrictedPermissions(
6150 @NonNull String packageName, @PermissionWhitelistFlags int whitelistFlag) {
6151 return Collections.emptySet();
6152 }
6153
6154 /**
6155 * Adds a whitelisted restricted permission for an app.
6156 *
6157 * <p> Permissions can be hard restricted which means that the app cannot hold
6158 * them or soft restricted where the app can hold the permission but in a weaker
6159 * form. Whether a permission is {@link PermissionInfo#FLAG_HARD_RESTRICTED hard
6160 * restricted} or {@link PermissionInfo#FLAG_SOFT_RESTRICTED soft restricted}
6161 * depends on the permission declaration. Whitelisting a hard restricted permission
6162 * allows for the to hold that permission and whitelisting a soft restricted
6163 * permission allows the app to hold the permission in its full, unrestricted form.
6164 *
6165 * <p><ol>There are four whitelists:
6166 *
6167 * <li>one for cases where the system permission policy whitelists a permission
6168 * This list corresponds to the {@link #FLAG_PERMISSION_WHITELIST_SYSTEM} flag.
6169 * Can only be modified by pre-installed holders of a dedicated permission.
6170 *
6171 * <li>one for cases where the system whitelists the permission when upgrading
6172 * from an OS version in which the permission was not restricted to an OS version
6173 * in which the permission is restricted. This list corresponds to the {@link
6174 * #FLAG_PERMISSION_WHITELIST_UPGRADE} flag. Can be modified by pre-installed
6175 * holders of a dedicated permission. The installer on record can only remove
6176 * permissions from this whitelist.
6177 *
6178 * <li>one for cases where the installer of the package whitelists a permission.
6179 * This list corresponds to the {@link #FLAG_PERMISSION_WHITELIST_INSTALLER} flag.
6180 * Can be modified by pre-installed holders of a dedicated permission or the installer
6181 * on record.
6182 * </ol>
6183 *
6184 * <p>You need to specify the whitelists for which to set the whitelisted permissions
6185 * which will clear the previous whitelisted permissions and replace them with the
6186 * provided ones.
6187 *
6188 * <p>
6189 * <strong>Note: </strong>In retrospect it would have been preferred to use
6190 * more inclusive terminology when naming this API. Similar APIs added will
6191 * refrain from using the term "whitelist".
6192 * </p>
6193 *
6194 * @param packageName The app for which to get whitelisted permissions.
6195 * @param permName The whitelisted permission to add.
6196 * @param whitelistFlags The whitelists to which to add. Passing multiple flags
6197 * updates all specified whitelists.
6198 * @return Whether the permission was added to the whitelist.
6199 *
6200 * @see #getWhitelistedRestrictedPermissions(String, int)
6201 * @see #removeWhitelistedRestrictedPermission(String, String, int)
6202 * @see #FLAG_PERMISSION_WHITELIST_SYSTEM
6203 * @see #FLAG_PERMISSION_WHITELIST_UPGRADE
6204 * @see #FLAG_PERMISSION_WHITELIST_INSTALLER
6205 *
6206 * @throws SecurityException if you try to modify a whitelist that you have no access to.
6207 */
6208 //@Deprecated
6209 @RequiresPermission(value = Manifest.permission.WHITELIST_RESTRICTED_PERMISSIONS,
6210 conditional = true)
6211 public boolean addWhitelistedRestrictedPermission(@NonNull String packageName,
6212 @NonNull String permName, @PermissionWhitelistFlags int whitelistFlags) {
6213 return false;
6214 }
6215
6216 /**
6217 * Removes a whitelisted restricted permission for an app.
6218 *
6219 * <p> Permissions can be hard restricted which means that the app cannot hold
6220 * them or soft restricted where the app can hold the permission but in a weaker
6221 * form. Whether a permission is {@link PermissionInfo#FLAG_HARD_RESTRICTED hard
6222 * restricted} or {@link PermissionInfo#FLAG_SOFT_RESTRICTED soft restricted}
6223 * depends on the permission declaration. Whitelisting a hard restricted permission
6224 * allows for the to hold that permission and whitelisting a soft restricted
6225 * permission allows the app to hold the permission in its full, unrestricted form.
6226 *
6227 * <p><ol>There are four whitelists:
6228 *
6229 * <li>one for cases where the system permission policy whitelists a permission
6230 * This list corresponds to the {@link #FLAG_PERMISSION_WHITELIST_SYSTEM} flag.
6231 * Can only be modified by pre-installed holders of a dedicated permission.
6232 *
6233 * <li>one for cases where the system whitelists the permission when upgrading
6234 * from an OS version in which the permission was not restricted to an OS version
6235 * in which the permission is restricted. This list corresponds to the {@link
6236 * #FLAG_PERMISSION_WHITELIST_UPGRADE} flag. Can be modified by pre-installed
6237 * holders of a dedicated permission. The installer on record can only remove
6238 * permissions from this whitelist.
6239 *
6240 * <li>one for cases where the installer of the package whitelists a permission.
6241 * This list corresponds to the {@link #FLAG_PERMISSION_WHITELIST_INSTALLER} flag.
6242 * Can be modified by pre-installed holders of a dedicated permission or the installer
6243 * on record.
6244 *
6245 * <li>one for cases where the system exempts the permission when upgrading
6246 * from an OS version in which the permission was not restricted to an OS version
6247 * in which the permission is restricted. This list corresponds to the {@link
6248 * #FLAG_PERMISSION_WHITELIST_UPGRADE} flag. Can be modified by pre-installed
6249 * holders of a dedicated permission. The installer on record can only remove
6250 * permissions from this allowlist.
6251 * </ol>
6252 *
6253 * <p>You need to specify the whitelists for which to set the whitelisted permissions
6254 * which will clear the previous whitelisted permissions and replace them with the
6255 * provided ones.
6256 *
6257 * <p>
6258 * <strong>Note: </strong>In retrospect it would have been preferred to use
6259 * more inclusive terminology when naming this API. Similar APIs added will
6260 * refrain from using the term "whitelist".
6261 * </p>
6262 *
6263 * @param packageName The app for which to get whitelisted permissions.
6264 * @param permName The whitelisted permission to remove.
6265 * @param whitelistFlags The whitelists from which to remove. Passing multiple flags
6266 * updates all specified whitelists.
6267 * @return Whether the permission was removed from the whitelist.
6268 *
6269 * @see #getWhitelistedRestrictedPermissions(String, int)
6270 * @see #addWhitelistedRestrictedPermission(String, String, int)
6271 * @see #FLAG_PERMISSION_WHITELIST_SYSTEM
6272 * @see #FLAG_PERMISSION_WHITELIST_UPGRADE
6273 * @see #FLAG_PERMISSION_WHITELIST_INSTALLER
6274 *
6275 * @throws SecurityException if you try to modify a whitelist that you have no access to.
6276 */
6277 //@Deprecated
6278 @RequiresPermission(value = Manifest.permission.WHITELIST_RESTRICTED_PERMISSIONS,
6279 conditional = true)
6280 public boolean removeWhitelistedRestrictedPermission(@NonNull String packageName,
6281 @NonNull String permName, @PermissionWhitelistFlags int whitelistFlags) {
6282 return false;
6283 }
6284
6285 /**
6286 * Marks an application exempt from having its permissions be automatically revoked when
6287 * the app is unused for an extended period of time.
6288 *
6289 * Only the installer on record that installed the given package is allowed to call this.
6290 *
6291 * Packages start in whitelisted state, and it is the installer's responsibility to
6292 * un-whitelist the packages it installs, unless auto-revoking permissions from that package
6293 * would cause breakages beyond having to re-request the permission(s).
6294 *
6295 * <p>
6296 * <strong>Note: </strong>In retrospect it would have been preferred to use
6297 * more inclusive terminology when naming this API. Similar APIs added will
6298 * refrain from using the term "whitelist".
6299 * </p>
6300 *
6301 * @param packageName The app for which to set exemption.
6302 * @param whitelisted Whether the app should be whitelisted.
6303 *
6304 * @return whether any change took effect.
6305 *
6306 * @see #isAutoRevokeWhitelisted
6307 *
6308 * @throws SecurityException if you you have no access to modify this.
6309 */
6310 //@Deprecated
6311 @RequiresPermission(value = Manifest.permission.WHITELIST_AUTO_REVOKE_PERMISSIONS,
6312 conditional = true)
6313 public boolean setAutoRevokeWhitelisted(@NonNull String packageName, boolean whitelisted) {
6314 return false;
6315 }
6316
6317 /**
6318 * Checks whether an application is exempt from having its permissions be automatically revoked
6319 * when the app is unused for an extended period of time.
6320 *
6321 * Only the installer on record that installed the given package, or a holder of
6322 * {@code WHITELIST_AUTO_REVOKE_PERMISSIONS} is allowed to call this.
6323 *
6324 * <p>
6325 * <strong>Note: </strong>In retrospect it would have been preferred to use
6326 * more inclusive terminology when naming this API. Similar APIs added will
6327 * refrain from using the term "whitelist".
6328 * </p>
6329 *
6330 * @param packageName The app for which to set exemption.
6331 *
6332 * @return Whether the app is whitelisted.
6333 *
6334 * @see #setAutoRevokeWhitelisted
6335 *
6336 * @throws SecurityException if you you have no access to this.
6337 */
6338 //@Deprecated
6339 @RequiresPermission(value = Manifest.permission.WHITELIST_AUTO_REVOKE_PERMISSIONS,
6340 conditional = true)
6341 public boolean isAutoRevokeWhitelisted(@NonNull String packageName) {
6342 return false;
6343 }
6344
6345
6346 /**
6347 * Gets whether you should show UI with rationale for requesting a permission.
6348 * You should do this only if you do not have the permission and the context in
6349 * which the permission is requested does not clearly communicate to the user
6350 * what would be the benefit from grating this permission.
6351 *
6352 * @param permName A permission your app wants to request.
6353 * @return Whether you can show permission rationale UI.
6354 *
6355 * @hide
6356 */
6357 //@Deprecated
6358 @SuppressWarnings("HiddenAbstractMethod")
6359 @UnsupportedAppUsage
6360 public abstract boolean shouldShowRequestPermissionRationale(@NonNull String permName);
6361
6362 /**
6363 * Gets the localized label that corresponds to the option in settings for granting
6364 * background access.
6365 *
6366 * <p>The intended use is for apps to reference this label in its instruction for users to grant
6367 * a background permission.
6368 *
6369 * @return the localized label that corresponds to the settings option for granting
6370 * background access
6371 */
6372 @NonNull
6373 public CharSequence getBackgroundPermissionOptionLabel() {
6374 return "";
6375 }
6376
6377 /**
6378 * Returns an {@link android.content.Intent} suitable for passing to
6379 * {@link android.app.Activity#startActivityForResult(android.content.Intent, int)}
6380 * which prompts the user to grant permissions to this application.
6381 *
6382 * @throws NullPointerException if {@code permissions} is {@code null} or empty.
6383 *
6384 * @hide
6385 */
6386 @NonNull
6387 @UnsupportedAppUsage
6388 public Intent buildRequestPermissionsIntent(@NonNull String[] permissions) {
6389 if (ArrayUtils.isEmpty(permissions)) {
6390 throw new IllegalArgumentException("permission cannot be null or empty");
6391 }
6392 Intent intent = new Intent(ACTION_REQUEST_PERMISSIONS);
6393 intent.putExtra(EXTRA_REQUEST_PERMISSIONS_NAMES, permissions);
6394 intent.setPackage(getPermissionControllerPackageName());
6395 return intent;
6396 }
6397
6398 /**
6399 * Compare the signatures of two packages to determine if the same
6400 * signature appears in both of them. If they do contain the same
6401 * signature, then they are allowed special privileges when working
6402 * with each other: they can share the same user-id, run instrumentation
6403 * against each other, etc.
6404 *
6405 * @param packageName1 First package name whose signature will be compared.
6406 * @param packageName2 Second package name whose signature will be compared.
6407 *
6408 * @return Returns an integer indicating whether all signatures on the
6409 * two packages match. The value is >= 0 ({@link #SIGNATURE_MATCH}) if
6410 * all signatures match or < 0 if there is not a match ({@link
6411 * #SIGNATURE_NO_MATCH} or {@link #SIGNATURE_UNKNOWN_PACKAGE}).
6412 *
6413 * @see #checkSignatures(int, int)
6414 */
6415 @CheckResult
6416 @SignatureResult
6417 public abstract int checkSignatures(@NonNull String packageName1,
6418 @NonNull String packageName2);
6419
6420 /**
6421 * Like {@link #checkSignatures(String, String)}, but takes UIDs of
6422 * the two packages to be checked. This can be useful, for example,
6423 * when doing the check in an IPC, where the UID is the only identity
6424 * available. It is functionally identical to determining the package
6425 * associated with the UIDs and checking their signatures.
6426 *
6427 * @param uid1 First UID whose signature will be compared.
6428 * @param uid2 Second UID whose signature will be compared.
6429 *
6430 * @return Returns an integer indicating whether all signatures on the
6431 * two packages match. The value is >= 0 ({@link #SIGNATURE_MATCH}) if
6432 * all signatures match or < 0 if there is not a match ({@link
6433 * #SIGNATURE_NO_MATCH} or {@link #SIGNATURE_UNKNOWN_PACKAGE}).
6434 *
6435 * @see #checkSignatures(String, String)
6436 */
6437 @CheckResult
6438 public abstract @SignatureResult int checkSignatures(int uid1, int uid2);
6439
6440 /**
6441 * Retrieve the names of all packages that are associated with a particular
6442 * user id. In most cases, this will be a single package name, the package
6443 * that has been assigned that user id. Where there are multiple packages
6444 * sharing the same user id through the "sharedUserId" mechanism, all
6445 * packages with that id will be returned.
6446 *
6447 * @param uid The user id for which you would like to retrieve the
6448 * associated packages.
6449 *
6450 * @return Returns an array of one or more packages assigned to the user
6451 * id, or null if there are no known packages with the given id.
6452 */
6453 public abstract @Nullable String[] getPackagesForUid(int uid);
6454
6455 /**
6456 * Retrieve the official name associated with a uid. This name is
6457 * guaranteed to never change, though it is possible for the underlying
6458 * uid to be changed. That is, if you are storing information about
6459 * uids in persistent storage, you should use the string returned
6460 * by this function instead of the raw uid.
6461 *
6462 * @param uid The uid for which you would like to retrieve a name.
6463 * @return Returns a unique name for the given uid, or null if the
6464 * uid is not currently assigned.
6465 */
6466 public abstract @Nullable String getNameForUid(int uid);
6467
6468 /**
6469 * Retrieves the official names associated with each given uid.
6470 * @see #getNameForUid(int)
6471 *
6472 * @hide
6473 */
6474 @SuppressWarnings({"HiddenAbstractMethod", "NullableCollection"})
6475 @TestApi
6476 public abstract @Nullable String[] getNamesForUids(int[] uids);
6477
6478 /**
6479 * Return the user id associated with a shared user name. Multiple
6480 * applications can specify a shared user name in their manifest and thus
6481 * end up using a common uid. This might be used for new applications
6482 * that use an existing shared user name and need to know the uid of the
6483 * shared user.
6484 *
6485 * @param sharedUserName The shared user name whose uid is to be retrieved.
6486 * @return Returns the UID associated with the shared user.
6487 * @throws NameNotFoundException if a package with the given name cannot be
6488 * found on the system.
6489 * @hide
6490 */
6491 @SuppressWarnings("HiddenAbstractMethod")
6492 @UnsupportedAppUsage
6493 public abstract int getUidForSharedUser(@NonNull String sharedUserName)
6494 throws NameNotFoundException;
6495
6496 /**
6497 * Return a List of all application packages that are installed for the
6498 * current user. If flag GET_UNINSTALLED_PACKAGES has been set, a list of all
6499 * applications including those deleted with {@code DELETE_KEEP_DATA}
6500 * (partially installed apps with data directory) will be returned.
6501 *
6502 * @param flags Additional option flags to modify the data returned.
6503 * @return A List of ApplicationInfo objects, one for each installed
6504 * application. In the unlikely case there are no installed
6505 * packages, an empty list is returned. If flag
6506 * {@code MATCH_UNINSTALLED_PACKAGES} is set, the application
6507 * information is retrieved from the list of uninstalled
6508 * applications (which includes installed applications as well as
6509 * applications with data directory i.e. applications which had been
6510 * deleted with {@code DELETE_KEEP_DATA} flag set).
6511 * @deprecated Use {@link #getInstalledApplications(ApplicationInfoFlags)} instead.
6512 */
6513 @NonNull
6514 @Deprecated
6515 public abstract List<ApplicationInfo> getInstalledApplications(int flags);
6516
6517 /**
6518 * See {@link #getInstalledApplications(int)}
6519 * @param flags
6520 */
6521 @NonNull
6522 public List<ApplicationInfo> getInstalledApplications(@NonNull ApplicationInfoFlags flags) {
6523 throw new UnsupportedOperationException(
6524 "getInstalledApplications not implemented in subclass");
6525 }
6526 /**
6527 * Return a List of all application packages that are installed on the
6528 * device, for a specific user. If flag GET_UNINSTALLED_PACKAGES has been
6529 * set, a list of all applications including those deleted with
6530 * {@code DELETE_KEEP_DATA} (partially installed apps with data directory)
6531 * will be returned.
6532 *
6533 * @param flags Additional option flags to modify the data returned.
6534 * @param userId The user for whom the installed applications are to be
6535 * listed
6536 * @return A List of ApplicationInfo objects, one for each installed
6537 * application. In the unlikely case there are no installed
6538 * packages, an empty list is returned. If flag
6539 * {@code MATCH_UNINSTALLED_PACKAGES} is set, the application
6540 * information is retrieved from the list of uninstalled
6541 * applications (which includes installed applications as well as
6542 * applications with data directory i.e. applications which had been
6543 * deleted with {@code DELETE_KEEP_DATA} flag set).
6544 * @deprecated Use {@link #getInstalledApplicationsAsUser(ApplicationInfoFlags, int)} instead.
6545 * @hide
6546 */
6547 @SuppressWarnings("HiddenAbstractMethod")
6548 @NonNull
6549 @TestApi
6550 @Deprecated
6551 public abstract List<ApplicationInfo> getInstalledApplicationsAsUser(
6552 int flags, @UserIdInt int userId);
6553
6554 /**
6555 * See {@link #getInstalledApplicationsAsUser(int, int}.
6556 * @hide
6557 */
6558 @NonNull
6559 @TestApi
6560 public List<ApplicationInfo> getInstalledApplicationsAsUser(
6561 @NonNull ApplicationInfoFlags flags, @UserIdInt int userId) {
6562 throw new UnsupportedOperationException(
6563 "getInstalledApplicationsAsUser not implemented in subclass");
6564 }
6565
6566 /**
6567 * Gets the instant applications the user recently used.
6568 *
6569 * @return The instant app list.
6570 *
6571 * @hide
6572 */
6573 @SuppressWarnings("HiddenAbstractMethod")
6574 @SystemApi
6575 @RequiresPermission(Manifest.permission.ACCESS_INSTANT_APPS)
6576 public abstract @NonNull List<InstantAppInfo> getInstantApps();
6577
6578 /**
6579 * Gets the icon for an instant application.
6580 *
6581 * @param packageName The app package name.
6582 *
6583 * @hide
6584 */
6585 @SuppressWarnings("HiddenAbstractMethod")
6586 @SystemApi
6587 @RequiresPermission(Manifest.permission.ACCESS_INSTANT_APPS)
6588 public abstract @Nullable Drawable getInstantAppIcon(String packageName);
6589
6590 /**
6591 * Gets whether this application is an instant app.
6592 *
6593 * @return Whether caller is an instant app.
6594 *
6595 * @see #isInstantApp(String)
6596 * @see #updateInstantAppCookie(byte[])
6597 * @see #getInstantAppCookie()
6598 * @see #getInstantAppCookieMaxBytes()
6599 */
6600 public abstract boolean isInstantApp();
6601
6602 /**
6603 * Gets whether the given package is an instant app.
6604 *
6605 * @param packageName The package to check
6606 * @return Whether the given package is an instant app.
6607 *
6608 * @see #isInstantApp()
6609 * @see #updateInstantAppCookie(byte[])
6610 * @see #getInstantAppCookie()
6611 * @see #getInstantAppCookieMaxBytes()
6612 * @see #clearInstantAppCookie()
6613 */
6614 public abstract boolean isInstantApp(@NonNull String packageName);
6615
6616 /**
6617 * Gets the maximum size in bytes of the cookie data an instant app
6618 * can store on the device.
6619 *
6620 * @return The max cookie size in bytes.
6621 *
6622 * @see #isInstantApp()
6623 * @see #isInstantApp(String)
6624 * @see #updateInstantAppCookie(byte[])
6625 * @see #getInstantAppCookie()
6626 * @see #clearInstantAppCookie()
6627 */
6628 public abstract int getInstantAppCookieMaxBytes();
6629
6630 /**
6631 * deprecated
6632 * @hide
6633 */
6634 @SuppressWarnings("HiddenAbstractMethod")
6635 public abstract int getInstantAppCookieMaxSize();
6636
6637 /**
6638 * Gets the instant application cookie for this app. Non
6639 * instant apps and apps that were instant but were upgraded
6640 * to normal apps can still access this API. For instant apps
6641 * this cookie is cached for some time after uninstall while for
6642 * normal apps the cookie is deleted after the app is uninstalled.
6643 * The cookie is always present while the app is installed.
6644 *
6645 * @return The cookie.
6646 *
6647 * @see #isInstantApp()
6648 * @see #isInstantApp(String)
6649 * @see #updateInstantAppCookie(byte[])
6650 * @see #getInstantAppCookieMaxBytes()
6651 * @see #clearInstantAppCookie()
6652 */
6653 public abstract @NonNull byte[] getInstantAppCookie();
6654
6655 /**
6656 * Clears the instant application cookie for the calling app.
6657 *
6658 * @see #isInstantApp()
6659 * @see #isInstantApp(String)
6660 * @see #getInstantAppCookieMaxBytes()
6661 * @see #getInstantAppCookie()
6662 * @see #clearInstantAppCookie()
6663 */
6664 public abstract void clearInstantAppCookie();
6665
6666 /**
6667 * Updates the instant application cookie for the calling app. Non
6668 * instant apps and apps that were instant but were upgraded
6669 * to normal apps can still access this API. For instant apps
6670 * this cookie is cached for some time after uninstall while for
6671 * normal apps the cookie is deleted after the app is uninstalled.
6672 * The cookie is always present while the app is installed. The
6673 * cookie size is limited by {@link #getInstantAppCookieMaxBytes()}.
6674 * Passing <code>null</code> or an empty array clears the cookie.
6675 * </p>
6676 *
6677 * @param cookie The cookie data.
6678 *
6679 * @see #isInstantApp()
6680 * @see #isInstantApp(String)
6681 * @see #getInstantAppCookieMaxBytes()
6682 * @see #getInstantAppCookie()
6683 * @see #clearInstantAppCookie()
6684 *
6685 * @throws IllegalArgumentException if the array exceeds max cookie size.
6686 */
6687 public abstract void updateInstantAppCookie(@Nullable byte[] cookie);
6688
6689 /**
6690 * @removed
6691 */
6692 @SuppressWarnings("HiddenAbstractMethod")
6693 public abstract boolean setInstantAppCookie(@Nullable byte[] cookie);
6694
6695 /**
6696 * Get a list of shared libraries that are available on the
6697 * system.
6698 *
6699 * @return An array of shared library names that are
6700 * available on the system, or null if none are installed.
6701 *
6702 */
6703 @Nullable
6704 public abstract String[] getSystemSharedLibraryNames();
6705
6706 /**
6707 * Get a list of shared libraries on the device.
6708 *
6709 * @param flags To filter the libraries to return.
6710 * @return The shared library list.
6711 *
6712 * @see #MATCH_UNINSTALLED_PACKAGES
6713 * @deprecated Use {@link #getSharedLibraries(PackageInfoFlags)} instead.
6714 */
6715 @Deprecated
6716 public abstract @NonNull List<SharedLibraryInfo> getSharedLibraries(int flags);
6717
6718 /**
6719 * See {@link #getSharedLibraries(int)}.
6720 * @param flags
6721 */
6722 public @NonNull List<SharedLibraryInfo> getSharedLibraries(@NonNull PackageInfoFlags flags) {
6723 throw new UnsupportedOperationException(
6724 "getSharedLibraries() not implemented in subclass");
6725 }
6726
6727 /**
6728 * Get a list of shared libraries on the device.
6729 *
6730 * @param flags To filter the libraries to return.
6731 * @param userId The user to query for.
6732 * @return The shared library list.
6733 *
6734 * @see #MATCH_FACTORY_ONLY
6735 * @see #MATCH_KNOWN_PACKAGES
6736 * @see #MATCH_ANY_USER
6737 * @see #MATCH_UNINSTALLED_PACKAGES
6738 *
6739 * @hide
6740 * @deprecated Use {@link #getSharedLibrariesAsUser(PackageInfoFlags, int)} instead.
6741 */
6742 @Deprecated
6743 @SuppressWarnings("HiddenAbstractMethod")
6744 public abstract @NonNull List<SharedLibraryInfo> getSharedLibrariesAsUser(int flags,
6745 @UserIdInt int userId);
6746
6747 /**
6748 * See {@link #getSharedLibrariesAsUser(int, int)}.
6749 * @hide
6750 */
6751 public @NonNull List<SharedLibraryInfo> getSharedLibrariesAsUser(
6752 @NonNull PackageInfoFlags flags, @UserIdInt int userId) {
6753 throw new UnsupportedOperationException(
6754 "getSharedLibrariesAsUser() not implemented in subclass");
6755 }
6756
6757 /**
6758 * Get the list of shared libraries declared by a package.
6759 *
6760 * @param packageName the package name to query
6761 * @param flags the flags to filter packages
6762 * @return the shared library list
6763 *
6764 * @hide
6765 * @deprecated Use {@link #getDeclaredSharedLibraries(String, PackageInfoFlags)} instead.
6766 */
6767 @Deprecated
6768 @SuppressWarnings("HiddenAbstractMethod")
6769 @NonNull
6770 @RequiresPermission(Manifest.permission.ACCESS_SHARED_LIBRARIES)
6771 @SystemApi
6772 public List<SharedLibraryInfo> getDeclaredSharedLibraries(@NonNull String packageName,
6773 int flags) {
6774 throw new UnsupportedOperationException(
6775 "getDeclaredSharedLibraries() not implemented in subclass");
6776 }
6777
6778 /**
6779 * See {@link #getDeclaredSharedLibraries(String, int)}.
6780 * @hide
6781 */
6782 @NonNull
6783 @RequiresPermission(Manifest.permission.ACCESS_SHARED_LIBRARIES)
6784 @SystemApi
6785 public List<SharedLibraryInfo> getDeclaredSharedLibraries(@NonNull String packageName,
6786 @NonNull PackageInfoFlags flags) {
6787 throw new UnsupportedOperationException(
6788 "getDeclaredSharedLibraries() not implemented in subclass");
6789 }
6790
6791 /**
6792 * Get the name of the package hosting the services shared library.
6793 * <p>
6794 * Note that this package is no longer a shared library since Android R. It is now a package
6795 * that hosts for a bunch of updatable services that the system binds to.
6796 *
6797 * @return The library host package.
6798 *
6799 * @hide
6800 */
6801 @SuppressWarnings("HiddenAbstractMethod")
6802 @UnsupportedAppUsage
6803 @TestApi
6804 public abstract @NonNull String getServicesSystemSharedLibraryPackageName();
6805
6806 /**
6807 * Get the name of the package hosting the shared components shared library.
6808 *
6809 * @return The library host package.
6810 *
6811 * @hide
6812 */
6813 @SuppressWarnings("HiddenAbstractMethod")
6814 @UnsupportedAppUsage
6815 @TestApi
6816 public abstract @NonNull String getSharedSystemSharedLibraryPackageName();
6817
6818 /**
6819 * Returns the names of the packages that have been changed
6820 * [eg. added, removed or updated] since the given sequence
6821 * number.
6822 * <p>If no packages have been changed, returns <code>null</code>.
6823 * <p>The sequence number starts at <code>0</code> and is
6824 * reset every boot.
6825 * @param sequenceNumber The first sequence number for which to retrieve package changes.
6826 * @see android.provider.Settings.Global#BOOT_COUNT
6827 */
6828 public abstract @Nullable ChangedPackages getChangedPackages(
6829 @IntRange(from=0) int sequenceNumber);
6830
6831 /**
6832 * Get a list of features that are available on the
6833 * system.
6834 *
6835 * @return An array of FeatureInfo classes describing the features
6836 * that are available on the system, or null if there are none(!!).
6837 */
6838 @NonNull
6839 public abstract FeatureInfo[] getSystemAvailableFeatures();
6840
6841 /**
6842 * Check whether the given feature name is one of the available features as
6843 * returned by {@link #getSystemAvailableFeatures()}. This tests for the
6844 * presence of <em>any</em> version of the given feature name; use
6845 * {@link #hasSystemFeature(String, int)} to check for a minimum version.
6846 *
6847 * @return Returns true if the devices supports the feature, else false.
6848 */
6849 public abstract boolean hasSystemFeature(@NonNull String featureName);
6850
6851 /**
6852 * Check whether the given feature name and version is one of the available
6853 * features as returned by {@link #getSystemAvailableFeatures()}. Since
6854 * features are defined to always be backwards compatible, this returns true
6855 * if the available feature version is greater than or equal to the
6856 * requested version.
6857 *
6858 * @return Returns true if the devices supports the feature, else false.
6859 */
6860 public abstract boolean hasSystemFeature(@NonNull String featureName, int version);
6861
6862 /**
6863 * Determine the best action to perform for a given Intent. This is how
6864 * {@link Intent#resolveActivity} finds an activity if a class has not been
6865 * explicitly specified.
6866 * <p>
6867 * <em>Note:</em> if using an implicit Intent (without an explicit
6868 * ComponentName specified), be sure to consider whether to set the
6869 * {@link #MATCH_DEFAULT_ONLY} only flag. You need to do so to resolve the
6870 * activity in the same way that
6871 * {@link android.content.Context#startActivity(Intent)} and
6872 * {@link android.content.Intent#resolveActivity(PackageManager)
6873 * Intent.resolveActivity(PackageManager)} do.
6874 * </p>
6875 *
6876 * @param intent An intent containing all of the desired specification
6877 * (action, data, type, category, and/or component).
6878 * @param flags Additional option flags to modify the data returned. The
6879 * most important is {@link #MATCH_DEFAULT_ONLY}, to limit the
6880 * resolution to only those activities that support the
6881 * {@link android.content.Intent#CATEGORY_DEFAULT}.
6882 * @return Returns a ResolveInfo object containing the final activity intent
6883 * that was determined to be the best action. Returns null if no
6884 * matching activity was found. If multiple matching activities are
6885 * found and there is no default set, returns a ResolveInfo object
6886 * containing something else, such as the activity resolver.
6887 * @deprecated Use {@link #resolveActivity(Intent, ResolveInfoFlags)} instead.
6888 */
6889 @Deprecated
6890 @Nullable
6891 public abstract ResolveInfo resolveActivity(@NonNull Intent intent, int flags);
6892
6893 /**
6894 * See {@link #resolveActivity(Intent, int)}.
6895 */
6896 @Nullable
6897 public ResolveInfo resolveActivity(@NonNull Intent intent, @NonNull ResolveInfoFlags flags) {
6898 throw new UnsupportedOperationException(
6899 "resolveActivity not implemented in subclass");
6900 }
6901
6902 /**
6903 * Determine the best action to perform for a given Intent for a given user.
6904 * This is how {@link Intent#resolveActivity} finds an activity if a class
6905 * has not been explicitly specified.
6906 * <p>
6907 * <em>Note:</em> if using an implicit Intent (without an explicit
6908 * ComponentName specified), be sure to consider whether to set the
6909 * {@link #MATCH_DEFAULT_ONLY} only flag. You need to do so to resolve the
6910 * activity in the same way that
6911 * {@link android.content.Context#startActivity(Intent)} and
6912 * {@link android.content.Intent#resolveActivity(PackageManager)
6913 * Intent.resolveActivity(PackageManager)} do.
6914 * </p>
6915 *
6916 * @param intent An intent containing all of the desired specification
6917 * (action, data, type, category, and/or component).
6918 * @param flags Additional option flags to modify the data returned. The
6919 * most important is {@link #MATCH_DEFAULT_ONLY}, to limit the
6920 * resolution to only those activities that support the
6921 * {@link android.content.Intent#CATEGORY_DEFAULT}.
6922 * @param userId The user id.
6923 * @return Returns a ResolveInfo object containing the final activity intent
6924 * that was determined to be the best action. Returns null if no
6925 * matching activity was found. If multiple matching activities are
6926 * found and there is no default set, returns a ResolveInfo object
6927 * containing something else, such as the activity resolver.
6928 * @hide
6929 * @deprecated Use {@link #resolveActivityAsUser(Intent, ResolveInfoFlags, int)} instead.
6930 */
6931 @Deprecated
6932 @SuppressWarnings("HiddenAbstractMethod")
6933 @Nullable
6934 @UnsupportedAppUsage
6935 public abstract ResolveInfo resolveActivityAsUser(@NonNull Intent intent,
6936 int flags, @UserIdInt int userId);
6937
6938 /**
6939 * See {@link #resolveActivityAsUser(Intent, int, int)}.
6940 * @hide
6941 */
6942 @Nullable
6943 public ResolveInfo resolveActivityAsUser(@NonNull Intent intent,
6944 @NonNull ResolveInfoFlags flags, @UserIdInt int userId) {
6945 throw new UnsupportedOperationException(
6946 "resolveActivityAsUser not implemented in subclass");
6947 }
6948
6949 /**
6950 * Retrieve all activities that can be performed for the given intent.
6951 *
6952 * @param intent The desired intent as per resolveActivity().
6953 * @param flags Additional option flags to modify the data returned. The
6954 * most important is {@link #MATCH_DEFAULT_ONLY}, to limit the
6955 * resolution to only those activities that support the
6956 * {@link android.content.Intent#CATEGORY_DEFAULT}. Or, set
6957 * {@link #MATCH_ALL} to prevent any filtering of the results.
6958 * @return Returns a List of ResolveInfo objects containing one entry for
6959 * each matching activity, ordered from best to worst. In other
6960 * words, the first item is what would be returned by
6961 * {@link #resolveActivity}. If there are no matching activities, an
6962 * empty list is returned.
6963 * @deprecated Use {@link #queryIntentActivities(Intent, ResolveInfoFlags)} instead.
6964 */
6965 @Deprecated
6966 @NonNull
6967 public abstract List<ResolveInfo> queryIntentActivities(@NonNull Intent intent, int flags);
6968
6969 /**
6970 * See {@link #queryIntentActivities(Intent, int)}.
6971 */
6972 @NonNull
6973 public List<ResolveInfo> queryIntentActivities(@NonNull Intent intent,
6974 @NonNull ResolveInfoFlags flags) {
6975 throw new UnsupportedOperationException(
6976 "queryIntentActivities not implemented in subclass");
6977 }
6978
6979 /**
6980 * Retrieve all activities that can be performed for the given intent, for a
6981 * specific user.
6982 *
6983 * @param intent The desired intent as per resolveActivity().
6984 * @param flags Additional option flags to modify the data returned. The
6985 * most important is {@link #MATCH_DEFAULT_ONLY}, to limit the
6986 * resolution to only those activities that support the
6987 * {@link android.content.Intent#CATEGORY_DEFAULT}. Or, set
6988 * {@link #MATCH_ALL} to prevent any filtering of the results.
6989 * @return Returns a List of ResolveInfo objects containing one entry for
6990 * each matching activity, ordered from best to worst. In other
6991 * words, the first item is what would be returned by
6992 * {@link #resolveActivity}. If there are no matching activities, an
6993 * empty list is returned.
6994 * @hide
6995 * @deprecated Use {@link #queryIntentActivitiesAsUser(Intent, ResolveInfoFlags, int)} instead.
6996 */
6997 @Deprecated
6998 @SuppressWarnings("HiddenAbstractMethod")
6999 @NonNull
7000 @UnsupportedAppUsage
7001 public abstract List<ResolveInfo> queryIntentActivitiesAsUser(@NonNull Intent intent,
7002 int flags, @UserIdInt int userId);
7003
7004 /**
7005 * See {@link #queryIntentActivitiesAsUser(Intent, int, int)}.
7006 * @hide
7007 */
7008 @NonNull
7009 public List<ResolveInfo> queryIntentActivitiesAsUser(@NonNull Intent intent,
7010 @NonNull ResolveInfoFlags flags, @UserIdInt int userId) {
7011 throw new UnsupportedOperationException(
7012 "queryIntentActivitiesAsUser not implemented in subclass");
7013 }
7014
7015 /**
7016 * Retrieve all activities that can be performed for the given intent, for a
7017 * specific user.
7018 *
7019 * @param intent The desired intent as per resolveActivity().
7020 * @param flags Additional option flags to modify the data returned. The
7021 * most important is {@link #MATCH_DEFAULT_ONLY}, to limit the
7022 * resolution to only those activities that support the
7023 * {@link android.content.Intent#CATEGORY_DEFAULT}. Or, set
7024 * {@link #MATCH_ALL} to prevent any filtering of the results.
7025 * @param user The user being queried.
7026 * @return Returns a List of ResolveInfo objects containing one entry for
7027 * each matching activity, ordered from best to worst. In other
7028 * words, the first item is what would be returned by
7029 * {@link #resolveActivity}. If there are no matching activities, an
7030 * empty list is returned.
7031 * @hide
7032 * @deprecated Use {@link #queryIntentActivitiesAsUser(Intent, ResolveInfoFlags, UserHandle)}
7033 * instead.
7034 */
7035 @Deprecated
7036 @SuppressWarnings("HiddenAbstractMethod")
7037 @NonNull
7038 @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS)
7039 @SystemApi
7040 public List<ResolveInfo> queryIntentActivitiesAsUser(@NonNull Intent intent,
7041 int flags, @NonNull UserHandle user) {
7042 return queryIntentActivitiesAsUser(intent, flags, user.getIdentifier());
7043 }
7044
7045 /**
7046 * See {@link #queryIntentActivitiesAsUser(Intent, int, UserHandle)}.
7047 * @hide
7048 */
7049 @NonNull
7050 @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS)
7051 @SystemApi
7052 public List<ResolveInfo> queryIntentActivitiesAsUser(@NonNull Intent intent,
7053 @NonNull ResolveInfoFlags flags, @NonNull UserHandle user) {
7054 return queryIntentActivitiesAsUser(intent, flags, user.getIdentifier());
7055 }
7056
7057 /**
7058 * Retrieve a set of activities that should be presented to the user as
7059 * similar options. This is like {@link #queryIntentActivities}, except it
7060 * also allows you to supply a list of more explicit Intents that you would
7061 * like to resolve to particular options, and takes care of returning the
7062 * final ResolveInfo list in a reasonable order, with no duplicates, based
7063 * on those inputs.
7064 *
7065 * @param caller The class name of the activity that is making the request.
7066 * This activity will never appear in the output list. Can be
7067 * null.
7068 * @param specifics An array of Intents that should be resolved to the first
7069 * specific results. Can be null.
7070 * @param intent The desired intent as per resolveActivity().
7071 * @param flags Additional option flags to modify the data returned. The
7072 * most important is {@link #MATCH_DEFAULT_ONLY}, to limit the
7073 * resolution to only those activities that support the
7074 * {@link android.content.Intent#CATEGORY_DEFAULT}.
7075 * @return Returns a List of ResolveInfo objects containing one entry for
7076 * each matching activity. The list is ordered first by all of the
7077 * intents resolved in <var>specifics</var> and then any additional
7078 * activities that can handle <var>intent</var> but did not get
7079 * included by one of the <var>specifics</var> intents. If there are
7080 * no matching activities, an empty list is returned.
7081 * @deprecated Use {@link #queryIntentActivityOptions(ComponentName, List, Intent,
7082 * ResolveInfoFlags)} instead.
7083 */
7084 @Deprecated
7085 @NonNull
7086 public abstract List<ResolveInfo> queryIntentActivityOptions(@Nullable ComponentName caller,
7087 @Nullable Intent[] specifics, @NonNull Intent intent, int flags);
7088
7089 /**
7090 * See {@link #queryIntentActivityOptions(ComponentName, Intent[], Intent, int)}.
7091 */
7092 @NonNull
7093 public List<ResolveInfo> queryIntentActivityOptions(@Nullable ComponentName caller,
7094 @Nullable List<Intent> specifics, @NonNull Intent intent,
7095 @NonNull ResolveInfoFlags flags) {
7096 throw new UnsupportedOperationException(
7097 "queryIntentActivityOptions not implemented in subclass");
7098 }
7099
7100 /**
7101 * Retrieve all receivers that can handle a broadcast of the given intent.
7102 *
7103 * @param intent The desired intent as per resolveActivity().
7104 * @param flags Additional option flags to modify the data returned.
7105 * @return Returns a List of ResolveInfo objects containing one entry for
7106 * each matching receiver, ordered from best to worst. If there are
7107 * no matching receivers, an empty list or null is returned.
7108 * @deprecated Use {@link #queryBroadcastReceivers(Intent, ResolveInfoFlags)} instead.
7109 */
7110 @Deprecated
7111 @NonNull
7112 public abstract List<ResolveInfo> queryBroadcastReceivers(@NonNull Intent intent, int flags);
7113
7114 /**
7115 * See {@link #queryBroadcastReceivers(Intent, int)}.
7116 */
7117 @NonNull
7118 public List<ResolveInfo> queryBroadcastReceivers(@NonNull Intent intent,
7119 @NonNull ResolveInfoFlags flags) {
7120 throw new UnsupportedOperationException(
7121 "queryBroadcastReceivers not implemented in subclass");
7122 }
7123
7124 /**
7125 * Retrieve all receivers that can handle a broadcast of the given intent,
7126 * for a specific user.
7127 *
7128 * @param intent The desired intent as per resolveActivity().
7129 * @param flags Additional option flags to modify the data returned.
7130 * @param userHandle UserHandle of the user being queried.
7131 * @return Returns a List of ResolveInfo objects containing one entry for
7132 * each matching receiver, ordered from best to worst. If there are
7133 * no matching receivers, an empty list or null is returned.
7134 * @hide
7135 * @deprecated Use {@link #queryBroadcastReceiversAsUser(Intent, ResolveInfoFlags, UserHandle)}
7136 * instead.
7137 */
7138 @Deprecated
7139 @SuppressWarnings("HiddenAbstractMethod")
7140 @NonNull
7141 @SystemApi
7142 @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS)
7143 public List<ResolveInfo> queryBroadcastReceiversAsUser(@NonNull Intent intent,
7144 int flags, UserHandle userHandle) {
7145 return queryBroadcastReceiversAsUser(intent, flags, userHandle.getIdentifier());
7146 }
7147
7148 /**
7149 * See {@link #queryBroadcastReceiversAsUser(Intent, int, UserHandle)}.
7150 * @hide
7151 */
7152 @NonNull
7153 @SystemApi
7154 @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS)
7155 public List<ResolveInfo> queryBroadcastReceiversAsUser(@NonNull Intent intent,
7156 @NonNull ResolveInfoFlags flags, @NonNull UserHandle userHandle) {
7157 return queryBroadcastReceiversAsUser(intent, flags, userHandle.getIdentifier());
7158 }
7159
7160 /**
7161 * @hide
7162 * @deprecated Use {@link #queryBroadcastReceiversAsUser(Intent, ResolveInfoFlags, int)}
7163 * instead.
7164 */
7165 @Deprecated
7166 @SuppressWarnings("HiddenAbstractMethod")
7167 @NonNull
7168 @UnsupportedAppUsage
7169 public abstract List<ResolveInfo> queryBroadcastReceiversAsUser(@NonNull Intent intent,
7170 int flags, @UserIdInt int userId);
7171
7172 /**
7173 * See {@link #queryBroadcastReceiversAsUser(Intent, int, int)}.
7174 * @hide
7175 */
7176 @NonNull
7177 public List<ResolveInfo> queryBroadcastReceiversAsUser(@NonNull Intent intent,
7178 @NonNull ResolveInfoFlags flags, @UserIdInt int userId) {
7179 throw new UnsupportedOperationException(
7180 "queryBroadcastReceiversAsUser not implemented in subclass");
7181 }
7182
7183
7184 /** @deprecated @hide */
7185 @NonNull
7186 @Deprecated
7187 @UnsupportedAppUsage
7188 public List<ResolveInfo> queryBroadcastReceivers(@NonNull Intent intent,
7189 int flags, @UserIdInt int userId) {
7190 final String msg = "Shame on you for calling the hidden API "
7191 + "queryBroadcastReceivers(). Shame!";
7192 if (VMRuntime.getRuntime().getTargetSdkVersion() >= Build.VERSION_CODES.O) {
7193 throw new UnsupportedOperationException(msg);
7194 } else {
7195 Log.d(TAG, msg);
7196 return queryBroadcastReceiversAsUser(intent, flags, userId);
7197 }
7198 }
7199
7200 /**
7201 * Determine the best service to handle for a given Intent.
7202 *
7203 * @param intent An intent containing all of the desired specification
7204 * (action, data, type, category, and/or component).
7205 * @param flags Additional option flags to modify the data returned.
7206 * @return Returns a ResolveInfo object containing the final service intent
7207 * that was determined to be the best action. Returns null if no
7208 * matching service was found.
7209 * @deprecated Use {@link #resolveService(Intent, ResolveInfoFlags)} instead.
7210 */
7211 @Deprecated
7212 @Nullable
7213 public abstract ResolveInfo resolveService(@NonNull Intent intent, int flags);
7214
7215 /**
7216 * See {@link #resolveService(Intent, int)}.
7217 */
7218 @Nullable
7219 public ResolveInfo resolveService(@NonNull Intent intent, @NonNull ResolveInfoFlags flags) {
7220 throw new UnsupportedOperationException(
7221 "resolveService not implemented in subclass");
7222 }
7223
7224 /**
7225 * @hide
7226 * @deprecated Use {@link #resolveServiceAsUser(Intent, ResolveInfoFlags, int)} instead.
7227 */
7228 @Deprecated
7229 @SuppressWarnings("HiddenAbstractMethod")
7230 @Nullable
7231 public abstract ResolveInfo resolveServiceAsUser(@NonNull Intent intent,
7232 int flags, @UserIdInt int userId);
7233
7234 /**
7235 * See {@link #resolveServiceAsUser(Intent, int, int)}.
7236 * @hide
7237 */
7238 @Nullable
7239 public ResolveInfo resolveServiceAsUser(@NonNull Intent intent,
7240 @NonNull ResolveInfoFlags flags, @UserIdInt int userId) {
7241 throw new UnsupportedOperationException(
7242 "resolveServiceAsUser not implemented in subclass");
7243 }
7244
7245 /**
7246 * Retrieve all services that can match the given intent.
7247 *
7248 * @param intent The desired intent as per resolveService().
7249 * @param flags Additional option flags to modify the data returned.
7250 * @return Returns a List of ResolveInfo objects containing one entry for
7251 * each matching service, ordered from best to worst. In other
7252 * words, the first item is what would be returned by
7253 * {@link #resolveService}. If there are no matching services, an
7254 * empty list or null is returned.
7255 * @deprecated Use {@link #queryIntentServices(Intent, ResolveInfoFlags)} instead.
7256 */
7257 @Deprecated
7258 @NonNull
7259 public abstract List<ResolveInfo> queryIntentServices(@NonNull Intent intent,
7260 int flags);
7261
7262 /**
7263 * See {@link #queryIntentServices(Intent, int)}.
7264 */
7265 @NonNull
7266 public List<ResolveInfo> queryIntentServices(@NonNull Intent intent,
7267 @NonNull ResolveInfoFlags flags) {
7268 throw new UnsupportedOperationException(
7269 "queryIntentServices not implemented in subclass");
7270 }
7271
7272 /**
7273 * Retrieve all services that can match the given intent for a given user.
7274 *
7275 * @param intent The desired intent as per resolveService().
7276 * @param flags Additional option flags to modify the data returned.
7277 * @param userId The user id.
7278 * @return Returns a List of ResolveInfo objects containing one entry for
7279 * each matching service, ordered from best to worst. In other
7280 * words, the first item is what would be returned by
7281 * {@link #resolveService}. If there are no matching services, an
7282 * empty list or null is returned.
7283 * @hide
7284 * @deprecated Use {@link #queryIntentServicesAsUser(Intent, ResolveInfoFlags, int)} instead.
7285 */
7286 @Deprecated
7287 @SuppressWarnings("HiddenAbstractMethod")
7288 @NonNull
7289 @UnsupportedAppUsage
7290 public abstract List<ResolveInfo> queryIntentServicesAsUser(@NonNull Intent intent,
7291 int flags, @UserIdInt int userId);
7292
7293 /**
7294 * See {@link #queryIntentServicesAsUser(Intent, int, int)}.
7295 * @hide
7296 */
7297 @NonNull
7298 public List<ResolveInfo> queryIntentServicesAsUser(@NonNull Intent intent,
7299 @NonNull ResolveInfoFlags flags, @UserIdInt int userId) {
7300 throw new UnsupportedOperationException(
7301 "queryIntentServicesAsUser not implemented in subclass");
7302 }
7303
7304 /**
7305 * Retrieve all services that can match the given intent for a given user.
7306 *
7307 * @param intent The desired intent as per resolveService().
7308 * @param flags Additional option flags to modify the data returned.
7309 * @param user The user being queried.
7310 * @return Returns a List of ResolveInfo objects containing one entry for
7311 * each matching service, ordered from best to worst. In other
7312 * words, the first item is what would be returned by
7313 * {@link #resolveService}. If there are no matching services, an
7314 * empty list or null is returned.
7315 * @hide
7316 * @deprecated Use {@link #queryIntentServicesAsUser(Intent, ResolveInfoFlags, UserHandle)}
7317 * instead.
7318 */
7319 @Deprecated
7320 @NonNull
7321 @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS)
7322 @SystemApi
7323 public List<ResolveInfo> queryIntentServicesAsUser(@NonNull Intent intent,
7324 int flags, @NonNull UserHandle user) {
7325 return queryIntentServicesAsUser(intent, flags, user.getIdentifier());
7326 }
7327
7328 /**
7329 * See {@link #queryIntentServicesAsUser(Intent, int, UserHandle)}.
7330 * @hide
7331 */
7332 @NonNull
7333 @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS)
7334 @SystemApi
7335 public List<ResolveInfo> queryIntentServicesAsUser(@NonNull Intent intent,
7336 @NonNull ResolveInfoFlags flags, @NonNull UserHandle user) {
7337 return queryIntentServicesAsUser(intent, flags, user.getIdentifier());
7338 }
7339 /**
7340 * Retrieve all providers that can match the given intent.
7341 *
7342 * @param intent An intent containing all of the desired specification
7343 * (action, data, type, category, and/or component).
7344 * @param flags Additional option flags to modify the data returned.
7345 * @param userId The user id.
7346 * @return Returns a List of ResolveInfo objects containing one entry for
7347 * each matching provider, ordered from best to worst. If there are
7348 * no matching services, an empty list or null is returned.
7349 * @hide
7350 * @deprecated Use {@link #queryIntentContentProvidersAsUser(Intent, ResolveInfoFlags, int)}
7351 * instead.
7352 */
7353 @Deprecated
7354 @SuppressWarnings("HiddenAbstractMethod")
7355 @NonNull
7356 @UnsupportedAppUsage
7357 public abstract List<ResolveInfo> queryIntentContentProvidersAsUser(
7358 @NonNull Intent intent, int flags, @UserIdInt int userId);
7359
7360 /**
7361 * See {@link #queryIntentContentProvidersAsUser(Intent, int, int)}.
7362 * @hide
7363 */
7364 @NonNull
7365 protected List<ResolveInfo> queryIntentContentProvidersAsUser(
7366 @NonNull Intent intent, @NonNull ResolveInfoFlags flags, @UserIdInt int userId) {
7367 throw new UnsupportedOperationException(
7368 "queryIntentContentProvidersAsUser not implemented in subclass");
7369 }
7370
7371 /**
7372 * Retrieve all providers that can match the given intent.
7373 *
7374 * @param intent An intent containing all of the desired specification
7375 * (action, data, type, category, and/or component).
7376 * @param flags Additional option flags to modify the data returned.
7377 * @param user The user being queried.
7378 * @return Returns a List of ResolveInfo objects containing one entry for
7379 * each matching provider, ordered from best to worst. If there are
7380 * no matching services, an empty list or null is returned.
7381 * @hide
7382 * @deprecated Use {@link #queryIntentContentProvidersAsUser(Intent, ResolveInfoFlags,
7383 * UserHandle)} instead.
7384 */
7385 @Deprecated
7386 @NonNull
7387 @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS)
7388 @SystemApi
7389 public List<ResolveInfo> queryIntentContentProvidersAsUser(@NonNull Intent intent,
7390 int flags, @NonNull UserHandle user) {
7391 return queryIntentContentProvidersAsUser(intent, flags, user.getIdentifier());
7392 }
7393
7394 /**
7395 * See {@link #queryIntentContentProvidersAsUser(Intent, int, UserHandle)}.
7396 * @hide
7397 */
7398 @NonNull
7399 @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS)
7400 @SystemApi
7401 public List<ResolveInfo> queryIntentContentProvidersAsUser(@NonNull Intent intent,
7402 @NonNull ResolveInfoFlags flags, @NonNull UserHandle user) {
7403 return queryIntentContentProvidersAsUser(intent, flags, user.getIdentifier());
7404 }
7405
7406 /**
7407 * Retrieve all providers that can match the given intent.
7408 *
7409 * @param intent An intent containing all of the desired specification
7410 * (action, data, type, category, and/or component).
7411 * @param flags Additional option flags to modify the data returned.
7412 * @return Returns a List of ResolveInfo objects containing one entry for
7413 * each matching provider, ordered from best to worst. If there are
7414 * no matching services, an empty list or null is returned.
7415 * @deprecated Use {@link #queryIntentContentProviders(Intent, ResolveInfoFlags)} instead.
7416 */
7417 @Deprecated
7418 @NonNull
7419 public abstract List<ResolveInfo> queryIntentContentProviders(@NonNull Intent intent,
7420 int flags);
7421
7422 /**
7423 * See {@link #queryIntentContentProviders(Intent, int)}.
7424 */
7425 @NonNull
7426 public List<ResolveInfo> queryIntentContentProviders(@NonNull Intent intent,
7427 @NonNull ResolveInfoFlags flags) {
7428 throw new UnsupportedOperationException(
7429 "queryIntentContentProviders not implemented in subclass");
7430 }
7431
7432 /**
7433 * Find a single content provider by its authority.
7434 * <p>
7435 * Example:<p>
7436 * <pre>
7437 * Uri uri = Uri.parse("content://com.example.app.provider/table1");
7438 * ProviderInfo info = packageManager.resolveContentProvider(uri.getAuthority(), flags);
7439 * </pre>
7440 *
7441 * @param authority The authority of the provider to find.
7442 * @param flags Additional option flags to modify the data returned.
7443 * @return A {@link ProviderInfo} object containing information about the
7444 * provider. If a provider was not found, returns null.
7445 * @deprecated Use {@link #resolveContentProvider(String, ComponentInfoFlags)} instead.
7446 */
7447 @Deprecated
7448 @Nullable
7449 public abstract ProviderInfo resolveContentProvider(@NonNull String authority,
7450 int flags);
7451
7452 /**
7453 * See {@link #resolveContentProvider(String, int)}.
7454 */
7455 @Nullable
7456 public ProviderInfo resolveContentProvider(@NonNull String authority,
7457 @NonNull ComponentInfoFlags flags) {
7458 throw new UnsupportedOperationException(
7459 "resolveContentProvider not implemented in subclass");
7460 }
7461
7462 /**
7463 * Find a single content provider by its base path name.
7464 *
7465 * @param providerName The name of the provider to find.
7466 * @param flags Additional option flags to modify the data returned.
7467 * @param userId The user id.
7468 * @return A {@link ProviderInfo} object containing information about the
7469 * provider. If a provider was not found, returns null.
7470 * @hide
7471 * @deprecated Use {@link #resolveContentProviderAsUser(String, ComponentInfoFlags, int)}
7472 * instead.
7473 */
7474 @SuppressWarnings("HiddenAbstractMethod")
7475 @Nullable
7476 @UnsupportedAppUsage
7477 public abstract ProviderInfo resolveContentProviderAsUser(@NonNull String providerName,
7478 int flags, @UserIdInt int userId);
7479
7480 /**
7481 * See {@link #resolveContentProviderAsUser(String, int, int)}.
7482 * @hide
7483 */
7484 @Nullable
7485 public ProviderInfo resolveContentProviderAsUser(@NonNull String providerName,
7486 @NonNull ComponentInfoFlags flags, @UserIdInt int userId) {
7487 throw new UnsupportedOperationException(
7488 "resolveContentProviderAsUser not implemented in subclass");
7489 }
7490
7491 /**
7492 * Retrieve content provider information.
7493 * <p>
7494 * <em>Note: unlike most other methods, an empty result set is indicated
7495 * by a null return instead of an empty list.</em>
7496 *
7497 * @param processName If non-null, limits the returned providers to only
7498 * those that are hosted by the given process. If null, all
7499 * content providers are returned.
7500 * @param uid If <var>processName</var> is non-null, this is the required
7501 * uid owning the requested content providers.
7502 * @param flags Additional option flags to modify the data returned.
7503 * @return A list of {@link ProviderInfo} objects containing one entry for
7504 * each provider either matching <var>processName</var> or, if
7505 * <var>processName</var> is null, all known content providers.
7506 * <em>If there are no matching providers, null is returned.</em>
7507 * @deprecated Use {@link #queryContentProviders(String, int, ComponentInfoFlags)} instead.
7508 */
7509 @Deprecated
7510 @NonNull
7511 public abstract List<ProviderInfo> queryContentProviders(
7512 @Nullable String processName, int uid, int flags);
7513
7514 /**
7515 * See {@link #queryContentProviders(String, int, int)}.
7516 */
7517 @NonNull
7518 public List<ProviderInfo> queryContentProviders(
7519 @Nullable String processName, int uid, @NonNull ComponentInfoFlags flags) {
7520 throw new UnsupportedOperationException(
7521 "queryContentProviders not implemented in subclass");
7522 }
7523
7524 /**
7525 * Same as {@link #queryContentProviders}, except when {@code metaDataKey} is not null,
7526 * it only returns providers which have metadata with the {@code metaDataKey} key.
7527 *
7528 * <p>DO NOT USE the {@code metaDataKey} parameter, unless you're the contacts provider.
7529 * You really shouldn't need it. Other apps should use {@link #queryIntentContentProviders}
7530 * instead.
7531 *
7532 * <p>The {@code metaDataKey} parameter was added to allow the contacts provider to quickly
7533 * scan the GAL providers on the device. Unfortunately the discovery protocol used metadata
7534 * to mark GAL providers, rather than intent filters, so we can't use
7535 * {@link #queryIntentContentProviders} for that.
7536 *
7537 * @hide
7538 * @deprecated Use {@link #queryContentProviders(String, int, ComponentInfoFlags, String)}
7539 * instead.
7540 */
7541 @Deprecated
7542 @NonNull
7543 public List<ProviderInfo> queryContentProviders(@Nullable String processName,
7544 int uid, int flags, String metaDataKey) {
7545 // Provide the default implementation for mocks.
7546 return queryContentProviders(processName, uid, flags);
7547 }
7548
7549 /**
7550 * See {@link #queryContentProviders(String, int, int, String)}.
7551 * @hide
7552 */
7553 @NonNull
7554 public List<ProviderInfo> queryContentProviders(@Nullable String processName,
7555 int uid, @NonNull ComponentInfoFlags flags, @Nullable String metaDataKey) {
7556 // Provide the default implementation for mocks.
7557 return queryContentProviders(processName, uid, flags);
7558 }
7559
7560 /**
7561 * Retrieve all of the information we know about a particular
7562 * instrumentation class.
7563 *
7564 * @param className The full name (i.e.
7565 * com.google.apps.contacts.InstrumentList) of an Instrumentation
7566 * class.
7567 * @param flags Additional option flags to modify the data returned.
7568 * @return An {@link InstrumentationInfo} object containing information
7569 * about the instrumentation.
7570 * @throws NameNotFoundException if a package with the given name cannot be
7571 * found on the system.
7572 */
7573 @NonNull
7574 public abstract InstrumentationInfo getInstrumentationInfo(@NonNull ComponentName className,
7575 @InstrumentationInfoFlags int flags) throws NameNotFoundException;
7576
7577 /**
7578 * Retrieve information about available instrumentation code. May be used to
7579 * retrieve either all instrumentation code, or only the code targeting a
7580 * particular package.
7581 *
7582 * @param targetPackage If null, all instrumentation is returned; only the
7583 * instrumentation targeting this package name is returned.
7584 * @param flags Additional option flags to modify the data returned.
7585 * @return A list of {@link InstrumentationInfo} objects containing one
7586 * entry for each matching instrumentation. If there are no
7587 * instrumentation available, returns an empty list.
7588 */
7589 @NonNull
7590 public abstract List<InstrumentationInfo> queryInstrumentation(@NonNull String targetPackage,
7591 @InstrumentationInfoFlags int flags);
7592
7593 /**
7594 * Retrieve an image from a package. This is a low-level API used by
7595 * the various package manager info structures (such as
7596 * {@link ComponentInfo} to implement retrieval of their associated
7597 * icon.
7598 *
7599 * @param packageName The name of the package that this icon is coming from.
7600 * Cannot be null.
7601 * @param resid The resource identifier of the desired image. Cannot be 0.
7602 * @param appInfo Overall information about <var>packageName</var>. This
7603 * may be null, in which case the application information will be retrieved
7604 * for you if needed; if you already have this information around, it can
7605 * be much more efficient to supply it here.
7606 *
7607 * @return Returns a Drawable holding the requested image. Returns null if
7608 * an image could not be found for any reason.
7609 */
7610 @Nullable
7611 public abstract Drawable getDrawable(@NonNull String packageName, @DrawableRes int resid,
7612 @Nullable ApplicationInfo appInfo);
7613
7614 /**
7615 * Retrieve the icon associated with an activity. Given the full name of
7616 * an activity, retrieves the information about it and calls
7617 * {@link ComponentInfo#loadIcon ComponentInfo.loadIcon()} to return its icon.
7618 * If the activity cannot be found, NameNotFoundException is thrown.
7619 *
7620 * @param activityName Name of the activity whose icon is to be retrieved.
7621 *
7622 * @return Returns the image of the icon, or the default activity icon if
7623 * it could not be found. Does not return null.
7624 * @throws NameNotFoundException Thrown if the resources for the given
7625 * activity could not be loaded.
7626 *
7627 * @see #getActivityIcon(Intent)
7628 */
7629 @NonNull
7630 public abstract Drawable getActivityIcon(@NonNull ComponentName activityName)
7631 throws NameNotFoundException;
7632
7633 /**
7634 * Retrieve the icon associated with an Intent. If intent.getClassName() is
7635 * set, this simply returns the result of
7636 * getActivityIcon(intent.getClassName()). Otherwise it resolves the intent's
7637 * component and returns the icon associated with the resolved component.
7638 * If intent.getClassName() cannot be found or the Intent cannot be resolved
7639 * to a component, NameNotFoundException is thrown.
7640 *
7641 * @param intent The intent for which you would like to retrieve an icon.
7642 *
7643 * @return Returns the image of the icon, or the default activity icon if
7644 * it could not be found. Does not return null.
7645 * @throws NameNotFoundException Thrown if the resources for application
7646 * matching the given intent could not be loaded.
7647 *
7648 * @see #getActivityIcon(ComponentName)
7649 */
7650 @NonNull
7651 public abstract Drawable getActivityIcon(@NonNull Intent intent)
7652 throws NameNotFoundException;
7653
7654 /**
7655 * Retrieve the banner associated with an activity. Given the full name of
7656 * an activity, retrieves the information about it and calls
7657 * {@link ComponentInfo#loadIcon ComponentInfo.loadIcon()} to return its
7658 * banner. If the activity cannot be found, NameNotFoundException is thrown.
7659 *
7660 * @param activityName Name of the activity whose banner is to be retrieved.
7661 * @return Returns the image of the banner, or null if the activity has no
7662 * banner specified.
7663 * @throws NameNotFoundException Thrown if the resources for the given
7664 * activity could not be loaded.
7665 * @see #getActivityBanner(Intent)
7666 */
7667 @Nullable
7668 public abstract Drawable getActivityBanner(@NonNull ComponentName activityName)
7669 throws NameNotFoundException;
7670
7671 /**
7672 * Retrieve the banner associated with an Intent. If intent.getClassName()
7673 * is set, this simply returns the result of
7674 * getActivityBanner(intent.getClassName()). Otherwise it resolves the
7675 * intent's component and returns the banner associated with the resolved
7676 * component. If intent.getClassName() cannot be found or the Intent cannot
7677 * be resolved to a component, NameNotFoundException is thrown.
7678 *
7679 * @param intent The intent for which you would like to retrieve a banner.
7680 * @return Returns the image of the banner, or null if the activity has no
7681 * banner specified.
7682 * @throws NameNotFoundException Thrown if the resources for application
7683 * matching the given intent could not be loaded.
7684 * @see #getActivityBanner(ComponentName)
7685 */
7686 @Nullable
7687 public abstract Drawable getActivityBanner(@NonNull Intent intent)
7688 throws NameNotFoundException;
7689
7690 /**
7691 * Return the generic icon for an activity that is used when no specific
7692 * icon is defined.
7693 *
7694 * @return Drawable Image of the icon.
7695 */
7696 @NonNull
7697 public abstract Drawable getDefaultActivityIcon();
7698
7699 /**
7700 * Retrieve the icon associated with an application. If it has not defined
7701 * an icon, the default app icon is returned. Does not return null.
7702 *
7703 * @param info Information about application being queried.
7704 *
7705 * @return Returns the image of the icon, or the default application icon
7706 * if it could not be found.
7707 *
7708 * @see #getApplicationIcon(String)
7709 */
7710 @NonNull
7711 public abstract Drawable getApplicationIcon(@NonNull ApplicationInfo info);
7712
7713 /**
7714 * Retrieve the icon associated with an application. Given the name of the
7715 * application's package, retrieves the information about it and calls
7716 * getApplicationIcon() to return its icon. If the application cannot be
7717 * found, NameNotFoundException is thrown.
7718 *
7719 * @param packageName Name of the package whose application icon is to be
7720 * retrieved.
7721 *
7722 * @return Returns the image of the icon, or the default application icon
7723 * if it could not be found. Does not return null.
7724 * @throws NameNotFoundException Thrown if the resources for the given
7725 * application could not be loaded.
7726 *
7727 * @see #getApplicationIcon(ApplicationInfo)
7728 */
7729 @NonNull
7730 public abstract Drawable getApplicationIcon(@NonNull String packageName)
7731 throws NameNotFoundException;
7732
7733 /**
7734 * Retrieve the banner associated with an application.
7735 *
7736 * @param info Information about application being queried.
7737 * @return Returns the image of the banner or null if the application has no
7738 * banner specified.
7739 * @see #getApplicationBanner(String)
7740 */
7741 @Nullable
7742 public abstract Drawable getApplicationBanner(@NonNull ApplicationInfo info);
7743
7744 /**
7745 * Retrieve the banner associated with an application. Given the name of the
7746 * application's package, retrieves the information about it and calls
7747 * getApplicationIcon() to return its banner. If the application cannot be
7748 * found, NameNotFoundException is thrown.
7749 *
7750 * @param packageName Name of the package whose application banner is to be
7751 * retrieved.
7752 * @return Returns the image of the banner or null if the application has no
7753 * banner specified.
7754 * @throws NameNotFoundException Thrown if the resources for the given
7755 * application could not be loaded.
7756 * @see #getApplicationBanner(ApplicationInfo)
7757 */
7758 @Nullable
7759 public abstract Drawable getApplicationBanner(@NonNull String packageName)
7760 throws NameNotFoundException;
7761
7762 /**
7763 * Retrieve the logo associated with an activity. Given the full name of an
7764 * activity, retrieves the information about it and calls
7765 * {@link ComponentInfo#loadLogo ComponentInfo.loadLogo()} to return its
7766 * logo. If the activity cannot be found, NameNotFoundException is thrown.
7767 *
7768 * @param activityName Name of the activity whose logo is to be retrieved.
7769 * @return Returns the image of the logo or null if the activity has no logo
7770 * specified.
7771 * @throws NameNotFoundException Thrown if the resources for the given
7772 * activity could not be loaded.
7773 * @see #getActivityLogo(Intent)
7774 */
7775 @Nullable
7776 public abstract Drawable getActivityLogo(@NonNull ComponentName activityName)
7777 throws NameNotFoundException;
7778
7779 /**
7780 * Retrieve the logo associated with an Intent. If intent.getClassName() is
7781 * set, this simply returns the result of
7782 * getActivityLogo(intent.getClassName()). Otherwise it resolves the intent's
7783 * component and returns the logo associated with the resolved component.
7784 * If intent.getClassName() cannot be found or the Intent cannot be resolved
7785 * to a component, NameNotFoundException is thrown.
7786 *
7787 * @param intent The intent for which you would like to retrieve a logo.
7788 *
7789 * @return Returns the image of the logo, or null if the activity has no
7790 * logo specified.
7791 *
7792 * @throws NameNotFoundException Thrown if the resources for application
7793 * matching the given intent could not be loaded.
7794 *
7795 * @see #getActivityLogo(ComponentName)
7796 */
7797 @Nullable
7798 public abstract Drawable getActivityLogo(@NonNull Intent intent)
7799 throws NameNotFoundException;
7800
7801 /**
7802 * Retrieve the logo associated with an application. If it has not specified
7803 * a logo, this method returns null.
7804 *
7805 * @param info Information about application being queried.
7806 *
7807 * @return Returns the image of the logo, or null if no logo is specified
7808 * by the application.
7809 *
7810 * @see #getApplicationLogo(String)
7811 */
7812 @Nullable
7813 public abstract Drawable getApplicationLogo(@NonNull ApplicationInfo info);
7814
7815 /**
7816 * Retrieve the logo associated with an application. Given the name of the
7817 * application's package, retrieves the information about it and calls
7818 * getApplicationLogo() to return its logo. If the application cannot be
7819 * found, NameNotFoundException is thrown.
7820 *
7821 * @param packageName Name of the package whose application logo is to be
7822 * retrieved.
7823 *
7824 * @return Returns the image of the logo, or null if no application logo
7825 * has been specified.
7826 *
7827 * @throws NameNotFoundException Thrown if the resources for the given
7828 * application could not be loaded.
7829 *
7830 * @see #getApplicationLogo(ApplicationInfo)
7831 */
7832 @Nullable
7833 public abstract Drawable getApplicationLogo(@NonNull String packageName)
7834 throws NameNotFoundException;
7835
7836 /**
7837 * If the target user is a managed profile, then this returns a badged copy of the given icon
7838 * to be able to distinguish it from the original icon. For badging an arbitrary drawable use
7839 * {@link #getUserBadgedDrawableForDensity(
7840 * android.graphics.drawable.Drawable, UserHandle, android.graphics.Rect, int)}.
7841 * <p>
7842 * If the original drawable is a BitmapDrawable and the backing bitmap is
7843 * mutable as per {@link android.graphics.Bitmap#isMutable()}, the badging
7844 * is performed in place and the original drawable is returned.
7845 * </p>
7846 *
7847 * @param drawable The drawable to badge.
7848 * @param user The target user.
7849 * @return A drawable that combines the original icon and a badge as
7850 * determined by the system.
7851 */
7852 @NonNull
7853 public abstract Drawable getUserBadgedIcon(@NonNull Drawable drawable,
7854 @NonNull UserHandle user);
7855
7856 /**
7857 * If the target user is a managed profile of the calling user or the caller
7858 * is itself a managed profile, then this returns a badged copy of the given
7859 * drawable allowing the user to distinguish it from the original drawable.
7860 * The caller can specify the location in the bounds of the drawable to be
7861 * badged where the badge should be applied as well as the density of the
7862 * badge to be used.
7863 * <p>
7864 * If the original drawable is a BitmapDrawable and the backing bitmap is
7865 * mutable as per {@link android.graphics.Bitmap#isMutable()}, the badging
7866 * is performed in place and the original drawable is returned.
7867 * </p>
7868 *
7869 * @param drawable The drawable to badge.
7870 * @param user The target user.
7871 * @param badgeLocation Where in the bounds of the badged drawable to place
7872 * the badge. If it's {@code null}, the badge is applied on top of the entire
7873 * drawable being badged.
7874 * @param badgeDensity The optional desired density for the badge as per
7875 * {@link android.util.DisplayMetrics#densityDpi}. If it's not positive,
7876 * the density of the display is used.
7877 * @return A drawable that combines the original drawable and a badge as
7878 * determined by the system.
7879 */
7880 @NonNull
7881 public abstract Drawable getUserBadgedDrawableForDensity(@NonNull Drawable drawable,
7882 @NonNull UserHandle user, @Nullable Rect badgeLocation, int badgeDensity);
7883
7884 /**
7885 * If the target user is a managed profile of the calling user or the caller
7886 * is itself a managed profile, then this returns a drawable to use as a small
7887 * icon to include in a view to distinguish it from the original icon.
7888 *
7889 * @param user The target user.
7890 * @param density The optional desired density for the badge as per
7891 * {@link android.util.DisplayMetrics#densityDpi}. If not provided
7892 * the density of the current display is used.
7893 * @return the drawable or null if no drawable is required.
7894 * @hide
7895 */
7896 @SuppressWarnings("HiddenAbstractMethod")
7897 @Nullable
7898 @UnsupportedAppUsage
7899 public abstract Drawable getUserBadgeForDensity(@NonNull UserHandle user, int density);
7900
7901 /**
7902 * If the target user is a managed profile of the calling user or the caller
7903 * is itself a managed profile, then this returns a drawable to use as a small
7904 * icon to include in a view to distinguish it from the original icon. This version
7905 * doesn't have background protection and should be used over a light background instead of
7906 * a badge.
7907 *
7908 * @param user The target user.
7909 * @param density The optional desired density for the badge as per
7910 * {@link android.util.DisplayMetrics#densityDpi}. If not provided
7911 * the density of the current display is used.
7912 * @return the drawable or null if no drawable is required.
7913 * @hide
7914 */
7915 @SuppressWarnings("HiddenAbstractMethod")
7916 @Nullable
7917 @UnsupportedAppUsage
7918 public abstract Drawable getUserBadgeForDensityNoBackground(@NonNull UserHandle user,
7919 int density);
7920
7921 /**
7922 * If the target user is a managed profile of the calling user or the caller
7923 * is itself a managed profile, then this returns a copy of the label with
7924 * badging for accessibility services like talkback. E.g. passing in "Email"
7925 * and it might return "Work Email" for Email in the work profile.
7926 *
7927 * @param label The label to change.
7928 * @param user The target user.
7929 * @return A label that combines the original label and a badge as
7930 * determined by the system.
7931 */
7932 @NonNull
7933 public abstract CharSequence getUserBadgedLabel(@NonNull CharSequence label,
7934 @NonNull UserHandle user);
7935
7936 /**
7937 * Retrieve text from a package. This is a low-level API used by
7938 * the various package manager info structures (such as
7939 * {@link ComponentInfo} to implement retrieval of their associated
7940 * labels and other text.
7941 *
7942 * @param packageName The name of the package that this text is coming from.
7943 * Cannot be null.
7944 * @param resid The resource identifier of the desired text. Cannot be 0.
7945 * @param appInfo Overall information about <var>packageName</var>. This
7946 * may be null, in which case the application information will be retrieved
7947 * for you if needed; if you already have this information around, it can
7948 * be much more efficient to supply it here.
7949 *
7950 * @return Returns a CharSequence holding the requested text. Returns null
7951 * if the text could not be found for any reason.
7952 */
7953 @Nullable
7954 public abstract CharSequence getText(@NonNull String packageName, @StringRes int resid,
7955 @Nullable ApplicationInfo appInfo);
7956
7957 /**
7958 * Retrieve an XML file from a package. This is a low-level API used to
7959 * retrieve XML meta data.
7960 *
7961 * @param packageName The name of the package that this xml is coming from.
7962 * Cannot be null.
7963 * @param resid The resource identifier of the desired xml. Cannot be 0.
7964 * @param appInfo Overall information about <var>packageName</var>. This
7965 * may be null, in which case the application information will be retrieved
7966 * for you if needed; if you already have this information around, it can
7967 * be much more efficient to supply it here.
7968 *
7969 * @return Returns an XmlPullParser allowing you to parse out the XML
7970 * data. Returns null if the xml resource could not be found for any
7971 * reason.
7972 */
7973 @Nullable
7974 public abstract XmlResourceParser getXml(@NonNull String packageName, @XmlRes int resid,
7975 @Nullable ApplicationInfo appInfo);
7976
7977 /**
7978 * Return the label to use for this application.
7979 *
7980 * @return Returns a {@link CharSequence} containing the label associated with
7981 * this application, or its name the item does not have a label.
7982 * @param info The {@link ApplicationInfo} of the application to get the label of.
7983 */
7984 @NonNull
7985 public abstract CharSequence getApplicationLabel(@NonNull ApplicationInfo info);
7986
7987 /**
7988 * Retrieve the resources associated with an activity. Given the full
7989 * name of an activity, retrieves the information about it and calls
7990 * getResources() to return its application's resources. If the activity
7991 * cannot be found, NameNotFoundException is thrown.
7992 *
7993 * @param activityName Name of the activity whose resources are to be
7994 * retrieved.
7995 *
7996 * @return Returns the application's Resources.
7997 * @throws NameNotFoundException Thrown if the resources for the given
7998 * application could not be loaded.
7999 *
8000 * @see #getResourcesForApplication(ApplicationInfo)
8001 */
8002 @NonNull
8003 public abstract Resources getResourcesForActivity(@NonNull ComponentName activityName)
8004 throws NameNotFoundException;
8005
8006 /**
8007 * Retrieve the resources for an application. Throws NameNotFoundException
8008 * if the package is no longer installed.
8009 *
8010 * @param app Information about the desired application.
8011 *
8012 * @return Returns the application's Resources.
8013 * @throws NameNotFoundException Thrown if the resources for the given
8014 * application could not be loaded (most likely because it was uninstalled).
8015 */
8016 @NonNull
8017 public abstract Resources getResourcesForApplication(@NonNull ApplicationInfo app)
8018 throws NameNotFoundException;
8019
8020 /**
8021 * Retrieve the resources for an application for the provided configuration.
8022 *
8023 * @param app Information about the desired application.
8024 * @param configuration Overridden configuration when loading the Resources
8025 *
8026 * @return Returns the application's Resources.
8027 * @throws NameNotFoundException Thrown if the resources for the given
8028 * application could not be loaded (most likely because it was uninstalled).
8029 */
8030 @NonNull
8031 public Resources getResourcesForApplication(@NonNull ApplicationInfo app, @Nullable
8032 Configuration configuration) throws NameNotFoundException {
8033 return getResourcesForApplication(app);
8034 }
8035
8036 /**
8037 * Retrieve the resources associated with an application. Given the full
8038 * package name of an application, retrieves the information about it and
8039 * calls getResources() to return its application's resources. If the
8040 * appPackageName cannot be found, NameNotFoundException is thrown.
8041 *
8042 * @param packageName Package name of the application whose resources
8043 * are to be retrieved.
8044 *
8045 * @return Returns the application's Resources.
8046 * @throws NameNotFoundException Thrown if the resources for the given
8047 * application could not be loaded.
8048 *
8049 * @see #getResourcesForApplication(ApplicationInfo)
8050 */
8051 @NonNull
8052 public abstract Resources getResourcesForApplication(@NonNull String packageName)
8053 throws NameNotFoundException;
8054
8055 /**
8056 * Please don't use this function because it is no longer supported.
8057 *
8058 * @deprecated Instead of using this function, please use
8059 * {@link Context#createContextAsUser(UserHandle, int)} to create the specified user
8060 * context, {@link Context#getPackageManager()} to get PackageManager instance for
8061 * the specified user, and then
8062 * {@link PackageManager#getResourcesForApplication(String)} to get the same
8063 * Resources instance.
8064 * @see {@link Context#createContextAsUser(android.os.UserHandle, int)}
8065 * @see {@link Context#getPackageManager()}
8066 * @see {@link android.content.pm.PackageManager#getResourcesForApplication(java.lang.String)}
8067 * TODO(b/170852794): mark maxTargetSdk as {@code Build.VERSION_CODES.S}
8068 * @hide
8069 */
8070 @SuppressWarnings("HiddenAbstractMethod")
8071 @NonNull
8072 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170928809,
8073 publicAlternatives = "Use {@code Context#createContextAsUser(UserHandle, int)}"
8074 + " to create the relevant user context,"
8075 + " {@link android.content.Context#getPackageManager()} and"
8076 + " {@link android.content.pm.PackageManager#getResourcesForApplication("
8077 + "java.lang.String)}"
8078 + " instead.")
8079 @Deprecated
8080 public abstract Resources getResourcesForApplicationAsUser(@NonNull String packageName,
8081 @UserIdInt int userId) throws NameNotFoundException;
8082
8083 /**
8084 * Retrieve overall information about an application package defined in a
8085 * package archive file
8086 *
8087 * @param archiveFilePath The path to the archive file
8088 * @param flags Additional option flags to modify the data returned.
8089 * @return A PackageInfo object containing information about the package
8090 * archive. If the package could not be parsed, returns null.
8091 * @deprecated Use {@link #getPackageArchiveInfo(String, PackageInfoFlags)} instead.
8092 */
8093 @Deprecated
8094 @Nullable
8095 public PackageInfo getPackageArchiveInfo(@NonNull String archiveFilePath, int flags) {
8096 return getPackageArchiveInfo(archiveFilePath, PackageInfoFlags.of(flags));
8097 }
8098
8099 /**
8100 * See {@link #getPackageArchiveInfo(String, int)}.
8101 */
8102 @Nullable
8103 public PackageInfo getPackageArchiveInfo(@NonNull String archiveFilePath,
8104 @NonNull PackageInfoFlags flags) {
8105 long flagsBits = flags.getValue();
8106 final PackageParser parser = new PackageParser();
8107 parser.setCallback(new PackageParser.CallbackImpl(this));
8108 final File apkFile = new File(archiveFilePath);
8109 try {
8110 if ((flagsBits & (MATCH_DIRECT_BOOT_UNAWARE | MATCH_DIRECT_BOOT_AWARE)) != 0) {
8111 // Caller expressed an explicit opinion about what encryption
8112 // aware/unaware components they want to see, so fall through and
8113 // give them what they want
8114 } else {
8115 // Caller expressed no opinion, so match everything
8116 flagsBits |= MATCH_DIRECT_BOOT_AWARE | MATCH_DIRECT_BOOT_UNAWARE;
8117 }
8118
8119 PackageParser.Package pkg = parser.parsePackage(apkFile, 0, false);
8120 if ((flagsBits & GET_SIGNATURES) != 0 || (flagsBits & GET_SIGNING_CERTIFICATES) != 0) {
8121 PackageParser.collectCertificates(pkg, false /* skipVerify */);
8122 }
8123 return PackageParser.generatePackageInfo(pkg, null, (int) flagsBits, 0, 0, null,
8124 FrameworkPackageUserState.DEFAULT);
8125 } catch (PackageParser.PackageParserException e) {
8126 Log.w(TAG, "Failure to parse package archive", e);
8127 return null;
8128 }
8129 }
8130
8131 /**
8132 * If there is already an application with the given package name installed
8133 * on the system for other users, also install it for the calling user.
8134 * @hide
8135 *
8136 * @deprecated use {@link PackageInstaller#installExistingPackage()} instead.
8137 */
8138 @SuppressWarnings("HiddenAbstractMethod")
8139 @Deprecated
8140 @SystemApi
8141 public abstract int installExistingPackage(@NonNull String packageName)
8142 throws NameNotFoundException;
8143
8144 /**
8145 * If there is already an application with the given package name installed
8146 * on the system for other users, also install it for the calling user.
8147 * @hide
8148 *
8149 * @deprecated use {@link PackageInstaller#installExistingPackage()} instead.
8150 */
8151 @SuppressWarnings("HiddenAbstractMethod")
8152 @Deprecated
8153 @SystemApi
8154 public abstract int installExistingPackage(@NonNull String packageName,
8155 @InstallReason int installReason) throws NameNotFoundException;
8156
8157 /**
8158 * If there is already an application with the given package name installed
8159 * on the system for other users, also install it for the specified user.
8160 * @hide
8161 *
8162 * @deprecated use {@link PackageInstaller#installExistingPackage()} instead.
8163 */
8164 @SuppressWarnings("HiddenAbstractMethod")
8165 @Deprecated
8166 @RequiresPermission(anyOf = {
8167 Manifest.permission.INSTALL_EXISTING_PACKAGES,
8168 Manifest.permission.INSTALL_PACKAGES,
8169 Manifest.permission.INTERACT_ACROSS_USERS_FULL})
8170 @UnsupportedAppUsage
8171 public abstract int installExistingPackageAsUser(@NonNull String packageName,
8172 @UserIdInt int userId) throws NameNotFoundException;
8173
8174 /**
8175 * Allows a package listening to the
8176 * {@link Intent#ACTION_PACKAGE_NEEDS_VERIFICATION package verification
8177 * broadcast} to respond to the package manager. The response must include
8178 * the {@code verificationCode} which is one of
8179 * {@link PackageManager#VERIFICATION_ALLOW} or
8180 * {@link PackageManager#VERIFICATION_REJECT}.
8181 *
8182 * @param id pending package identifier as passed via the
8183 * {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra.
8184 * @param verificationCode either {@link PackageManager#VERIFICATION_ALLOW}
8185 * or {@link PackageManager#VERIFICATION_REJECT}.
8186 * @throws SecurityException if the caller does not have the
8187 * PACKAGE_VERIFICATION_AGENT permission.
8188 */
8189 public abstract void verifyPendingInstall(int id, int verificationCode);
8190
8191 /**
8192 * Allows a package listening to the
8193 * {@link Intent#ACTION_PACKAGE_NEEDS_VERIFICATION package verification
8194 * broadcast} to extend the default timeout for a response and declare what
8195 * action to perform after the timeout occurs. The response must include
8196 * the {@code verificationCodeAtTimeout} which is one of
8197 * {@link PackageManager#VERIFICATION_ALLOW} or
8198 * {@link PackageManager#VERIFICATION_REJECT}.
8199 *
8200 * This method may only be called once per package id. Additional calls
8201 * will have no effect.
8202 *
8203 * @param id pending package identifier as passed via the
8204 * {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra.
8205 * @param verificationCodeAtTimeout either
8206 * {@link PackageManager#VERIFICATION_ALLOW} or
8207 * {@link PackageManager#VERIFICATION_REJECT}. If
8208 * {@code verificationCodeAtTimeout} is neither
8209 * {@link PackageManager#VERIFICATION_ALLOW} or
8210 * {@link PackageManager#VERIFICATION_REJECT}, then
8211 * {@code verificationCodeAtTimeout} will default to
8212 * {@link PackageManager#VERIFICATION_REJECT}.
8213 * @param millisecondsToDelay the amount of time requested for the timeout.
8214 * Must be positive and less than
8215 * {@link PackageManager#MAXIMUM_VERIFICATION_TIMEOUT}. If
8216 * {@code millisecondsToDelay} is out of bounds,
8217 * {@code millisecondsToDelay} will be set to the closest in
8218 * bounds value; namely, 0 or
8219 * {@link PackageManager#MAXIMUM_VERIFICATION_TIMEOUT}.
8220 * @throws SecurityException if the caller does not have the
8221 * PACKAGE_VERIFICATION_AGENT permission.
8222 */
8223 public abstract void extendVerificationTimeout(int id,
8224 int verificationCodeAtTimeout, long millisecondsToDelay);
8225
8226 /**
8227 * Allows a package listening to the
8228 * {@link Intent#ACTION_INTENT_FILTER_NEEDS_VERIFICATION} intent filter verification
8229 * broadcast to respond to the package manager. The response must include
8230 * the {@code verificationCode} which is one of
8231 * {@link PackageManager#INTENT_FILTER_VERIFICATION_SUCCESS} or
8232 * {@link PackageManager#INTENT_FILTER_VERIFICATION_FAILURE}.
8233 *
8234 * @param verificationId pending package identifier as passed via the
8235 * {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra.
8236 * @param verificationCode either {@link PackageManager#INTENT_FILTER_VERIFICATION_SUCCESS}
8237 * or {@link PackageManager#INTENT_FILTER_VERIFICATION_FAILURE}.
8238 * @param failedDomains a list of failed domains if the verificationCode is
8239 * {@link PackageManager#INTENT_FILTER_VERIFICATION_FAILURE}, otherwise null;
8240 * @throws SecurityException if the caller does not have the
8241 * INTENT_FILTER_VERIFICATION_AGENT permission.
8242 *
8243 * @deprecated Use {@link DomainVerificationManager} APIs.
8244 * @hide
8245 */
8246 @Deprecated
8247 @SuppressWarnings("HiddenAbstractMethod")
8248 @SystemApi
8249 @RequiresPermission(android.Manifest.permission.INTENT_FILTER_VERIFICATION_AGENT)
8250 public abstract void verifyIntentFilter(int verificationId, int verificationCode,
8251 @NonNull List<String> failedDomains);
8252
8253 /**
8254 * Get the status of a Domain Verification Result for an IntentFilter. This is
8255 * related to the {@link android.content.IntentFilter#setAutoVerify(boolean)} and
8256 * {@link android.content.IntentFilter#getAutoVerify()}
8257 *
8258 * This is used by the ResolverActivity to change the status depending on what the User select
8259 * in the Disambiguation Dialog and also used by the Settings App for changing the default App
8260 * for a domain.
8261 *
8262 * @param packageName The package name of the Activity associated with the IntentFilter.
8263 * @param userId The user id.
8264 *
8265 * @return The status to set to. This can be
8266 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK} or
8267 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS} or
8268 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER} or
8269 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_UNDEFINED}
8270 *
8271 * @deprecated Use {@link DomainVerificationManager} APIs.
8272 * @hide
8273 */
8274 @Deprecated
8275 @SuppressWarnings("HiddenAbstractMethod")
8276 @SystemApi
8277 @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS_FULL)
8278 public abstract int getIntentVerificationStatusAsUser(@NonNull String packageName,
8279 @UserIdInt int userId);
8280
8281 /**
8282 * Allow to change the status of a Intent Verification status for all IntentFilter of an App.
8283 * This is related to the {@link android.content.IntentFilter#setAutoVerify(boolean)} and
8284 * {@link android.content.IntentFilter#getAutoVerify()}
8285 *
8286 * This is used by the ResolverActivity to change the status depending on what the User select
8287 * in the Disambiguation Dialog and also used by the Settings App for changing the default App
8288 * for a domain.
8289 *
8290 * @param packageName The package name of the Activity associated with the IntentFilter.
8291 * @param status The status to set to. This can be
8292 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK} or
8293 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS} or
8294 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER}
8295 * @param userId The user id.
8296 *
8297 * @return true if the status has been set. False otherwise.
8298 *
8299 * @deprecated This API represents a very dangerous behavior where Settings or a system app with
8300 * the right permissions can force an application to be verified for all of its declared
8301 * domains. This has been removed to prevent unintended usage, and no longer does anything,
8302 * always returning false. If a caller truly wishes to grant <i></i>every</i> declared web
8303 * domain to an application, use
8304 * {@link DomainVerificationManager#setDomainVerificationUserSelection(UUID, Set, boolean)},
8305 * passing in all of the domains returned inside
8306 * {@link DomainVerificationManager#getDomainVerificationUserState(String)}.
8307 *
8308 * @hide
8309 */
8310 @Deprecated
8311 @SuppressWarnings("HiddenAbstractMethod")
8312 @SystemApi
8313 @RequiresPermission(android.Manifest.permission.SET_PREFERRED_APPLICATIONS)
8314 public abstract boolean updateIntentVerificationStatusAsUser(@NonNull String packageName,
8315 int status, @UserIdInt int userId);
8316
8317 /**
8318 * Get the list of IntentFilterVerificationInfo for a specific package and User.
8319 *
8320 * @param packageName the package name. When this parameter is set to a non null value,
8321 * the results will be filtered by the package name provided.
8322 * Otherwise, there will be no filtering and it will return a list
8323 * corresponding for all packages
8324 *
8325 * @return a list of IntentFilterVerificationInfo for a specific package.
8326 *
8327 * @deprecated Use {@link DomainVerificationManager} instead.
8328 * @hide
8329 */
8330 @Deprecated
8331 @SuppressWarnings("HiddenAbstractMethod")
8332 @NonNull
8333 @SystemApi
8334 public abstract List<IntentFilterVerificationInfo> getIntentFilterVerifications(
8335 @NonNull String packageName);
8336
8337 /**
8338 * Get the list of IntentFilter for a specific package.
8339 *
8340 * @param packageName the package name. This parameter is set to a non null value,
8341 * the list will contain all the IntentFilter for that package.
8342 * Otherwise, the list will be empty.
8343 *
8344 * @return a list of IntentFilter for a specific package.
8345 *
8346 * @hide
8347 */
8348 @SuppressWarnings("HiddenAbstractMethod")
8349 @NonNull
8350 @SystemApi
8351 public abstract List<IntentFilter> getAllIntentFilters(@NonNull String packageName);
8352
8353 /**
8354 * Get the default Browser package name for a specific user.
8355 *
8356 * @param userId The user id.
8357 *
8358 * @return the package name of the default Browser for the specified user. If the user id passed
8359 * is -1 (all users) it will return a null value.
8360 *
8361 * @hide
8362 */
8363 @SuppressWarnings("HiddenAbstractMethod")
8364 @Nullable
8365 @SystemApi
8366 @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS_FULL)
8367 public abstract String getDefaultBrowserPackageNameAsUser(@UserIdInt int userId);
8368
8369 /**
8370 * Set the default Browser package name for a specific user.
8371 *
8372 * @param packageName The package name of the default Browser.
8373 * @param userId The user id.
8374 *
8375 * @return true if the default Browser for the specified user has been set,
8376 * otherwise return false. If the user id passed is -1 (all users) this call will not
8377 * do anything and just return false.
8378 *
8379 * @hide
8380 */
8381 @SuppressWarnings("HiddenAbstractMethod")
8382 @SystemApi
8383 @RequiresPermission(allOf = {
8384 Manifest.permission.SET_PREFERRED_APPLICATIONS,
8385 Manifest.permission.INTERACT_ACROSS_USERS_FULL})
8386 public abstract boolean setDefaultBrowserPackageNameAsUser(@Nullable String packageName,
8387 @UserIdInt int userId);
8388
8389 /**
8390 * Change the installer associated with a given package. There are limitations
8391 * on how the installer package can be changed; in particular:
8392 * <ul>
8393 * <li> A SecurityException will be thrown if <var>installerPackageName</var>
8394 * is not signed with the same certificate as the calling application.
8395 * <li> A SecurityException will be thrown if <var>targetPackage</var> already
8396 * has an installer package, and that installer package is not signed with
8397 * the same certificate as the calling application.
8398 * </ul>
8399 *
8400 * @param targetPackage The installed package whose installer will be changed.
8401 * @param installerPackageName The package name of the new installer. May be
8402 * null to clear the association.
8403 */
8404 public abstract void setInstallerPackageName(@NonNull String targetPackage,
8405 @Nullable String installerPackageName);
8406
8407 /** @hide */
8408 @SuppressWarnings("HiddenAbstractMethod")
8409 @SystemApi
8410 @RequiresPermission(Manifest.permission.INSTALL_PACKAGES)
8411 public abstract void setUpdateAvailable(@NonNull String packageName, boolean updateAvaialble);
8412
8413 /**
8414 * Attempts to delete a package. Since this may take a little while, the
8415 * result will be posted back to the given observer. A deletion will fail if
8416 * the calling context lacks the
8417 * {@link android.Manifest.permission#DELETE_PACKAGES} permission, if the
8418 * named package cannot be found, or if the named package is a system
8419 * package.
8420 *
8421 * @param packageName The name of the package to delete
8422 * @param observer An observer callback to get notified when the package
8423 * deletion is complete.
8424 * {@link android.content.pm.IPackageDeleteObserver#packageDeleted}
8425 * will be called when that happens. observer may be null to
8426 * indicate that no callback is desired.
8427 * @hide
8428 */
8429 @SuppressWarnings("HiddenAbstractMethod")
8430 @RequiresPermission(Manifest.permission.DELETE_PACKAGES)
8431 @UnsupportedAppUsage
8432 public abstract void deletePackage(@NonNull String packageName,
8433 @Nullable IPackageDeleteObserver observer, @DeleteFlags int flags);
8434
8435 /**
8436 * Attempts to delete a package. Since this may take a little while, the
8437 * result will be posted back to the given observer. A deletion will fail if
8438 * the named package cannot be found, or if the named package is a system
8439 * package.
8440 *
8441 * @param packageName The name of the package to delete
8442 * @param observer An observer callback to get notified when the package
8443 * deletion is complete.
8444 * {@link android.content.pm.IPackageDeleteObserver#packageDeleted}
8445 * will be called when that happens. observer may be null to
8446 * indicate that no callback is desired.
8447 * @param userId The user Id
8448 * @hide
8449 */
8450 @SuppressWarnings("HiddenAbstractMethod")
8451 @RequiresPermission(anyOf = {
8452 Manifest.permission.DELETE_PACKAGES,
8453 Manifest.permission.INTERACT_ACROSS_USERS_FULL})
8454 @UnsupportedAppUsage
8455 public abstract void deletePackageAsUser(@NonNull String packageName,
8456 @Nullable IPackageDeleteObserver observer, @DeleteFlags int flags,
8457 @UserIdInt int userId);
8458
8459 /**
8460 * Retrieve the package name of the application that installed a package. This identifies
8461 * which market the package came from.
8462 *
8463 * @param packageName The name of the package to query
8464 * @throws IllegalArgumentException if the given package name is not installed
8465 *
8466 * @deprecated use {@link #getInstallSourceInfo(String)} instead
8467 */
8468 @SuppressWarnings("HiddenAbstractMethod")
8469 @Deprecated
8470 @Nullable
8471 public abstract String getInstallerPackageName(@NonNull String packageName);
8472
8473 /**
8474 * Retrieves information about how a package was installed or updated.
8475 * <p>
8476 * If the calling application does not hold the INSTALL_PACKAGES permission then
8477 * the result will always return {@code null} from
8478 * {@link InstallSourceInfo#getOriginatingPackageName()}.
8479 * <p>
8480 * If the package that requested the install has been uninstalled, then information about it
8481 * will only be returned from {@link InstallSourceInfo#getInitiatingPackageName()} and
8482 * {@link InstallSourceInfo#getInitiatingPackageSigningInfo()} if the calling package is
8483 * requesting its own install information and is not an instant app.
8484 *
8485 * @param packageName The name of the package to query
8486 * @throws NameNotFoundException if the given package name is not installed
8487 */
8488 @NonNull
8489 public InstallSourceInfo getInstallSourceInfo(@NonNull String packageName)
8490 throws NameNotFoundException {
8491 throw new UnsupportedOperationException("getInstallSourceInfo not implemented");
8492 }
8493
8494 /**
8495 * Attempts to clear the user data directory of an application.
8496 * Since this may take a little while, the result will
8497 * be posted back to the given observer. A deletion will fail if the
8498 * named package cannot be found, or if the named package is a "system package".
8499 *
8500 * @param packageName The name of the package
8501 * @param observer An observer callback to get notified when the operation is finished
8502 * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)}
8503 * will be called when that happens. observer may be null to indicate that
8504 * no callback is desired.
8505 *
8506 * @hide
8507 */
8508 @SuppressWarnings("HiddenAbstractMethod")
8509 @UnsupportedAppUsage
8510 public abstract void clearApplicationUserData(@NonNull String packageName,
8511 @Nullable IPackageDataObserver observer);
8512 /**
8513 * Attempts to delete the cache files associated with an application.
8514 * Since this may take a little while, the result will
8515 * be posted back to the given observer. A deletion will fail if the calling context
8516 * lacks the {@link android.Manifest.permission#DELETE_CACHE_FILES} permission, if the
8517 * named package cannot be found, or if the named package is a "system package".
8518 *
8519 * @param packageName The name of the package to delete
8520 * @param observer An observer callback to get notified when the cache file deletion
8521 * is complete.
8522 * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)}
8523 * will be called when that happens. observer may be null to indicate that
8524 * no callback is desired.
8525 *
8526 * @hide
8527 */
8528 @SuppressWarnings("HiddenAbstractMethod")
8529 @UnsupportedAppUsage
8530 public abstract void deleteApplicationCacheFiles(@NonNull String packageName,
8531 @Nullable IPackageDataObserver observer);
8532
8533 /**
8534 * Attempts to delete the cache files associated with an application for a given user. Since
8535 * this may take a little while, the result will be posted back to the given observer. A
8536 * deletion will fail if the calling context lacks the
8537 * {@link android.Manifest.permission#DELETE_CACHE_FILES} permission, if the named package
8538 * cannot be found, or if the named package is a "system package". If {@code userId} does not
8539 * belong to the calling user, the caller must have
8540 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} permission.
8541 *
8542 * @param packageName The name of the package to delete
8543 * @param userId the user for which the cache files needs to be deleted
8544 * @param observer An observer callback to get notified when the cache file deletion is
8545 * complete.
8546 * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)}
8547 * will be called when that happens. observer may be null to indicate that no
8548 * callback is desired.
8549 * @hide
8550 */
8551 @SuppressWarnings("HiddenAbstractMethod")
8552 @UnsupportedAppUsage
8553 public abstract void deleteApplicationCacheFilesAsUser(@NonNull String packageName,
8554 @UserIdInt int userId, @Nullable IPackageDataObserver observer);
8555
8556 /**
8557 * Free storage by deleting LRU sorted list of cache files across
8558 * all applications. If the currently available free storage
8559 * on the device is greater than or equal to the requested
8560 * free storage, no cache files are cleared. If the currently
8561 * available storage on the device is less than the requested
8562 * free storage, some or all of the cache files across
8563 * all applications are deleted (based on last accessed time)
8564 * to increase the free storage space on the device to
8565 * the requested value. There is no guarantee that clearing all
8566 * the cache files from all applications will clear up
8567 * enough storage to achieve the desired value.
8568 * @param freeStorageSize The number of bytes of storage to be
8569 * freed by the system. Say if freeStorageSize is XX,
8570 * and the current free storage is YY,
8571 * if XX is less than YY, just return. if not free XX-YY number
8572 * of bytes if possible.
8573 * @param observer call back used to notify when
8574 * the operation is completed
8575 *
8576 * @hide
8577 */
8578 @UnsupportedAppUsage
8579 public void freeStorageAndNotify(long freeStorageSize,
8580 @Nullable IPackageDataObserver observer) {
8581 freeStorageAndNotify(null, freeStorageSize, observer);
8582 }
8583
8584 /** {@hide} */
8585 @SuppressWarnings("HiddenAbstractMethod")
8586 @UnsupportedAppUsage
8587 public abstract void freeStorageAndNotify(@Nullable String volumeUuid, long freeStorageSize,
8588 @Nullable IPackageDataObserver observer);
8589
8590 /**
8591 * Free storage by deleting LRU sorted list of cache files across
8592 * all applications. If the currently available free storage
8593 * on the device is greater than or equal to the requested
8594 * free storage, no cache files are cleared. If the currently
8595 * available storage on the device is less than the requested
8596 * free storage, some or all of the cache files across
8597 * all applications are deleted (based on last accessed time)
8598 * to increase the free storage space on the device to
8599 * the requested value. There is no guarantee that clearing all
8600 * the cache files from all applications will clear up
8601 * enough storage to achieve the desired value.
8602 * @param freeStorageSize The number of bytes of storage to be
8603 * freed by the system. Say if freeStorageSize is XX,
8604 * and the current free storage is YY,
8605 * if XX is less than YY, just return. if not free XX-YY number
8606 * of bytes if possible.
8607 * @param pi IntentSender call back used to
8608 * notify when the operation is completed.May be null
8609 * to indicate that no call back is desired.
8610 *
8611 * @hide
8612 */
8613 @UnsupportedAppUsage
8614 public void freeStorage(long freeStorageSize, @Nullable IntentSender pi) {
8615 freeStorage(null, freeStorageSize, pi);
8616 }
8617
8618 /** {@hide} */
8619 @SuppressWarnings("HiddenAbstractMethod")
8620 @UnsupportedAppUsage
8621 public abstract void freeStorage(@Nullable String volumeUuid, long freeStorageSize,
8622 @Nullable IntentSender pi);
8623
8624 /**
8625 * Retrieve the size information for a package.
8626 * Since this may take a little while, the result will
8627 * be posted back to the given observer. The calling context
8628 * should have the {@link android.Manifest.permission#GET_PACKAGE_SIZE} permission.
8629 *
8630 * @param packageName The name of the package whose size information is to be retrieved
8631 * @param userId The user whose size information should be retrieved.
8632 * @param observer An observer callback to get notified when the operation
8633 * is complete.
8634 * {@link android.content.pm.IPackageStatsObserver#onGetStatsCompleted(PackageStats, boolean)}
8635 * The observer's callback is invoked with a PackageStats object(containing the
8636 * code, data and cache sizes of the package) and a boolean value representing
8637 * the status of the operation. observer may be null to indicate that
8638 * no callback is desired.
8639 *
8640 * @deprecated use {@link StorageStatsManager} instead.
8641 * @hide
8642 */
8643 @SuppressWarnings("HiddenAbstractMethod")
8644 @Deprecated
8645 @UnsupportedAppUsage
8646 public abstract void getPackageSizeInfoAsUser(@NonNull String packageName,
8647 @UserIdInt int userId, @Nullable IPackageStatsObserver observer);
8648
8649 /**
8650 * Like {@link #getPackageSizeInfoAsUser(String, int, IPackageStatsObserver)}, but
8651 * returns the size for the calling user.
8652 *
8653 * @deprecated use {@link StorageStatsManager} instead.
8654 * @hide
8655 */
8656 @Deprecated
8657 @UnsupportedAppUsage
8658 public void getPackageSizeInfo(@NonNull String packageName, IPackageStatsObserver observer) {
8659 getPackageSizeInfoAsUser(packageName, getUserId(), observer);
8660 }
8661
8662 /**
8663 * @deprecated This function no longer does anything. It is the platform's
8664 * responsibility to assign preferred activities and this cannot be modified
8665 * directly. To determine the activities resolved by the platform, use
8666 * {@link #resolveActivity} or {@link #queryIntentActivities}. To configure
8667 * an app to be responsible for a particular role and to check current role
8668 * holders, see {@link android.app.role.RoleManager}.
8669 */
8670 @Deprecated
8671 public abstract void addPackageToPreferred(@NonNull String packageName);
8672
8673 /**
8674 * @deprecated This function no longer does anything. It is the platform's
8675 * responsibility to assign preferred activities and this cannot be modified
8676 * directly. To determine the activities resolved by the platform, use
8677 * {@link #resolveActivity} or {@link #queryIntentActivities}. To configure
8678 * an app to be responsible for a particular role and to check current role
8679 * holders, see {@link android.app.role.RoleManager}.
8680 */
8681 @Deprecated
8682 public abstract void removePackageFromPreferred(@NonNull String packageName);
8683
8684 /**
8685 * Retrieve the list of all currently configured preferred packages. The
8686 * first package on the list is the most preferred, the last is the least
8687 * preferred.
8688 *
8689 * @param flags Additional option flags to modify the data returned.
8690 * @return A List of PackageInfo objects, one for each preferred
8691 * application, in order of preference.
8692 *
8693 * @deprecated This function no longer does anything. It is the platform's
8694 * responsibility to assign preferred activities and this cannot be modified
8695 * directly. To determine the activities resolved by the platform, use
8696 * {@link #resolveActivity} or {@link #queryIntentActivities}. To configure
8697 * an app to be responsible for a particular role and to check current role
8698 * holders, see {@link android.app.role.RoleManager}.
8699 */
8700 @NonNull
8701 @Deprecated
8702 public abstract List<PackageInfo> getPreferredPackages(int flags);
8703
8704 /**
8705 * Add a new preferred activity mapping to the system. This will be used
8706 * to automatically select the given activity component when
8707 * {@link Context#startActivity(Intent) Context.startActivity()} finds
8708 * multiple matching activities and also matches the given filter.
8709 *
8710 * @param filter The set of intents under which this activity will be
8711 * made preferred.
8712 * @param match The IntentFilter match category that this preference
8713 * applies to.
8714 * @param set The set of activities that the user was picking from when
8715 * this preference was made.
8716 * @param activity The component name of the activity that is to be
8717 * preferred.
8718 *
8719 * @deprecated This function no longer does anything. It is the platform's
8720 * responsibility to assign preferred activities and this cannot be modified
8721 * directly. To determine the activities resolved by the platform, use
8722 * {@link #resolveActivity} or {@link #queryIntentActivities}. To configure
8723 * an app to be responsible for a particular role and to check current role
8724 * holders, see {@link android.app.role.RoleManager}.
8725 */
8726 @Deprecated
8727 public abstract void addPreferredActivity(@NonNull IntentFilter filter, int match,
8728 @Nullable ComponentName[] set, @NonNull ComponentName activity);
8729
8730 /**
8731 * Same as {@link #addPreferredActivity(IntentFilter, int,
8732 ComponentName[], ComponentName)}, but with a specific userId to apply the preference
8733 to.
8734 * @hide
8735 *
8736 * @deprecated This function no longer does anything. It is the platform's
8737 * responsibility to assign preferred activities and this cannot be modified
8738 * directly. To determine the activities resolved by the platform, use
8739 * {@link #resolveActivity} or {@link #queryIntentActivities}. To configure
8740 * an app to be responsible for a particular role and to check current role
8741 * holders, see {@link android.app.role.RoleManager}.
8742 */
8743 @Deprecated
8744 @UnsupportedAppUsage
8745 public void addPreferredActivityAsUser(@NonNull IntentFilter filter, int match,
8746 @Nullable ComponentName[] set, @NonNull ComponentName activity, @UserIdInt int userId) {
8747 throw new RuntimeException("Not implemented. Must override in a subclass.");
8748 }
8749
8750 /**
8751 * Replaces an existing preferred activity mapping to the system, and if that were not present
8752 * adds a new preferred activity. This will be used
8753 * to automatically select the given activity component when
8754 * {@link Context#startActivity(Intent) Context.startActivity()} finds
8755 * multiple matching activities and also matches the given filter.
8756 *
8757 * @param filter The set of intents under which this activity will be
8758 * made preferred.
8759 * @param match The IntentFilter match category that this preference
8760 * applies to.
8761 * @param set The set of activities that the user was picking from when
8762 * this preference was made.
8763 * @param activity The component name of the activity that is to be
8764 * preferred.
8765 *
8766 * @hide
8767 *
8768 * @deprecated This function no longer does anything. It is the platform's
8769 * responsibility to assign preferred activities and this cannot be modified
8770 * directly. To determine the activities resolved by the platform, use
8771 * {@link #resolveActivity} or {@link #queryIntentActivities}. To configure
8772 * an app to be responsible for a particular role and to check current role
8773 * holders, see {@link android.app.role.RoleManager}.
8774 */
8775 @SuppressWarnings("HiddenAbstractMethod")
8776 @Deprecated
8777 @UnsupportedAppUsage
8778 public abstract void replacePreferredActivity(@NonNull IntentFilter filter, int match,
8779 @Nullable ComponentName[] set, @NonNull ComponentName activity);
8780
8781 /**
8782 * Replaces an existing preferred activity mapping to the system, and if that were not present
8783 * adds a new preferred activity. This will be used to automatically select the given activity
8784 * component when {@link Context#startActivity(Intent) Context.startActivity()} finds multiple
8785 * matching activities and also matches the given filter.
8786 *
8787 * @param filter The set of intents under which this activity will be made preferred.
8788 * @param match The IntentFilter match category that this preference applies to. Should be a
8789 * combination of {@link IntentFilter#MATCH_CATEGORY_MASK} and
8790 * {@link IntentFilter#MATCH_ADJUSTMENT_MASK}).
8791 * @param set The set of activities that the user was picking from when this preference was
8792 * made.
8793 * @param activity The component name of the activity that is to be preferred.
8794 *
8795 * @hide
8796 */
8797 @SystemApi
8798 public void replacePreferredActivity(@NonNull IntentFilter filter, int match,
8799 @NonNull List<ComponentName> set, @NonNull ComponentName activity) {
8800 replacePreferredActivity(filter, match, set.toArray(new ComponentName[0]), activity);
8801 }
8802
8803 /**
8804 * @hide
8805 *
8806 * @deprecated This function no longer does anything. It is the platform's
8807 * responsibility to assign preferred activities and this cannot be modified
8808 * directly. To determine the activities resolved by the platform, use
8809 * {@link #resolveActivity} or {@link #queryIntentActivities}. To configure
8810 * an app to be responsible for a particular role and to check current role
8811 * holders, see {@link android.app.role.RoleManager}.
8812 */
8813 @Deprecated
8814 @UnsupportedAppUsage
8815 public void replacePreferredActivityAsUser(@NonNull IntentFilter filter, int match,
8816 @Nullable ComponentName[] set, @NonNull ComponentName activity, @UserIdInt int userId) {
8817 throw new RuntimeException("Not implemented. Must override in a subclass.");
8818 }
8819
8820 /**
8821 * Remove all preferred activity mappings, previously added with
8822 * {@link #addPreferredActivity}, from the
8823 * system whose activities are implemented in the given package name.
8824 * An application can only clear its own package(s).
8825 *
8826 * @param packageName The name of the package whose preferred activity
8827 * mappings are to be removed.
8828 *
8829 * @deprecated This function no longer does anything. It is the platform's
8830 * responsibility to assign preferred activities and this cannot be modified
8831 * directly. To determine the activities resolved by the platform, use
8832 * {@link #resolveActivity} or {@link #queryIntentActivities}. To configure
8833 * an app to be responsible for a particular role and to check current role
8834 * holders, see {@link android.app.role.RoleManager}.
8835 */
8836 @Deprecated
8837 public abstract void clearPackagePreferredActivities(@NonNull String packageName);
8838
8839 /**
8840 * Same as {@link #addPreferredActivity(IntentFilter, int, ComponentName[], ComponentName)},
8841 * but removes all existing entries that match this filter.
8842 * @hide
8843 */
8844 public void addUniquePreferredActivity(@NonNull IntentFilter filter, int match,
8845 @Nullable ComponentName[] set, @NonNull ComponentName activity) {
8846 throw new UnsupportedOperationException(
8847 "addUniquePreferredActivity not implemented in subclass");
8848 }
8849
8850 /**
8851 * Retrieve all preferred activities, previously added with
8852 * {@link #addPreferredActivity}, that are
8853 * currently registered with the system.
8854 *
8855 * @param outFilters A required list in which to place the filters of all of the
8856 * preferred activities.
8857 * @param outActivities A required list in which to place the component names of
8858 * all of the preferred activities.
8859 * @param packageName An optional package in which you would like to limit
8860 * the list. If null, all activities will be returned; if non-null, only
8861 * those activities in the given package are returned.
8862 *
8863 * @return Returns the total number of registered preferred activities
8864 * (the number of distinct IntentFilter records, not the number of unique
8865 * activity components) that were found.
8866 *
8867 * @deprecated This function no longer does anything. It is the platform's
8868 * responsibility to assign preferred activities and this cannot be modified
8869 * directly. To determine the activities resolved by the platform, use
8870 * {@link #resolveActivity} or {@link #queryIntentActivities}. To configure
8871 * an app to be responsible for a particular role and to check current role
8872 * holders, see {@link android.app.role.RoleManager}.
8873 */
8874 @Deprecated
8875 public abstract int getPreferredActivities(@NonNull List<IntentFilter> outFilters,
8876 @NonNull List<ComponentName> outActivities, @Nullable String packageName);
8877
8878 /**
8879 * Ask for the set of available 'home' activities and the current explicit
8880 * default, if any.
8881 * @hide
8882 */
8883 @SuppressWarnings("HiddenAbstractMethod")
8884 @Nullable
8885 @UnsupportedAppUsage
8886 public abstract ComponentName getHomeActivities(@NonNull List<ResolveInfo> outActivities);
8887
8888 /**
8889 * Set the enabled setting for a package component (activity, receiver, service, provider).
8890 * This setting will override any enabled state which may have been set by the component in its
8891 * manifest.
8892 *
8893 * <p>Consider using {@link #setComponentEnabledSettings(List)} if multiple components need to
8894 * be updated atomically.
8895 *
8896 * @param componentName The component to enable
8897 * @param newState The new enabled state for the component.
8898 * @param flags Optional behavior flags.
8899 */
8900 @RequiresPermission(value = android.Manifest.permission.CHANGE_COMPONENT_ENABLED_STATE,
8901 conditional = true)
8902 public abstract void setComponentEnabledSetting(@NonNull ComponentName componentName,
8903 @EnabledState int newState, @EnabledFlags int flags);
8904
8905 /**
8906 * Set the enabled settings for package components such as activities, receivers, services and
8907 * providers. This setting will override any enabled state which may have been set by the
8908 * component in its manifest.
8909 *
8910 * <p>This api accepts a list of component changes, and applies them all atomically. The
8911 * application can use this api if components have dependencies and need to be updated
8912 * atomically.
8913 *
8914 * <p>The permission is not required if target components are running under the same uid with
8915 * the caller.
8916 *
8917 * @param settings The list of component enabled settings to update. Note that an
8918 * {@link IllegalArgumentException} is thrown if the duplicated component name
8919 * is in the list or there's a conflict {@link #DONT_KILL_APP} flag between
8920 * different components in the same package.
8921 *
8922 * @see #setComponentEnabledSetting(ComponentName, int, int)
8923 */
8924 @RequiresPermission(value = android.Manifest.permission.CHANGE_COMPONENT_ENABLED_STATE,
8925 conditional = true)
8926 public void setComponentEnabledSettings(@NonNull List<ComponentEnabledSetting> settings) {
8927 throw new UnsupportedOperationException("setComponentEnabledSettings not implemented"
8928 + "in subclass");
8929 }
8930
8931 /**
8932 * Return the enabled setting for a package component (activity,
8933 * receiver, service, provider). This returns the last value set by
8934 * {@link #setComponentEnabledSetting(ComponentName, int, int)}; in most
8935 * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since
8936 * the value originally specified in the manifest has not been modified.
8937 *
8938 * @param componentName The component to retrieve.
8939 * @return Returns the current enabled state for the component.
8940 */
8941 public abstract @EnabledState int getComponentEnabledSetting(
8942 @NonNull ComponentName componentName);
8943
8944 /**
8945 * Set whether a synthetic app details activity will be generated if the app has no enabled
8946 * launcher activity. Disabling this allows the app to have no launcher icon.
8947 *
8948 * @param packageName The package name of the app
8949 * @param enabled The new enabled state for the synthetic app details activity.
8950 *
8951 * @hide
8952 */
8953 @RequiresPermission(value = android.Manifest.permission.CHANGE_COMPONENT_ENABLED_STATE,
8954 conditional = true)
8955 @SystemApi
8956 public void setSyntheticAppDetailsActivityEnabled(@NonNull String packageName,
8957 boolean enabled) {
8958 throw new UnsupportedOperationException(
8959 "setSyntheticAppDetailsActivityEnabled not implemented");
8960 }
8961
8962
8963 /**
8964 * Return whether a synthetic app details activity will be generated if the app has no enabled
8965 * launcher activity.
8966 *
8967 * @param packageName The package name of the app
8968 * @return Returns the enabled state for the synthetic app details activity.
8969 *
8970 *
8971 */
8972 public boolean getSyntheticAppDetailsActivityEnabled(@NonNull String packageName) {
8973 throw new UnsupportedOperationException(
8974 "getSyntheticAppDetailsActivityEnabled not implemented");
8975 }
8976
8977 /**
8978 * Set the enabled setting for an application
8979 * This setting will override any enabled state which may have been set by the application in
8980 * its manifest. It also overrides the enabled state set in the manifest for any of the
8981 * application's components. It does not override any enabled state set by
8982 * {@link #setComponentEnabledSetting} for any of the application's components.
8983 *
8984 * @param packageName The package name of the application to enable
8985 * @param newState The new enabled state for the application.
8986 * @param flags Optional behavior flags.
8987 */
8988 @RequiresPermission(value = android.Manifest.permission.CHANGE_COMPONENT_ENABLED_STATE,
8989 conditional = true)
8990 public abstract void setApplicationEnabledSetting(@NonNull String packageName,
8991 @EnabledState int newState, @EnabledFlags int flags);
8992
8993 /**
8994 * Return the enabled setting for an application. This returns
8995 * the last value set by
8996 * {@link #setApplicationEnabledSetting(String, int, int)}; in most
8997 * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since
8998 * the value originally specified in the manifest has not been modified.
8999 *
9000 * @param packageName The package name of the application to retrieve.
9001 * @return Returns the current enabled state for the application.
9002 * @throws IllegalArgumentException if the named package does not exist.
9003 */
9004 public abstract @EnabledState int getApplicationEnabledSetting(@NonNull String packageName);
9005
9006 /**
9007 * Flush the package restrictions for a given user to disk. This forces the package restrictions
9008 * like component and package enabled settings to be written to disk and avoids the delay that
9009 * is otherwise present when changing those settings.
9010 *
9011 * @param userId Ther userId of the user whose restrictions are to be flushed.
9012 * @hide
9013 */
9014 @SuppressWarnings("HiddenAbstractMethod")
9015 @UnsupportedAppUsage
9016 public abstract void flushPackageRestrictionsAsUser(@UserIdInt int userId);
9017
9018 /**
9019 * Puts the package in a hidden state, which is almost like an uninstalled state,
9020 * making the package unavailable, but it doesn't remove the data or the actual
9021 * package file. Application can be unhidden by either resetting the hidden state
9022 * or by installing it, such as with {@link #installExistingPackage(String)}
9023 * @hide
9024 */
9025 @SuppressWarnings("HiddenAbstractMethod")
9026 @UnsupportedAppUsage
9027 public abstract boolean setApplicationHiddenSettingAsUser(@NonNull String packageName,
9028 boolean hidden, @NonNull UserHandle userHandle);
9029
9030 /**
9031 * Returns the hidden state of a package.
9032 * @see #setApplicationHiddenSettingAsUser(String, boolean, UserHandle)
9033 * @hide
9034 */
9035 @SuppressWarnings("HiddenAbstractMethod")
9036 @UnsupportedAppUsage
9037 public abstract boolean getApplicationHiddenSettingAsUser(@NonNull String packageName,
9038 @NonNull UserHandle userHandle);
9039
9040 /**
9041 * Sets the state of a system app.
9042 *
9043 * This method can be used to change a system app's hidden-until-installed state (via
9044 * {@link #SYSTEM_APP_STATE_HIDDEN_UNTIL_INSTALLED_HIDDEN} and
9045 * {@link #SYSTEM_APP_STATE_HIDDEN_UNTIL_INSTALLED_VISIBLE} or its installation state (via
9046 * {@link #SYSTEM_APP_STATE_INSTALLED} and {@link #SYSTEM_APP_STATE_UNINSTALLED}.
9047 *
9048 * This API may only be called from {@link android.os.Process#SYSTEM_UID} or
9049 * {@link android.os.Process#PHONE_UID}.
9050 *
9051 * @param packageName Package name of the app.
9052 * @param state State of the app.
9053 * @hide
9054 */
9055 @SystemApi
9056 public void setSystemAppState(@NonNull String packageName, @SystemAppState int state) {
9057 throw new RuntimeException("Not implemented. Must override in a subclass");
9058 }
9059
9060 /**
9061 * Return whether the device has been booted into safe mode.
9062 */
9063 public abstract boolean isSafeMode();
9064
9065 /**
9066 * Adds a listener for permission changes for installed packages.
9067 *
9068 * @param listener The listener to add.
9069 *
9070 * @hide
9071 */
9072 //@Deprecated
9073 @SuppressWarnings("HiddenAbstractMethod")
9074 @SystemApi
9075 @RequiresPermission(Manifest.permission.OBSERVE_GRANT_REVOKE_PERMISSIONS)
9076 public abstract void addOnPermissionsChangeListener(
9077 @NonNull OnPermissionsChangedListener listener);
9078
9079 /**
9080 * Remvoes a listener for permission changes for installed packages.
9081 *
9082 * @param listener The listener to remove.
9083 *
9084 * @hide
9085 */
9086 //@Deprecated
9087 @SuppressWarnings("HiddenAbstractMethod")
9088 @SystemApi
9089 @RequiresPermission(Manifest.permission.OBSERVE_GRANT_REVOKE_PERMISSIONS)
9090 public abstract void removeOnPermissionsChangeListener(
9091 @NonNull OnPermissionsChangedListener listener);
9092
9093 /**
9094 * Return the {@link KeySet} associated with the String alias for this
9095 * application.
9096 *
9097 * @param alias The alias for a given {@link KeySet} as defined in the
9098 * application's AndroidManifest.xml.
9099 * @hide
9100 */
9101 @SuppressWarnings("HiddenAbstractMethod")
9102 @NonNull
9103 @UnsupportedAppUsage
9104 public abstract KeySet getKeySetByAlias(@NonNull String packageName, @NonNull String alias);
9105
9106 /** Return the signing {@link KeySet} for this application.
9107 * @hide
9108 */
9109 @SuppressWarnings("HiddenAbstractMethod")
9110 @NonNull
9111 @UnsupportedAppUsage
9112 public abstract KeySet getSigningKeySet(@NonNull String packageName);
9113
9114 /**
9115 * Return whether the package denoted by packageName has been signed by all
9116 * of the keys specified by the {@link KeySet} ks. This will return true if
9117 * the package has been signed by additional keys (a superset) as well.
9118 * Compare to {@link #isSignedByExactly(String packageName, KeySet ks)}.
9119 * @hide
9120 */
9121 @SuppressWarnings("HiddenAbstractMethod")
9122 @UnsupportedAppUsage
9123 public abstract boolean isSignedBy(@NonNull String packageName, @NonNull KeySet ks);
9124
9125 /**
9126 * Return whether the package denoted by packageName has been signed by all
9127 * of, and only, the keys specified by the {@link KeySet} ks. Compare to
9128 * {@link #isSignedBy(String packageName, KeySet ks)}.
9129 * @hide
9130 */
9131 @SuppressWarnings("HiddenAbstractMethod")
9132 @UnsupportedAppUsage
9133 public abstract boolean isSignedByExactly(@NonNull String packageName, @NonNull KeySet ks);
9134
9135 /**
9136 * Flag to denote no restrictions. This should be used to clear any restrictions that may have
9137 * been previously set for the package.
9138 * @hide
9139 * @see #setDistractingPackageRestrictions(String[], int)
9140 */
9141 @SystemApi
9142 public static final int RESTRICTION_NONE = 0x0;
9143
9144 /**
9145 * Flag to denote that a package should be hidden from any suggestions to the user.
9146 * @hide
9147 * @see #setDistractingPackageRestrictions(String[], int)
9148 */
9149 @SystemApi
9150 public static final int RESTRICTION_HIDE_FROM_SUGGESTIONS = 0x00000001;
9151
9152 /**
9153 * Flag to denote that a package's notifications should be hidden.
9154 * @hide
9155 * @see #setDistractingPackageRestrictions(String[], int)
9156 */
9157 @SystemApi
9158 public static final int RESTRICTION_HIDE_NOTIFICATIONS = 0x00000002;
9159
9160 /**
9161 * Restriction flags to set on a package that is considered as distracting to the user.
9162 * These should help the user to restrict their usage of these apps.
9163 *
9164 * @see #setDistractingPackageRestrictions(String[], int)
9165 * @hide
9166 */
9167 @IntDef(flag = true, prefix = {"RESTRICTION_"}, value = {
9168 RESTRICTION_NONE,
9169 RESTRICTION_HIDE_FROM_SUGGESTIONS,
9170 RESTRICTION_HIDE_NOTIFICATIONS
9171 })
9172 @Retention(RetentionPolicy.SOURCE)
9173 public @interface DistractionRestriction {}
9174
9175 /**
9176 * Mark or unmark the given packages as distracting to the user.
9177 * These packages can have certain restrictions set that should discourage the user to launch
9178 * them often. For example, notifications from such an app can be hidden, or the app can be
9179 * removed from launcher suggestions, so the user is able to restrict their use of these apps.
9180 *
9181 * <p>The caller must hold {@link android.Manifest.permission#SUSPEND_APPS} to use this API.
9182 *
9183 * @param packages Packages to mark as distracting.
9184 * @param restrictionFlags Any combination of restrictions to impose on the given packages.
9185 * {@link #RESTRICTION_NONE} can be used to clear any existing
9186 * restrictions.
9187 * @return A list of packages that could not have the {@code restrictionFlags} set. The system
9188 * may prevent restricting critical packages to preserve normal device function.
9189 *
9190 * @hide
9191 * @see #RESTRICTION_NONE
9192 * @see #RESTRICTION_HIDE_FROM_SUGGESTIONS
9193 * @see #RESTRICTION_HIDE_NOTIFICATIONS
9194 */
9195 @SystemApi
9196 @RequiresPermission(android.Manifest.permission.SUSPEND_APPS)
9197 @NonNull
9198 public String[] setDistractingPackageRestrictions(@NonNull String[] packages,
9199 @DistractionRestriction int restrictionFlags) {
9200 throw new UnsupportedOperationException(
9201 "setDistractingPackageRestrictions not implemented");
9202 }
9203
9204 /**
9205 * Puts the package in a suspended state, where attempts at starting activities are denied.
9206 *
9207 * <p>It doesn't remove the data or the actual package file. The application's notifications
9208 * will be hidden, any of its started activities will be stopped and it will not be able to
9209 * show toasts or system alert windows or ring the device.
9210 *
9211 * <p>When the user tries to launch a suspended app, a system dialog with the given
9212 * {@code dialogMessage} will be shown instead. Since the message is supplied to the system as
9213 * a {@link String}, the caller needs to take care of localization as needed.
9214 * The dialog message can optionally contain a placeholder for the name of the suspended app.
9215 * The system uses {@link String#format(Locale, String, Object...) String.format} to insert the
9216 * app name into the message, so an example format string could be {@code "The app %1$s is
9217 * currently suspended"}. This makes it easier for callers to provide a single message which
9218 * works for all the packages being suspended in a single call.
9219 *
9220 * <p>The package must already be installed. If the package is uninstalled while suspended
9221 * the package will no longer be suspended. </p>
9222 *
9223 * <p>Optionally, the suspending app can provide extra information in the form of
9224 * {@link PersistableBundle} objects to be shared with the apps being suspended and the
9225 * launcher to support customization that they might need to handle the suspended state.
9226 *
9227 * <p>The caller must hold {@link Manifest.permission#SUSPEND_APPS} to use this API.
9228 *
9229 * @param packageNames The names of the packages to set the suspended status.
9230 * @param suspended If set to {@code true}, the packages will be suspended, if set to
9231 * {@code false}, the packages will be unsuspended.
9232 * @param appExtras An optional {@link PersistableBundle} that the suspending app can provide
9233 * which will be shared with the apps being suspended. Ignored if
9234 * {@code suspended} is false.
9235 * @param launcherExtras An optional {@link PersistableBundle} that the suspending app can
9236 * provide which will be shared with the launcher. Ignored if
9237 * {@code suspended} is false.
9238 * @param dialogMessage The message to be displayed to the user, when they try to launch a
9239 * suspended app.
9240 *
9241 * @return an array of package names for which the suspended status could not be set as
9242 * requested in this method. Returns {@code null} if {@code packageNames} was {@code null}.
9243 *
9244 * @deprecated use {@link #setPackagesSuspended(String[], boolean, PersistableBundle,
9245 * PersistableBundle, android.content.pm.SuspendDialogInfo)} instead.
9246 *
9247 * @hide
9248 */
9249 @SystemApi
9250 @Deprecated
9251 @RequiresPermission(Manifest.permission.SUSPEND_APPS)
9252 @Nullable
9253 public String[] setPackagesSuspended(@Nullable String[] packageNames, boolean suspended,
9254 @Nullable PersistableBundle appExtras, @Nullable PersistableBundle launcherExtras,
9255 @Nullable String dialogMessage) {
9256 throw new UnsupportedOperationException("setPackagesSuspended not implemented");
9257 }
9258
9259 /**
9260 * Puts the given packages in a suspended state, where attempts at starting activities are
9261 * denied.
9262 *
9263 * <p>The suspended application's notifications and all of its windows will be hidden, any
9264 * of its started activities will be stopped and it won't be able to ring the device.
9265 * It doesn't remove the data or the actual package file.
9266 *
9267 * <p>When the user tries to launch a suspended app, a system dialog alerting them that the app
9268 * is suspended will be shown instead.
9269 * The caller can optionally customize the dialog by passing a {@link SuspendDialogInfo} object
9270 * to this API. This dialog will have a button that starts the
9271 * {@link Intent#ACTION_SHOW_SUSPENDED_APP_DETAILS} intent if the suspending app declares an
9272 * activity which handles this action.
9273 *
9274 * <p>The packages being suspended must already be installed. If a package is uninstalled, it
9275 * will no longer be suspended.
9276 *
9277 * <p>Optionally, the suspending app can provide extra information in the form of
9278 * {@link PersistableBundle} objects to be shared with the apps being suspended and the
9279 * launcher to support customization that they might need to handle the suspended state.
9280 *
9281 * <p>The caller must hold {@link Manifest.permission#SUSPEND_APPS} to use this API.
9282 *
9283 * @param packageNames The names of the packages to set the suspended status.
9284 * @param suspended If set to {@code true}, the packages will be suspended, if set to
9285 * {@code false}, the packages will be unsuspended.
9286 * @param appExtras An optional {@link PersistableBundle} that the suspending app can provide
9287 * which will be shared with the apps being suspended. Ignored if
9288 * {@code suspended} is false.
9289 * @param launcherExtras An optional {@link PersistableBundle} that the suspending app can
9290 * provide which will be shared with the launcher. Ignored if
9291 * {@code suspended} is false.
9292 * @param dialogInfo An optional {@link SuspendDialogInfo} object describing the dialog that
9293 * should be shown to the user when they try to launch a suspended app.
9294 * Ignored if {@code suspended} is false.
9295 *
9296 * @return an array of package names for which the suspended status could not be set as
9297 * requested in this method. Returns {@code null} if {@code packageNames} was {@code null}.
9298 *
9299 * @see #isPackageSuspended
9300 * @see SuspendDialogInfo
9301 * @see SuspendDialogInfo.Builder
9302 * @see Intent#ACTION_SHOW_SUSPENDED_APP_DETAILS
9303 *
9304 * @hide
9305 */
9306 @SystemApi
9307 @RequiresPermission(Manifest.permission.SUSPEND_APPS)
9308 @Nullable
9309 public String[] setPackagesSuspended(@Nullable String[] packageNames, boolean suspended,
9310 @Nullable PersistableBundle appExtras, @Nullable PersistableBundle launcherExtras,
9311 @Nullable SuspendDialogInfo dialogInfo) {
9312 throw new UnsupportedOperationException("setPackagesSuspended not implemented");
9313 }
9314
9315 /**
9316 * Returns any packages in a given set of packages that cannot be suspended via a call to {@link
9317 * #setPackagesSuspended(String[], boolean, PersistableBundle, PersistableBundle,
9318 * SuspendDialogInfo) setPackagesSuspended}. The platform prevents suspending certain critical
9319 * packages to keep the device in a functioning state, e.g. the default dialer and launcher.
9320 * Apps need to hold {@link Manifest.permission#SUSPEND_APPS SUSPEND_APPS} to call this API.
9321 *
9322 * <p>
9323 * Note that this set of critical packages can change with time, so even though a package name
9324 * was not returned by this call, it does not guarantee that a subsequent call to
9325 * {@link #setPackagesSuspended(String[], boolean, PersistableBundle, PersistableBundle,
9326 * SuspendDialogInfo) setPackagesSuspended} for that package will succeed, especially if
9327 * significant time elapsed between the two calls.
9328 *
9329 * @param packageNames The packages to check.
9330 * @return A list of packages that can not be currently suspended by the system.
9331 * @hide
9332 */
9333 @SystemApi
9334 @RequiresPermission(Manifest.permission.SUSPEND_APPS)
9335 @NonNull
9336 public String[] getUnsuspendablePackages(@NonNull String[] packageNames) {
9337 throw new UnsupportedOperationException("getUnsuspendablePackages not implemented");
9338 }
9339
9340 /**
9341 * @see #setPackagesSuspended(String[], boolean, PersistableBundle, PersistableBundle, String)
9342 * @param packageName The name of the package to get the suspended status of.
9343 * @param userId The user id.
9344 * @return {@code true} if the package is suspended or {@code false} if the package is not
9345 * suspended.
9346 * @throws IllegalArgumentException if the package was not found.
9347 * @hide
9348 */
9349 @SuppressWarnings("HiddenAbstractMethod")
9350 @UnsupportedAppUsage
9351 public abstract boolean isPackageSuspendedForUser(@NonNull String packageName, int userId);
9352
9353 /**
9354 * Query if an app is currently suspended.
9355 *
9356 * @return {@code true} if the given package is suspended, {@code false} otherwise
9357 * @throws NameNotFoundException if the package could not be found.
9358 *
9359 * @see #isPackageSuspended()
9360 */
9361 public boolean isPackageSuspended(@NonNull String packageName) throws NameNotFoundException {
9362 throw new UnsupportedOperationException("isPackageSuspended not implemented");
9363 }
9364
9365 /**
9366 * Apps can query this to know if they have been suspended. A system app with the permission
9367 * {@code android.permission.SUSPEND_APPS} can put any app on the device into a suspended state.
9368 *
9369 * <p>While in this state, the application's notifications will be hidden, any of its started
9370 * activities will be stopped and it will not be able to show toasts or dialogs or play audio.
9371 * When the user tries to launch a suspended app, the system will, instead, show a
9372 * dialog to the user informing them that they cannot use this app while it is suspended.
9373 *
9374 * <p>When an app is put into this state, the broadcast action
9375 * {@link Intent#ACTION_MY_PACKAGE_SUSPENDED} will be delivered to any of its broadcast
9376 * receivers that included this action in their intent-filters, <em>including manifest
9377 * receivers.</em> Similarly, a broadcast action {@link Intent#ACTION_MY_PACKAGE_UNSUSPENDED}
9378 * is delivered when a previously suspended app is taken out of this state. Apps are expected to
9379 * use these to gracefully deal with transitions to and from this state.
9380 *
9381 * @return {@code true} if the calling package has been suspended, {@code false} otherwise.
9382 *
9383 * @see #getSuspendedPackageAppExtras()
9384 * @see Intent#ACTION_MY_PACKAGE_SUSPENDED
9385 * @see Intent#ACTION_MY_PACKAGE_UNSUSPENDED
9386 */
9387 public boolean isPackageSuspended() {
9388 throw new UnsupportedOperationException("isPackageSuspended not implemented");
9389 }
9390
9391 /**
9392 * Returns a {@link Bundle} of extras that was meant to be sent to the calling app when it was
9393 * suspended. An app with the permission {@code android.permission.SUSPEND_APPS} can supply this
9394 * to the system at the time of suspending an app.
9395 *
9396 * <p>This is the same {@link Bundle} that is sent along with the broadcast
9397 * {@link Intent#ACTION_MY_PACKAGE_SUSPENDED}, whenever the app is suspended. The contents of
9398 * this {@link Bundle} are a contract between the suspended app and the suspending app.
9399 *
9400 * <p>Note: These extras are optional, so if no extras were supplied to the system, this method
9401 * will return {@code null}, even when the calling app has been suspended.
9402 *
9403 * @return A {@link Bundle} containing the extras for the app, or {@code null} if the
9404 * package is not currently suspended.
9405 *
9406 * @see #isPackageSuspended()
9407 * @see Intent#ACTION_MY_PACKAGE_UNSUSPENDED
9408 * @see Intent#ACTION_MY_PACKAGE_SUSPENDED
9409 * @see Intent#EXTRA_SUSPENDED_PACKAGE_EXTRAS
9410 */
9411 public @Nullable Bundle getSuspendedPackageAppExtras() {
9412 throw new UnsupportedOperationException("getSuspendedPackageAppExtras not implemented");
9413 }
9414
9415 /**
9416 * Provide a hint of what the {@link ApplicationInfo#category} value should
9417 * be for the given package.
9418 * <p>
9419 * This hint can only be set by the app which installed this package, as
9420 * determined by {@link #getInstallerPackageName(String)}.
9421 *
9422 * @param packageName the package to change the category hint for.
9423 * @param categoryHint the category hint to set.
9424 */
9425 @SuppressWarnings("HiddenAbstractMethod")
9426 public abstract void setApplicationCategoryHint(@NonNull String packageName,
9427 @ApplicationInfo.Category int categoryHint);
9428
9429 /** {@hide} */
9430 public static boolean isMoveStatusFinished(int status) {
9431 return (status < 0 || status > 100);
9432 }
9433
9434 /** {@hide} */
9435 public static abstract class MoveCallback {
9436 public void onCreated(int moveId, Bundle extras) {}
9437 public abstract void onStatusChanged(int moveId, int status, long estMillis);
9438 }
9439
9440 /** {@hide} */
9441 @SuppressWarnings("HiddenAbstractMethod")
9442 @UnsupportedAppUsage
9443 public abstract int getMoveStatus(int moveId);
9444
9445 /** {@hide} */
9446 @SuppressWarnings("HiddenAbstractMethod")
9447 @UnsupportedAppUsage
9448 public abstract void registerMoveCallback(@NonNull MoveCallback callback,
9449 @NonNull Handler handler);
9450 /** {@hide} */
9451 @SuppressWarnings("HiddenAbstractMethod")
9452 @UnsupportedAppUsage
9453 public abstract void unregisterMoveCallback(@NonNull MoveCallback callback);
9454
9455 /** {@hide} */
9456 @SuppressWarnings("HiddenAbstractMethod")
9457 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
9458 public abstract int movePackage(@NonNull String packageName, @NonNull VolumeInfo vol);
9459 /** {@hide} */
9460 @SuppressWarnings("HiddenAbstractMethod")
9461 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
9462 public abstract @Nullable VolumeInfo getPackageCurrentVolume(@NonNull ApplicationInfo app);
9463 /** {@hide} */
9464 @SuppressWarnings("HiddenAbstractMethod")
9465 @NonNull
9466 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
9467 public abstract List<VolumeInfo> getPackageCandidateVolumes(
9468 @NonNull ApplicationInfo app);
9469
9470 /** {@hide} */
9471 @SuppressWarnings("HiddenAbstractMethod")
9472 public abstract int movePrimaryStorage(@NonNull VolumeInfo vol);
9473 /** {@hide} */
9474 @SuppressWarnings("HiddenAbstractMethod")
9475 public abstract @Nullable VolumeInfo getPrimaryStorageCurrentVolume();
9476 /** {@hide} */
9477 @SuppressWarnings("HiddenAbstractMethod")
9478 public abstract @NonNull List<VolumeInfo> getPrimaryStorageCandidateVolumes();
9479
9480 /**
9481 * Returns the device identity that verifiers can use to associate their scheme to a particular
9482 * device. This should not be used by anything other than a package verifier.
9483 *
9484 * @return identity that uniquely identifies current device
9485 * @hide
9486 */
9487 @SuppressWarnings("HiddenAbstractMethod")
9488 @NonNull
9489 public abstract VerifierDeviceIdentity getVerifierDeviceIdentity();
9490
9491 /**
9492 * Returns true if the device is upgrading, such as first boot after OTA.
9493 *
9494 * @hide
9495 */
9496 @SuppressWarnings("HiddenAbstractMethod")
9497 @UnsupportedAppUsage
9498 public abstract boolean isUpgrade();
9499
9500 /**
9501 * Returns true if the device is upgrading, such as first boot after OTA.
9502 */
9503 public boolean isDeviceUpgrading() {
9504 return false;
9505 }
9506
9507 /**
9508 * Return interface that offers the ability to install, upgrade, and remove
9509 * applications on the device.
9510 */
9511 public abstract @NonNull PackageInstaller getPackageInstaller();
9512
9513 /**
9514 * Adds a {@code CrossProfileIntentFilter}. After calling this method all
9515 * intents sent from the user with id sourceUserId can also be be resolved
9516 * by activities in the user with id targetUserId if they match the
9517 * specified intent filter.
9518 *
9519 * @param filter The {@link IntentFilter} the intent has to match
9520 * @param sourceUserId The source user id.
9521 * @param targetUserId The target user id.
9522 * @param flags The possible values are {@link #SKIP_CURRENT_PROFILE} and
9523 * {@link #ONLY_IF_NO_MATCH_FOUND}.
9524 * @hide
9525 */
9526 @SuppressWarnings("HiddenAbstractMethod")
9527 @UnsupportedAppUsage
9528 public abstract void addCrossProfileIntentFilter(@NonNull IntentFilter filter,
9529 @UserIdInt int sourceUserId, @UserIdInt int targetUserId, int flags);
9530
9531 /**
9532 * Clearing {@code CrossProfileIntentFilter}s which have the specified user
9533 * as their source, and have been set by the app calling this method.
9534 *
9535 * @param sourceUserId The source user id.
9536 * @hide
9537 */
9538 @SuppressWarnings("HiddenAbstractMethod")
9539 @UnsupportedAppUsage
9540 public abstract void clearCrossProfileIntentFilters(@UserIdInt int sourceUserId);
9541
9542 /**
9543 * @hide
9544 */
9545 @SuppressWarnings("HiddenAbstractMethod")
9546 @NonNull
9547 @UnsupportedAppUsage
9548 public abstract Drawable loadItemIcon(@NonNull PackageItemInfo itemInfo,
9549 @Nullable ApplicationInfo appInfo);
9550
9551 /**
9552 * @hide
9553 */
9554 @SuppressWarnings("HiddenAbstractMethod")
9555 @NonNull
9556 @UnsupportedAppUsage
9557 public abstract Drawable loadUnbadgedItemIcon(@NonNull PackageItemInfo itemInfo,
9558 @Nullable ApplicationInfo appInfo);
9559
9560 /** {@hide} */
9561 @SuppressWarnings("HiddenAbstractMethod")
9562 @UnsupportedAppUsage
9563 public abstract boolean isPackageAvailable(@NonNull String packageName);
9564
9565 /** {@hide} */
9566 @NonNull
9567 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
9568 public static String installStatusToString(int status, @Nullable String msg) {
9569 final String str = installStatusToString(status);
9570 if (msg != null) {
9571 return str + ": " + msg;
9572 } else {
9573 return str;
9574 }
9575 }
9576
9577 /** {@hide} */
9578 @NonNull
9579 @UnsupportedAppUsage
9580 public static String installStatusToString(int status) {
9581 switch (status) {
9582 case INSTALL_SUCCEEDED: return "INSTALL_SUCCEEDED";
9583 case INSTALL_FAILED_ALREADY_EXISTS: return "INSTALL_FAILED_ALREADY_EXISTS";
9584 case INSTALL_FAILED_INVALID_APK: return "INSTALL_FAILED_INVALID_APK";
9585 case INSTALL_FAILED_INVALID_URI: return "INSTALL_FAILED_INVALID_URI";
9586 case INSTALL_FAILED_INSUFFICIENT_STORAGE: return "INSTALL_FAILED_INSUFFICIENT_STORAGE";
9587 case INSTALL_FAILED_DUPLICATE_PACKAGE: return "INSTALL_FAILED_DUPLICATE_PACKAGE";
9588 case INSTALL_FAILED_NO_SHARED_USER: return "INSTALL_FAILED_NO_SHARED_USER";
9589 case INSTALL_FAILED_UPDATE_INCOMPATIBLE: return "INSTALL_FAILED_UPDATE_INCOMPATIBLE";
9590 case INSTALL_FAILED_SHARED_USER_INCOMPATIBLE: return "INSTALL_FAILED_SHARED_USER_INCOMPATIBLE";
9591 case INSTALL_FAILED_MISSING_SHARED_LIBRARY: return "INSTALL_FAILED_MISSING_SHARED_LIBRARY";
9592 case INSTALL_FAILED_REPLACE_COULDNT_DELETE: return "INSTALL_FAILED_REPLACE_COULDNT_DELETE";
9593 case INSTALL_FAILED_DEXOPT: return "INSTALL_FAILED_DEXOPT";
9594 case INSTALL_FAILED_OLDER_SDK: return "INSTALL_FAILED_OLDER_SDK";
9595 case INSTALL_FAILED_CONFLICTING_PROVIDER: return "INSTALL_FAILED_CONFLICTING_PROVIDER";
9596 case INSTALL_FAILED_NEWER_SDK: return "INSTALL_FAILED_NEWER_SDK";
9597 case INSTALL_FAILED_TEST_ONLY: return "INSTALL_FAILED_TEST_ONLY";
9598 case INSTALL_FAILED_CPU_ABI_INCOMPATIBLE: return "INSTALL_FAILED_CPU_ABI_INCOMPATIBLE";
9599 case INSTALL_FAILED_MISSING_FEATURE: return "INSTALL_FAILED_MISSING_FEATURE";
9600 case INSTALL_FAILED_CONTAINER_ERROR: return "INSTALL_FAILED_CONTAINER_ERROR";
9601 case INSTALL_FAILED_INVALID_INSTALL_LOCATION: return "INSTALL_FAILED_INVALID_INSTALL_LOCATION";
9602 case INSTALL_FAILED_MEDIA_UNAVAILABLE: return "INSTALL_FAILED_MEDIA_UNAVAILABLE";
9603 case INSTALL_FAILED_VERIFICATION_TIMEOUT: return "INSTALL_FAILED_VERIFICATION_TIMEOUT";
9604 case INSTALL_FAILED_VERIFICATION_FAILURE: return "INSTALL_FAILED_VERIFICATION_FAILURE";
9605 case INSTALL_FAILED_PACKAGE_CHANGED: return "INSTALL_FAILED_PACKAGE_CHANGED";
9606 case INSTALL_FAILED_UID_CHANGED: return "INSTALL_FAILED_UID_CHANGED";
9607 case INSTALL_FAILED_VERSION_DOWNGRADE: return "INSTALL_FAILED_VERSION_DOWNGRADE";
9608 case INSTALL_PARSE_FAILED_NOT_APK: return "INSTALL_PARSE_FAILED_NOT_APK";
9609 case INSTALL_PARSE_FAILED_BAD_MANIFEST: return "INSTALL_PARSE_FAILED_BAD_MANIFEST";
9610 case INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION: return "INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION";
9611 case INSTALL_PARSE_FAILED_NO_CERTIFICATES: return "INSTALL_PARSE_FAILED_NO_CERTIFICATES";
9612 case INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES: return "INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES";
9613 case INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING: return "INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING";
9614 case INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME: return "INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME";
9615 case INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID: return "INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID";
9616 case INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: return "INSTALL_PARSE_FAILED_MANIFEST_MALFORMED";
9617 case INSTALL_PARSE_FAILED_MANIFEST_EMPTY: return "INSTALL_PARSE_FAILED_MANIFEST_EMPTY";
9618 case INSTALL_FAILED_INTERNAL_ERROR: return "INSTALL_FAILED_INTERNAL_ERROR";
9619 case INSTALL_FAILED_USER_RESTRICTED: return "INSTALL_FAILED_USER_RESTRICTED";
9620 case INSTALL_FAILED_DUPLICATE_PERMISSION: return "INSTALL_FAILED_DUPLICATE_PERMISSION";
9621 case INSTALL_FAILED_NO_MATCHING_ABIS: return "INSTALL_FAILED_NO_MATCHING_ABIS";
9622 case INSTALL_FAILED_ABORTED: return "INSTALL_FAILED_ABORTED";
9623 case INSTALL_FAILED_BAD_DEX_METADATA: return "INSTALL_FAILED_BAD_DEX_METADATA";
9624 case INSTALL_FAILED_MISSING_SPLIT: return "INSTALL_FAILED_MISSING_SPLIT";
9625 case INSTALL_FAILED_BAD_SIGNATURE: return "INSTALL_FAILED_BAD_SIGNATURE";
9626 case INSTALL_FAILED_WRONG_INSTALLED_VERSION: return "INSTALL_FAILED_WRONG_INSTALLED_VERSION";
9627 case INSTALL_FAILED_PROCESS_NOT_DEFINED: return "INSTALL_FAILED_PROCESS_NOT_DEFINED";
9628 case INSTALL_FAILED_SESSION_INVALID: return "INSTALL_FAILED_SESSION_INVALID";
9629 default: return Integer.toString(status);
9630 }
9631 }
9632
9633 /** {@hide} */
9634 public static int installStatusToPublicStatus(int status) {
9635 switch (status) {
9636 case INSTALL_SUCCEEDED: return PackageInstaller.STATUS_SUCCESS;
9637 case INSTALL_FAILED_ALREADY_EXISTS: return PackageInstaller.STATUS_FAILURE_CONFLICT;
9638 case INSTALL_FAILED_INVALID_APK: return PackageInstaller.STATUS_FAILURE_INVALID;
9639 case INSTALL_FAILED_INVALID_URI: return PackageInstaller.STATUS_FAILURE_INVALID;
9640 case INSTALL_FAILED_INSUFFICIENT_STORAGE: return PackageInstaller.STATUS_FAILURE_STORAGE;
9641 case INSTALL_FAILED_DUPLICATE_PACKAGE: return PackageInstaller.STATUS_FAILURE_CONFLICT;
9642 case INSTALL_FAILED_NO_SHARED_USER: return PackageInstaller.STATUS_FAILURE_CONFLICT;
9643 case INSTALL_FAILED_UPDATE_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_CONFLICT;
9644 case INSTALL_FAILED_SHARED_USER_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_CONFLICT;
9645 case INSTALL_FAILED_MISSING_SHARED_LIBRARY: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
9646 case INSTALL_FAILED_REPLACE_COULDNT_DELETE: return PackageInstaller.STATUS_FAILURE_CONFLICT;
9647 case INSTALL_FAILED_DEXOPT: return PackageInstaller.STATUS_FAILURE_INVALID;
9648 case INSTALL_FAILED_OLDER_SDK: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
9649 case INSTALL_FAILED_CONFLICTING_PROVIDER: return PackageInstaller.STATUS_FAILURE_CONFLICT;
9650 case INSTALL_FAILED_NEWER_SDK: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
9651 case INSTALL_FAILED_TEST_ONLY: return PackageInstaller.STATUS_FAILURE_INVALID;
9652 case INSTALL_FAILED_CPU_ABI_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
9653 case INSTALL_FAILED_MISSING_FEATURE: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
9654 case INSTALL_FAILED_CONTAINER_ERROR: return PackageInstaller.STATUS_FAILURE_STORAGE;
9655 case INSTALL_FAILED_INVALID_INSTALL_LOCATION: return PackageInstaller.STATUS_FAILURE_STORAGE;
9656 case INSTALL_FAILED_MEDIA_UNAVAILABLE: return PackageInstaller.STATUS_FAILURE_STORAGE;
9657 case INSTALL_FAILED_VERIFICATION_TIMEOUT: return PackageInstaller.STATUS_FAILURE_ABORTED;
9658 case INSTALL_FAILED_VERIFICATION_FAILURE: return PackageInstaller.STATUS_FAILURE_ABORTED;
9659 case INSTALL_FAILED_PACKAGE_CHANGED: return PackageInstaller.STATUS_FAILURE_INVALID;
9660 case INSTALL_FAILED_UID_CHANGED: return PackageInstaller.STATUS_FAILURE_INVALID;
9661 case INSTALL_FAILED_VERSION_DOWNGRADE: return PackageInstaller.STATUS_FAILURE_INVALID;
9662 case INSTALL_FAILED_PERMISSION_MODEL_DOWNGRADE: return PackageInstaller.STATUS_FAILURE_INVALID;
9663 case INSTALL_PARSE_FAILED_NOT_APK: return PackageInstaller.STATUS_FAILURE_INVALID;
9664 case INSTALL_PARSE_FAILED_BAD_MANIFEST: return PackageInstaller.STATUS_FAILURE_INVALID;
9665 case INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION: return PackageInstaller.STATUS_FAILURE_INVALID;
9666 case INSTALL_PARSE_FAILED_NO_CERTIFICATES: return PackageInstaller.STATUS_FAILURE_INVALID;
9667 case INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES: return PackageInstaller.STATUS_FAILURE_INVALID;
9668 case INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING: return PackageInstaller.STATUS_FAILURE_INVALID;
9669 case INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME: return PackageInstaller.STATUS_FAILURE_INVALID;
9670 case INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID: return PackageInstaller.STATUS_FAILURE_INVALID;
9671 case INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: return PackageInstaller.STATUS_FAILURE_INVALID;
9672 case INSTALL_PARSE_FAILED_MANIFEST_EMPTY: return PackageInstaller.STATUS_FAILURE_INVALID;
9673 case INSTALL_FAILED_BAD_DEX_METADATA: return PackageInstaller.STATUS_FAILURE_INVALID;
9674 case INSTALL_FAILED_BAD_SIGNATURE: return PackageInstaller.STATUS_FAILURE_INVALID;
9675 case INSTALL_FAILED_INTERNAL_ERROR: return PackageInstaller.STATUS_FAILURE;
9676 case INSTALL_FAILED_USER_RESTRICTED: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
9677 case INSTALL_FAILED_DUPLICATE_PERMISSION: return PackageInstaller.STATUS_FAILURE_CONFLICT;
9678 case INSTALL_FAILED_NO_MATCHING_ABIS: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
9679 case INSTALL_FAILED_ABORTED: return PackageInstaller.STATUS_FAILURE_ABORTED;
9680 case INSTALL_FAILED_MISSING_SPLIT: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
9681 default: return PackageInstaller.STATUS_FAILURE;
9682 }
9683 }
9684
9685 /** {@hide} */
9686 @NonNull
9687 public static String deleteStatusToString(int status, @Nullable String msg) {
9688 final String str = deleteStatusToString(status);
9689 if (msg != null) {
9690 return str + ": " + msg;
9691 } else {
9692 return str;
9693 }
9694 }
9695
9696 /** {@hide} */
9697 @NonNull
9698 @UnsupportedAppUsage
9699 public static String deleteStatusToString(int status) {
9700 switch (status) {
9701 case DELETE_SUCCEEDED: return "DELETE_SUCCEEDED";
9702 case DELETE_FAILED_INTERNAL_ERROR: return "DELETE_FAILED_INTERNAL_ERROR";
9703 case DELETE_FAILED_DEVICE_POLICY_MANAGER: return "DELETE_FAILED_DEVICE_POLICY_MANAGER";
9704 case DELETE_FAILED_USER_RESTRICTED: return "DELETE_FAILED_USER_RESTRICTED";
9705 case DELETE_FAILED_OWNER_BLOCKED: return "DELETE_FAILED_OWNER_BLOCKED";
9706 case DELETE_FAILED_ABORTED: return "DELETE_FAILED_ABORTED";
9707 case DELETE_FAILED_USED_SHARED_LIBRARY: return "DELETE_FAILED_USED_SHARED_LIBRARY";
9708 case DELETE_FAILED_APP_PINNED: return "DELETE_FAILED_APP_PINNED";
9709 default: return Integer.toString(status);
9710 }
9711 }
9712
9713 /** {@hide} */
9714 public static int deleteStatusToPublicStatus(int status) {
9715 switch (status) {
9716 case DELETE_SUCCEEDED: return PackageInstaller.STATUS_SUCCESS;
9717 case DELETE_FAILED_INTERNAL_ERROR: return PackageInstaller.STATUS_FAILURE;
9718 case DELETE_FAILED_DEVICE_POLICY_MANAGER: return PackageInstaller.STATUS_FAILURE_BLOCKED;
9719 case DELETE_FAILED_USER_RESTRICTED: return PackageInstaller.STATUS_FAILURE_BLOCKED;
9720 case DELETE_FAILED_OWNER_BLOCKED: return PackageInstaller.STATUS_FAILURE_BLOCKED;
9721 case DELETE_FAILED_ABORTED: return PackageInstaller.STATUS_FAILURE_ABORTED;
9722 case DELETE_FAILED_USED_SHARED_LIBRARY: return PackageInstaller.STATUS_FAILURE_CONFLICT;
9723 case DELETE_FAILED_APP_PINNED: return PackageInstaller.STATUS_FAILURE_BLOCKED;
9724 default: return PackageInstaller.STATUS_FAILURE;
9725 }
9726 }
9727
9728 /** {@hide} */
9729 @NonNull
9730 public static String permissionFlagToString(int flag) {
9731 switch (flag) {
9732 case FLAG_PERMISSION_GRANTED_BY_DEFAULT: return "GRANTED_BY_DEFAULT";
9733 case FLAG_PERMISSION_POLICY_FIXED: return "POLICY_FIXED";
9734 case FLAG_PERMISSION_SYSTEM_FIXED: return "SYSTEM_FIXED";
9735 case FLAG_PERMISSION_USER_SET: return "USER_SET";
9736 case FLAG_PERMISSION_USER_FIXED: return "USER_FIXED";
9737 case FLAG_PERMISSION_REVIEW_REQUIRED: return "REVIEW_REQUIRED";
9738 case FLAG_PERMISSION_REVOKE_WHEN_REQUESTED: return "REVOKE_WHEN_REQUESTED";
9739 case FLAG_PERMISSION_USER_SENSITIVE_WHEN_GRANTED: return "USER_SENSITIVE_WHEN_GRANTED";
9740 case FLAG_PERMISSION_USER_SENSITIVE_WHEN_DENIED: return "USER_SENSITIVE_WHEN_DENIED";
9741 case FLAG_PERMISSION_RESTRICTION_INSTALLER_EXEMPT: return "RESTRICTION_INSTALLER_EXEMPT";
9742 case FLAG_PERMISSION_RESTRICTION_SYSTEM_EXEMPT: return "RESTRICTION_SYSTEM_EXEMPT";
9743 case FLAG_PERMISSION_RESTRICTION_UPGRADE_EXEMPT: return "RESTRICTION_UPGRADE_EXEMPT";
9744 case FLAG_PERMISSION_APPLY_RESTRICTION: return "APPLY_RESTRICTION";
9745 case FLAG_PERMISSION_GRANTED_BY_ROLE: return "GRANTED_BY_ROLE";
9746 case FLAG_PERMISSION_REVOKED_COMPAT: return "REVOKED_COMPAT";
9747 case FLAG_PERMISSION_ONE_TIME: return "ONE_TIME";
9748 case FLAG_PERMISSION_AUTO_REVOKED: return "AUTO_REVOKED";
9749 default: return Integer.toString(flag);
9750 }
9751 }
9752
9753 /** {@hide} */
9754 public static class LegacyPackageDeleteObserver extends PackageDeleteObserver {
9755 private final IPackageDeleteObserver mLegacy;
9756
9757 public LegacyPackageDeleteObserver(IPackageDeleteObserver legacy) {
9758 mLegacy = legacy;
9759 }
9760
9761 @Override
9762 public void onPackageDeleted(String basePackageName, int returnCode, String msg) {
9763 if (mLegacy == null) return;
9764 try {
9765 mLegacy.packageDeleted(basePackageName, returnCode);
9766 } catch (RemoteException ignored) {
9767 }
9768 }
9769 }
9770
9771 /**
9772 * Return the install reason that was recorded when a package was first
9773 * installed for a specific user. Requesting the install reason for another
9774 * user will require the permission INTERACT_ACROSS_USERS_FULL.
9775 *
9776 * @param packageName The package for which to retrieve the install reason
9777 * @param user The user for whom to retrieve the install reason
9778 * @return The install reason. If the package is not installed for the given
9779 * user, {@code INSTALL_REASON_UNKNOWN} is returned.
9780 * @hide
9781 */
9782 @SuppressWarnings("HiddenAbstractMethod")
9783 @TestApi
9784 @InstallReason
9785 public abstract int getInstallReason(@NonNull String packageName, @NonNull UserHandle user);
9786
9787 /**
9788 * Checks whether the calling package is allowed to request package installs through package
9789 * installer. Apps are encouraged to call this API before launching the package installer via
9790 * intent {@link android.content.Intent#ACTION_INSTALL_PACKAGE}. Starting from Android O, the
9791 * user can explicitly choose what external sources they trust to install apps on the device.
9792 * If this API returns false, the install request will be blocked by the package installer and
9793 * a dialog will be shown to the user with an option to launch settings to change their
9794 * preference. An application must target Android O or higher and declare permission
9795 * {@link android.Manifest.permission#REQUEST_INSTALL_PACKAGES} in order to use this API.
9796 *
9797 * @return true if the calling package is trusted by the user to request install packages on
9798 * the device, false otherwise.
9799 * @see android.content.Intent#ACTION_INSTALL_PACKAGE
9800 * @see android.provider.Settings#ACTION_MANAGE_UNKNOWN_APP_SOURCES
9801 */
9802 public abstract boolean canRequestPackageInstalls();
9803
9804 /**
9805 * Return the {@link ComponentName} of the activity providing Settings for the Instant App
9806 * resolver.
9807 *
9808 * @see {@link android.content.Intent#ACTION_INSTANT_APP_RESOLVER_SETTINGS}
9809 * @hide
9810 */
9811 @SuppressWarnings("HiddenAbstractMethod")
9812 @Nullable
9813 @SystemApi
9814 public abstract ComponentName getInstantAppResolverSettingsComponent();
9815
9816 /**
9817 * Return the {@link ComponentName} of the activity responsible for installing instant
9818 * applications.
9819 *
9820 * @see {@link android.content.Intent#ACTION_INSTALL_INSTANT_APP_PACKAGE}
9821 * @hide
9822 */
9823 @SuppressWarnings("HiddenAbstractMethod")
9824 @Nullable
9825 @SystemApi
9826 public abstract ComponentName getInstantAppInstallerComponent();
9827
9828 /**
9829 * Return the Android Id for a given Instant App.
9830 *
9831 * @see {@link android.provider.Settings.Secure#ANDROID_ID}
9832 * @hide
9833 */
9834 @SuppressWarnings("HiddenAbstractMethod")
9835 @Nullable
9836 public abstract String getInstantAppAndroidId(@NonNull String packageName,
9837 @NonNull UserHandle user);
9838
9839 /**
9840 * Callback use to notify the callers of module registration that the operation
9841 * has finished.
9842 *
9843 * @hide
9844 */
9845 @SystemApi
9846 public static abstract class DexModuleRegisterCallback {
9847 public abstract void onDexModuleRegistered(String dexModulePath, boolean success,
9848 String message);
9849 }
9850
9851 /**
9852 * Register an application dex module with the package manager.
9853 * The package manager will keep track of the given module for future optimizations.
9854 *
9855 * Dex module optimizations will disable the classpath checking at runtime. The client bares
9856 * the responsibility to ensure that the static assumptions on classes in the optimized code
9857 * hold at runtime (e.g. there's no duplicate classes in the classpath).
9858 *
9859 * Note that the package manager already keeps track of dex modules loaded with
9860 * {@link dalvik.system.DexClassLoader} and {@link dalvik.system.PathClassLoader}.
9861 * This can be called for an eager registration.
9862 *
9863 * The call might take a while and the results will be posted on the main thread, using
9864 * the given callback.
9865 *
9866 * If the module is intended to be shared with other apps, make sure that the file
9867 * permissions allow for it.
9868 * If at registration time the permissions allow for others to read it, the module would
9869 * be marked as a shared module which might undergo a different optimization strategy.
9870 * (usually shared modules will generated larger optimizations artifacts,
9871 * taking more disk space).
9872 *
9873 * @param dexModulePath the absolute path of the dex module.
9874 * @param callback if not null, {@link DexModuleRegisterCallback#onDexModuleRegistered} will
9875 * be called once the registration finishes.
9876 *
9877 * @hide
9878 */
9879 @SuppressWarnings("HiddenAbstractMethod")
9880 @SystemApi
9881 public abstract void registerDexModule(@NonNull String dexModulePath,
9882 @Nullable DexModuleRegisterCallback callback);
9883
9884 /**
9885 * Returns the {@link ArtManager} associated with this package manager.
9886 *
9887 * @hide
9888 */
9889 @SystemApi
9890 public @NonNull ArtManager getArtManager() {
9891 throw new UnsupportedOperationException("getArtManager not implemented in subclass");
9892 }
9893
9894 /**
9895 * Sets or clears the harmful app warning details for the given app.
9896 *
9897 * When set, any attempt to launch an activity in this package will be intercepted and a
9898 * warning dialog will be shown to the user instead, with the given warning. The user
9899 * will have the option to proceed with the activity launch, or to uninstall the application.
9900 *
9901 * @param packageName The full name of the package to warn on.
9902 * @param warning A warning string to display to the user describing the threat posed by the
9903 * application, or null to clear the warning.
9904 *
9905 * @hide
9906 */
9907 @RequiresPermission(Manifest.permission.SET_HARMFUL_APP_WARNINGS)
9908 @SystemApi
9909 public void setHarmfulAppWarning(@NonNull String packageName, @Nullable CharSequence warning) {
9910 throw new UnsupportedOperationException("setHarmfulAppWarning not implemented in subclass");
9911 }
9912
9913 /**
9914 * Returns the harmful app warning string for the given app, or null if there is none set.
9915 *
9916 * @param packageName The full name of the desired package.
9917 *
9918 * @hide
9919 */
9920 @RequiresPermission(Manifest.permission.SET_HARMFUL_APP_WARNINGS)
9921 @Nullable
9922 @SystemApi
9923 public CharSequence getHarmfulAppWarning(@NonNull String packageName) {
9924 throw new UnsupportedOperationException("getHarmfulAppWarning not implemented in subclass");
9925 }
9926
9927 /** @hide */
9928 @IntDef(prefix = { "CERT_INPUT_" }, value = {
9929 CERT_INPUT_RAW_X509,
9930 CERT_INPUT_SHA256
9931 })
9932 @Retention(RetentionPolicy.SOURCE)
9933 public @interface CertificateInputType {}
9934
9935 /**
9936 * Certificate input bytes: the input bytes represent an encoded X.509 Certificate which could
9937 * be generated using an {@code CertificateFactory}
9938 */
9939 public static final int CERT_INPUT_RAW_X509 = 0;
9940
9941 /**
9942 * Certificate input bytes: the input bytes represent the SHA256 output of an encoded X.509
9943 * Certificate.
9944 */
9945 public static final int CERT_INPUT_SHA256 = 1;
9946
9947 /**
9948 * Searches the set of signing certificates by which the given package has proven to have been
9949 * signed. This should be used instead of {@code getPackageInfo} with {@code GET_SIGNATURES}
9950 * since it takes into account the possibility of signing certificate rotation, except in the
9951 * case of packages that are signed by multiple certificates, for which signing certificate
9952 * rotation is not supported. This method is analogous to using {@code getPackageInfo} with
9953 * {@code GET_SIGNING_CERTIFICATES} and then searching through the resulting {@code
9954 * signingInfo} field to see if the desired certificate is present.
9955 *
9956 * @param packageName package whose signing certificates to check
9957 * @param certificate signing certificate for which to search
9958 * @param type representation of the {@code certificate}
9959 * @return true if this package was or is signed by exactly the certificate {@code certificate}
9960 */
9961 public boolean hasSigningCertificate(@NonNull String packageName, @NonNull byte[] certificate,
9962 @CertificateInputType int type) {
9963 throw new UnsupportedOperationException(
9964 "hasSigningCertificate not implemented in subclass");
9965 }
9966
9967 /**
9968 * Searches the set of signing certificates by which the package(s) for the given uid has proven
9969 * to have been signed. For multiple packages sharing the same uid, this will return the
9970 * signing certificates found in the signing history of the "newest" package, where "newest"
9971 * indicates the package with the newest signing certificate in the shared uid group. This
9972 * method should be used instead of {@code getPackageInfo} with {@code GET_SIGNATURES}
9973 * since it takes into account the possibility of signing certificate rotation, except in the
9974 * case of packages that are signed by multiple certificates, for which signing certificate
9975 * rotation is not supported. This method is analogous to using {@code getPackagesForUid}
9976 * followed by {@code getPackageInfo} with {@code GET_SIGNING_CERTIFICATES}, selecting the
9977 * {@code PackageInfo} of the newest-signed bpackage , and finally searching through the
9978 * resulting {@code signingInfo} field to see if the desired certificate is there.
9979 *
9980 * @param uid uid whose signing certificates to check
9981 * @param certificate signing certificate for which to search
9982 * @param type representation of the {@code certificate}
9983 * @return true if this package was or is signed by exactly the certificate {@code certificate}
9984 */
9985 public boolean hasSigningCertificate(
9986 int uid, @NonNull byte[] certificate, @CertificateInputType int type) {
9987 throw new UnsupportedOperationException(
9988 "hasSigningCertificate not implemented in subclass");
9989 }
9990
9991 /**
9992 * Trust any Installer to provide checksums for the package.
9993 * @see #requestChecksums
9994 */
9995 public static final @NonNull List<Certificate> TRUST_ALL = Collections.singletonList(null);
9996
9997 /**
9998 * Don't trust any Installer to provide checksums for the package.
9999 * This effectively disables optimized Installer-enforced checksums.
10000 * @see #requestChecksums
10001 */
10002 public static final @NonNull List<Certificate> TRUST_NONE = Collections.singletonList(null);
10003
10004 /** Listener that gets notified when checksums are available. */
10005 @FunctionalInterface
10006 public interface OnChecksumsReadyListener {
10007 /**
10008 * Called when the checksums are available.
10009 *
10010 * @param checksums array of checksums.
10011 */
10012 void onChecksumsReady(@NonNull List<ApkChecksum> checksums);
10013 }
10014
10015 /**
10016 * Requests the checksums for APKs within a package.
10017 * The checksums will be returned asynchronously via onChecksumsReadyListener.
10018 *
10019 * By default returns all readily available checksums:
10020 * - enforced by platform,
10021 * - enforced by installer.
10022 * If caller needs a specific checksum kind, they can specify it as required.
10023 *
10024 * <b>Caution: Android can not verify installer-provided checksums. Make sure you specify
10025 * trusted installers.</b>
10026 *
10027 * @param packageName whose checksums to return.
10028 * @param includeSplits whether to include checksums for non-base splits.
10029 * @param required explicitly request the checksum types. May incur significant
10030 * CPU/memory/disk usage.
10031 * @param trustedInstallers for checksums enforced by installer, which installers are to be
10032 * trusted.
10033 * {@link #TRUST_ALL} will return checksums from any installer,
10034 * {@link #TRUST_NONE} disables optimized installer-enforced checksums,
10035 * otherwise the list has to be non-empty list of certificates.
10036 * @param onChecksumsReadyListener called once when the results are available.
10037 * @throws CertificateEncodingException if an encoding error occurs for trustedInstallers.
10038 * @throws IllegalArgumentException if the list of trusted installer certificates is empty.
10039 * @throws NameNotFoundException if a package with the given name cannot be found on the system.
10040 */
10041 public void requestChecksums(@NonNull String packageName, boolean includeSplits,
10042 @Checksum.TypeMask int required, @NonNull List<Certificate> trustedInstallers,
10043 @NonNull OnChecksumsReadyListener onChecksumsReadyListener)
10044 throws CertificateEncodingException, NameNotFoundException {
10045 throw new UnsupportedOperationException("requestChecksums not implemented in subclass");
10046 }
10047
10048 /**
10049 * @return the default text classifier package name, or null if there's none.
10050 *
10051 * @hide
10052 */
10053 @Nullable
10054 @TestApi
10055 public String getDefaultTextClassifierPackageName() {
10056 throw new UnsupportedOperationException(
10057 "getDefaultTextClassifierPackageName not implemented in subclass");
10058 }
10059
10060 /**
10061 * @return the system defined text classifier package names, or null if there's none.
10062 *
10063 * @hide
10064 */
10065 @Nullable
10066 @TestApi
10067 public String getSystemTextClassifierPackageName() {
10068 throw new UnsupportedOperationException(
10069 "getSystemTextClassifierPackageName not implemented in subclass");
10070 }
10071
10072 /**
10073 * @return attention service package name, or null if there's none.
10074 *
10075 * @hide
10076 */
10077 public String getAttentionServicePackageName() {
10078 throw new UnsupportedOperationException(
10079 "getAttentionServicePackageName not implemented in subclass");
10080 }
10081
10082 /**
10083 * @return rotation resolver service's package name, or null if there's none.
10084 *
10085 * @hide
10086 */
10087 public String getRotationResolverPackageName() {
10088 throw new UnsupportedOperationException(
10089 "getRotationResolverPackageName not implemented in subclass");
10090 }
10091
10092 /**
10093 * @return the wellbeing app package name, or null if it's not defined by the OEM.
10094 *
10095 * @hide
10096 */
10097 @Nullable
10098 @TestApi
10099 public String getWellbeingPackageName() {
10100 throw new UnsupportedOperationException(
10101 "getWellbeingPackageName not implemented in subclass");
10102 }
10103
10104 /**
10105 * @return the system defined app predictor package name, or null if there's none.
10106 *
10107 * @hide
10108 */
10109 @Nullable
10110 public String getAppPredictionServicePackageName() {
10111 throw new UnsupportedOperationException(
10112 "getAppPredictionServicePackageName not implemented in subclass");
10113 }
10114
10115 /**
10116 * @return the system defined content capture service package name, or null if there's none.
10117 *
10118 * @hide
10119 */
10120 @Nullable
10121 public String getSystemCaptionsServicePackageName() {
10122 throw new UnsupportedOperationException(
10123 "getSystemCaptionsServicePackageName not implemented in subclass");
10124 }
10125
10126 /**
10127 * @return the system defined setup wizard package name, or null if there's none.
10128 *
10129 * @hide
10130 */
10131 @Nullable
10132 public String getSetupWizardPackageName() {
10133 throw new UnsupportedOperationException(
10134 "getSetupWizardPackageName not implemented in subclass");
10135 }
10136
10137 /**
10138 * @return the system defined content capture package name, or null if there's none.
10139 *
10140 * @hide
10141 */
10142 @TestApi
10143 @Nullable
10144 public String getContentCaptureServicePackageName() {
10145 throw new UnsupportedOperationException(
10146 "getContentCaptureServicePackageName not implemented in subclass");
10147 }
10148
10149 /**
10150 * @return the incident report approver app package name, or null if it's not defined
10151 * by the OEM.
10152 *
10153 * @hide
10154 */
10155 @SystemApi
10156 @Nullable
10157 public String getIncidentReportApproverPackageName() {
10158 throw new UnsupportedOperationException(
10159 "getIncidentReportApproverPackageName not implemented in subclass");
10160 }
10161
10162 /**
10163 * @return whether a given package's state is protected, e.g. package cannot be disabled,
10164 * suspended, hidden or force stopped.
10165 *
10166 * @hide
10167 */
10168 public boolean isPackageStateProtected(@NonNull String packageName, @UserIdInt int userId) {
10169 throw new UnsupportedOperationException(
10170 "isPackageStateProtected not implemented in subclass");
10171 }
10172
10173 /**
10174 * Notify to the rest of the system that a new device configuration has
10175 * been prepared and that it is time to refresh caches.
10176 *
10177 * @see android.content.Intent#ACTION_DEVICE_CUSTOMIZATION_READY
10178 *
10179 * @hide
10180 */
10181 @SystemApi
10182 public void sendDeviceCustomizationReadyBroadcast() {
10183 throw new UnsupportedOperationException(
10184 "sendDeviceCustomizationReadyBroadcast not implemented in subclass");
10185 }
10186
10187 /**
10188 * <p>
10189 * <strong>Note: </strong>In retrospect it would have been preferred to use
10190 * more inclusive terminology when naming this API. Similar APIs added will
10191 * refrain from using the term "whitelist".
10192 * </p>
10193 *
10194 * @return whether this package is whitelisted from having its runtime permission be
10195 * auto-revoked if unused for an extended period of time.
10196 */
10197 public boolean isAutoRevokeWhitelisted() {
10198 throw new UnsupportedOperationException(
10199 "isAutoRevokeWhitelisted not implemented in subclass");
10200 }
10201
10202 /**
10203 * Returns if the provided drawable represents the default activity icon provided by the system.
10204 *
10205 * PackageManager silently returns a default application icon for any package/activity if the
10206 * app itself does not define one or if the system encountered any error when loading the icon.
10207 *
10208 * Developers can use this to check implement app specific logic around retrying or caching.
10209 *
10210 * @return true if the drawable represents the default activity icon, false otherwise
10211 * @see #getDefaultActivityIcon()
10212 * @see #getActivityIcon
10213 * @see LauncherActivityInfo#getIcon(int)
10214 */
10215 public boolean isDefaultApplicationIcon(@NonNull Drawable drawable) {
10216 int resId = drawable instanceof AdaptiveIconDrawable
10217 ? ((AdaptiveIconDrawable) drawable).getSourceDrawableResId() : Resources.ID_NULL;
10218 return resId == com.android.internal.R.drawable.sym_def_app_icon
10219 || resId == com.android.internal.R.drawable.sym_app_on_sd_unavailable_icon;
10220 }
10221
10222 /**
10223 * Sets MIME group's MIME types.
10224 *
10225 * Libraries should use a reverse-DNS prefix followed by a ':' character and library-specific
10226 * group name to avoid namespace collisions, e.g. "com.example:myFeature".
10227 *
10228 * @param mimeGroup MIME group to modify.
10229 * @param mimeTypes new MIME types contained by MIME group.
10230 * @throws IllegalArgumentException if the MIME group was not declared in the manifest.
10231 */
10232 public void setMimeGroup(@NonNull String mimeGroup, @NonNull Set<String> mimeTypes) {
10233 throw new UnsupportedOperationException(
10234 "setMimeGroup not implemented in subclass");
10235 }
10236
10237 /**
10238 * Gets all MIME types contained by MIME group.
10239 *
10240 * Libraries should use a reverse-DNS prefix followed by a ':' character and library-specific
10241 * group name to avoid namespace collisions, e.g. "com.example:myFeature".
10242 *
10243 * @param mimeGroup MIME group to retrieve.
10244 * @return MIME types contained by the MIME group.
10245 * @throws IllegalArgumentException if the MIME group was not declared in the manifest.
10246 */
10247 @NonNull
10248 public Set<String> getMimeGroup(@NonNull String mimeGroup) {
10249 throw new UnsupportedOperationException(
10250 "getMimeGroup not implemented in subclass");
10251 }
10252
10253 /**
10254 * Returns the property defined in the given package's &lt;appliction&gt; tag.
10255 *
10256 * @throws NameNotFoundException if either the given package is not installed or if the
10257 * given property is not defined within the &lt;application&gt; tag.
10258 */
10259 @NonNull
10260 public Property getProperty(@NonNull String propertyName, @NonNull String packageName)
10261 throws NameNotFoundException {
10262 throw new UnsupportedOperationException(
10263 "getProperty not implemented in subclass");
10264 }
10265
10266 /**
10267 * Returns the property defined in the given component declaration.
10268 *
10269 * @throws NameNotFoundException if either the given component does not exist or if the
10270 * given property is not defined within the component declaration.
10271 */
10272 @NonNull
10273 public Property getProperty(@NonNull String propertyName, @NonNull ComponentName component)
10274 throws NameNotFoundException {
10275 throw new UnsupportedOperationException(
10276 "getProperty not implemented in subclass");
10277 }
10278
10279 /**
10280 * Returns the property definition for all &lt;application&gt; tags.
10281 * <p>If the property is not defined with any &lt;application&gt; tag,
10282 * returns and empty list.
10283 */
10284 @NonNull
10285 public List<Property> queryApplicationProperty(@NonNull String propertyName) {
10286 throw new UnsupportedOperationException(
10287 "qeuryApplicationProperty not implemented in subclass");
10288 }
10289
10290 /**
10291 * Returns the property definition for all &lt;activity&gt; and &lt;activity-alias&gt; tags.
10292 * <p>If the property is not defined with any &lt;activity&gt; and &lt;activity-alias&gt; tag,
10293 * returns and empty list.
10294 */
10295 @NonNull
10296 public List<Property> queryActivityProperty(@NonNull String propertyName) {
10297 throw new UnsupportedOperationException(
10298 "qeuryActivityProperty not implemented in subclass");
10299 }
10300
10301 /**
10302 * Returns the property definition for all &lt;provider&gt; tags.
10303 * <p>If the property is not defined with any &lt;provider&gt; tag,
10304 * returns and empty list.
10305 */
10306 @NonNull
10307 public List<Property> queryProviderProperty(@NonNull String propertyName) {
10308 throw new UnsupportedOperationException(
10309 "qeuryProviderProperty not implemented in subclass");
10310 }
10311
10312 /**
10313 * Returns the property definition for all &lt;receiver&gt; tags.
10314 * <p>If the property is not defined with any &lt;receiver&gt; tag,
10315 * returns and empty list.
10316 */
10317 @NonNull
10318 public List<Property> queryReceiverProperty(@NonNull String propertyName) {
10319 throw new UnsupportedOperationException(
10320 "qeuryReceiverProperty not implemented in subclass");
10321 }
10322
10323 /**
10324 * Returns the property definition for all &lt;service&gt; tags.
10325 * <p>If the property is not defined with any &lt;service&gt; tag,
10326 * returns and empty list.
10327 */
10328 @NonNull
10329 public List<Property> queryServiceProperty(@NonNull String propertyName) {
10330 throw new UnsupportedOperationException(
10331 "qeuryServiceProperty not implemented in subclass");
10332 }
10333
10334 /**
10335 * Returns {@code true} if the source package is able to query for details about the
10336 * target package. Applications that share details about other applications should
10337 * use this API to determine if those details should be withheld from callers that
10338 * do not otherwise have visibility of them.
10339 * <p>
10340 * Note: The caller must be able to query for details about the source and target
10341 * package. A {@link NameNotFoundException} is thrown if it isn't.
10342 *
10343 * @param sourcePackageName The source package that would receive details about the
10344 * target package.
10345 * @param targetPackageName The target package whose details would be shared with the
10346 * source package.
10347 * @return {@code true} if the source package is able to query for details about the
10348 * target package.
10349 * @throws NameNotFoundException if either a given package can not be found on the
10350 * system, or if the caller is not able to query for details about the source or
10351 * target package.
10352 */
10353 public boolean canPackageQuery(@NonNull String sourcePackageName,
10354 @NonNull String targetPackageName) throws NameNotFoundException {
10355 throw new UnsupportedOperationException(
10356 "canPackageQuery not implemented in subclass");
10357 }
10358
10359 /**
10360 * Makes a package that provides an authority {@code visibleAuthority} become visible to the
10361 * application {@code recipientUid}.
10362 *
10363 * @throws SecurityException when called by a package other than the contacts provider
10364 * @hide
10365 */
10366 public void makeProviderVisible(int recipientUid, String visibleAuthority) {
10367 try {
10368 ActivityThread.getPackageManager().makeProviderVisible(recipientUid, visibleAuthority);
10369 } catch (RemoteException e) {
10370 throw e.rethrowFromSystemServer();
10371 }
10372 }
10373
10374 /**
10375 * Makes the package associated with the uid {@code visibleUid} become visible to the
10376 * recipient application. The recipient application can receive the details about the
10377 * visible package if successful.
10378 * <p>
10379 * Read <a href="/training/basics/intents/package-visibility">package visibility</a> for more
10380 * information.
10381 *
10382 * @param recipientUid The uid of the application that is being given access to {@code
10383 * visibleUid}
10384 * @param visibleUid The uid of the application that is becoming accessible to {@code
10385 * recipientAppId}
10386 * @hide
10387 */
10388 @RequiresPermission(android.Manifest.permission.MAKE_UID_VISIBLE)
10389 @TestApi
10390 @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
10391 public void makeUidVisible(int recipientUid, int visibleUid) {
10392 throw new UnsupportedOperationException(
10393 "makeUidVisible not implemented in subclass");
10394 }
10395
10396 // Some of the flags don't affect the query result, but let's be conservative and cache
10397 // each combination of flags separately.
10398
10399 private static final class ApplicationInfoQuery {
10400 final String packageName;
10401 final long flags;
10402 final int userId;
10403
10404 ApplicationInfoQuery(@Nullable String packageName, @ApplicationInfoFlagsBits long flags,
10405 int userId) {
10406 this.packageName = packageName;
10407 this.flags = flags;
10408 this.userId = userId;
10409 }
10410
10411 @Override
10412 public String toString() {
10413 return String.format(
10414 "ApplicationInfoQuery(packageName=\"%s\", flags=%s, userId=%s)",
10415 packageName, flags, userId);
10416 }
10417
10418 @Override
10419 public int hashCode() {
10420 int hash = Objects.hashCode(packageName);
10421 hash = hash * 13 + Objects.hashCode(flags);
10422 hash = hash * 13 + Objects.hashCode(userId);
10423 return hash;
10424 }
10425
10426 @Override
10427 public boolean equals(@Nullable Object rval) {
10428 if (rval == null) {
10429 return false;
10430 }
10431 ApplicationInfoQuery other;
10432 try {
10433 other = (ApplicationInfoQuery) rval;
10434 } catch (ClassCastException ex) {
10435 return false;
10436 }
10437 return Objects.equals(packageName, other.packageName)
10438 && flags == other.flags
10439 && userId == other.userId;
10440 }
10441 }
10442
10443 private static ApplicationInfo getApplicationInfoAsUserUncached(
10444 String packageName, @ApplicationInfoFlagsBits long flags, int userId) {
10445 try {
10446 return ActivityThread.getPackageManager()
10447 .getApplicationInfo(packageName, flags, userId);
10448 } catch (RemoteException e) {
10449 throw e.rethrowFromSystemServer();
10450 }
10451 }
10452
10453 private static final PropertyInvalidatedCache<ApplicationInfoQuery, ApplicationInfo>
10454 sApplicationInfoCache =
10455 new PropertyInvalidatedCache<ApplicationInfoQuery, ApplicationInfo>(
10456 16, PermissionManager.CACHE_KEY_PACKAGE_INFO,
10457 "getApplicationInfo") {
10458 @Override
10459 public ApplicationInfo recompute(ApplicationInfoQuery query) {
10460 return getApplicationInfoAsUserUncached(
10461 query.packageName, query.flags, query.userId);
10462 }
10463 @Override
10464 public boolean resultEquals(ApplicationInfo cached, ApplicationInfo fetched) {
10465 // Implementing this debug check for ApplicationInfo would require a
10466 // complicated deep comparison, so just bypass it for now.
10467 return true;
10468 }
10469 };
10470
10471 /** @hide */
10472 public static ApplicationInfo getApplicationInfoAsUserCached(
10473 String packageName, @ApplicationInfoFlagsBits long flags, int userId) {
10474 return sApplicationInfoCache.query(
10475 new ApplicationInfoQuery(packageName, flags, userId));
10476 }
10477
10478 /**
10479 * Make getApplicationInfoAsUser() bypass the cache in this process.
10480 *
10481 * @hide
10482 */
10483 public static void disableApplicationInfoCache() {
10484 sApplicationInfoCache.disableLocal();
10485 }
10486
10487 private static final PropertyInvalidatedCache.AutoCorker sCacheAutoCorker =
10488 new PropertyInvalidatedCache.AutoCorker(PermissionManager.CACHE_KEY_PACKAGE_INFO);
10489
10490 /**
10491 * Invalidate caches of package and permission information system-wide.
10492 *
10493 * @hide
10494 */
10495 public static void invalidatePackageInfoCache() {
10496 sCacheAutoCorker.autoCork();
10497 }
10498
10499 // Some of the flags don't affect the query result, but let's be conservative and cache
10500 // each combination of flags separately.
10501
10502 private static final class PackageInfoQuery {
10503 final String packageName;
10504 final long flags;
10505 final int userId;
10506
10507 PackageInfoQuery(@Nullable String packageName, @PackageInfoFlagsBits long flags, int userId) {
10508 this.packageName = packageName;
10509 this.flags = flags;
10510 this.userId = userId;
10511 }
10512
10513 @Override
10514 public String toString() {
10515 return String.format(
10516 "PackageInfoQuery(packageName=\"%s\", flags=%s, userId=%s)",
10517 packageName, flags, userId);
10518 }
10519
10520 @Override
10521 public int hashCode() {
10522 int hash = Objects.hashCode(packageName);
10523 hash = hash * 13 + Objects.hashCode(flags);
10524 hash = hash * 13 + Objects.hashCode(userId);
10525 return hash;
10526 }
10527
10528 @Override
10529 public boolean equals(@Nullable Object rval) {
10530 if (rval == null) {
10531 return false;
10532 }
10533 PackageInfoQuery other;
10534 try {
10535 other = (PackageInfoQuery) rval;
10536 } catch (ClassCastException ex) {
10537 return false;
10538 }
10539 return Objects.equals(packageName, other.packageName)
10540 && flags == other.flags
10541 && userId == other.userId;
10542 }
10543 }
10544
10545 private static PackageInfo getPackageInfoAsUserUncached(
10546 String packageName, @PackageInfoFlagsBits long flags, int userId) {
10547 try {
10548 return ActivityThread.getPackageManager().getPackageInfo(packageName, flags, userId);
10549 } catch (RemoteException e) {
10550 throw e.rethrowFromSystemServer();
10551 }
10552 }
10553
10554 private static final PropertyInvalidatedCache<PackageInfoQuery, PackageInfo>
10555 sPackageInfoCache =
10556 new PropertyInvalidatedCache<PackageInfoQuery, PackageInfo>(
10557 32, PermissionManager.CACHE_KEY_PACKAGE_INFO,
10558 "getPackageInfo") {
10559 @Override
10560 public PackageInfo recompute(PackageInfoQuery query) {
10561 return getPackageInfoAsUserUncached(
10562 query.packageName, query.flags, query.userId);
10563 }
10564 @Override
10565 public boolean resultEquals(PackageInfo cached, PackageInfo fetched) {
10566 // Implementing this debug check for PackageInfo would require a
10567 // complicated deep comparison, so just bypass it for now.
10568 return true;
10569 }
10570 };
10571
10572 /** @hide */
10573 public static PackageInfo getPackageInfoAsUserCached(
10574 String packageName, @PackageInfoFlagsBits long flags, int userId) {
10575 return sPackageInfoCache.query(new PackageInfoQuery(packageName, flags, userId));
10576 }
10577
10578 /**
10579 * Make getPackageInfoAsUser() bypass the cache in this process.
10580 * @hide
10581 */
10582 public static void disablePackageInfoCache() {
10583 sPackageInfoCache.disableLocal();
10584 }
10585
10586 /**
10587 * Inhibit package info cache invalidations when correct.
10588 *
10589 * @hide */
10590 public static void corkPackageInfoCache() {
10591 PropertyInvalidatedCache.corkInvalidations(PermissionManager.CACHE_KEY_PACKAGE_INFO);
10592 }
10593
10594 /**
10595 * Enable package info cache invalidations.
10596 *
10597 * @hide */
10598 public static void uncorkPackageInfoCache() {
10599 PropertyInvalidatedCache.uncorkInvalidations(PermissionManager.CACHE_KEY_PACKAGE_INFO);
10600 }
10601
10602 /**
10603 * Returns the token to be used by the subsequent calls to holdLock().
10604 * @hide
10605 */
10606 @RequiresPermission(android.Manifest.permission.INJECT_EVENTS)
10607 @TestApi
10608 public IBinder getHoldLockToken() {
10609 try {
10610 return ActivityThread.getPackageManager().getHoldLockToken();
10611 } catch (RemoteException e) {
10612 throw e.rethrowFromSystemServer();
10613 }
10614 }
10615
10616 /**
10617 * Holds the PM lock for the specified amount of milliseconds.
10618 * Intended for use by the tests that need to imitate lock contention.
10619 * The token should be obtained by
10620 * {@link android.content.pm.PackageManager#getHoldLockToken()}.
10621 * @hide
10622 */
10623 @TestApi
10624 public void holdLock(IBinder token, int durationMs) {
10625 try {
10626 ActivityThread.getPackageManager().holdLock(token, durationMs);
10627 } catch (RemoteException e) {
10628 throw e.rethrowFromSystemServer();
10629 }
10630 }
10631
10632 /**
10633 * Set a list of apps to keep around as APKs even if no user has currently installed it.
10634 * @param packageList List of package names to keep cached.
10635 *
10636 * @hide
10637 */
10638 @RequiresPermission(android.Manifest.permission.KEEP_UNINSTALLED_PACKAGES)
10639 @TestApi
10640 public void setKeepUninstalledPackages(@NonNull List<String> packageList) {
10641 try {
10642 ActivityThread.getPackageManager().setKeepUninstalledPackages(packageList);
10643 } catch (RemoteException e) {
10644 throw e.rethrowFromSystemServer();
10645 }
10646 }
10647 }