PackageManager.java revision dd9bda81f698043a0110d4e2178d20cb160ba829
1f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie/*
2f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie * Copyright (C) 2006 The Android Open Source Project
3f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie *
4f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie * Licensed under the Apache License, Version 2.0 (the "License");
5f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie * you may not use this file except in compliance with the License.
6f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie * You may obtain a copy of the License at
7f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie *
8f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie *      http://www.apache.org/licenses/LICENSE-2.0
9f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie *
10f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie * Unless required by applicable law or agreed to in writing, software
11f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie * distributed under the License is distributed on an "AS IS" BASIS,
12f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie * See the License for the specific language governing permissions and
14f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie * limitations under the License.
15f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie */
16f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie
17f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffiepackage android.content.pm;
18f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie
19f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffieimport android.Manifest;
20f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffieimport android.annotation.CheckResult;
21913d06c099bd689375483a839e11057ccf284d1cMikhail Naganovimport android.annotation.DrawableRes;
22f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffieimport android.annotation.IntDef;
23f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffieimport android.annotation.IntRange;
24f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffieimport android.annotation.NonNull;
25f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffieimport android.annotation.Nullable;
26f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffieimport android.annotation.RequiresPermission;
27f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffieimport android.annotation.SdkConstant;
28f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffieimport android.annotation.SdkConstant.SdkConstantType;
29f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffieimport android.annotation.StringRes;
30f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffieimport android.annotation.SystemApi;
31f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffieimport android.annotation.TestApi;
32f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffieimport android.annotation.UserIdInt;
33f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffieimport android.annotation.XmlRes;
34f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffieimport android.app.PackageDeleteObserver;
35f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffieimport android.app.PackageInstallObserver;
36f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffieimport android.app.admin.DevicePolicyManager;
37f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffieimport android.content.ComponentName;
38f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffieimport android.content.Context;
39f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffieimport android.content.Intent;
40f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffieimport android.content.IntentFilter;
41f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffieimport android.content.IntentSender;
42f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffieimport android.content.pm.PackageParser.PackageParserException;
43f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffieimport android.content.res.Resources;
44f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffieimport android.content.res.XmlResourceParser;
45f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffieimport android.graphics.Rect;
46f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffieimport android.graphics.drawable.Drawable;
47f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffieimport android.net.Uri;
48f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffieimport android.os.Bundle;
49f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffieimport android.os.Handler;
50c9d7c4e35afd48ac8a315f53666943b6210dafa1François Gaffieimport android.os.RemoteException;
51c9d7c4e35afd48ac8a315f53666943b6210dafa1François Gaffieimport android.os.UserHandle;
52c9d7c4e35afd48ac8a315f53666943b6210dafa1François Gaffieimport android.os.UserManager;
5319219b44e05555b29e00ce56ce273d168fa83888François Gaffieimport android.os.storage.VolumeInfo;
54c9d7c4e35afd48ac8a315f53666943b6210dafa1François Gaffieimport android.util.AndroidException;
55c9d7c4e35afd48ac8a315f53666943b6210dafa1François Gaffieimport android.util.Log;
5619219b44e05555b29e00ce56ce273d168fa83888François Gaffie
5719219b44e05555b29e00ce56ce273d168fa83888François Gaffieimport com.android.internal.util.ArrayUtils;
5819219b44e05555b29e00ce56ce273d168fa83888François Gaffie
5919219b44e05555b29e00ce56ce273d168fa83888François Gaffieimport java.io.File;
6019219b44e05555b29e00ce56ce273d168fa83888François Gaffieimport java.lang.annotation.Retention;
6119219b44e05555b29e00ce56ce273d168fa83888François Gaffieimport java.lang.annotation.RetentionPolicy;
6219219b44e05555b29e00ce56ce273d168fa83888François Gaffieimport java.util.List;
6319219b44e05555b29e00ce56ce273d168fa83888François Gaffie
6419219b44e05555b29e00ce56ce273d168fa83888François Gaffie/**
6519219b44e05555b29e00ce56ce273d168fa83888François Gaffie * Class for retrieving various kinds of information related to the application
6619219b44e05555b29e00ce56ce273d168fa83888François Gaffie * packages that are currently installed on the device.
6719219b44e05555b29e00ce56ce273d168fa83888François Gaffie *
6819219b44e05555b29e00ce56ce273d168fa83888François Gaffie * You can find this class through {@link Context#getPackageManager}.
6919219b44e05555b29e00ce56ce273d168fa83888François Gaffie */
70c9d7c4e35afd48ac8a315f53666943b6210dafa1François Gaffiepublic abstract class PackageManager {
7119219b44e05555b29e00ce56ce273d168fa83888François Gaffie    private static final String TAG = "PackageManager";
72c9d7c4e35afd48ac8a315f53666943b6210dafa1François Gaffie
73c9d7c4e35afd48ac8a315f53666943b6210dafa1François Gaffie    /** {@hide} */
74c9d7c4e35afd48ac8a315f53666943b6210dafa1François Gaffie    public static final boolean APPLY_DEFAULT_TO_DEVICE_PROTECTED_STORAGE = true;
75f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie
76f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    /**
77f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * This exception is thrown when a given package, application, or component
78f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * name cannot be found.
79f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     */
80f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    public static class NameNotFoundException extends AndroidException {
81f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie        public NameNotFoundException() {
82f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie        }
83f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie
84f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie        public NameNotFoundException(String name) {
85f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie            super(name);
86f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie        }
87f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    }
88d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffie
89d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffie    /**
90d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffie     * Listener for changes in permissions granted to a UID.
91f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     *
92d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffie     * @hide
93d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffie     */
94f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    @SystemApi
95d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffie    public interface OnPermissionsChangedListener {
96f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie
97f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie        /**
98f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie         * Called when the permissions for a UID change.
99f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie         * @param uid The UID with a change.
100f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie         */
101f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie        public void onPermissionsChanged(int uid);
102f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    }
103f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie
104d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffie    /**
105d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffie     * As a guiding principle:
106d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffie     * <p>
107d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffie     * {@code GET_} flags are used to request additional data that may have been
108f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * elided to save wire space.
109d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffie     * <p>
110f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * {@code MATCH_} flags are used to include components or packages that
111d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffie     * would have otherwise been omitted from a result set by current system
112f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * state.
113f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     */
114f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie
115f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    /** @hide */
116f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    @IntDef(flag = true, value = {
117f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie            GET_ACTIVITIES,
118f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie            GET_CONFIGURATIONS,
119f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie            GET_GIDS,
120f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie            GET_INSTRUMENTATION,
121f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie            GET_INTENT_FILTERS,
122f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie            GET_META_DATA,
123f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie            GET_PERMISSIONS,
124f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie            GET_PROVIDERS,
125f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie            GET_RECEIVERS,
126f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie            GET_SERVICES,
127f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie            GET_SHARED_LIBRARY_FILES,
128f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie            GET_SIGNATURES,
129f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie            GET_URI_PERMISSION_PATTERNS,
130f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie            MATCH_UNINSTALLED_PACKAGES,
131f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie            MATCH_DISABLED_COMPONENTS,
132f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie            MATCH_DISABLED_UNTIL_USED_COMPONENTS,
133f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie            MATCH_SYSTEM_ONLY,
134f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie            MATCH_FACTORY_ONLY,
135f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie            MATCH_DEBUG_TRIAGED_MISSING,
136f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie            GET_DISABLED_COMPONENTS,
137f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie            GET_DISABLED_UNTIL_USED_COMPONENTS,
138f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie            GET_UNINSTALLED_PACKAGES,
139f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    })
140f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    @Retention(RetentionPolicy.SOURCE)
141f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    public @interface PackageInfoFlags {}
142f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie
143f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    /** @hide */
144f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    @IntDef(flag = true, value = {
145f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie            GET_META_DATA,
146f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie            GET_SHARED_LIBRARY_FILES,
147f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie            MATCH_UNINSTALLED_PACKAGES,
148f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie            MATCH_SYSTEM_ONLY,
149f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie            MATCH_DEBUG_TRIAGED_MISSING,
150f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie            MATCH_DISABLED_UNTIL_USED_COMPONENTS,
151f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie            GET_DISABLED_UNTIL_USED_COMPONENTS,
152f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie            GET_UNINSTALLED_PACKAGES,
153f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    })
154f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    @Retention(RetentionPolicy.SOURCE)
155f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    public @interface ApplicationInfoFlags {}
156f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie
157f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    /** @hide */
158f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    @IntDef(flag = true, value = {
159f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie            GET_META_DATA,
160f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie            GET_SHARED_LIBRARY_FILES,
161f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie            MATCH_ALL,
162f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie            MATCH_DEBUG_TRIAGED_MISSING,
163f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie            MATCH_DEFAULT_ONLY,
164f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie            MATCH_DISABLED_COMPONENTS,
165f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie            MATCH_DISABLED_UNTIL_USED_COMPONENTS,
166f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie            MATCH_DIRECT_BOOT_AWARE,
167f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie            MATCH_DIRECT_BOOT_UNAWARE,
168f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie            MATCH_SYSTEM_ONLY,
169f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie            MATCH_UNINSTALLED_PACKAGES,
170f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie            GET_DISABLED_COMPONENTS,
171f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie            GET_DISABLED_UNTIL_USED_COMPONENTS,
172f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie            GET_UNINSTALLED_PACKAGES,
173f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    })
174f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    @Retention(RetentionPolicy.SOURCE)
175f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    public @interface ComponentInfoFlags {}
176f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie
177f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    /** @hide */
178f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    @IntDef(flag = true, value = {
179f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie            GET_META_DATA,
180f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie            GET_RESOLVED_FILTER,
181f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie            GET_SHARED_LIBRARY_FILES,
182f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie            MATCH_ALL,
183f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie            MATCH_DEBUG_TRIAGED_MISSING,
184f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie            MATCH_DISABLED_COMPONENTS,
185f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie            MATCH_DISABLED_UNTIL_USED_COMPONENTS,
186f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie            MATCH_DEFAULT_ONLY,
187f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie            MATCH_DIRECT_BOOT_AWARE,
188f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie            MATCH_DIRECT_BOOT_UNAWARE,
189f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie            MATCH_SYSTEM_ONLY,
190f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie            MATCH_UNINSTALLED_PACKAGES,
191f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie            GET_DISABLED_COMPONENTS,
192f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie            GET_DISABLED_UNTIL_USED_COMPONENTS,
193f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie            GET_UNINSTALLED_PACKAGES,
194f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    })
195f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    @Retention(RetentionPolicy.SOURCE)
196f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    public @interface ResolveInfoFlags {}
197f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie
198f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    /** @hide */
199f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    @IntDef(flag = true, value = {
200f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie            GET_META_DATA,
201f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    })
202913d06c099bd689375483a839e11057ccf284d1cMikhail Naganov    @Retention(RetentionPolicy.SOURCE)
203913d06c099bd689375483a839e11057ccf284d1cMikhail Naganov    public @interface PermissionInfoFlags {}
204f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie
205f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    /** @hide */
206f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    @IntDef(flag = true, value = {
207f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie            GET_META_DATA,
208f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    })
209f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    @Retention(RetentionPolicy.SOURCE)
210f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    public @interface PermissionGroupInfoFlags {}
211f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie
212f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    /** @hide */
213f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    @IntDef(flag = true, value = {
214f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie            GET_META_DATA,
215f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    })
216f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    @Retention(RetentionPolicy.SOURCE)
217f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    public @interface InstrumentationInfoFlags {}
218f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie
219f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    /**
220f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * {@link PackageInfo} flag: return information about
221f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * activities in the package in {@link PackageInfo#activities}.
222f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     */
223f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    public static final int GET_ACTIVITIES              = 0x00000001;
224f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie
225f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    /**
226f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * {@link PackageInfo} flag: return information about
227f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * intent receivers in the package in
228f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * {@link PackageInfo#receivers}.
229f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     */
230f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    public static final int GET_RECEIVERS               = 0x00000002;
231f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie
232f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    /**
233f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * {@link PackageInfo} flag: return information about
234f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * services in the package in {@link PackageInfo#services}.
235f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     */
236f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    public static final int GET_SERVICES                = 0x00000004;
237f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie
238f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    /**
239f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * {@link PackageInfo} flag: return information about
240f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * content providers in the package in
241f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * {@link PackageInfo#providers}.
242f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     */
243f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    public static final int GET_PROVIDERS               = 0x00000008;
244f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie
245f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    /**
246f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * {@link PackageInfo} flag: return information about
247f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * instrumentation in the package in
248f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * {@link PackageInfo#instrumentation}.
249f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     */
250f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    public static final int GET_INSTRUMENTATION         = 0x00000010;
251f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie
252f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    /**
253f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * {@link PackageInfo} flag: return information about the
254f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * intent filters supported by the activity.
255f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     */
256f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    public static final int GET_INTENT_FILTERS          = 0x00000020;
257f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie
258f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    /**
259f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * {@link PackageInfo} flag: return information about the
260f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * signatures included in the package.
261f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     */
262f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    public static final int GET_SIGNATURES          = 0x00000040;
263f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie
264f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    /**
265f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * {@link ResolveInfo} flag: return the IntentFilter that
266f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * was matched for a particular ResolveInfo in
267f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * {@link ResolveInfo#filter}.
268f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     */
269f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    public static final int GET_RESOLVED_FILTER         = 0x00000040;
270f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie
271f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    /**
272f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * {@link ComponentInfo} flag: return the {@link ComponentInfo#metaData}
273f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * data {@link android.os.Bundle}s that are associated with a component.
274f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * This applies for any API returning a ComponentInfo subclass.
275f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     */
276f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    public static final int GET_META_DATA               = 0x00000080;
277f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie
278f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    /**
279f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * {@link PackageInfo} flag: return the
280f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * {@link PackageInfo#gids group ids} that are associated with an
281f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * application.
282f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * This applies for any API returning a PackageInfo class, either
283f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * directly or nested inside of another.
284f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     */
285f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    public static final int GET_GIDS                    = 0x00000100;
286f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie
287f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    /**
288f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * @deprecated replaced with {@link #MATCH_DISABLED_COMPONENTS}
289f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     */
290f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    @Deprecated
291f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    public static final int GET_DISABLED_COMPONENTS = 0x00000200;
292f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie
293f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    /**
294f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * {@link PackageInfo} flag: include disabled components in the returned info.
295f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     */
296f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    public static final int MATCH_DISABLED_COMPONENTS = 0x00000200;
297f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie
298f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    /**
299f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * {@link ApplicationInfo} flag: return the
300f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * {@link ApplicationInfo#sharedLibraryFiles paths to the shared libraries}
301f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * that are associated with an application.
302f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * This applies for any API returning an ApplicationInfo class, either
303f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * directly or nested inside of another.
304913d06c099bd689375483a839e11057ccf284d1cMikhail Naganov     */
305f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    public static final int GET_SHARED_LIBRARY_FILES    = 0x00000400;
306f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie
307f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    /**
308f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * {@link ProviderInfo} flag: return the
309f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * {@link ProviderInfo#uriPermissionPatterns URI permission patterns}
310f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * that are associated with a content provider.
311f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * This applies for any API returning a ProviderInfo class, either
312f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * directly or nested inside of another.
313f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     */
314f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    public static final int GET_URI_PERMISSION_PATTERNS  = 0x00000800;
315f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    /**
316f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * {@link PackageInfo} flag: return information about
317f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * permissions in the package in
318f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * {@link PackageInfo#permissions}.
319f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     */
320f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    public static final int GET_PERMISSIONS               = 0x00001000;
321f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie
322f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    /**
323f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * @deprecated replaced with {@link #MATCH_UNINSTALLED_PACKAGES}
324f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     */
325f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    @Deprecated
326f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    public static final int GET_UNINSTALLED_PACKAGES = 0x00002000;
327f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie
328f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    /**
329f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * Flag parameter to retrieve some information about all applications (even
330f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * uninstalled ones) which have data directories. This state could have
331f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * resulted if applications have been deleted with flag
332f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * {@code DONT_DELETE_DATA} with a possibility of being replaced or
333f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * reinstalled in future.
334f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * <p>
335f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * Note: this flag may cause less information about currently installed
336f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * applications to be returned.
337f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     */
338f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    public static final int MATCH_UNINSTALLED_PACKAGES = 0x00002000;
339f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie
340f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    /**
341f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * {@link PackageInfo} flag: return information about
342f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * hardware preferences in
343f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * {@link PackageInfo#configPreferences PackageInfo.configPreferences},
344f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * and requested features in {@link PackageInfo#reqFeatures} and
345f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * {@link PackageInfo#featureGroups}.
346f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     */
347f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    public static final int GET_CONFIGURATIONS = 0x00004000;
348f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie
349f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    /**
350f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * @deprecated replaced with {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}.
351f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     */
352f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    @Deprecated
353f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    public static final int GET_DISABLED_UNTIL_USED_COMPONENTS = 0x00008000;
354f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie
355f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    /**
356f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * {@link PackageInfo} flag: include disabled components which are in
357f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * that state only because of {@link #COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED}
358f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * in the returned info.  Note that if you set this flag, applications
359f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * that are in this disabled state will be reported as enabled.
360f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     */
361f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    public static final int MATCH_DISABLED_UNTIL_USED_COMPONENTS = 0x00008000;
362f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie
363f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    /**
364f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * Resolution and querying flag: if set, only filters that support the
365f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * {@link android.content.Intent#CATEGORY_DEFAULT} will be considered for
366f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * matching.  This is a synonym for including the CATEGORY_DEFAULT in your
367f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * supplied Intent.
368f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     */
369f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    public static final int MATCH_DEFAULT_ONLY  = 0x00010000;
370f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie
371f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    /**
372f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * Querying flag: if set and if the platform is doing any filtering of the
373f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * results, then the filtering will not happen. This is a synonym for saying
374f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * that all results should be returned.
375f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * <p>
376f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * <em>This flag should be used with extreme care.</em>
377f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     */
378f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    public static final int MATCH_ALL = 0x00020000;
379f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie
380f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    /**
381f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * Querying flag: match components which are direct boot <em>unaware</em> in
382f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * the returned info, regardless of the current user state.
383f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * <p>
384f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * When neither {@link #MATCH_DIRECT_BOOT_AWARE} nor
385f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * {@link #MATCH_DIRECT_BOOT_UNAWARE} are specified, the default behavior is
386f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * to match only runnable components based on the user state. For example,
387cc7c0d6fff90c867f661b795e803043aee4d0bb8Yunlian Jiang     * when a user is started but credentials have not been presented yet, the
388f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * user is running "locked" and only {@link #MATCH_DIRECT_BOOT_AWARE}
389f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * components are returned. Once the user credentials have been presented,
390f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * the user is running "unlocked" and both {@link #MATCH_DIRECT_BOOT_AWARE}
391f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * and {@link #MATCH_DIRECT_BOOT_UNAWARE} components are returned.
392f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     *
393f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * @see UserManager#isUserUnlocked()
394f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     */
395f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    public static final int MATCH_DIRECT_BOOT_UNAWARE = 0x00040000;
396f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie
397f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    /**
398f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * Querying flag: match components which are direct boot <em>aware</em> in
399f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * the returned info, regardless of the current user state.
400f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * <p>
401f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * When neither {@link #MATCH_DIRECT_BOOT_AWARE} nor
402f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * {@link #MATCH_DIRECT_BOOT_UNAWARE} are specified, the default behavior is
403f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * to match only runnable components based on the user state. For example,
404f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * when a user is started but credentials have not been presented yet, the
405f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * user is running "locked" and only {@link #MATCH_DIRECT_BOOT_AWARE}
406f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * components are returned. Once the user credentials have been presented,
407f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * the user is running "unlocked" and both {@link #MATCH_DIRECT_BOOT_AWARE}
408f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * and {@link #MATCH_DIRECT_BOOT_UNAWARE} components are returned.
409f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     *
410f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * @see UserManager#isUserUnlocked()
411f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     */
412f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    public static final int MATCH_DIRECT_BOOT_AWARE = 0x00080000;
413f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie
414f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    /**
415f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * Querying flag: include only components from applications that are marked
416f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * with {@link ApplicationInfo#FLAG_SYSTEM}.
417f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     */
418f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    public static final int MATCH_SYSTEM_ONLY = 0x00100000;
419f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie
420f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    /**
421f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * Internal {@link PackageInfo} flag: include only components on the system image.
422f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * This will not return information on any unbundled update to system components.
4239ee0540d3a61bff03d561ca431a371c3d9335d2bMikhail Naganov     * @hide
424f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     */
425f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    public static final int MATCH_FACTORY_ONLY = 0x00200000;
4269ee0540d3a61bff03d561ca431a371c3d9335d2bMikhail Naganov
4279ee0540d3a61bff03d561ca431a371c3d9335d2bMikhail Naganov    /**
4289ee0540d3a61bff03d561ca431a371c3d9335d2bMikhail Naganov     * Allows querying of packages installed for any user, not just the specific one. This flag
429f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * is only meant for use by apps that have INTERACT_ACROSS_USERS permission.
430f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * @hide
431f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     */
432f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    @SystemApi
4339ee0540d3a61bff03d561ca431a371c3d9335d2bMikhail Naganov    public static final int MATCH_ANY_USER = 0x00400000;
434f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie
435f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    /**
436f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * Combination of MATCH_ANY_USER and MATCH_UNINSTALLED_PACKAGES to mean any known
437f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * package.
438f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * @hide
439f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     */
440f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    public static final int MATCH_KNOWN_PACKAGES = MATCH_UNINSTALLED_PACKAGES | MATCH_ANY_USER;
441f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie
442f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    /**
443f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * Internal {@link PackageInfo} flag: include components that are part of an
444f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * instant app. By default, instant app components are not matched.
445f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * @hide
446f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     */
447f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    public static final int MATCH_INSTANT = 0x00800000;
448f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie
449f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    /**
450f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * Internal {@link PackageInfo} flag: include only components that are exposed to
451f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * ephemeral apps.
452f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * @hide
453f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     */
454f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    public static final int MATCH_VISIBLE_TO_INSTANT_APP_ONLY = 0x01000000;
455f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie
456f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    /**
457f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * Internal flag used to indicate that a system component has done their
458f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * homework and verified that they correctly handle packages and components
459f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * that come and go over time. In particular:
460f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * <ul>
461f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * <li>Apps installed on external storage, which will appear to be
462f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * uninstalled while the the device is ejected.
463f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * <li>Apps with encryption unaware components, which will appear to not
464f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * exist while the device is locked.
465f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * </ul>
466f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     *
467f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * @see #MATCH_UNINSTALLED_PACKAGES
468f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * @see #MATCH_DIRECT_BOOT_AWARE
469f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * @see #MATCH_DIRECT_BOOT_UNAWARE
470f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * @hide
471f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     */
472f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    public static final int MATCH_DEBUG_TRIAGED_MISSING = 0x10000000;
473f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie
474f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    /**
475f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * Flag for {@link #addCrossProfileIntentFilter}: if this flag is set: when
476f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * resolving an intent that matches the {@code CrossProfileIntentFilter},
477f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * the current profile will be skipped. Only activities in the target user
478f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * can respond to the intent.
479f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     *
480f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * @hide
481f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     */
482f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    public static final int SKIP_CURRENT_PROFILE = 0x00000002;
483f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie
484f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    /**
485f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * Flag for {@link #addCrossProfileIntentFilter}: if this flag is set:
486f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * activities in the other profiles can respond to the intent only if no activity with
487f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * non-negative priority in current profile can respond to the intent.
488f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * @hide
489f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     */
490f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    public static final int ONLY_IF_NO_MATCH_FOUND = 0x00000004;
491f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie
492f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    /** @hide */
493f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    @IntDef({PERMISSION_GRANTED, PERMISSION_DENIED})
494f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    @Retention(RetentionPolicy.SOURCE)
495f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    public @interface PermissionResult {}
496f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie
497f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    /**
498f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * Permission check result: this is returned by {@link #checkPermission}
499f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * if the permission has been granted to the given package.
500f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     */
501f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    public static final int PERMISSION_GRANTED = 0;
502f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie
503f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    /**
504f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * Permission check result: this is returned by {@link #checkPermission}
505f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * if the permission has not been granted to the given package.
506f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     */
507f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    public static final int PERMISSION_DENIED = -1;
508f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie
509f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    /**
510f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * Signature check result: this is returned by {@link #checkSignatures}
511f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * if all signatures on the two packages match.
512f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     */
513f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    public static final int SIGNATURE_MATCH = 0;
514f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie
515f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    /**
516f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * Signature check result: this is returned by {@link #checkSignatures}
517f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * if neither of the two packages is signed.
518c9d7c4e35afd48ac8a315f53666943b6210dafa1François Gaffie     */
519f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    public static final int SIGNATURE_NEITHER_SIGNED = 1;
520f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie
521f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    /**
522f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * Signature check result: this is returned by {@link #checkSignatures}
523f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * if the first package is not signed but the second is.
524f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     */
525f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    public static final int SIGNATURE_FIRST_NOT_SIGNED = -1;
526f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie
527f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    /**
528f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * Signature check result: this is returned by {@link #checkSignatures}
529f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * if the second package is not signed but the first is.
530f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     */
531f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    public static final int SIGNATURE_SECOND_NOT_SIGNED = -2;
532f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie
533f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    /**
534f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * Signature check result: this is returned by {@link #checkSignatures}
535f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * if not all signatures on both packages match.
536f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     */
537f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    public static final int SIGNATURE_NO_MATCH = -3;
538f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie
539f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    /**
540f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * Signature check result: this is returned by {@link #checkSignatures}
541f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * if either of the packages are not valid.
542f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     */
543f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    public static final int SIGNATURE_UNKNOWN_PACKAGE = -4;
544c9d7c4e35afd48ac8a315f53666943b6210dafa1François Gaffie
545c9d7c4e35afd48ac8a315f53666943b6210dafa1François Gaffie    /**
546c9d7c4e35afd48ac8a315f53666943b6210dafa1François Gaffie     * Flag for {@link #setApplicationEnabledSetting(String, int, int)}
547c9d7c4e35afd48ac8a315f53666943b6210dafa1François Gaffie     * and {@link #setComponentEnabledSetting(ComponentName, int, int)}: This
54819219b44e05555b29e00ce56ce273d168fa83888François Gaffie     * component or application is in its default enabled state (as specified
549c9d7c4e35afd48ac8a315f53666943b6210dafa1François Gaffie     * in its manifest).
550c9d7c4e35afd48ac8a315f53666943b6210dafa1François Gaffie     */
551c9d7c4e35afd48ac8a315f53666943b6210dafa1François Gaffie    public static final int COMPONENT_ENABLED_STATE_DEFAULT = 0;
552c9d7c4e35afd48ac8a315f53666943b6210dafa1François Gaffie
553c9d7c4e35afd48ac8a315f53666943b6210dafa1François Gaffie    /**
554c9d7c4e35afd48ac8a315f53666943b6210dafa1François Gaffie     * Flag for {@link #setApplicationEnabledSetting(String, int, int)}
555d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffie     * and {@link #setComponentEnabledSetting(ComponentName, int, int)}: This
556d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffie     * component or application has been explictily enabled, regardless of
557c9d7c4e35afd48ac8a315f53666943b6210dafa1François Gaffie     * what it has specified in its manifest.
558f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     */
559f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    public static final int COMPONENT_ENABLED_STATE_ENABLED = 1;
560f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie
561f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    /**
562f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * Flag for {@link #setApplicationEnabledSetting(String, int, int)}
563f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * and {@link #setComponentEnabledSetting(ComponentName, int, int)}: This
564f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * component or application has been explicitly disabled, regardless of
565f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * what it has specified in its manifest.
566f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     */
567f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    public static final int COMPONENT_ENABLED_STATE_DISABLED = 2;
568f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie
569f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    /**
570f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * Flag for {@link #setApplicationEnabledSetting(String, int, int)} only: The
571f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * user has explicitly disabled the application, regardless of what it has
572d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffie     * specified in its manifest.  Because this is due to the user's request,
573f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * they may re-enable it if desired through the appropriate system UI.  This
574f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * option currently <strong>cannot</strong> be used with
575f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * {@link #setComponentEnabledSetting(ComponentName, int, int)}.
576f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     */
577f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    public static final int COMPONENT_ENABLED_STATE_DISABLED_USER = 3;
578f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie
579f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    /**
580f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * Flag for {@link #setApplicationEnabledSetting(String, int, int)} only: This
581f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * application should be considered, until the point where the user actually
582f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * wants to use it.  This means that it will not normally show up to the user
583f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * (such as in the launcher), but various parts of the user interface can
584f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * use {@link #GET_DISABLED_UNTIL_USED_COMPONENTS} to still see it and allow
585f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * the user to select it (as for example an IME, device admin, etc).  Such code,
586f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * once the user has selected the app, should at that point also make it enabled.
587f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * This option currently <strong>can not</strong> be used with
588f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * {@link #setComponentEnabledSetting(ComponentName, int, int)}.
589f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     */
590f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    public static final int COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED = 4;
591f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie
592f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    /** @hide */
593f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    @IntDef(flag = true, value = {
594f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie            INSTALL_FORWARD_LOCK,
595f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie            INSTALL_REPLACE_EXISTING,
596f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie            INSTALL_ALLOW_TEST,
597f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie            INSTALL_EXTERNAL,
598f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie            INSTALL_INTERNAL,
599f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie            INSTALL_FROM_ADB,
600f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie            INSTALL_ALL_USERS,
601f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie            INSTALL_ALLOW_DOWNGRADE,
602f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie            INSTALL_GRANT_RUNTIME_PERMISSIONS,
603f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie            INSTALL_FORCE_VOLUME_UUID,
604f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie            INSTALL_FORCE_PERMISSION_PROMPT,
605f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie            INSTALL_INSTANT_APP,
606f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie            INSTALL_DONT_KILL_APP,
607f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    })
608f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    @Retention(RetentionPolicy.SOURCE)
609f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    public @interface InstallFlags {}
610f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie
611f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    /**
612f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * Flag parameter for {@link #installPackage} to indicate that this package
613f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * should be installed as forward locked, i.e. only the app itself should
614f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * have access to its code and non-resource assets.
615f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     *
616f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * @hide
617f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     */
618f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    public static final int INSTALL_FORWARD_LOCK = 0x00000001;
619f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie
620f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    /**
621f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * Flag parameter for {@link #installPackage} to indicate that you want to
622f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * replace an already installed package, if one exists.
623f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     *
624f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * @hide
625f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     */
626f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    public static final int INSTALL_REPLACE_EXISTING = 0x00000002;
627f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie
628f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    /**
629f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * Flag parameter for {@link #installPackage} to indicate that you want to
630f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * allow test packages (those that have set android:testOnly in their
631d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffie     * manifest) to be installed.
632d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffie     * @hide
633f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     */
634f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    public static final int INSTALL_ALLOW_TEST = 0x00000004;
635f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie
636f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie    /**
637f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * Flag parameter for {@link #installPackage} to indicate that this package
638f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * must be installed to an ASEC on a {@link VolumeInfo#TYPE_PUBLIC}.
639f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     *
640f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     * @hide
641f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie     */
642    public static final int INSTALL_EXTERNAL = 0x00000008;
643
644    /**
645     * Flag parameter for {@link #installPackage} to indicate that this package
646     * must be installed to internal storage.
647     *
648     * @hide
649     */
650    public static final int INSTALL_INTERNAL = 0x00000010;
651
652    /**
653     * Flag parameter for {@link #installPackage} to indicate that this install
654     * was initiated via ADB.
655     *
656     * @hide
657     */
658    public static final int INSTALL_FROM_ADB = 0x00000020;
659
660    /**
661     * Flag parameter for {@link #installPackage} to indicate that this install
662     * should immediately be visible to all users.
663     *
664     * @hide
665     */
666    public static final int INSTALL_ALL_USERS = 0x00000040;
667
668    /**
669     * Flag parameter for {@link #installPackage} to indicate that it is okay
670     * to install an update to an app where the newly installed app has a lower
671     * version code than the currently installed app. This is permitted only if
672     * the currently installed app is marked debuggable.
673     *
674     * @hide
675     */
676    public static final int INSTALL_ALLOW_DOWNGRADE = 0x00000080;
677
678    /**
679     * Flag parameter for {@link #installPackage} to indicate that all runtime
680     * permissions should be granted to the package. If {@link #INSTALL_ALL_USERS}
681     * is set the runtime permissions will be granted to all users, otherwise
682     * only to the owner.
683     *
684     * @hide
685     */
686    public static final int INSTALL_GRANT_RUNTIME_PERMISSIONS = 0x00000100;
687
688    /** {@hide} */
689    public static final int INSTALL_FORCE_VOLUME_UUID = 0x00000200;
690
691    /**
692     * Flag parameter for {@link #installPackage} to indicate that we always want to force
693     * the prompt for permission approval. This overrides any special behaviour for internal
694     * components.
695     *
696     * @hide
697     */
698    public static final int INSTALL_FORCE_PERMISSION_PROMPT = 0x00000400;
699
700    /**
701     * Flag parameter for {@link #installPackage} to indicate that this package is
702     * to be installed as a lightweight "ephemeral" app.
703     *
704     * @hide
705     */
706    public static final int INSTALL_INSTANT_APP = 0x00000800;
707
708    /**
709     * Flag parameter for {@link #installPackage} to indicate that this package is
710     * to be installed as a heavy weight app. This is fundamentally the opposite of
711     * {@link #INSTALL_INSTANT_APP}.
712     *
713     * @hide
714     */
715    public static final int INSTALL_FULL_APP = 0x00004000;
716
717    /**
718     * Flag parameter for {@link #installPackage} to indicate that this package contains
719     * a feature split to an existing application and the existing application should not
720     * be killed during the installation process.
721     *
722     * @hide
723     */
724    public static final int INSTALL_DONT_KILL_APP = 0x00001000;
725
726    /**
727     * Flag parameter for {@link #installPackage} to indicate that this package is an
728     * upgrade to a package that refers to the SDK via release letter.
729     *
730     * @hide
731     */
732    public static final int INSTALL_FORCE_SDK = 0x00002000;
733
734    /**
735     * Flag parameter for
736     * {@link #setComponentEnabledSetting(android.content.ComponentName, int, int)} to indicate
737     * that you don't want to kill the app containing the component.  Be careful when you set this
738     * since changing component states can make the containing application's behavior unpredictable.
739     */
740    public static final int DONT_KILL_APP = 0x00000001;
741
742    /** @hide */
743    @IntDef({INSTALL_REASON_UNKNOWN, INSTALL_REASON_POLICY})
744    @Retention(RetentionPolicy.SOURCE)
745    public @interface InstallReason {}
746
747    /**
748     * Code indicating that the reason for installing this package is unknown.
749     */
750    public static final int INSTALL_REASON_UNKNOWN = 0;
751
752    /**
753     * Code indicating that this package was installed due to enterprise policy.
754     */
755    public static final int INSTALL_REASON_POLICY = 1;
756
757    /**
758     * Installation return code: this is passed to the
759     * {@link IPackageInstallObserver} on success.
760     *
761     * @hide
762     */
763    @SystemApi
764    public static final int INSTALL_SUCCEEDED = 1;
765
766    /**
767     * Installation return code: this is passed to the
768     * {@link IPackageInstallObserver} if the package is already installed.
769     *
770     * @hide
771     */
772    @SystemApi
773    public static final int INSTALL_FAILED_ALREADY_EXISTS = -1;
774
775    /**
776     * Installation return code: this is passed to the
777     * {@link IPackageInstallObserver} if the package archive file is invalid.
778     *
779     * @hide
780     */
781    @SystemApi
782    public static final int INSTALL_FAILED_INVALID_APK = -2;
783
784    /**
785     * Installation return code: this is passed to the
786     * {@link IPackageInstallObserver} if the URI passed in is invalid.
787     *
788     * @hide
789     */
790    @SystemApi
791    public static final int INSTALL_FAILED_INVALID_URI = -3;
792
793    /**
794     * Installation return code: this is passed to the
795     * {@link IPackageInstallObserver} if the package manager service found that
796     * the device didn't have enough storage space to install the app.
797     *
798     * @hide
799     */
800    @SystemApi
801    public static final int INSTALL_FAILED_INSUFFICIENT_STORAGE = -4;
802
803    /**
804     * Installation return code: this is passed to the
805     * {@link IPackageInstallObserver} if a package is already installed with
806     * the same name.
807     *
808     * @hide
809     */
810    @SystemApi
811    public static final int INSTALL_FAILED_DUPLICATE_PACKAGE = -5;
812
813    /**
814     * Installation return code: this is passed to the
815     * {@link IPackageInstallObserver} if the requested shared user does not
816     * exist.
817     *
818     * @hide
819     */
820    @SystemApi
821    public static final int INSTALL_FAILED_NO_SHARED_USER = -6;
822
823    /**
824     * Installation return code: this is passed to the
825     * {@link IPackageInstallObserver} if a previously installed package of the
826     * same name has a different signature than the new package (and the old
827     * package's data was not removed).
828     *
829     * @hide
830     */
831    @SystemApi
832    public static final int INSTALL_FAILED_UPDATE_INCOMPATIBLE = -7;
833
834    /**
835     * Installation return code: this is passed to the
836     * {@link IPackageInstallObserver} if the new package is requested a shared
837     * user which is already installed on the device and does not have matching
838     * signature.
839     *
840     * @hide
841     */
842    @SystemApi
843    public static final int INSTALL_FAILED_SHARED_USER_INCOMPATIBLE = -8;
844
845    /**
846     * Installation return code: this is passed to the
847     * {@link IPackageInstallObserver} if the new package uses a shared library
848     * that is not available.
849     *
850     * @hide
851     */
852    @SystemApi
853    public static final int INSTALL_FAILED_MISSING_SHARED_LIBRARY = -9;
854
855    /**
856     * Installation return code: this is passed to the
857     * {@link IPackageInstallObserver} if the new package uses a shared library
858     * that is not available.
859     *
860     * @hide
861     */
862    @SystemApi
863    public static final int INSTALL_FAILED_REPLACE_COULDNT_DELETE = -10;
864
865    /**
866     * Installation return code: this is passed to the
867     * {@link IPackageInstallObserver} if the new package failed while
868     * optimizing and validating its dex files, either because there was not
869     * enough storage or the validation failed.
870     *
871     * @hide
872     */
873    @SystemApi
874    public static final int INSTALL_FAILED_DEXOPT = -11;
875
876    /**
877     * Installation return code: this is passed to the
878     * {@link IPackageInstallObserver} if the new package failed because the
879     * current SDK version is older than that required by the package.
880     *
881     * @hide
882     */
883    @SystemApi
884    public static final int INSTALL_FAILED_OLDER_SDK = -12;
885
886    /**
887     * Installation return code: this is passed to the
888     * {@link IPackageInstallObserver} if the new package failed because it
889     * contains a content provider with the same authority as a provider already
890     * installed in the system.
891     *
892     * @hide
893     */
894    @SystemApi
895    public static final int INSTALL_FAILED_CONFLICTING_PROVIDER = -13;
896
897    /**
898     * Installation return code: this is passed to the
899     * {@link IPackageInstallObserver} if the new package failed because the
900     * current SDK version is newer than that required by the package.
901     *
902     * @hide
903     */
904    @SystemApi
905    public static final int INSTALL_FAILED_NEWER_SDK = -14;
906
907    /**
908     * Installation return code: this is passed to the
909     * {@link IPackageInstallObserver} if the new package failed because it has
910     * specified that it is a test-only package and the caller has not supplied
911     * the {@link #INSTALL_ALLOW_TEST} flag.
912     *
913     * @hide
914     */
915    @SystemApi
916    public static final int INSTALL_FAILED_TEST_ONLY = -15;
917
918    /**
919     * Installation return code: this is passed to the
920     * {@link IPackageInstallObserver} if the package being installed contains
921     * native code, but none that is compatible with the device's CPU_ABI.
922     *
923     * @hide
924     */
925    @SystemApi
926    public static final int INSTALL_FAILED_CPU_ABI_INCOMPATIBLE = -16;
927
928    /**
929     * Installation return code: this is passed to the
930     * {@link IPackageInstallObserver} if the new package uses a feature that is
931     * not available.
932     *
933     * @hide
934     */
935    @SystemApi
936    public static final int INSTALL_FAILED_MISSING_FEATURE = -17;
937
938    // ------ Errors related to sdcard
939    /**
940     * Installation return code: this is passed to the
941     * {@link IPackageInstallObserver} if a secure container mount point
942     * couldn't be accessed on external media.
943     *
944     * @hide
945     */
946    @SystemApi
947    public static final int INSTALL_FAILED_CONTAINER_ERROR = -18;
948
949    /**
950     * Installation return code: this is passed to the
951     * {@link IPackageInstallObserver} if the new package couldn't be installed
952     * in the specified install location.
953     *
954     * @hide
955     */
956    @SystemApi
957    public static final int INSTALL_FAILED_INVALID_INSTALL_LOCATION = -19;
958
959    /**
960     * Installation return code: this is passed to the
961     * {@link IPackageInstallObserver} if the new package couldn't be installed
962     * in the specified install location because the media is not available.
963     *
964     * @hide
965     */
966    @SystemApi
967    public static final int INSTALL_FAILED_MEDIA_UNAVAILABLE = -20;
968
969    /**
970     * Installation return code: this is passed to the
971     * {@link IPackageInstallObserver} if the new package couldn't be installed
972     * because the verification timed out.
973     *
974     * @hide
975     */
976    @SystemApi
977    public static final int INSTALL_FAILED_VERIFICATION_TIMEOUT = -21;
978
979    /**
980     * Installation return code: this is passed to the
981     * {@link IPackageInstallObserver} if the new package couldn't be installed
982     * because the verification did not succeed.
983     *
984     * @hide
985     */
986    @SystemApi
987    public static final int INSTALL_FAILED_VERIFICATION_FAILURE = -22;
988
989    /**
990     * Installation return code: this is passed to the
991     * {@link IPackageInstallObserver} if the package changed from what the
992     * calling program expected.
993     *
994     * @hide
995     */
996    @SystemApi
997    public static final int INSTALL_FAILED_PACKAGE_CHANGED = -23;
998
999    /**
1000     * Installation return code: this is passed to the
1001     * {@link IPackageInstallObserver} if the new package is assigned a
1002     * different UID than it previously held.
1003     *
1004     * @hide
1005     */
1006    public static final int INSTALL_FAILED_UID_CHANGED = -24;
1007
1008    /**
1009     * Installation return code: this is passed to the
1010     * {@link IPackageInstallObserver} if the new package has an older version
1011     * code than the currently installed package.
1012     *
1013     * @hide
1014     */
1015    public static final int INSTALL_FAILED_VERSION_DOWNGRADE = -25;
1016
1017    /**
1018     * Installation return code: this is passed to the
1019     * {@link IPackageInstallObserver} if the old package has target SDK high
1020     * enough to support runtime permission and the new package has target SDK
1021     * low enough to not support runtime permissions.
1022     *
1023     * @hide
1024     */
1025    @SystemApi
1026    public static final int INSTALL_FAILED_PERMISSION_MODEL_DOWNGRADE = -26;
1027
1028    /**
1029     * Installation parse return code: this is passed to the
1030     * {@link IPackageInstallObserver} if the parser was given a path that is
1031     * not a file, or does not end with the expected '.apk' extension.
1032     *
1033     * @hide
1034     */
1035    @SystemApi
1036    public static final int INSTALL_PARSE_FAILED_NOT_APK = -100;
1037
1038    /**
1039     * Installation parse return code: this is passed to the
1040     * {@link IPackageInstallObserver} if the parser was unable to retrieve the
1041     * AndroidManifest.xml file.
1042     *
1043     * @hide
1044     */
1045    @SystemApi
1046    public static final int INSTALL_PARSE_FAILED_BAD_MANIFEST = -101;
1047
1048    /**
1049     * Installation parse return code: this is passed to the
1050     * {@link IPackageInstallObserver} if the parser encountered an unexpected
1051     * exception.
1052     *
1053     * @hide
1054     */
1055    @SystemApi
1056    public static final int INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION = -102;
1057
1058    /**
1059     * Installation parse return code: this is passed to the
1060     * {@link IPackageInstallObserver} if the parser did not find any
1061     * certificates in the .apk.
1062     *
1063     * @hide
1064     */
1065    @SystemApi
1066    public static final int INSTALL_PARSE_FAILED_NO_CERTIFICATES = -103;
1067
1068    /**
1069     * Installation parse return code: this is passed to the
1070     * {@link IPackageInstallObserver} if the parser found inconsistent
1071     * certificates on the files in the .apk.
1072     *
1073     * @hide
1074     */
1075    @SystemApi
1076    public static final int INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES = -104;
1077
1078    /**
1079     * Installation parse return code: this is passed to the
1080     * {@link IPackageInstallObserver} if the parser encountered a
1081     * CertificateEncodingException in one of the files in the .apk.
1082     *
1083     * @hide
1084     */
1085    @SystemApi
1086    public static final int INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING = -105;
1087
1088    /**
1089     * Installation parse return code: this is passed to the
1090     * {@link IPackageInstallObserver} if the parser encountered a bad or
1091     * missing package name in the manifest.
1092     *
1093     * @hide
1094     */
1095    @SystemApi
1096    public static final int INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME = -106;
1097
1098    /**
1099     * Installation parse return code: this is passed to the
1100     * {@link IPackageInstallObserver} if the parser encountered a bad shared
1101     * user id name in the manifest.
1102     *
1103     * @hide
1104     */
1105    @SystemApi
1106    public static final int INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID = -107;
1107
1108    /**
1109     * Installation parse return code: this is passed to the
1110     * {@link IPackageInstallObserver} if the parser encountered some structural
1111     * problem in the manifest.
1112     *
1113     * @hide
1114     */
1115    @SystemApi
1116    public static final int INSTALL_PARSE_FAILED_MANIFEST_MALFORMED = -108;
1117
1118    /**
1119     * Installation parse return code: this is passed to the
1120     * {@link IPackageInstallObserver} if the parser did not find any actionable
1121     * tags (instrumentation or application) in the manifest.
1122     *
1123     * @hide
1124     */
1125    @SystemApi
1126    public static final int INSTALL_PARSE_FAILED_MANIFEST_EMPTY = -109;
1127
1128    /**
1129     * Installation failed return code: this is passed to the
1130     * {@link IPackageInstallObserver} if the system failed to install the
1131     * package because of system issues.
1132     *
1133     * @hide
1134     */
1135    @SystemApi
1136    public static final int INSTALL_FAILED_INTERNAL_ERROR = -110;
1137
1138    /**
1139     * Installation failed return code: this is passed to the
1140     * {@link IPackageInstallObserver} if the system failed to install the
1141     * package because the user is restricted from installing apps.
1142     *
1143     * @hide
1144     */
1145    public static final int INSTALL_FAILED_USER_RESTRICTED = -111;
1146
1147    /**
1148     * Installation failed return code: this is passed to the
1149     * {@link IPackageInstallObserver} if the system failed to install the
1150     * package because it is attempting to define a permission that is already
1151     * defined by some existing package.
1152     * <p>
1153     * The package name of the app which has already defined the permission is
1154     * passed to a {@link PackageInstallObserver}, if any, as the
1155     * {@link #EXTRA_FAILURE_EXISTING_PACKAGE} string extra; and the name of the
1156     * permission being redefined is passed in the
1157     * {@link #EXTRA_FAILURE_EXISTING_PERMISSION} string extra.
1158     *
1159     * @hide
1160     */
1161    public static final int INSTALL_FAILED_DUPLICATE_PERMISSION = -112;
1162
1163    /**
1164     * Installation failed return code: this is passed to the
1165     * {@link IPackageInstallObserver} if the system failed to install the
1166     * package because its packaged native code did not match any of the ABIs
1167     * supported by the system.
1168     *
1169     * @hide
1170     */
1171    public static final int INSTALL_FAILED_NO_MATCHING_ABIS = -113;
1172
1173    /**
1174     * Internal return code for NativeLibraryHelper methods to indicate that the package
1175     * being processed did not contain any native code. This is placed here only so that
1176     * it can belong to the same value space as the other install failure codes.
1177     *
1178     * @hide
1179     */
1180    public static final int NO_NATIVE_LIBRARIES = -114;
1181
1182    /** {@hide} */
1183    public static final int INSTALL_FAILED_ABORTED = -115;
1184
1185    /**
1186     * Installation failed return code: instant app installs are incompatible with some
1187     * other installation flags supplied for the operation; or other circumstances such
1188     * as trying to upgrade a system app via an instant app install.
1189     * @hide
1190     */
1191    public static final int INSTALL_FAILED_INSTANT_APP_INVALID = -116;
1192
1193    /** @hide */
1194    @IntDef(flag = true, value = {
1195            DELETE_KEEP_DATA,
1196            DELETE_ALL_USERS,
1197            DELETE_SYSTEM_APP,
1198            DELETE_DONT_KILL_APP,
1199    })
1200    @Retention(RetentionPolicy.SOURCE)
1201    public @interface DeleteFlags {}
1202
1203    /**
1204     * Flag parameter for {@link #deletePackage} to indicate that you don't want to delete the
1205     * package's data directory.
1206     *
1207     * @hide
1208     */
1209    public static final int DELETE_KEEP_DATA = 0x00000001;
1210
1211    /**
1212     * Flag parameter for {@link #deletePackage} to indicate that you want the
1213     * package deleted for all users.
1214     *
1215     * @hide
1216     */
1217    public static final int DELETE_ALL_USERS = 0x00000002;
1218
1219    /**
1220     * Flag parameter for {@link #deletePackage} to indicate that, if you are calling
1221     * uninstall on a system that has been updated, then don't do the normal process
1222     * of uninstalling the update and rolling back to the older system version (which
1223     * needs to happen for all users); instead, just mark the app as uninstalled for
1224     * the current user.
1225     *
1226     * @hide
1227     */
1228    public static final int DELETE_SYSTEM_APP = 0x00000004;
1229
1230    /**
1231     * Flag parameter for {@link #deletePackage} to indicate that, if you are calling
1232     * uninstall on a package that is replaced to provide new feature splits, the
1233     * existing application should not be killed during the removal process.
1234     *
1235     * @hide
1236     */
1237    public static final int DELETE_DONT_KILL_APP = 0x00000008;
1238
1239    /**
1240     * Return code for when package deletion succeeds. This is passed to the
1241     * {@link IPackageDeleteObserver} if the system succeeded in deleting the
1242     * package.
1243     *
1244     * @hide
1245     */
1246    public static final int DELETE_SUCCEEDED = 1;
1247
1248    /**
1249     * Deletion failed return code: this is passed to the
1250     * {@link IPackageDeleteObserver} if the system failed to delete the package
1251     * for an unspecified reason.
1252     *
1253     * @hide
1254     */
1255    public static final int DELETE_FAILED_INTERNAL_ERROR = -1;
1256
1257    /**
1258     * Deletion failed return code: this is passed to the
1259     * {@link IPackageDeleteObserver} if the system failed to delete the package
1260     * because it is the active DevicePolicy manager.
1261     *
1262     * @hide
1263     */
1264    public static final int DELETE_FAILED_DEVICE_POLICY_MANAGER = -2;
1265
1266    /**
1267     * Deletion failed return code: this is passed to the
1268     * {@link IPackageDeleteObserver} if the system failed to delete the package
1269     * since the user is restricted.
1270     *
1271     * @hide
1272     */
1273    public static final int DELETE_FAILED_USER_RESTRICTED = -3;
1274
1275    /**
1276     * Deletion failed return code: this is passed to the
1277     * {@link IPackageDeleteObserver} if the system failed to delete the package
1278     * because a profile or device owner has marked the package as
1279     * uninstallable.
1280     *
1281     * @hide
1282     */
1283    public static final int DELETE_FAILED_OWNER_BLOCKED = -4;
1284
1285    /** {@hide} */
1286    public static final int DELETE_FAILED_ABORTED = -5;
1287
1288    /**
1289     * Deletion failed return code: this is passed to the
1290     * {@link IPackageDeleteObserver} if the system failed to delete the package
1291     * because the packge is a shared library used by other installed packages.
1292     * {@hide} */
1293    public static final int DELETE_FAILED_USED_SHARED_LIBRARY = -6;
1294
1295    /**
1296     * Return code that is passed to the {@link IPackageMoveObserver} when the
1297     * package has been successfully moved by the system.
1298     *
1299     * @hide
1300     */
1301    public static final int MOVE_SUCCEEDED = -100;
1302
1303    /**
1304     * Error code that is passed to the {@link IPackageMoveObserver} when the
1305     * package hasn't been successfully moved by the system because of
1306     * insufficient memory on specified media.
1307     *
1308     * @hide
1309     */
1310    public static final int MOVE_FAILED_INSUFFICIENT_STORAGE = -1;
1311
1312    /**
1313     * Error code that is passed to the {@link IPackageMoveObserver} if the
1314     * specified package doesn't exist.
1315     *
1316     * @hide
1317     */
1318    public static final int MOVE_FAILED_DOESNT_EXIST = -2;
1319
1320    /**
1321     * Error code that is passed to the {@link IPackageMoveObserver} if the
1322     * specified package cannot be moved since its a system package.
1323     *
1324     * @hide
1325     */
1326    public static final int MOVE_FAILED_SYSTEM_PACKAGE = -3;
1327
1328    /**
1329     * Error code that is passed to the {@link IPackageMoveObserver} if the
1330     * specified package cannot be moved since its forward locked.
1331     *
1332     * @hide
1333     */
1334    public static final int MOVE_FAILED_FORWARD_LOCKED = -4;
1335
1336    /**
1337     * Error code that is passed to the {@link IPackageMoveObserver} if the
1338     * specified package cannot be moved to the specified location.
1339     *
1340     * @hide
1341     */
1342    public static final int MOVE_FAILED_INVALID_LOCATION = -5;
1343
1344    /**
1345     * Error code that is passed to the {@link IPackageMoveObserver} if the
1346     * specified package cannot be moved to the specified location.
1347     *
1348     * @hide
1349     */
1350    public static final int MOVE_FAILED_INTERNAL_ERROR = -6;
1351
1352    /**
1353     * Error code that is passed to the {@link IPackageMoveObserver} if the
1354     * specified package already has an operation pending in the queue.
1355     *
1356     * @hide
1357     */
1358    public static final int MOVE_FAILED_OPERATION_PENDING = -7;
1359
1360    /**
1361     * Error code that is passed to the {@link IPackageMoveObserver} if the
1362     * specified package cannot be moved since it contains a device admin.
1363     *
1364     * @hide
1365     */
1366    public static final int MOVE_FAILED_DEVICE_ADMIN = -8;
1367
1368    /**
1369     * Error code that is passed to the {@link IPackageMoveObserver} if system does not allow
1370     * non-system apps to be moved to internal storage.
1371     *
1372     * @hide
1373     */
1374    public static final int MOVE_FAILED_3RD_PARTY_NOT_ALLOWED_ON_INTERNAL = -9;
1375
1376    /**
1377     * Flag parameter for {@link #movePackage} to indicate that
1378     * the package should be moved to internal storage if its
1379     * been installed on external media.
1380     * @hide
1381     */
1382    @Deprecated
1383    public static final int MOVE_INTERNAL = 0x00000001;
1384
1385    /**
1386     * Flag parameter for {@link #movePackage} to indicate that
1387     * the package should be moved to external media.
1388     * @hide
1389     */
1390    @Deprecated
1391    public static final int MOVE_EXTERNAL_MEDIA = 0x00000002;
1392
1393    /** {@hide} */
1394    public static final String EXTRA_MOVE_ID = "android.content.pm.extra.MOVE_ID";
1395
1396    /**
1397     * Usable by the required verifier as the {@code verificationCode} argument
1398     * for {@link PackageManager#verifyPendingInstall} to indicate that it will
1399     * allow the installation to proceed without any of the optional verifiers
1400     * needing to vote.
1401     *
1402     * @hide
1403     */
1404    public static final int VERIFICATION_ALLOW_WITHOUT_SUFFICIENT = 2;
1405
1406    /**
1407     * Used as the {@code verificationCode} argument for
1408     * {@link PackageManager#verifyPendingInstall} to indicate that the calling
1409     * package verifier allows the installation to proceed.
1410     */
1411    public static final int VERIFICATION_ALLOW = 1;
1412
1413    /**
1414     * Used as the {@code verificationCode} argument for
1415     * {@link PackageManager#verifyPendingInstall} to indicate the calling
1416     * package verifier does not vote to allow the installation to proceed.
1417     */
1418    public static final int VERIFICATION_REJECT = -1;
1419
1420    /**
1421     * Used as the {@code verificationCode} argument for
1422     * {@link PackageManager#verifyIntentFilter} to indicate that the calling
1423     * IntentFilter Verifier confirms that the IntentFilter is verified.
1424     *
1425     * @hide
1426     */
1427    @SystemApi
1428    public static final int INTENT_FILTER_VERIFICATION_SUCCESS = 1;
1429
1430    /**
1431     * Used as the {@code verificationCode} argument for
1432     * {@link PackageManager#verifyIntentFilter} to indicate that the calling
1433     * IntentFilter Verifier confirms that the IntentFilter is NOT verified.
1434     *
1435     * @hide
1436     */
1437    @SystemApi
1438    public static final int INTENT_FILTER_VERIFICATION_FAILURE = -1;
1439
1440    /**
1441     * Internal status code to indicate that an IntentFilter verification result is not specified.
1442     *
1443     * @hide
1444     */
1445    @SystemApi
1446    public static final int INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_UNDEFINED = 0;
1447
1448    /**
1449     * Used as the {@code status} argument for
1450     * {@link #updateIntentVerificationStatusAsUser} to indicate that the User
1451     * will always be prompted the Intent Disambiguation Dialog if there are two
1452     * or more Intent resolved for the IntentFilter's domain(s).
1453     *
1454     * @hide
1455     */
1456    @SystemApi
1457    public static final int INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK = 1;
1458
1459    /**
1460     * Used as the {@code status} argument for
1461     * {@link #updateIntentVerificationStatusAsUser} to indicate that the User
1462     * will never be prompted the Intent Disambiguation Dialog if there are two
1463     * or more resolution of the Intent. The default App for the domain(s)
1464     * specified in the IntentFilter will also ALWAYS be used.
1465     *
1466     * @hide
1467     */
1468    @SystemApi
1469    public static final int INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS = 2;
1470
1471    /**
1472     * Used as the {@code status} argument for
1473     * {@link #updateIntentVerificationStatusAsUser} to indicate that the User
1474     * may be prompted the Intent Disambiguation Dialog if there are two or more
1475     * Intent resolved. The default App for the domain(s) specified in the
1476     * IntentFilter will also NEVER be presented to the User.
1477     *
1478     * @hide
1479     */
1480    @SystemApi
1481    public static final int INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER = 3;
1482
1483    /**
1484     * Used as the {@code status} argument for
1485     * {@link #updateIntentVerificationStatusAsUser} to indicate that this app
1486     * should always be considered as an ambiguous candidate for handling the
1487     * matching Intent even if there are other candidate apps in the "always"
1488     * state. Put another way: if there are any 'always ask' apps in a set of
1489     * more than one candidate app, then a disambiguation is *always* presented
1490     * even if there is another candidate app with the 'always' state.
1491     *
1492     * @hide
1493     */
1494    @SystemApi
1495    public static final int INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS_ASK = 4;
1496
1497    /**
1498     * Can be used as the {@code millisecondsToDelay} argument for
1499     * {@link PackageManager#extendVerificationTimeout}. This is the
1500     * maximum time {@code PackageManager} waits for the verification
1501     * agent to return (in milliseconds).
1502     */
1503    public static final long MAXIMUM_VERIFICATION_TIMEOUT = 60*60*1000;
1504
1505    /**
1506     * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device's
1507     * audio pipeline is low-latency, more suitable for audio applications sensitive to delays or
1508     * lag in sound input or output.
1509     */
1510    @SdkConstant(SdkConstantType.FEATURE)
1511    public static final String FEATURE_AUDIO_LOW_LATENCY = "android.hardware.audio.low_latency";
1512
1513    /**
1514     * Feature for {@link #getSystemAvailableFeatures} and
1515     * {@link #hasSystemFeature}: The device includes at least one form of audio
1516     * output, such as speakers, audio jack or streaming over bluetooth
1517     */
1518    @SdkConstant(SdkConstantType.FEATURE)
1519    public static final String FEATURE_AUDIO_OUTPUT = "android.hardware.audio.output";
1520
1521    /**
1522     * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
1523     * The device has professional audio level of functionality and performance.
1524     */
1525    @SdkConstant(SdkConstantType.FEATURE)
1526    public static final String FEATURE_AUDIO_PRO = "android.hardware.audio.pro";
1527
1528    /**
1529     * Feature for {@link #getSystemAvailableFeatures} and
1530     * {@link #hasSystemFeature}: The device is capable of communicating with
1531     * other devices via Bluetooth.
1532     */
1533    @SdkConstant(SdkConstantType.FEATURE)
1534    public static final String FEATURE_BLUETOOTH = "android.hardware.bluetooth";
1535
1536    /**
1537     * Feature for {@link #getSystemAvailableFeatures} and
1538     * {@link #hasSystemFeature}: The device is capable of communicating with
1539     * other devices via Bluetooth Low Energy radio.
1540     */
1541    @SdkConstant(SdkConstantType.FEATURE)
1542    public static final String FEATURE_BLUETOOTH_LE = "android.hardware.bluetooth_le";
1543
1544    /**
1545     * Feature for {@link #getSystemAvailableFeatures} and
1546     * {@link #hasSystemFeature}: The device has a camera facing away
1547     * from the screen.
1548     */
1549    @SdkConstant(SdkConstantType.FEATURE)
1550    public static final String FEATURE_CAMERA = "android.hardware.camera";
1551
1552    /**
1553     * Feature for {@link #getSystemAvailableFeatures} and
1554     * {@link #hasSystemFeature}: The device's camera supports auto-focus.
1555     */
1556    @SdkConstant(SdkConstantType.FEATURE)
1557    public static final String FEATURE_CAMERA_AUTOFOCUS = "android.hardware.camera.autofocus";
1558
1559    /**
1560     * Feature for {@link #getSystemAvailableFeatures} and
1561     * {@link #hasSystemFeature}: The device has at least one camera pointing in
1562     * some direction, or can support an external camera being connected to it.
1563     */
1564    @SdkConstant(SdkConstantType.FEATURE)
1565    public static final String FEATURE_CAMERA_ANY = "android.hardware.camera.any";
1566
1567    /**
1568     * Feature for {@link #getSystemAvailableFeatures} and
1569     * {@link #hasSystemFeature}: The device can support having an external camera connected to it.
1570     * The external camera may not always be connected or available to applications to use.
1571     */
1572    @SdkConstant(SdkConstantType.FEATURE)
1573    public static final String FEATURE_CAMERA_EXTERNAL = "android.hardware.camera.external";
1574
1575    /**
1576     * Feature for {@link #getSystemAvailableFeatures} and
1577     * {@link #hasSystemFeature}: The device's camera supports flash.
1578     */
1579    @SdkConstant(SdkConstantType.FEATURE)
1580    public static final String FEATURE_CAMERA_FLASH = "android.hardware.camera.flash";
1581
1582    /**
1583     * Feature for {@link #getSystemAvailableFeatures} and
1584     * {@link #hasSystemFeature}: The device has a front facing camera.
1585     */
1586    @SdkConstant(SdkConstantType.FEATURE)
1587    public static final String FEATURE_CAMERA_FRONT = "android.hardware.camera.front";
1588
1589    /**
1590     * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: At least one
1591     * of the cameras on the device supports the
1592     * {@link android.hardware.camera2.CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL full hardware}
1593     * capability level.
1594     */
1595    @SdkConstant(SdkConstantType.FEATURE)
1596    public static final String FEATURE_CAMERA_LEVEL_FULL = "android.hardware.camera.level.full";
1597
1598    /**
1599     * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: At least one
1600     * of the cameras on the device supports the
1601     * {@link android.hardware.camera2.CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_MANUAL_SENSOR manual sensor}
1602     * capability level.
1603     */
1604    @SdkConstant(SdkConstantType.FEATURE)
1605    public static final String FEATURE_CAMERA_CAPABILITY_MANUAL_SENSOR =
1606            "android.hardware.camera.capability.manual_sensor";
1607
1608    /**
1609     * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: At least one
1610     * of the cameras on the device supports the
1611     * {@link android.hardware.camera2.CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_MANUAL_POST_PROCESSING manual post-processing}
1612     * capability level.
1613     */
1614    @SdkConstant(SdkConstantType.FEATURE)
1615    public static final String FEATURE_CAMERA_CAPABILITY_MANUAL_POST_PROCESSING =
1616            "android.hardware.camera.capability.manual_post_processing";
1617
1618    /**
1619     * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: At least one
1620     * of the cameras on the device supports the
1621     * {@link android.hardware.camera2.CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_RAW RAW}
1622     * capability level.
1623     */
1624    @SdkConstant(SdkConstantType.FEATURE)
1625    public static final String FEATURE_CAMERA_CAPABILITY_RAW =
1626            "android.hardware.camera.capability.raw";
1627
1628    /**
1629     * Feature for {@link #getSystemAvailableFeatures} and
1630     * {@link #hasSystemFeature}: The device is capable of communicating with
1631     * consumer IR devices.
1632     */
1633    @SdkConstant(SdkConstantType.FEATURE)
1634    public static final String FEATURE_CONSUMER_IR = "android.hardware.consumerir";
1635
1636    /**
1637     * Feature for {@link #getSystemAvailableFeatures} and
1638     * {@link #hasSystemFeature}: The device supports one or more methods of
1639     * reporting current location.
1640     */
1641    @SdkConstant(SdkConstantType.FEATURE)
1642    public static final String FEATURE_LOCATION = "android.hardware.location";
1643
1644    /**
1645     * Feature for {@link #getSystemAvailableFeatures} and
1646     * {@link #hasSystemFeature}: The device has a Global Positioning System
1647     * receiver and can report precise location.
1648     */
1649    @SdkConstant(SdkConstantType.FEATURE)
1650    public static final String FEATURE_LOCATION_GPS = "android.hardware.location.gps";
1651
1652    /**
1653     * Feature for {@link #getSystemAvailableFeatures} and
1654     * {@link #hasSystemFeature}: The device can report location with coarse
1655     * accuracy using a network-based geolocation system.
1656     */
1657    @SdkConstant(SdkConstantType.FEATURE)
1658    public static final String FEATURE_LOCATION_NETWORK = "android.hardware.location.network";
1659
1660    /**
1661     * Feature for {@link #getSystemAvailableFeatures} and
1662     * {@link #hasSystemFeature}: The device can record audio via a
1663     * microphone.
1664     */
1665    @SdkConstant(SdkConstantType.FEATURE)
1666    public static final String FEATURE_MICROPHONE = "android.hardware.microphone";
1667
1668    /**
1669     * Feature for {@link #getSystemAvailableFeatures} and
1670     * {@link #hasSystemFeature}: The device can communicate using Near-Field
1671     * Communications (NFC).
1672     */
1673    @SdkConstant(SdkConstantType.FEATURE)
1674    public static final String FEATURE_NFC = "android.hardware.nfc";
1675
1676    /**
1677     * Feature for {@link #getSystemAvailableFeatures} and
1678     * {@link #hasSystemFeature}: The device supports host-
1679     * based NFC card emulation.
1680     *
1681     * TODO remove when depending apps have moved to new constant.
1682     * @hide
1683     * @deprecated
1684     */
1685    @Deprecated
1686    @SdkConstant(SdkConstantType.FEATURE)
1687    public static final String FEATURE_NFC_HCE = "android.hardware.nfc.hce";
1688
1689    /**
1690     * Feature for {@link #getSystemAvailableFeatures} and
1691     * {@link #hasSystemFeature}: The device supports host-
1692     * based NFC card emulation.
1693     */
1694    @SdkConstant(SdkConstantType.FEATURE)
1695    public static final String FEATURE_NFC_HOST_CARD_EMULATION = "android.hardware.nfc.hce";
1696
1697    /**
1698     * Feature for {@link #getSystemAvailableFeatures} and
1699     * {@link #hasSystemFeature}: The device supports host-
1700     * based NFC-F card emulation.
1701     */
1702    @SdkConstant(SdkConstantType.FEATURE)
1703    public static final String FEATURE_NFC_HOST_CARD_EMULATION_NFCF = "android.hardware.nfc.hcef";
1704
1705    /**
1706     * Feature for {@link #getSystemAvailableFeatures} and
1707     * {@link #hasSystemFeature}: The device supports the OpenGL ES
1708     * <a href="http://www.khronos.org/registry/gles/extensions/ANDROID/ANDROID_extension_pack_es31a.txt">
1709     * Android Extension Pack</a>.
1710     */
1711    @SdkConstant(SdkConstantType.FEATURE)
1712    public static final String FEATURE_OPENGLES_EXTENSION_PACK = "android.hardware.opengles.aep";
1713
1714    /**
1715     * Feature for {@link #getSystemAvailableFeatures} and
1716     * {@link #hasSystemFeature(String, int)}: If this feature is supported, the Vulkan native API
1717     * will enumerate at least one {@code VkPhysicalDevice}, and the feature version will indicate
1718     * what level of optional hardware features limits it supports.
1719     * <p>
1720     * Level 0 includes the base Vulkan requirements as well as:
1721     * <ul><li>{@code VkPhysicalDeviceFeatures::textureCompressionETC2}</li></ul>
1722     * <p>
1723     * Level 1 additionally includes:
1724     * <ul>
1725     * <li>{@code VkPhysicalDeviceFeatures::fullDrawIndexUint32}</li>
1726     * <li>{@code VkPhysicalDeviceFeatures::imageCubeArray}</li>
1727     * <li>{@code VkPhysicalDeviceFeatures::independentBlend}</li>
1728     * <li>{@code VkPhysicalDeviceFeatures::geometryShader}</li>
1729     * <li>{@code VkPhysicalDeviceFeatures::tessellationShader}</li>
1730     * <li>{@code VkPhysicalDeviceFeatures::sampleRateShading}</li>
1731     * <li>{@code VkPhysicalDeviceFeatures::textureCompressionASTC_LDR}</li>
1732     * <li>{@code VkPhysicalDeviceFeatures::fragmentStoresAndAtomics}</li>
1733     * <li>{@code VkPhysicalDeviceFeatures::shaderImageGatherExtended}</li>
1734     * <li>{@code VkPhysicalDeviceFeatures::shaderUniformBufferArrayDynamicIndexing}</li>
1735     * <li>{@code VkPhysicalDeviceFeatures::shaderSampledImageArrayDynamicIndexing}</li>
1736     * </ul>
1737     */
1738    @SdkConstant(SdkConstantType.FEATURE)
1739    public static final String FEATURE_VULKAN_HARDWARE_LEVEL = "android.hardware.vulkan.level";
1740
1741    /**
1742     * Feature for {@link #getSystemAvailableFeatures} and
1743     * {@link #hasSystemFeature(String, int)}: If this feature is supported, the Vulkan native API
1744     * will enumerate at least one {@code VkPhysicalDevice}, and the feature version will indicate
1745     * what level of optional compute features are supported beyond the Vulkan 1.0 requirements.
1746     * <p>
1747     * Compute level 0 indicates support for:
1748     * <ul>
1749     * <li>Ability to use pointers to buffer data from shaders</li>
1750     * <li>Ability to load/store 16-bit values from buffers</li>
1751     * <li>Ability to control shader floating point rounding mode</li>
1752     * </ul>
1753     */
1754    @SdkConstant(SdkConstantType.FEATURE)
1755    public static final String FEATURE_VULKAN_HARDWARE_COMPUTE = "android.hardware.vulkan.compute";
1756
1757    /**
1758     * Feature for {@link #getSystemAvailableFeatures} and
1759     * {@link #hasSystemFeature(String, int)}: The version of this feature indicates the highest
1760     * {@code VkPhysicalDeviceProperties::apiVersion} supported by the physical devices that support
1761     * the hardware level indicated by {@link #FEATURE_VULKAN_HARDWARE_LEVEL}. The feature version
1762     * uses the same encoding as Vulkan version numbers:
1763     * <ul>
1764     * <li>Major version number in bits 31-22</li>
1765     * <li>Minor version number in bits 21-12</li>
1766     * <li>Patch version number in bits 11-0</li>
1767     * </ul>
1768     */
1769    @SdkConstant(SdkConstantType.FEATURE)
1770    public static final String FEATURE_VULKAN_HARDWARE_VERSION = "android.hardware.vulkan.version";
1771
1772    /**
1773     * Feature for {@link #getSystemAvailableFeatures} and
1774     * {@link #hasSystemFeature}: The device includes an accelerometer.
1775     */
1776    @SdkConstant(SdkConstantType.FEATURE)
1777    public static final String FEATURE_SENSOR_ACCELEROMETER = "android.hardware.sensor.accelerometer";
1778
1779    /**
1780     * Feature for {@link #getSystemAvailableFeatures} and
1781     * {@link #hasSystemFeature}: The device includes a barometer (air
1782     * pressure sensor.)
1783     */
1784    @SdkConstant(SdkConstantType.FEATURE)
1785    public static final String FEATURE_SENSOR_BAROMETER = "android.hardware.sensor.barometer";
1786
1787    /**
1788     * Feature for {@link #getSystemAvailableFeatures} and
1789     * {@link #hasSystemFeature}: The device includes a magnetometer (compass).
1790     */
1791    @SdkConstant(SdkConstantType.FEATURE)
1792    public static final String FEATURE_SENSOR_COMPASS = "android.hardware.sensor.compass";
1793
1794    /**
1795     * Feature for {@link #getSystemAvailableFeatures} and
1796     * {@link #hasSystemFeature}: The device includes a gyroscope.
1797     */
1798    @SdkConstant(SdkConstantType.FEATURE)
1799    public static final String FEATURE_SENSOR_GYROSCOPE = "android.hardware.sensor.gyroscope";
1800
1801    /**
1802     * Feature for {@link #getSystemAvailableFeatures} and
1803     * {@link #hasSystemFeature}: The device includes a light sensor.
1804     */
1805    @SdkConstant(SdkConstantType.FEATURE)
1806    public static final String FEATURE_SENSOR_LIGHT = "android.hardware.sensor.light";
1807
1808    /**
1809     * Feature for {@link #getSystemAvailableFeatures} and
1810     * {@link #hasSystemFeature}: The device includes a proximity sensor.
1811     */
1812    @SdkConstant(SdkConstantType.FEATURE)
1813    public static final String FEATURE_SENSOR_PROXIMITY = "android.hardware.sensor.proximity";
1814
1815    /**
1816     * Feature for {@link #getSystemAvailableFeatures} and
1817     * {@link #hasSystemFeature}: The device includes a hardware step counter.
1818     */
1819    @SdkConstant(SdkConstantType.FEATURE)
1820    public static final String FEATURE_SENSOR_STEP_COUNTER = "android.hardware.sensor.stepcounter";
1821
1822    /**
1823     * Feature for {@link #getSystemAvailableFeatures} and
1824     * {@link #hasSystemFeature}: The device includes a hardware step detector.
1825     */
1826    @SdkConstant(SdkConstantType.FEATURE)
1827    public static final String FEATURE_SENSOR_STEP_DETECTOR = "android.hardware.sensor.stepdetector";
1828
1829    /**
1830     * Feature for {@link #getSystemAvailableFeatures} and
1831     * {@link #hasSystemFeature}: The device includes a heart rate monitor.
1832     */
1833    @SdkConstant(SdkConstantType.FEATURE)
1834    public static final String FEATURE_SENSOR_HEART_RATE = "android.hardware.sensor.heartrate";
1835
1836    /**
1837     * Feature for {@link #getSystemAvailableFeatures} and
1838     * {@link #hasSystemFeature}: The heart rate sensor on this device is an Electrocardiogram.
1839     */
1840    @SdkConstant(SdkConstantType.FEATURE)
1841    public static final String FEATURE_SENSOR_HEART_RATE_ECG =
1842            "android.hardware.sensor.heartrate.ecg";
1843
1844    /**
1845     * Feature for {@link #getSystemAvailableFeatures} and
1846     * {@link #hasSystemFeature}: The device includes a relative humidity sensor.
1847     */
1848    @SdkConstant(SdkConstantType.FEATURE)
1849    public static final String FEATURE_SENSOR_RELATIVE_HUMIDITY =
1850            "android.hardware.sensor.relative_humidity";
1851
1852    /**
1853     * Feature for {@link #getSystemAvailableFeatures} and
1854     * {@link #hasSystemFeature}: The device includes an ambient temperature sensor.
1855     */
1856    @SdkConstant(SdkConstantType.FEATURE)
1857    public static final String FEATURE_SENSOR_AMBIENT_TEMPERATURE =
1858            "android.hardware.sensor.ambient_temperature";
1859
1860    /**
1861     * Feature for {@link #getSystemAvailableFeatures} and
1862     * {@link #hasSystemFeature}: The device supports high fidelity sensor processing
1863     * capabilities.
1864     */
1865    @SdkConstant(SdkConstantType.FEATURE)
1866    public static final String FEATURE_HIFI_SENSORS =
1867            "android.hardware.sensor.hifi_sensors";
1868
1869    /**
1870     * Feature for {@link #getSystemAvailableFeatures} and
1871     * {@link #hasSystemFeature}: The device has a telephony radio with data
1872     * communication support.
1873     */
1874    @SdkConstant(SdkConstantType.FEATURE)
1875    public static final String FEATURE_TELEPHONY = "android.hardware.telephony";
1876
1877    /**
1878     * Feature for {@link #getSystemAvailableFeatures} and
1879     * {@link #hasSystemFeature}: The device has a CDMA telephony stack.
1880     */
1881    @SdkConstant(SdkConstantType.FEATURE)
1882    public static final String FEATURE_TELEPHONY_CDMA = "android.hardware.telephony.cdma";
1883
1884    /**
1885     * Feature for {@link #getSystemAvailableFeatures} and
1886     * {@link #hasSystemFeature}: The device has a GSM telephony stack.
1887     */
1888    @SdkConstant(SdkConstantType.FEATURE)
1889    public static final String FEATURE_TELEPHONY_GSM = "android.hardware.telephony.gsm";
1890
1891    /**
1892     * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
1893     * The device supports telephony carrier restriction mechanism.
1894     *
1895     * <p>Devices declaring this feature must have an implementation of the
1896     * {@link android.telephony.TelephonyManager#getAllowedCarriers} and
1897     * {@link android.telephony.TelephonyManager#setAllowedCarriers}.
1898     * @hide
1899     */
1900    @SystemApi
1901    @SdkConstant(SdkConstantType.FEATURE)
1902    public static final String FEATURE_TELEPHONY_CARRIERLOCK =
1903            "android.hardware.telephony.carrierlock";
1904
1905    /**
1906     * Feature for {@link #getSystemAvailableFeatures} and
1907     * {@link #hasSystemFeature}: The device supports connecting to USB devices
1908     * as the USB host.
1909     */
1910    @SdkConstant(SdkConstantType.FEATURE)
1911    public static final String FEATURE_USB_HOST = "android.hardware.usb.host";
1912
1913    /**
1914     * Feature for {@link #getSystemAvailableFeatures} and
1915     * {@link #hasSystemFeature}: The device supports connecting to USB accessories.
1916     */
1917    @SdkConstant(SdkConstantType.FEATURE)
1918    public static final String FEATURE_USB_ACCESSORY = "android.hardware.usb.accessory";
1919
1920    /**
1921     * Feature for {@link #getSystemAvailableFeatures} and
1922     * {@link #hasSystemFeature}: The SIP API is enabled on the device.
1923     */
1924    @SdkConstant(SdkConstantType.FEATURE)
1925    public static final String FEATURE_SIP = "android.software.sip";
1926
1927    /**
1928     * Feature for {@link #getSystemAvailableFeatures} and
1929     * {@link #hasSystemFeature}: The device supports SIP-based VOIP.
1930     */
1931    @SdkConstant(SdkConstantType.FEATURE)
1932    public static final String FEATURE_SIP_VOIP = "android.software.sip.voip";
1933
1934    /**
1935     * Feature for {@link #getSystemAvailableFeatures} and
1936     * {@link #hasSystemFeature}: The Connection Service API is enabled on the device.
1937     */
1938    @SdkConstant(SdkConstantType.FEATURE)
1939    public static final String FEATURE_CONNECTION_SERVICE = "android.software.connectionservice";
1940
1941    /**
1942     * Feature for {@link #getSystemAvailableFeatures} and
1943     * {@link #hasSystemFeature}: The device's display has a touch screen.
1944     */
1945    @SdkConstant(SdkConstantType.FEATURE)
1946    public static final String FEATURE_TOUCHSCREEN = "android.hardware.touchscreen";
1947
1948    /**
1949     * Feature for {@link #getSystemAvailableFeatures} and
1950     * {@link #hasSystemFeature}: The device's touch screen supports
1951     * multitouch sufficient for basic two-finger gesture detection.
1952     */
1953    @SdkConstant(SdkConstantType.FEATURE)
1954    public static final String FEATURE_TOUCHSCREEN_MULTITOUCH = "android.hardware.touchscreen.multitouch";
1955
1956    /**
1957     * Feature for {@link #getSystemAvailableFeatures} and
1958     * {@link #hasSystemFeature}: The device's touch screen is capable of
1959     * tracking two or more fingers fully independently.
1960     */
1961    @SdkConstant(SdkConstantType.FEATURE)
1962    public static final String FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT = "android.hardware.touchscreen.multitouch.distinct";
1963
1964    /**
1965     * Feature for {@link #getSystemAvailableFeatures} and
1966     * {@link #hasSystemFeature}: The device's touch screen is capable of
1967     * tracking a full hand of fingers fully independently -- that is, 5 or
1968     * more simultaneous independent pointers.
1969     */
1970    @SdkConstant(SdkConstantType.FEATURE)
1971    public static final String FEATURE_TOUCHSCREEN_MULTITOUCH_JAZZHAND = "android.hardware.touchscreen.multitouch.jazzhand";
1972
1973    /**
1974     * Feature for {@link #getSystemAvailableFeatures} and
1975     * {@link #hasSystemFeature}: The device does not have a touch screen, but
1976     * does support touch emulation for basic events. For instance, the
1977     * device might use a mouse or remote control to drive a cursor, and
1978     * emulate basic touch pointer events like down, up, drag, etc. All
1979     * devices that support android.hardware.touchscreen or a sub-feature are
1980     * presumed to also support faketouch.
1981     */
1982    @SdkConstant(SdkConstantType.FEATURE)
1983    public static final String FEATURE_FAKETOUCH = "android.hardware.faketouch";
1984
1985    /**
1986     * Feature for {@link #getSystemAvailableFeatures} and
1987     * {@link #hasSystemFeature}: The device does not have a touch screen, but
1988     * does support touch emulation for basic events that supports distinct
1989     * tracking of two or more fingers.  This is an extension of
1990     * {@link #FEATURE_FAKETOUCH} for input devices with this capability.  Note
1991     * that unlike a distinct multitouch screen as defined by
1992     * {@link #FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT}, these kinds of input
1993     * devices will not actually provide full two-finger gestures since the
1994     * input is being transformed to cursor movement on the screen.  That is,
1995     * single finger gestures will move a cursor; two-finger swipes will
1996     * result in single-finger touch events; other two-finger gestures will
1997     * result in the corresponding two-finger touch event.
1998     */
1999    @SdkConstant(SdkConstantType.FEATURE)
2000    public static final String FEATURE_FAKETOUCH_MULTITOUCH_DISTINCT = "android.hardware.faketouch.multitouch.distinct";
2001
2002    /**
2003     * Feature for {@link #getSystemAvailableFeatures} and
2004     * {@link #hasSystemFeature}: The device does not have a touch screen, but
2005     * does support touch emulation for basic events that supports tracking
2006     * a hand of fingers (5 or more fingers) fully independently.
2007     * This is an extension of
2008     * {@link #FEATURE_FAKETOUCH} for input devices with this capability.  Note
2009     * that unlike a multitouch screen as defined by
2010     * {@link #FEATURE_TOUCHSCREEN_MULTITOUCH_JAZZHAND}, not all two finger
2011     * gestures can be detected due to the limitations described for
2012     * {@link #FEATURE_FAKETOUCH_MULTITOUCH_DISTINCT}.
2013     */
2014    @SdkConstant(SdkConstantType.FEATURE)
2015    public static final String FEATURE_FAKETOUCH_MULTITOUCH_JAZZHAND = "android.hardware.faketouch.multitouch.jazzhand";
2016
2017    /**
2018     * Feature for {@link #getSystemAvailableFeatures} and
2019     * {@link #hasSystemFeature}: The device has biometric hardware to detect a fingerprint.
2020      */
2021    @SdkConstant(SdkConstantType.FEATURE)
2022    public static final String FEATURE_FINGERPRINT = "android.hardware.fingerprint";
2023
2024    /**
2025     * Feature for {@link #getSystemAvailableFeatures} and
2026     * {@link #hasSystemFeature}: The device supports portrait orientation
2027     * screens.  For backwards compatibility, you can assume that if neither
2028     * this nor {@link #FEATURE_SCREEN_LANDSCAPE} is set then the device supports
2029     * both portrait and landscape.
2030     */
2031    @SdkConstant(SdkConstantType.FEATURE)
2032    public static final String FEATURE_SCREEN_PORTRAIT = "android.hardware.screen.portrait";
2033
2034    /**
2035     * Feature for {@link #getSystemAvailableFeatures} and
2036     * {@link #hasSystemFeature}: The device supports landscape orientation
2037     * screens.  For backwards compatibility, you can assume that if neither
2038     * this nor {@link #FEATURE_SCREEN_PORTRAIT} is set then the device supports
2039     * both portrait and landscape.
2040     */
2041    @SdkConstant(SdkConstantType.FEATURE)
2042    public static final String FEATURE_SCREEN_LANDSCAPE = "android.hardware.screen.landscape";
2043
2044    /**
2045     * Feature for {@link #getSystemAvailableFeatures} and
2046     * {@link #hasSystemFeature}: The device supports live wallpapers.
2047     */
2048    @SdkConstant(SdkConstantType.FEATURE)
2049    public static final String FEATURE_LIVE_WALLPAPER = "android.software.live_wallpaper";
2050    /**
2051     * Feature for {@link #getSystemAvailableFeatures} and
2052     * {@link #hasSystemFeature}: The device supports app widgets.
2053     */
2054    @SdkConstant(SdkConstantType.FEATURE)
2055    public static final String FEATURE_APP_WIDGETS = "android.software.app_widgets";
2056
2057    /**
2058     * @hide
2059     * Feature for {@link #getSystemAvailableFeatures} and
2060     * {@link #hasSystemFeature}: The device supports
2061     * {@link android.service.voice.VoiceInteractionService} and
2062     * {@link android.app.VoiceInteractor}.
2063     */
2064    @SdkConstant(SdkConstantType.FEATURE)
2065    public static final String FEATURE_VOICE_RECOGNIZERS = "android.software.voice_recognizers";
2066
2067
2068    /**
2069     * Feature for {@link #getSystemAvailableFeatures} and
2070     * {@link #hasSystemFeature}: The device supports a home screen that is replaceable
2071     * by third party applications.
2072     */
2073    @SdkConstant(SdkConstantType.FEATURE)
2074    public static final String FEATURE_HOME_SCREEN = "android.software.home_screen";
2075
2076    /**
2077     * Feature for {@link #getSystemAvailableFeatures} and
2078     * {@link #hasSystemFeature}: The device supports adding new input methods implemented
2079     * with the {@link android.inputmethodservice.InputMethodService} API.
2080     */
2081    @SdkConstant(SdkConstantType.FEATURE)
2082    public static final String FEATURE_INPUT_METHODS = "android.software.input_methods";
2083
2084    /**
2085     * Feature for {@link #getSystemAvailableFeatures} and
2086     * {@link #hasSystemFeature}: The device supports device policy enforcement via device admins.
2087     */
2088    @SdkConstant(SdkConstantType.FEATURE)
2089    public static final String FEATURE_DEVICE_ADMIN = "android.software.device_admin";
2090
2091    /**
2092     * Feature for {@link #getSystemAvailableFeatures} and
2093     * {@link #hasSystemFeature}: The device supports leanback UI. This is
2094     * typically used in a living room television experience, but is a software
2095     * feature unlike {@link #FEATURE_TELEVISION}. Devices running with this
2096     * feature will use resources associated with the "television" UI mode.
2097     */
2098    @SdkConstant(SdkConstantType.FEATURE)
2099    public static final String FEATURE_LEANBACK = "android.software.leanback";
2100
2101    /**
2102     * Feature for {@link #getSystemAvailableFeatures} and
2103     * {@link #hasSystemFeature}: The device supports only leanback UI. Only
2104     * applications designed for this experience should be run, though this is
2105     * not enforced by the system.
2106     * @hide
2107     */
2108    @SdkConstant(SdkConstantType.FEATURE)
2109    public static final String FEATURE_LEANBACK_ONLY = "android.software.leanback_only";
2110
2111    /**
2112     * Feature for {@link #getSystemAvailableFeatures} and
2113     * {@link #hasSystemFeature}: The device supports live TV and can display
2114     * contents from TV inputs implemented with the
2115     * {@link android.media.tv.TvInputService} API.
2116     */
2117    @SdkConstant(SdkConstantType.FEATURE)
2118    public static final String FEATURE_LIVE_TV = "android.software.live_tv";
2119
2120    /**
2121     * Feature for {@link #getSystemAvailableFeatures} and
2122     * {@link #hasSystemFeature}: The device supports WiFi (802.11) networking.
2123     */
2124    @SdkConstant(SdkConstantType.FEATURE)
2125    public static final String FEATURE_WIFI = "android.hardware.wifi";
2126
2127    /**
2128     * Feature for {@link #getSystemAvailableFeatures} and
2129     * {@link #hasSystemFeature}: The device supports Wi-Fi Direct networking.
2130     */
2131    @SdkConstant(SdkConstantType.FEATURE)
2132    public static final String FEATURE_WIFI_DIRECT = "android.hardware.wifi.direct";
2133
2134    /**
2135     * Feature for {@link #getSystemAvailableFeatures} and
2136     * {@link #hasSystemFeature}: The device supports Wi-Fi Aware.
2137     */
2138    @SdkConstant(SdkConstantType.FEATURE)
2139    public static final String FEATURE_WIFI_AWARE = "android.hardware.wifi.aware";
2140
2141    /**
2142     * Feature for {@link #getSystemAvailableFeatures} and
2143     * {@link #hasSystemFeature}: This is a device dedicated to showing UI
2144     * on a vehicle headunit. A headunit here is defined to be inside a
2145     * vehicle that may or may not be moving. A headunit uses either a
2146     * primary display in the center console and/or additional displays in
2147     * the instrument cluster or elsewhere in the vehicle. Headunit display(s)
2148     * have limited size and resolution. The user will likely be focused on
2149     * driving so limiting driver distraction is a primary concern. User input
2150     * can be a variety of hard buttons, touch, rotary controllers and even mouse-
2151     * like interfaces.
2152     */
2153    @SdkConstant(SdkConstantType.FEATURE)
2154    public static final String FEATURE_AUTOMOTIVE = "android.hardware.type.automotive";
2155
2156    /**
2157     * Feature for {@link #getSystemAvailableFeatures} and
2158     * {@link #hasSystemFeature}: This is a device dedicated to showing UI
2159     * on a television.  Television here is defined to be a typical living
2160     * room television experience: displayed on a big screen, where the user
2161     * is sitting far away from it, and the dominant form of input will be
2162     * something like a DPAD, not through touch or mouse.
2163     * @deprecated use {@link #FEATURE_LEANBACK} instead.
2164     */
2165    @Deprecated
2166    @SdkConstant(SdkConstantType.FEATURE)
2167    public static final String FEATURE_TELEVISION = "android.hardware.type.television";
2168
2169    /**
2170     * Feature for {@link #getSystemAvailableFeatures} and
2171     * {@link #hasSystemFeature}: This is a device dedicated to showing UI
2172     * on a watch. A watch here is defined to be a device worn on the body, perhaps on
2173     * the wrist. The user is very close when interacting with the device.
2174     */
2175    @SdkConstant(SdkConstantType.FEATURE)
2176    public static final String FEATURE_WATCH = "android.hardware.type.watch";
2177
2178    /**
2179     * Feature for {@link #getSystemAvailableFeatures} and
2180     * {@link #hasSystemFeature}: This is a device for IoT and may not have an UI. An embedded
2181     * device is defined as a full stack Android device with or without a display and no
2182     * user-installable apps.
2183     */
2184    @SdkConstant(SdkConstantType.FEATURE)
2185    public static final String FEATURE_EMBEDDED = "android.hardware.type.embedded";
2186
2187    /**
2188     * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
2189     * The device supports printing.
2190     */
2191    @SdkConstant(SdkConstantType.FEATURE)
2192    public static final String FEATURE_PRINTING = "android.software.print";
2193
2194    /**
2195     * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
2196     * The device can perform backup and restore operations on installed applications.
2197     */
2198    @SdkConstant(SdkConstantType.FEATURE)
2199    public static final String FEATURE_BACKUP = "android.software.backup";
2200
2201    /**
2202     * Feature for {@link #getSystemAvailableFeatures} and
2203     * {@link #hasSystemFeature}: The device supports freeform window management.
2204     * Windows have title bars and can be moved and resized.
2205     */
2206    // If this feature is present, you also need to set
2207    // com.android.internal.R.config_freeformWindowManagement to true in your configuration overlay.
2208    @SdkConstant(SdkConstantType.FEATURE)
2209    public static final String FEATURE_FREEFORM_WINDOW_MANAGEMENT
2210            = "android.software.freeform_window_management";
2211
2212    /**
2213     * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
2214     * The device supports picture-in-picture multi-window mode.
2215     */
2216    @SdkConstant(SdkConstantType.FEATURE)
2217    public static final String FEATURE_PICTURE_IN_PICTURE = "android.software.picture_in_picture";
2218
2219    /**
2220     * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
2221     * The device supports creating secondary users and managed profiles via
2222     * {@link DevicePolicyManager}.
2223     */
2224    @SdkConstant(SdkConstantType.FEATURE)
2225    public static final String FEATURE_MANAGED_USERS = "android.software.managed_users";
2226
2227    /**
2228     * @hide
2229     * TODO: Remove after dependencies updated b/17392243
2230     */
2231    public static final String FEATURE_MANAGED_PROFILES = "android.software.managed_users";
2232
2233    /**
2234     * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
2235     * The device supports verified boot.
2236     */
2237    @SdkConstant(SdkConstantType.FEATURE)
2238    public static final String FEATURE_VERIFIED_BOOT = "android.software.verified_boot";
2239
2240    /**
2241     * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
2242     * The device supports secure removal of users. When a user is deleted the data associated
2243     * with that user is securely deleted and no longer available.
2244     */
2245    @SdkConstant(SdkConstantType.FEATURE)
2246    public static final String FEATURE_SECURELY_REMOVES_USERS
2247            = "android.software.securely_removes_users";
2248
2249    /** {@hide} */
2250    @SdkConstant(SdkConstantType.FEATURE)
2251    public static final String FEATURE_FILE_BASED_ENCRYPTION
2252            = "android.software.file_based_encryption";
2253
2254    /**
2255     * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
2256     * The device has a full implementation of the android.webkit.* APIs. Devices
2257     * lacking this feature will not have a functioning WebView implementation.
2258     */
2259    @SdkConstant(SdkConstantType.FEATURE)
2260    public static final String FEATURE_WEBVIEW = "android.software.webview";
2261
2262    /**
2263     * Feature for {@link #getSystemAvailableFeatures} and
2264     * {@link #hasSystemFeature}: This device supports ethernet.
2265     */
2266    @SdkConstant(SdkConstantType.FEATURE)
2267    public static final String FEATURE_ETHERNET = "android.hardware.ethernet";
2268
2269    /**
2270     * Feature for {@link #getSystemAvailableFeatures} and
2271     * {@link #hasSystemFeature}: This device supports HDMI-CEC.
2272     * @hide
2273     */
2274    @SdkConstant(SdkConstantType.FEATURE)
2275    public static final String FEATURE_HDMI_CEC = "android.hardware.hdmi.cec";
2276
2277    /**
2278     * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
2279     * The device has all of the inputs necessary to be considered a compatible game controller, or
2280     * includes a compatible game controller in the box.
2281     */
2282    @SdkConstant(SdkConstantType.FEATURE)
2283    public static final String FEATURE_GAMEPAD = "android.hardware.gamepad";
2284
2285    /**
2286     * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
2287     * The device has a full implementation of the android.media.midi.* APIs.
2288     */
2289    @SdkConstant(SdkConstantType.FEATURE)
2290    public static final String FEATURE_MIDI = "android.software.midi";
2291
2292    /**
2293     * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
2294     * The device implements an optimized mode for virtual reality (VR) applications that handles
2295     * stereoscopic rendering of notifications, and disables most monocular system UI components
2296     * while a VR application has user focus.
2297     * Devices declaring this feature must include an application implementing a
2298     * {@link android.service.vr.VrListenerService} that can be targeted by VR applications via
2299     * {@link android.app.Activity#setVrModeEnabled}.
2300     */
2301    @SdkConstant(SdkConstantType.FEATURE)
2302    public static final String FEATURE_VR_MODE = "android.software.vr.mode";
2303
2304    /**
2305     * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
2306     * The device implements {@link #FEATURE_VR_MODE} but additionally meets extra CDD requirements
2307     * to provide a high-quality VR experience.  In general, devices declaring this feature will
2308     * additionally:
2309     * <ul>
2310     *   <li>Deliver consistent performance at a high framerate over an extended period of time
2311     *   for typical VR application CPU/GPU workloads with a minimal number of frame drops for VR
2312     *   applications that have called
2313     *   {@link android.view.Window#setSustainedPerformanceMode}.</li>
2314     *   <li>Implement {@link #FEATURE_HIFI_SENSORS} and have a low sensor latency.</li>
2315     *   <li>Include optimizations to lower display persistence while running VR applications.</li>
2316     *   <li>Implement an optimized render path to minimize latency to draw to the device's main
2317     *   display.</li>
2318     *   <li>Include the following EGL extensions: EGL_ANDROID_create_native_client_buffer,
2319     *   EGL_ANDROID_front_buffer_auto_refresh, EGL_EXT_protected_content,
2320     *   EGL_KHR_mutable_render_buffer, EGL_KHR_reusable_sync, and EGL_KHR_wait_sync.</li>
2321     *   <li>Provide at least one CPU core that is reserved for use solely by the top, foreground
2322     *   VR application process for critical render threads while such an application is
2323     *   running.</li>
2324     * </ul>
2325     */
2326    @SdkConstant(SdkConstantType.FEATURE)
2327    public static final String FEATURE_VR_MODE_HIGH_PERFORMANCE
2328            = "android.hardware.vr.high_performance";
2329
2330    /**
2331     * Action to external storage service to clean out removed apps.
2332     * @hide
2333     */
2334    public static final String ACTION_CLEAN_EXTERNAL_STORAGE
2335            = "android.content.pm.CLEAN_EXTERNAL_STORAGE";
2336
2337    /**
2338     * Extra field name for the URI to a verification file. Passed to a package
2339     * verifier.
2340     *
2341     * @hide
2342     */
2343    public static final String EXTRA_VERIFICATION_URI = "android.content.pm.extra.VERIFICATION_URI";
2344
2345    /**
2346     * Extra field name for the ID of a package pending verification. Passed to
2347     * a package verifier and is used to call back to
2348     * {@link PackageManager#verifyPendingInstall(int, int)}
2349     */
2350    public static final String EXTRA_VERIFICATION_ID = "android.content.pm.extra.VERIFICATION_ID";
2351
2352    /**
2353     * Extra field name for the package identifier which is trying to install
2354     * the package.
2355     *
2356     * @hide
2357     */
2358    public static final String EXTRA_VERIFICATION_INSTALLER_PACKAGE
2359            = "android.content.pm.extra.VERIFICATION_INSTALLER_PACKAGE";
2360
2361    /**
2362     * Extra field name for the requested install flags for a package pending
2363     * verification. Passed to a package verifier.
2364     *
2365     * @hide
2366     */
2367    public static final String EXTRA_VERIFICATION_INSTALL_FLAGS
2368            = "android.content.pm.extra.VERIFICATION_INSTALL_FLAGS";
2369
2370    /**
2371     * Extra field name for the uid of who is requesting to install
2372     * the package.
2373     *
2374     * @hide
2375     */
2376    public static final String EXTRA_VERIFICATION_INSTALLER_UID
2377            = "android.content.pm.extra.VERIFICATION_INSTALLER_UID";
2378
2379    /**
2380     * Extra field name for the package name of a package pending verification.
2381     *
2382     * @hide
2383     */
2384    public static final String EXTRA_VERIFICATION_PACKAGE_NAME
2385            = "android.content.pm.extra.VERIFICATION_PACKAGE_NAME";
2386    /**
2387     * Extra field name for the result of a verification, either
2388     * {@link #VERIFICATION_ALLOW}, or {@link #VERIFICATION_REJECT}.
2389     * Passed to package verifiers after a package is verified.
2390     */
2391    public static final String EXTRA_VERIFICATION_RESULT
2392            = "android.content.pm.extra.VERIFICATION_RESULT";
2393
2394    /**
2395     * Extra field name for the version code of a package pending verification.
2396     *
2397     * @hide
2398     */
2399    public static final String EXTRA_VERIFICATION_VERSION_CODE
2400            = "android.content.pm.extra.VERIFICATION_VERSION_CODE";
2401
2402    /**
2403     * Extra field name for the ID of a intent filter pending verification.
2404     * Passed to an intent filter verifier and is used to call back to
2405     * {@link #verifyIntentFilter}
2406     *
2407     * @hide
2408     */
2409    public static final String EXTRA_INTENT_FILTER_VERIFICATION_ID
2410            = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_ID";
2411
2412    /**
2413     * Extra field name for the scheme used for an intent filter pending verification. Passed to
2414     * an intent filter verifier and is used to construct the URI to verify against.
2415     *
2416     * Usually this is "https"
2417     *
2418     * @hide
2419     */
2420    public static final String EXTRA_INTENT_FILTER_VERIFICATION_URI_SCHEME
2421            = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_URI_SCHEME";
2422
2423    /**
2424     * Extra field name for the host names to be used for an intent filter pending verification.
2425     * Passed to an intent filter verifier and is used to construct the URI to verify the
2426     * intent filter.
2427     *
2428     * This is a space delimited list of hosts.
2429     *
2430     * @hide
2431     */
2432    public static final String EXTRA_INTENT_FILTER_VERIFICATION_HOSTS
2433            = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_HOSTS";
2434
2435    /**
2436     * Extra field name for the package name to be used for an intent filter pending verification.
2437     * Passed to an intent filter verifier and is used to check the verification responses coming
2438     * from the hosts. Each host response will need to include the package name of APK containing
2439     * the intent filter.
2440     *
2441     * @hide
2442     */
2443    public static final String EXTRA_INTENT_FILTER_VERIFICATION_PACKAGE_NAME
2444            = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_PACKAGE_NAME";
2445
2446    /**
2447     * The action used to request that the user approve a permission request
2448     * from the application.
2449     *
2450     * @hide
2451     */
2452    @SystemApi
2453    public static final String ACTION_REQUEST_PERMISSIONS =
2454            "android.content.pm.action.REQUEST_PERMISSIONS";
2455
2456    /**
2457     * The names of the requested permissions.
2458     * <p>
2459     * <strong>Type:</strong> String[]
2460     * </p>
2461     *
2462     * @hide
2463     */
2464    @SystemApi
2465    public static final String EXTRA_REQUEST_PERMISSIONS_NAMES =
2466            "android.content.pm.extra.REQUEST_PERMISSIONS_NAMES";
2467
2468    /**
2469     * The results from the permissions request.
2470     * <p>
2471     * <strong>Type:</strong> int[] of #PermissionResult
2472     * </p>
2473     *
2474     * @hide
2475     */
2476    @SystemApi
2477    public static final String EXTRA_REQUEST_PERMISSIONS_RESULTS
2478            = "android.content.pm.extra.REQUEST_PERMISSIONS_RESULTS";
2479
2480    /**
2481     * String extra for {@link PackageInstallObserver} in the 'extras' Bundle in case of
2482     * {@link #INSTALL_FAILED_DUPLICATE_PERMISSION}.  This extra names the package which provides
2483     * the existing definition for the permission.
2484     * @hide
2485     */
2486    public static final String EXTRA_FAILURE_EXISTING_PACKAGE
2487            = "android.content.pm.extra.FAILURE_EXISTING_PACKAGE";
2488
2489    /**
2490     * String extra for {@link PackageInstallObserver} in the 'extras' Bundle in case of
2491     * {@link #INSTALL_FAILED_DUPLICATE_PERMISSION}.  This extra names the permission that is
2492     * being redundantly defined by the package being installed.
2493     * @hide
2494     */
2495    public static final String EXTRA_FAILURE_EXISTING_PERMISSION
2496            = "android.content.pm.extra.FAILURE_EXISTING_PERMISSION";
2497
2498   /**
2499    * Permission flag: The permission is set in its current state
2500    * by the user and apps can still request it at runtime.
2501    *
2502    * @hide
2503    */
2504    @SystemApi
2505    public static final int FLAG_PERMISSION_USER_SET = 1 << 0;
2506
2507    /**
2508     * Permission flag: The permission is set in its current state
2509     * by the user and it is fixed, i.e. apps can no longer request
2510     * this permission.
2511     *
2512     * @hide
2513     */
2514    @SystemApi
2515    public static final int FLAG_PERMISSION_USER_FIXED =  1 << 1;
2516
2517    /**
2518     * Permission flag: The permission is set in its current state
2519     * by device policy and neither apps nor the user can change
2520     * its state.
2521     *
2522     * @hide
2523     */
2524    @SystemApi
2525    public static final int FLAG_PERMISSION_POLICY_FIXED =  1 << 2;
2526
2527    /**
2528     * Permission flag: The permission is set in a granted state but
2529     * access to resources it guards is restricted by other means to
2530     * enable revoking a permission on legacy apps that do not support
2531     * runtime permissions. If this permission is upgraded to runtime
2532     * because the app was updated to support runtime permissions, the
2533     * the permission will be revoked in the upgrade process.
2534     *
2535     * @hide
2536     */
2537    @SystemApi
2538    public static final int FLAG_PERMISSION_REVOKE_ON_UPGRADE =  1 << 3;
2539
2540    /**
2541     * Permission flag: The permission is set in its current state
2542     * because the app is a component that is a part of the system.
2543     *
2544     * @hide
2545     */
2546    @SystemApi
2547    public static final int FLAG_PERMISSION_SYSTEM_FIXED =  1 << 4;
2548
2549    /**
2550     * Permission flag: The permission is granted by default because it
2551     * enables app functionality that is expected to work out-of-the-box
2552     * for providing a smooth user experience. For example, the phone app
2553     * is expected to have the phone permission.
2554     *
2555     * @hide
2556     */
2557    @SystemApi
2558    public static final int FLAG_PERMISSION_GRANTED_BY_DEFAULT =  1 << 5;
2559
2560    /**
2561     * Permission flag: The permission has to be reviewed before any of
2562     * the app components can run.
2563     *
2564     * @hide
2565     */
2566    @SystemApi
2567    public static final int FLAG_PERMISSION_REVIEW_REQUIRED =  1 << 6;
2568
2569    /**
2570     * Mask for all permission flags.
2571     *
2572     * @hide
2573     */
2574    @SystemApi
2575    public static final int MASK_PERMISSION_FLAGS = 0xFF;
2576
2577    /**
2578     * This is a library that contains components apps can invoke. For
2579     * example, a services for apps to bind to, or standard chooser UI,
2580     * etc. This library is versioned and backwards compatible. Clients
2581     * should check its version via {@link android.ext.services.Version
2582     * #getVersionCode()} and avoid calling APIs added in later versions.
2583     *
2584     * @hide
2585     */
2586    public static final String SYSTEM_SHARED_LIBRARY_SERVICES = "android.ext.services";
2587
2588    /**
2589     * This is a library that contains components apps can dynamically
2590     * load. For example, new widgets, helper classes, etc. This library
2591     * is versioned and backwards compatible. Clients should check its
2592     * version via {@link android.ext.shared.Version#getVersionCode()}
2593     * and avoid calling APIs added in later versions.
2594     *
2595     * @hide
2596     */
2597    public static final String SYSTEM_SHARED_LIBRARY_SHARED = "android.ext.shared";
2598
2599    /**
2600     * Used when starting a process for an Activity.
2601     *
2602     * @hide
2603     */
2604    public static final int NOTIFY_PACKAGE_USE_ACTIVITY = 0;
2605
2606    /**
2607     * Used when starting a process for a Service.
2608     *
2609     * @hide
2610     */
2611    public static final int NOTIFY_PACKAGE_USE_SERVICE = 1;
2612
2613    /**
2614     * Used when moving a Service to the foreground.
2615     *
2616     * @hide
2617     */
2618    public static final int NOTIFY_PACKAGE_USE_FOREGROUND_SERVICE = 2;
2619
2620    /**
2621     * Used when starting a process for a BroadcastReceiver.
2622     *
2623     * @hide
2624     */
2625    public static final int NOTIFY_PACKAGE_USE_BROADCAST_RECEIVER = 3;
2626
2627    /**
2628     * Used when starting a process for a ContentProvider.
2629     *
2630     * @hide
2631     */
2632    public static final int NOTIFY_PACKAGE_USE_CONTENT_PROVIDER = 4;
2633
2634    /**
2635     * Used when starting a process for a BroadcastReceiver.
2636     *
2637     * @hide
2638     */
2639    public static final int NOTIFY_PACKAGE_USE_BACKUP = 5;
2640
2641    /**
2642     * Used with Context.getClassLoader() across Android packages.
2643     *
2644     * @hide
2645     */
2646    public static final int NOTIFY_PACKAGE_USE_CROSS_PACKAGE = 6;
2647
2648    /**
2649     * Used when starting a package within a process for Instrumentation.
2650     *
2651     * @hide
2652     */
2653    public static final int NOTIFY_PACKAGE_USE_INSTRUMENTATION = 7;
2654
2655    /**
2656     * Total number of usage reasons.
2657     *
2658     * @hide
2659     */
2660    public static final int NOTIFY_PACKAGE_USE_REASONS_COUNT = 8;
2661
2662    /**
2663     * Constant for specifying the highest installed package version code.
2664     */
2665    public static final int VERSION_CODE_HIGHEST = -1;
2666
2667    /**
2668     * Retrieve overall information about an application package that is
2669     * installed on the system.
2670     *
2671     * @param packageName The full name (i.e. com.google.apps.contacts) of the
2672     *         desired package.
2673     * @param flags Additional option flags. Use any combination of
2674     *         {@link #GET_ACTIVITIES}, {@link #GET_CONFIGURATIONS},
2675     *         {@link #GET_GIDS}, {@link #GET_INSTRUMENTATION},
2676     *         {@link #GET_INTENT_FILTERS}, {@link #GET_META_DATA},
2677     *         {@link #GET_PERMISSIONS}, {@link #GET_PROVIDERS},
2678     *         {@link #GET_RECEIVERS}, {@link #GET_SERVICES},
2679     *         {@link #GET_SHARED_LIBRARY_FILES}, {@link #GET_SIGNATURES},
2680     *         {@link #GET_URI_PERMISSION_PATTERNS}, {@link #GET_UNINSTALLED_PACKAGES},
2681     *         {@link #MATCH_DISABLED_COMPONENTS}, {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
2682     *         {@link #MATCH_UNINSTALLED_PACKAGES}
2683     *         to modify the data returned.
2684     *
2685     * @return A PackageInfo object containing information about the
2686     *         package. If flag {@code MATCH_UNINSTALLED_PACKAGES} is set and if the
2687     *         package is not found in the list of installed applications, the
2688     *         package information is retrieved from the list of uninstalled
2689     *         applications (which includes installed applications as well as
2690     *         applications with data directory i.e. applications which had been
2691     *         deleted with {@code DONT_DELETE_DATA} flag set).
2692     * @throws NameNotFoundException if a package with the given name cannot be
2693     *             found on the system.
2694     * @see #GET_ACTIVITIES
2695     * @see #GET_CONFIGURATIONS
2696     * @see #GET_GIDS
2697     * @see #GET_INSTRUMENTATION
2698     * @see #GET_INTENT_FILTERS
2699     * @see #GET_META_DATA
2700     * @see #GET_PERMISSIONS
2701     * @see #GET_PROVIDERS
2702     * @see #GET_RECEIVERS
2703     * @see #GET_SERVICES
2704     * @see #GET_SHARED_LIBRARY_FILES
2705     * @see #GET_SIGNATURES
2706     * @see #GET_URI_PERMISSION_PATTERNS
2707     * @see #MATCH_DISABLED_COMPONENTS
2708     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
2709     * @see #MATCH_UNINSTALLED_PACKAGES
2710     */
2711    public abstract PackageInfo getPackageInfo(String packageName, @PackageInfoFlags int flags)
2712            throws NameNotFoundException;
2713
2714    /**
2715     * Retrieve overall information about an application package that is
2716     * installed on the system. This method can be used for retrieving
2717     * information about packages for which multiple versions can be
2718     * installed at the time. Currently only packages hosting static shared
2719     * libraries can have multiple installed versions. The method can also
2720     * be used to get info for a package that has a single version installed
2721     * by passing {@link #VERSION_CODE_HIGHEST} in the {@link VersionedPackage}
2722     * constructor.
2723     *
2724     * @param versionedPackage The versioned packages for which to query.
2725     * @param flags Additional option flags. Use any combination of
2726     *         {@link #GET_ACTIVITIES}, {@link #GET_CONFIGURATIONS},
2727     *         {@link #GET_GIDS}, {@link #GET_INSTRUMENTATION},
2728     *         {@link #GET_INTENT_FILTERS}, {@link #GET_META_DATA},
2729     *         {@link #GET_PERMISSIONS}, {@link #GET_PROVIDERS},
2730     *         {@link #GET_RECEIVERS}, {@link #GET_SERVICES},
2731     *         {@link #GET_SHARED_LIBRARY_FILES}, {@link #GET_SIGNATURES},
2732     *         {@link #GET_URI_PERMISSION_PATTERNS}, {@link #GET_UNINSTALLED_PACKAGES},
2733     *         {@link #MATCH_DISABLED_COMPONENTS}, {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
2734     *         {@link #MATCH_UNINSTALLED_PACKAGES}
2735     *         to modify the data returned.
2736     *
2737     * @return A PackageInfo object containing information about the
2738     *         package. If flag {@code MATCH_UNINSTALLED_PACKAGES} is set and if the
2739     *         package is not found in the list of installed applications, the
2740     *         package information is retrieved from the list of uninstalled
2741     *         applications (which includes installed applications as well as
2742     *         applications with data directory i.e. applications which had been
2743     *         deleted with {@code DONT_DELETE_DATA} flag set).
2744     * @throws NameNotFoundException if a package with the given name cannot be
2745     *             found on the system.
2746     * @see #GET_ACTIVITIES
2747     * @see #GET_CONFIGURATIONS
2748     * @see #GET_GIDS
2749     * @see #GET_INSTRUMENTATION
2750     * @see #GET_INTENT_FILTERS
2751     * @see #GET_META_DATA
2752     * @see #GET_PERMISSIONS
2753     * @see #GET_PROVIDERS
2754     * @see #GET_RECEIVERS
2755     * @see #GET_SERVICES
2756     * @see #GET_SHARED_LIBRARY_FILES
2757     * @see #GET_SIGNATURES
2758     * @see #GET_URI_PERMISSION_PATTERNS
2759     * @see #MATCH_DISABLED_COMPONENTS
2760     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
2761     * @see #MATCH_UNINSTALLED_PACKAGES
2762     */
2763    public abstract PackageInfo getPackageInfo(VersionedPackage versionedPackage,
2764            @PackageInfoFlags int flags) throws NameNotFoundException;
2765
2766    /**
2767     * Retrieve overall information about an application package that is
2768     * installed on the system.
2769     *
2770     * @param packageName The full name (i.e. com.google.apps.contacts) of the
2771     *         desired package.
2772     * @param flags Additional option flags. Use any combination of
2773     *         {@link #GET_ACTIVITIES}, {@link #GET_CONFIGURATIONS},
2774     *         {@link #GET_GIDS}, {@link #GET_INSTRUMENTATION},
2775     *         {@link #GET_INTENT_FILTERS}, {@link #GET_META_DATA},
2776     *         {@link #GET_PERMISSIONS}, {@link #GET_PROVIDERS},
2777     *         {@link #GET_RECEIVERS}, {@link #GET_SERVICES},
2778     *         {@link #GET_SHARED_LIBRARY_FILES}, {@link #GET_SIGNATURES},
2779     *         {@link #GET_URI_PERMISSION_PATTERNS}, {@link #GET_UNINSTALLED_PACKAGES},
2780     *         {@link #MATCH_DISABLED_COMPONENTS}, {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
2781     *         {@link #MATCH_UNINSTALLED_PACKAGES}
2782     *         to modify the data returned.
2783     * @param userId The user id.
2784     *
2785     * @return A PackageInfo object containing information about the
2786     *         package. If flag {@code MATCH_UNINSTALLED_PACKAGES} is set and if the
2787     *         package is not found in the list of installed applications, the
2788     *         package information is retrieved from the list of uninstalled
2789     *         applications (which includes installed applications as well as
2790     *         applications with data directory i.e. applications which had been
2791     *         deleted with {@code DONT_DELETE_DATA} flag set).
2792     * @throws NameNotFoundException if a package with the given name cannot be
2793     *             found on the system.
2794     * @see #GET_ACTIVITIES
2795     * @see #GET_CONFIGURATIONS
2796     * @see #GET_GIDS
2797     * @see #GET_INSTRUMENTATION
2798     * @see #GET_INTENT_FILTERS
2799     * @see #GET_META_DATA
2800     * @see #GET_PERMISSIONS
2801     * @see #GET_PROVIDERS
2802     * @see #GET_RECEIVERS
2803     * @see #GET_SERVICES
2804     * @see #GET_SHARED_LIBRARY_FILES
2805     * @see #GET_SIGNATURES
2806     * @see #GET_URI_PERMISSION_PATTERNS
2807     * @see #MATCH_DISABLED_COMPONENTS
2808     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
2809     * @see #MATCH_UNINSTALLED_PACKAGES
2810     *
2811     * @hide
2812     */
2813    @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS)
2814    public abstract PackageInfo getPackageInfoAsUser(String packageName,
2815            @PackageInfoFlags int flags, @UserIdInt int userId) throws NameNotFoundException;
2816
2817    /**
2818     * Map from the current package names in use on the device to whatever
2819     * the current canonical name of that package is.
2820     * @param names Array of current names to be mapped.
2821     * @return Returns an array of the same size as the original, containing
2822     * the canonical name for each package.
2823     */
2824    public abstract String[] currentToCanonicalPackageNames(String[] names);
2825
2826    /**
2827     * Map from a packages canonical name to the current name in use on the device.
2828     * @param names Array of new names to be mapped.
2829     * @return Returns an array of the same size as the original, containing
2830     * the current name for each package.
2831     */
2832    public abstract String[] canonicalToCurrentPackageNames(String[] names);
2833
2834    /**
2835     * Returns a "good" intent to launch a front-door activity in a package.
2836     * This is used, for example, to implement an "open" button when browsing
2837     * through packages.  The current implementation looks first for a main
2838     * activity in the category {@link Intent#CATEGORY_INFO}, and next for a
2839     * main activity in the category {@link Intent#CATEGORY_LAUNCHER}. Returns
2840     * <code>null</code> if neither are found.
2841     *
2842     * @param packageName The name of the package to inspect.
2843     *
2844     * @return A fully-qualified {@link Intent} that can be used to launch the
2845     * main activity in the package. Returns <code>null</code> if the package
2846     * does not contain such an activity, or if <em>packageName</em> is not
2847     * recognized.
2848     */
2849    public abstract Intent getLaunchIntentForPackage(String packageName);
2850
2851    /**
2852     * Return a "good" intent to launch a front-door Leanback activity in a
2853     * package, for use for example to implement an "open" button when browsing
2854     * through packages. The current implementation will look for a main
2855     * activity in the category {@link Intent#CATEGORY_LEANBACK_LAUNCHER}, or
2856     * return null if no main leanback activities are found.
2857     *
2858     * @param packageName The name of the package to inspect.
2859     * @return Returns either a fully-qualified Intent that can be used to launch
2860     *         the main Leanback activity in the package, or null if the package
2861     *         does not contain such an activity.
2862     */
2863    public abstract Intent getLeanbackLaunchIntentForPackage(String packageName);
2864
2865    /**
2866     * Return an array of all of the POSIX secondary group IDs that have been
2867     * assigned to the given package.
2868     * <p>
2869     * Note that the same package may have different GIDs under different
2870     * {@link UserHandle} on the same device.
2871     *
2872     * @param packageName The full name (i.e. com.google.apps.contacts) of the
2873     *            desired package.
2874     * @return Returns an int array of the assigned GIDs, or null if there are
2875     *         none.
2876     * @throws NameNotFoundException if a package with the given name cannot be
2877     *             found on the system.
2878     */
2879    public abstract int[] getPackageGids(String packageName)
2880            throws NameNotFoundException;
2881
2882    /**
2883     * Return an array of all of the POSIX secondary group IDs that have been
2884     * assigned to the given package.
2885     * <p>
2886     * Note that the same package may have different GIDs under different
2887     * {@link UserHandle} on the same device.
2888     *
2889     * @param packageName The full name (i.e. com.google.apps.contacts) of the
2890     *            desired package.
2891     * @return Returns an int array of the assigned gids, or null if there are
2892     *         none.
2893     * @throws NameNotFoundException if a package with the given name cannot be
2894     *             found on the system.
2895     */
2896    public abstract int[] getPackageGids(String packageName, @PackageInfoFlags int flags)
2897            throws NameNotFoundException;
2898
2899    /**
2900     * Return the UID associated with the given package name.
2901     * <p>
2902     * Note that the same package will have different UIDs under different
2903     * {@link UserHandle} on the same device.
2904     *
2905     * @param packageName The full name (i.e. com.google.apps.contacts) of the
2906     *            desired package.
2907     * @return Returns an integer UID who owns the given package name.
2908     * @throws NameNotFoundException if a package with the given name can not be
2909     *             found on the system.
2910     */
2911    public abstract int getPackageUid(String packageName, @PackageInfoFlags int flags)
2912            throws NameNotFoundException;
2913
2914    /**
2915     * Return the UID associated with the given package name.
2916     * <p>
2917     * Note that the same package will have different UIDs under different
2918     * {@link UserHandle} on the same device.
2919     *
2920     * @param packageName The full name (i.e. com.google.apps.contacts) of the
2921     *            desired package.
2922     * @param userId The user handle identifier to look up the package under.
2923     * @return Returns an integer UID who owns the given package name.
2924     * @throws NameNotFoundException if a package with the given name can not be
2925     *             found on the system.
2926     * @hide
2927     */
2928    public abstract int getPackageUidAsUser(String packageName, @UserIdInt int userId)
2929            throws NameNotFoundException;
2930
2931    /**
2932     * Return the UID associated with the given package name.
2933     * <p>
2934     * Note that the same package will have different UIDs under different
2935     * {@link UserHandle} on the same device.
2936     *
2937     * @param packageName The full name (i.e. com.google.apps.contacts) of the
2938     *            desired package.
2939     * @param userId The user handle identifier to look up the package under.
2940     * @return Returns an integer UID who owns the given package name.
2941     * @throws NameNotFoundException if a package with the given name can not be
2942     *             found on the system.
2943     * @hide
2944     */
2945    public abstract int getPackageUidAsUser(String packageName, @PackageInfoFlags int flags,
2946            @UserIdInt int userId) throws NameNotFoundException;
2947
2948    /**
2949     * Retrieve all of the information we know about a particular permission.
2950     *
2951     * @param name The fully qualified name (i.e. com.google.permission.LOGIN)
2952     *         of the permission you are interested in.
2953     * @param flags Additional option flags.  Use {@link #GET_META_DATA} to
2954     *         retrieve any meta-data associated with the permission.
2955     *
2956     * @return Returns a {@link PermissionInfo} containing information about the
2957     *         permission.
2958     * @throws NameNotFoundException if a package with the given name cannot be
2959     *             found on the system.
2960     *
2961     * @see #GET_META_DATA
2962     */
2963    public abstract PermissionInfo getPermissionInfo(String name, @PermissionInfoFlags int flags)
2964            throws NameNotFoundException;
2965
2966    /**
2967     * Query for all of the permissions associated with a particular group.
2968     *
2969     * @param group The fully qualified name (i.e. com.google.permission.LOGIN)
2970     *         of the permission group you are interested in.  Use null to
2971     *         find all of the permissions not associated with a group.
2972     * @param flags Additional option flags.  Use {@link #GET_META_DATA} to
2973     *         retrieve any meta-data associated with the permissions.
2974     *
2975     * @return Returns a list of {@link PermissionInfo} containing information
2976     *             about all of the permissions in the given group.
2977     * @throws NameNotFoundException if a package with the given name cannot be
2978     *             found on the system.
2979     *
2980     * @see #GET_META_DATA
2981     */
2982    public abstract List<PermissionInfo> queryPermissionsByGroup(String group,
2983            @PermissionInfoFlags int flags) throws NameNotFoundException;
2984
2985    /**
2986     * Returns true if Permission Review Mode is enabled, false otherwise.
2987     *
2988     * @hide
2989     */
2990    @TestApi
2991    public abstract boolean isPermissionReviewModeEnabled();
2992
2993    /**
2994     * Retrieve all of the information we know about a particular group of
2995     * permissions.
2996     *
2997     * @param name The fully qualified name (i.e. com.google.permission_group.APPS)
2998     *         of the permission you are interested in.
2999     * @param flags Additional option flags.  Use {@link #GET_META_DATA} to
3000     *         retrieve any meta-data associated with the permission group.
3001     *
3002     * @return Returns a {@link PermissionGroupInfo} containing information
3003     *         about the permission.
3004     * @throws NameNotFoundException if a package with the given name cannot be
3005     *             found on the system.
3006     *
3007     * @see #GET_META_DATA
3008     */
3009    public abstract PermissionGroupInfo getPermissionGroupInfo(String name,
3010            @PermissionGroupInfoFlags int flags) throws NameNotFoundException;
3011
3012    /**
3013     * Retrieve all of the known permission groups in the system.
3014     *
3015     * @param flags Additional option flags.  Use {@link #GET_META_DATA} to
3016     *         retrieve any meta-data associated with the permission group.
3017     *
3018     * @return Returns a list of {@link PermissionGroupInfo} containing
3019     *         information about all of the known permission groups.
3020     *
3021     * @see #GET_META_DATA
3022     */
3023    public abstract List<PermissionGroupInfo> getAllPermissionGroups(
3024            @PermissionGroupInfoFlags int flags);
3025
3026    /**
3027     * Retrieve all of the information we know about a particular
3028     * package/application.
3029     *
3030     * @param packageName The full name (i.e. com.google.apps.contacts) of an
3031     *         application.
3032     * @param flags Additional option flags. Use any combination of
3033     *         {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
3034     *         {@link #MATCH_SYSTEM_ONLY}, {@link #MATCH_UNINSTALLED_PACKAGES}
3035     *         to modify the data returned.
3036     *
3037     * @return An {@link ApplicationInfo} containing information about the
3038     *         package. If flag {@code MATCH_UNINSTALLED_PACKAGES} is set and if the
3039     *         package is not found in the list of installed applications, the
3040     *         application information is retrieved from the list of uninstalled
3041     *         applications (which includes installed applications as well as
3042     *         applications with data directory i.e. applications which had been
3043     *         deleted with {@code DONT_DELETE_DATA} flag set).
3044     * @throws NameNotFoundException if a package with the given name cannot be
3045     *             found on the system.
3046     *
3047     * @see #GET_META_DATA
3048     * @see #GET_SHARED_LIBRARY_FILES
3049     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
3050     * @see #MATCH_SYSTEM_ONLY
3051     * @see #MATCH_UNINSTALLED_PACKAGES
3052     */
3053    public abstract ApplicationInfo getApplicationInfo(String packageName,
3054            @ApplicationInfoFlags int flags) throws NameNotFoundException;
3055
3056    /** {@hide} */
3057    public abstract ApplicationInfo getApplicationInfoAsUser(String packageName,
3058            @ApplicationInfoFlags int flags, @UserIdInt int userId) throws NameNotFoundException;
3059
3060    /**
3061     * Retrieve all of the information we know about a particular activity
3062     * class.
3063     *
3064     * @param component The full component name (i.e.
3065     *            com.google.apps.contacts/com.google.apps.contacts.
3066     *            ContactsList) of an Activity class.
3067     * @param flags Additional option flags. Use any combination of
3068     *            {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
3069     *            {@link #MATCH_ALL}, {@link #MATCH_DEFAULT_ONLY},
3070     *            {@link #MATCH_DISABLED_COMPONENTS},
3071     *            {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
3072     *            {@link #MATCH_DIRECT_BOOT_AWARE},
3073     *            {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY}
3074     *            {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data
3075     *            returned.
3076     * @return An {@link ActivityInfo} containing information about the
3077     *         activity.
3078     * @throws NameNotFoundException if a package with the given name cannot be
3079     *             found on the system.
3080     * @see #GET_META_DATA
3081     * @see #GET_SHARED_LIBRARY_FILES
3082     * @see #MATCH_ALL
3083     * @see #MATCH_DEBUG_TRIAGED_MISSING
3084     * @see #MATCH_DEFAULT_ONLY
3085     * @see #MATCH_DISABLED_COMPONENTS
3086     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
3087     * @see #MATCH_DIRECT_BOOT_AWARE
3088     * @see #MATCH_DIRECT_BOOT_UNAWARE
3089     * @see #MATCH_SYSTEM_ONLY
3090     * @see #MATCH_UNINSTALLED_PACKAGES
3091     */
3092    public abstract ActivityInfo getActivityInfo(ComponentName component,
3093            @ComponentInfoFlags int flags) throws NameNotFoundException;
3094
3095    /**
3096     * Retrieve all of the information we know about a particular receiver
3097     * class.
3098     *
3099     * @param component The full component name (i.e.
3100     *            com.google.apps.calendar/com.google.apps.calendar.
3101     *            CalendarAlarm) of a Receiver class.
3102     * @param flags Additional option flags. Use any combination of
3103     *            {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
3104     *            {@link #MATCH_ALL}, {@link #MATCH_DEFAULT_ONLY},
3105     *            {@link #MATCH_DISABLED_COMPONENTS},
3106     *            {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
3107     *            {@link #MATCH_DIRECT_BOOT_AWARE},
3108     *            {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY}
3109     *            {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data
3110     *            returned.
3111     * @return An {@link ActivityInfo} containing information about the
3112     *         receiver.
3113     * @throws NameNotFoundException if a package with the given name cannot be
3114     *             found on the system.
3115     * @see #GET_META_DATA
3116     * @see #GET_SHARED_LIBRARY_FILES
3117     * @see #MATCH_ALL
3118     * @see #MATCH_DEBUG_TRIAGED_MISSING
3119     * @see #MATCH_DEFAULT_ONLY
3120     * @see #MATCH_DISABLED_COMPONENTS
3121     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
3122     * @see #MATCH_DIRECT_BOOT_AWARE
3123     * @see #MATCH_DIRECT_BOOT_UNAWARE
3124     * @see #MATCH_SYSTEM_ONLY
3125     * @see #MATCH_UNINSTALLED_PACKAGES
3126     */
3127    public abstract ActivityInfo getReceiverInfo(ComponentName component,
3128            @ComponentInfoFlags int flags) throws NameNotFoundException;
3129
3130    /**
3131     * Retrieve all of the information we know about a particular service class.
3132     *
3133     * @param component The full component name (i.e.
3134     *            com.google.apps.media/com.google.apps.media.
3135     *            BackgroundPlayback) of a Service class.
3136     * @param flags Additional option flags. Use any combination of
3137     *            {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
3138     *            {@link #MATCH_ALL}, {@link #MATCH_DEFAULT_ONLY},
3139     *            {@link #MATCH_DISABLED_COMPONENTS},
3140     *            {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
3141     *            {@link #MATCH_DIRECT_BOOT_AWARE},
3142     *            {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY}
3143     *            {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data
3144     *            returned.
3145     * @return A {@link ServiceInfo} object containing information about the
3146     *         service.
3147     * @throws NameNotFoundException if a package with the given name cannot be
3148     *             found on the system.
3149     * @see #GET_META_DATA
3150     * @see #GET_SHARED_LIBRARY_FILES
3151     * @see #MATCH_ALL
3152     * @see #MATCH_DEBUG_TRIAGED_MISSING
3153     * @see #MATCH_DEFAULT_ONLY
3154     * @see #MATCH_DISABLED_COMPONENTS
3155     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
3156     * @see #MATCH_DIRECT_BOOT_AWARE
3157     * @see #MATCH_DIRECT_BOOT_UNAWARE
3158     * @see #MATCH_SYSTEM_ONLY
3159     * @see #MATCH_UNINSTALLED_PACKAGES
3160     */
3161    public abstract ServiceInfo getServiceInfo(ComponentName component,
3162            @ComponentInfoFlags int flags) throws NameNotFoundException;
3163
3164    /**
3165     * Retrieve all of the information we know about a particular content
3166     * provider class.
3167     *
3168     * @param component The full component name (i.e.
3169     *            com.google.providers.media/com.google.providers.media.
3170     *            MediaProvider) of a ContentProvider class.
3171     * @param flags Additional option flags. Use any combination of
3172     *            {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
3173     *            {@link #MATCH_ALL}, {@link #MATCH_DEFAULT_ONLY},
3174     *            {@link #MATCH_DISABLED_COMPONENTS},
3175     *            {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
3176     *            {@link #MATCH_DIRECT_BOOT_AWARE},
3177     *            {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY}
3178     *            {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data
3179     *            returned.
3180     * @return A {@link ProviderInfo} object containing information about the
3181     *         provider.
3182     * @throws NameNotFoundException if a package with the given name cannot be
3183     *             found on the system.
3184     * @see #GET_META_DATA
3185     * @see #GET_SHARED_LIBRARY_FILES
3186     * @see #MATCH_ALL
3187     * @see #MATCH_DEBUG_TRIAGED_MISSING
3188     * @see #MATCH_DEFAULT_ONLY
3189     * @see #MATCH_DISABLED_COMPONENTS
3190     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
3191     * @see #MATCH_DIRECT_BOOT_AWARE
3192     * @see #MATCH_DIRECT_BOOT_UNAWARE
3193     * @see #MATCH_SYSTEM_ONLY
3194     * @see #MATCH_UNINSTALLED_PACKAGES
3195     */
3196    public abstract ProviderInfo getProviderInfo(ComponentName component,
3197            @ComponentInfoFlags int flags) throws NameNotFoundException;
3198
3199    /**
3200     * Return a List of all packages that are installed
3201     * on the device.
3202     *
3203     * @param flags Additional option flags. Use any combination of
3204     *         {@link #GET_ACTIVITIES}, {@link #GET_CONFIGURATIONS},
3205     *         {@link #GET_GIDS}, {@link #GET_INSTRUMENTATION},
3206     *         {@link #GET_INTENT_FILTERS}, {@link #GET_META_DATA},
3207     *         {@link #GET_PERMISSIONS}, {@link #GET_PROVIDERS},
3208     *         {@link #GET_RECEIVERS}, {@link #GET_SERVICES},
3209     *         {@link #GET_SHARED_LIBRARY_FILES}, {@link #GET_SIGNATURES},
3210     *         {@link #GET_URI_PERMISSION_PATTERNS}, {@link #GET_UNINSTALLED_PACKAGES},
3211     *         {@link #MATCH_DISABLED_COMPONENTS}, {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
3212     *         {@link #MATCH_UNINSTALLED_PACKAGES}
3213     *         to modify the data returned.
3214     *
3215     * @return A List of PackageInfo objects, one for each installed package,
3216     *         containing information about the package.  In the unlikely case
3217     *         there are no installed packages, an empty list is returned. If
3218     *         flag {@code MATCH_UNINSTALLED_PACKAGES} is set, the package
3219     *         information is retrieved from the list of uninstalled
3220     *         applications (which includes installed applications as well as
3221     *         applications with data directory i.e. applications which had been
3222     *         deleted with {@code DONT_DELETE_DATA} flag set).
3223     *
3224     * @see #GET_ACTIVITIES
3225     * @see #GET_CONFIGURATIONS
3226     * @see #GET_GIDS
3227     * @see #GET_INSTRUMENTATION
3228     * @see #GET_INTENT_FILTERS
3229     * @see #GET_META_DATA
3230     * @see #GET_PERMISSIONS
3231     * @see #GET_PROVIDERS
3232     * @see #GET_RECEIVERS
3233     * @see #GET_SERVICES
3234     * @see #GET_SHARED_LIBRARY_FILES
3235     * @see #GET_SIGNATURES
3236     * @see #GET_URI_PERMISSION_PATTERNS
3237     * @see #MATCH_DISABLED_COMPONENTS
3238     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
3239     * @see #MATCH_UNINSTALLED_PACKAGES
3240     */
3241    public abstract List<PackageInfo> getInstalledPackages(@PackageInfoFlags int flags);
3242
3243    /**
3244     * Return a List of all installed packages that are currently
3245     * holding any of the given permissions.
3246     *
3247     * @param flags Additional option flags. Use any combination of
3248     *         {@link #GET_ACTIVITIES}, {@link #GET_CONFIGURATIONS},
3249     *         {@link #GET_GIDS}, {@link #GET_INSTRUMENTATION},
3250     *         {@link #GET_INTENT_FILTERS}, {@link #GET_META_DATA},
3251     *         {@link #GET_PERMISSIONS}, {@link #GET_PROVIDERS},
3252     *         {@link #GET_RECEIVERS}, {@link #GET_SERVICES},
3253     *         {@link #GET_SHARED_LIBRARY_FILES}, {@link #GET_SIGNATURES},
3254     *         {@link #GET_URI_PERMISSION_PATTERNS}, {@link #GET_UNINSTALLED_PACKAGES},
3255     *         {@link #MATCH_DISABLED_COMPONENTS}, {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
3256     *         {@link #MATCH_UNINSTALLED_PACKAGES}
3257     *         to modify the data returned.
3258     *
3259     * @return A List of PackageInfo objects, one for each installed package
3260     *         that holds any of the permissions that were provided, containing
3261     *         information about the package. If no installed packages hold any
3262     *         of the permissions, an empty list is returned. If flag
3263     *         {@code MATCH_UNINSTALLED_PACKAGES} is set, the package information
3264     *         is retrieved from the list of uninstalled applications (which
3265     *         includes installed applications as well as applications with data
3266     *         directory i.e. applications which had been deleted with
3267     *         {@code DONT_DELETE_DATA} flag set).
3268     *
3269     * @see #GET_ACTIVITIES
3270     * @see #GET_CONFIGURATIONS
3271     * @see #GET_GIDS
3272     * @see #GET_INSTRUMENTATION
3273     * @see #GET_INTENT_FILTERS
3274     * @see #GET_META_DATA
3275     * @see #GET_PERMISSIONS
3276     * @see #GET_PROVIDERS
3277     * @see #GET_RECEIVERS
3278     * @see #GET_SERVICES
3279     * @see #GET_SHARED_LIBRARY_FILES
3280     * @see #GET_SIGNATURES
3281     * @see #GET_URI_PERMISSION_PATTERNS
3282     * @see #MATCH_DISABLED_COMPONENTS
3283     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
3284     * @see #MATCH_UNINSTALLED_PACKAGES
3285     */
3286    public abstract List<PackageInfo> getPackagesHoldingPermissions(
3287            String[] permissions, @PackageInfoFlags int flags);
3288
3289    /**
3290     * Return a List of all packages that are installed on the device, for a specific user.
3291     * Requesting a list of installed packages for another user
3292     * will require the permission INTERACT_ACROSS_USERS_FULL.
3293     *
3294     * @param flags Additional option flags. Use any combination of
3295     *         {@link #GET_ACTIVITIES}, {@link #GET_CONFIGURATIONS},
3296     *         {@link #GET_GIDS}, {@link #GET_INSTRUMENTATION},
3297     *         {@link #GET_INTENT_FILTERS}, {@link #GET_META_DATA},
3298     *         {@link #GET_PERMISSIONS}, {@link #GET_PROVIDERS},
3299     *         {@link #GET_RECEIVERS}, {@link #GET_SERVICES},
3300     *         {@link #GET_SHARED_LIBRARY_FILES}, {@link #GET_SIGNATURES},
3301     *         {@link #GET_URI_PERMISSION_PATTERNS}, {@link #GET_UNINSTALLED_PACKAGES},
3302     *         {@link #MATCH_DISABLED_COMPONENTS}, {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
3303     *         {@link #MATCH_UNINSTALLED_PACKAGES}
3304     *         to modify the data returned.
3305     * @param userId The user for whom the installed packages are to be listed
3306     *
3307     * @return A List of PackageInfo objects, one for each installed package,
3308     *         containing information about the package.  In the unlikely case
3309     *         there are no installed packages, an empty list is returned. If
3310     *         flag {@code MATCH_UNINSTALLED_PACKAGES} is set, the package
3311     *         information is retrieved from the list of uninstalled
3312     *         applications (which includes installed applications as well as
3313     *         applications with data directory i.e. applications which had been
3314     *         deleted with {@code DONT_DELETE_DATA} flag set).
3315     *
3316     * @see #GET_ACTIVITIES
3317     * @see #GET_CONFIGURATIONS
3318     * @see #GET_GIDS
3319     * @see #GET_INSTRUMENTATION
3320     * @see #GET_INTENT_FILTERS
3321     * @see #GET_META_DATA
3322     * @see #GET_PERMISSIONS
3323     * @see #GET_PROVIDERS
3324     * @see #GET_RECEIVERS
3325     * @see #GET_SERVICES
3326     * @see #GET_SHARED_LIBRARY_FILES
3327     * @see #GET_SIGNATURES
3328     * @see #GET_URI_PERMISSION_PATTERNS
3329     * @see #MATCH_DISABLED_COMPONENTS
3330     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
3331     * @see #MATCH_UNINSTALLED_PACKAGES
3332     *
3333     * @hide
3334     */
3335    @SystemApi
3336    public abstract List<PackageInfo> getInstalledPackagesAsUser(@PackageInfoFlags int flags,
3337            @UserIdInt int userId);
3338
3339    /**
3340     * Check whether a particular package has been granted a particular
3341     * permission.
3342     *
3343     * @param permName The name of the permission you are checking for.
3344     * @param pkgName The name of the package you are checking against.
3345     *
3346     * @return If the package has the permission, PERMISSION_GRANTED is
3347     * returned.  If it does not have the permission, PERMISSION_DENIED
3348     * is returned.
3349     *
3350     * @see #PERMISSION_GRANTED
3351     * @see #PERMISSION_DENIED
3352     */
3353    @CheckResult
3354    public abstract int checkPermission(String permName, String pkgName);
3355
3356    /**
3357     * Checks whether a particular permissions has been revoked for a
3358     * package by policy. Typically the device owner or the profile owner
3359     * may apply such a policy. The user cannot grant policy revoked
3360     * permissions, hence the only way for an app to get such a permission
3361     * is by a policy change.
3362     *
3363     * @param permName The name of the permission you are checking for.
3364     * @param pkgName The name of the package you are checking against.
3365     *
3366     * @return Whether the permission is restricted by policy.
3367     */
3368    @CheckResult
3369    public abstract boolean isPermissionRevokedByPolicy(@NonNull String permName,
3370            @NonNull String pkgName);
3371
3372    /**
3373     * Gets the package name of the component controlling runtime permissions.
3374     *
3375     * @return The package name.
3376     *
3377     * @hide
3378     */
3379    public abstract String getPermissionControllerPackageName();
3380
3381    /**
3382     * Add a new dynamic permission to the system.  For this to work, your
3383     * package must have defined a permission tree through the
3384     * {@link android.R.styleable#AndroidManifestPermissionTree
3385     * &lt;permission-tree&gt;} tag in its manifest.  A package can only add
3386     * permissions to trees that were defined by either its own package or
3387     * another with the same user id; a permission is in a tree if it
3388     * matches the name of the permission tree + ".": for example,
3389     * "com.foo.bar" is a member of the permission tree "com.foo".
3390     *
3391     * <p>It is good to make your permission tree name descriptive, because you
3392     * are taking possession of that entire set of permission names.  Thus, it
3393     * must be under a domain you control, with a suffix that will not match
3394     * any normal permissions that may be declared in any applications that
3395     * are part of that domain.
3396     *
3397     * <p>New permissions must be added before
3398     * any .apks are installed that use those permissions.  Permissions you
3399     * add through this method are remembered across reboots of the device.
3400     * If the given permission already exists, the info you supply here
3401     * will be used to update it.
3402     *
3403     * @param info Description of the permission to be added.
3404     *
3405     * @return Returns true if a new permission was created, false if an
3406     * existing one was updated.
3407     *
3408     * @throws SecurityException if you are not allowed to add the
3409     * given permission name.
3410     *
3411     * @see #removePermission(String)
3412     */
3413    public abstract boolean addPermission(PermissionInfo info);
3414
3415    /**
3416     * Like {@link #addPermission(PermissionInfo)} but asynchronously
3417     * persists the package manager state after returning from the call,
3418     * allowing it to return quicker and batch a series of adds at the
3419     * expense of no guarantee the added permission will be retained if
3420     * the device is rebooted before it is written.
3421     */
3422    public abstract boolean addPermissionAsync(PermissionInfo info);
3423
3424    /**
3425     * Removes a permission that was previously added with
3426     * {@link #addPermission(PermissionInfo)}.  The same ownership rules apply
3427     * -- you are only allowed to remove permissions that you are allowed
3428     * to add.
3429     *
3430     * @param name The name of the permission to remove.
3431     *
3432     * @throws SecurityException if you are not allowed to remove the
3433     * given permission name.
3434     *
3435     * @see #addPermission(PermissionInfo)
3436     */
3437    public abstract void removePermission(String name);
3438
3439    /**
3440     * Permission flags set when granting or revoking a permission.
3441     *
3442     * @hide
3443     */
3444    @SystemApi
3445    @IntDef({FLAG_PERMISSION_USER_SET,
3446            FLAG_PERMISSION_USER_FIXED,
3447            FLAG_PERMISSION_POLICY_FIXED,
3448            FLAG_PERMISSION_REVOKE_ON_UPGRADE,
3449            FLAG_PERMISSION_SYSTEM_FIXED,
3450            FLAG_PERMISSION_GRANTED_BY_DEFAULT})
3451    @Retention(RetentionPolicy.SOURCE)
3452    public @interface PermissionFlags {}
3453
3454    /**
3455     * Grant a runtime permission to an application which the application does not
3456     * already have. The permission must have been requested by the application.
3457     * If the application is not allowed to hold the permission, a {@link
3458     * java.lang.SecurityException} is thrown. If the package or permission is
3459     * invalid, a {@link java.lang.IllegalArgumentException} is thrown.
3460     * <p>
3461     * <strong>Note: </strong>Using this API requires holding
3462     * android.permission.GRANT_RUNTIME_PERMISSIONS and if the user id is
3463     * not the current user android.permission.INTERACT_ACROSS_USERS_FULL.
3464     * </p>
3465     *
3466     * @param packageName The package to which to grant the permission.
3467     * @param permissionName The permission name to grant.
3468     * @param user The user for which to grant the permission.
3469     *
3470     * @see #revokeRuntimePermission(String, String, android.os.UserHandle)
3471     *
3472     * @hide
3473     */
3474    @SystemApi
3475    public abstract void grantRuntimePermission(@NonNull String packageName,
3476            @NonNull String permissionName, @NonNull UserHandle user);
3477
3478    /**
3479     * Revoke a runtime permission that was previously granted by {@link
3480     * #grantRuntimePermission(String, String, android.os.UserHandle)}. The
3481     * permission must have been requested by and granted to the application.
3482     * If the application is not allowed to hold the permission, a {@link
3483     * java.lang.SecurityException} is thrown. If the package or permission is
3484     * invalid, a {@link java.lang.IllegalArgumentException} is thrown.
3485     * <p>
3486     * <strong>Note: </strong>Using this API requires holding
3487     * android.permission.REVOKE_RUNTIME_PERMISSIONS and if the user id is
3488     * not the current user android.permission.INTERACT_ACROSS_USERS_FULL.
3489     * </p>
3490     *
3491     * @param packageName The package from which to revoke the permission.
3492     * @param permissionName The permission name to revoke.
3493     * @param user The user for which to revoke the permission.
3494     *
3495     * @see #grantRuntimePermission(String, String, android.os.UserHandle)
3496     *
3497     * @hide
3498     */
3499    @SystemApi
3500    public abstract void revokeRuntimePermission(@NonNull String packageName,
3501            @NonNull String permissionName, @NonNull UserHandle user);
3502
3503    /**
3504     * Gets the state flags associated with a permission.
3505     *
3506     * @param permissionName The permission for which to get the flags.
3507     * @param packageName The package name for which to get the flags.
3508     * @param user The user for which to get permission flags.
3509     * @return The permission flags.
3510     *
3511     * @hide
3512     */
3513    @SystemApi
3514    public abstract @PermissionFlags int getPermissionFlags(String permissionName,
3515            String packageName, @NonNull UserHandle user);
3516
3517    /**
3518     * Updates the flags associated with a permission by replacing the flags in
3519     * the specified mask with the provided flag values.
3520     *
3521     * @param permissionName The permission for which to update the flags.
3522     * @param packageName The package name for which to update the flags.
3523     * @param flagMask The flags which to replace.
3524     * @param flagValues The flags with which to replace.
3525     * @param user The user for which to update the permission flags.
3526     *
3527     * @hide
3528     */
3529    @SystemApi
3530    public abstract void updatePermissionFlags(String permissionName,
3531            String packageName, @PermissionFlags int flagMask, int flagValues,
3532            @NonNull UserHandle user);
3533
3534    /**
3535     * Gets whether you should show UI with rationale for requesting a permission.
3536     * You should do this only if you do not have the permission and the context in
3537     * which the permission is requested does not clearly communicate to the user
3538     * what would be the benefit from grating this permission.
3539     *
3540     * @param permission A permission your app wants to request.
3541     * @return Whether you can show permission rationale UI.
3542     *
3543     * @hide
3544     */
3545    public abstract boolean shouldShowRequestPermissionRationale(String permission);
3546
3547    /**
3548     * Returns an {@link android.content.Intent} suitable for passing to
3549     * {@link android.app.Activity#startActivityForResult(android.content.Intent, int)}
3550     * which prompts the user to grant permissions to this application.
3551     *
3552     * @throws NullPointerException if {@code permissions} is {@code null} or empty.
3553     *
3554     * @hide
3555     */
3556    public Intent buildRequestPermissionsIntent(@NonNull String[] permissions) {
3557        if (ArrayUtils.isEmpty(permissions)) {
3558           throw new IllegalArgumentException("permission cannot be null or empty");
3559        }
3560        Intent intent = new Intent(ACTION_REQUEST_PERMISSIONS);
3561        intent.putExtra(EXTRA_REQUEST_PERMISSIONS_NAMES, permissions);
3562        intent.setPackage(getPermissionControllerPackageName());
3563        return intent;
3564    }
3565
3566    /**
3567     * Compare the signatures of two packages to determine if the same
3568     * signature appears in both of them.  If they do contain the same
3569     * signature, then they are allowed special privileges when working
3570     * with each other: they can share the same user-id, run instrumentation
3571     * against each other, etc.
3572     *
3573     * @param pkg1 First package name whose signature will be compared.
3574     * @param pkg2 Second package name whose signature will be compared.
3575     *
3576     * @return Returns an integer indicating whether all signatures on the
3577     * two packages match. The value is >= 0 ({@link #SIGNATURE_MATCH}) if
3578     * all signatures match or < 0 if there is not a match ({@link
3579     * #SIGNATURE_NO_MATCH} or {@link #SIGNATURE_UNKNOWN_PACKAGE}).
3580     *
3581     * @see #checkSignatures(int, int)
3582     * @see #SIGNATURE_MATCH
3583     * @see #SIGNATURE_NO_MATCH
3584     * @see #SIGNATURE_UNKNOWN_PACKAGE
3585     */
3586    @CheckResult
3587    public abstract int checkSignatures(String pkg1, String pkg2);
3588
3589    /**
3590     * Like {@link #checkSignatures(String, String)}, but takes UIDs of
3591     * the two packages to be checked.  This can be useful, for example,
3592     * when doing the check in an IPC, where the UID is the only identity
3593     * available.  It is functionally identical to determining the package
3594     * associated with the UIDs and checking their signatures.
3595     *
3596     * @param uid1 First UID whose signature will be compared.
3597     * @param uid2 Second UID whose signature will be compared.
3598     *
3599     * @return Returns an integer indicating whether all signatures on the
3600     * two packages match. The value is >= 0 ({@link #SIGNATURE_MATCH}) if
3601     * all signatures match or < 0 if there is not a match ({@link
3602     * #SIGNATURE_NO_MATCH} or {@link #SIGNATURE_UNKNOWN_PACKAGE}).
3603     *
3604     * @see #checkSignatures(String, String)
3605     * @see #SIGNATURE_MATCH
3606     * @see #SIGNATURE_NO_MATCH
3607     * @see #SIGNATURE_UNKNOWN_PACKAGE
3608     */
3609    @CheckResult
3610    public abstract int checkSignatures(int uid1, int uid2);
3611
3612    /**
3613     * Retrieve the names of all packages that are associated with a particular
3614     * user id.  In most cases, this will be a single package name, the package
3615     * that has been assigned that user id.  Where there are multiple packages
3616     * sharing the same user id through the "sharedUserId" mechanism, all
3617     * packages with that id will be returned.
3618     *
3619     * @param uid The user id for which you would like to retrieve the
3620     * associated packages.
3621     *
3622     * @return Returns an array of one or more packages assigned to the user
3623     * id, or null if there are no known packages with the given id.
3624     */
3625    public abstract @Nullable String[] getPackagesForUid(int uid);
3626
3627    /**
3628     * Retrieve the official name associated with a uid. This name is
3629     * guaranteed to never change, though it is possible for the underlying
3630     * uid to be changed.  That is, if you are storing information about
3631     * uids in persistent storage, you should use the string returned
3632     * by this function instead of the raw uid.
3633     *
3634     * @param uid The uid for which you would like to retrieve a name.
3635     * @return Returns a unique name for the given uid, or null if the
3636     * uid is not currently assigned.
3637     */
3638    public abstract @Nullable String getNameForUid(int uid);
3639
3640    /**
3641     * Return the user id associated with a shared user name. Multiple
3642     * applications can specify a shared user name in their manifest and thus
3643     * end up using a common uid. This might be used for new applications
3644     * that use an existing shared user name and need to know the uid of the
3645     * shared user.
3646     *
3647     * @param sharedUserName The shared user name whose uid is to be retrieved.
3648     * @return Returns the UID associated with the shared user.
3649     * @throws NameNotFoundException if a package with the given name cannot be
3650     *             found on the system.
3651     * @hide
3652     */
3653    public abstract int getUidForSharedUser(String sharedUserName)
3654            throws NameNotFoundException;
3655
3656    /**
3657     * Return a List of all application packages that are installed on the
3658     * device. If flag GET_UNINSTALLED_PACKAGES has been set, a list of all
3659     * applications including those deleted with {@code DONT_DELETE_DATA} (partially
3660     * installed apps with data directory) will be returned.
3661     *
3662     * @param flags Additional option flags. Use any combination of
3663     * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
3664     * {@link #MATCH_SYSTEM_ONLY}, {@link #MATCH_UNINSTALLED_PACKAGES}
3665     * to modify the data returned.
3666     *
3667     * @return A List of ApplicationInfo objects, one for each installed application.
3668     *         In the unlikely case there are no installed packages, an empty list
3669     *         is returned. If flag {@code MATCH_UNINSTALLED_PACKAGES} is set, the
3670     *         application information is retrieved from the list of uninstalled
3671     *         applications (which includes installed applications as well as
3672     *         applications with data directory i.e. applications which had been
3673     *         deleted with {@code DONT_DELETE_DATA} flag set).
3674     *
3675     * @see #GET_META_DATA
3676     * @see #GET_SHARED_LIBRARY_FILES
3677     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
3678     * @see #MATCH_SYSTEM_ONLY
3679     * @see #MATCH_UNINSTALLED_PACKAGES
3680     */
3681    public abstract List<ApplicationInfo> getInstalledApplications(@ApplicationInfoFlags int flags);
3682
3683    /**
3684     * Return a List of all application packages that are installed on the device, for a specific
3685     * user. If flag GET_UNINSTALLED_PACKAGES has been set, a list of all applications including
3686     * those deleted with {@code DONT_DELETE_DATA} (partially installed apps with data directory)
3687     * will be returned.
3688     *
3689     * @param flags Additional option flags. Use any combination of
3690     * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
3691     * {@link #MATCH_SYSTEM_ONLY}, {@link #MATCH_UNINSTALLED_PACKAGES}
3692     * to modify the data returned.
3693     * @param userId The user for whom the installed applications are to be listed
3694     *
3695     * @return A List of ApplicationInfo objects, one for each installed application.
3696     *         In the unlikely case there are no installed packages, an empty list
3697     *         is returned. If flag {@code MATCH_UNINSTALLED_PACKAGES} is set, the
3698     *         application information is retrieved from the list of uninstalled
3699     *         applications (which includes installed applications as well as
3700     *         applications with data directory i.e. applications which had been
3701     *         deleted with {@code DONT_DELETE_DATA} flag set).
3702     * @hide
3703     *
3704     * @see #GET_META_DATA
3705     * @see #GET_SHARED_LIBRARY_FILES
3706     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
3707     * @see #MATCH_SYSTEM_ONLY
3708     * @see #MATCH_UNINSTALLED_PACKAGES
3709     */
3710    public abstract List<ApplicationInfo> getInstalledApplicationsAsUser(
3711            @ApplicationInfoFlags int flags, @UserIdInt int userId);
3712
3713    /**
3714     * Gets the instant applications the user recently used. Requires
3715     * holding "android.permission.ACCESS_INSTANT_APPS".
3716     *
3717     * @return The instant app list.
3718     *
3719     * @hide
3720     */
3721    @RequiresPermission(Manifest.permission.ACCESS_INSTANT_APPS)
3722    public abstract @NonNull List<InstantAppInfo> getInstantApps();
3723
3724    /**
3725     * Gets the icon for an instant application.
3726     *
3727     * @param packageName The app package name.
3728     *
3729     * @hide
3730     */
3731    @RequiresPermission(Manifest.permission.ACCESS_INSTANT_APPS)
3732    public abstract @Nullable Drawable getInstantAppIcon(String packageName);
3733
3734    /**
3735     * Gets whether the caller is an instant app.
3736     *
3737     * @return Whether caller is an instant app.
3738     *
3739     * @see #setInstantAppCookie(byte[])
3740     * @see #getInstantAppCookie()
3741     * @see #getInstantAppCookieMaxSize()
3742     */
3743    public abstract boolean isInstantApp();
3744
3745    /**
3746     * Gets the maximum size in bytes of the cookie data an instant app
3747     * can store on the device.
3748     *
3749     * @return The max cookie size in bytes.
3750     *
3751     * @see #isInstantApp()
3752     * @see #setInstantAppCookie(byte[])
3753     * @see #getInstantAppCookie()
3754     */
3755    public abstract int getInstantAppCookieMaxSize();
3756
3757    /**
3758     * Gets the instant application cookie for this app. Non
3759     * instant apps and apps that were instant but were upgraded
3760     * to normal apps can still access this API. For instant apps
3761     * this cooke is cached for some time after uninstall while for
3762     * normal apps the cookie is deleted after the app is uninstalled.
3763     * The cookie is always present while the app is installed.
3764     *
3765     * @return The cookie.
3766     *
3767     * @see #isInstantApp()
3768     * @see #setInstantAppCookie(byte[])
3769     * @see #getInstantAppCookieMaxSize()
3770     */
3771    public abstract @NonNull byte[] getInstantAppCookie();
3772
3773    /**
3774     * Sets the instant application cookie for the calling app. Non
3775     * instant apps and apps that were instant but were upgraded
3776     * to normal apps can still access this API. For instant apps
3777     * this cooke is cached for some time after uninstall while for
3778     * normal apps the cookie is deleted after the app is uninstalled.
3779     * The cookie is always present while the app is installed. The
3780     * cookie size is limited by {@link #getInstantAppCookieMaxSize()}.
3781     * If the provided cookie size is over the limit this method
3782     * returns <code>false</code>. Passing <code>null</code> or an empty
3783     * array clears the cookie.
3784     * </p>
3785     *
3786     * @param cookie The cookie data.
3787     * @return Whether the cookie was set.
3788     *
3789     * @see #isInstantApp()
3790     * @see #getInstantAppCookieMaxSize()
3791     * @see #getInstantAppCookie()
3792     */
3793    public abstract boolean setInstantAppCookie(@Nullable byte[] cookie);
3794
3795    /**
3796     * Get a list of shared libraries that are available on the
3797     * system.
3798     *
3799     * @return An array of shared library names that are
3800     * available on the system, or null if none are installed.
3801     *
3802     */
3803    public abstract String[] getSystemSharedLibraryNames();
3804
3805    /**
3806     * Get a list of shared libraries on the device.
3807     *
3808     * @param flags To filter the libraries to return.
3809     * @return The shared library list.
3810     *
3811     * @see #MATCH_FACTORY_ONLY
3812     * @see #MATCH_KNOWN_PACKAGES
3813     * @see #MATCH_ANY_USER
3814     * @see #MATCH_UNINSTALLED_PACKAGES
3815     */
3816    public abstract @NonNull List<SharedLibraryInfo> getSharedLibraries(
3817            @InstallFlags int flags);
3818
3819    /**
3820     * Get a list of shared libraries on the device.
3821     *
3822     * @param flags To filter the libraries to return.
3823     * @param userId The user to query for.
3824     * @return The shared library list.
3825     *
3826     * @see #MATCH_FACTORY_ONLY
3827     * @see #MATCH_KNOWN_PACKAGES
3828     * @see #MATCH_ANY_USER
3829     * @see #MATCH_UNINSTALLED_PACKAGES
3830     *
3831     * @hide
3832     */
3833    public abstract @NonNull List<SharedLibraryInfo> getSharedLibrariesAsUser(
3834            @InstallFlags int flags, @UserIdInt int userId);
3835
3836    /**
3837     * Get the name of the package hosting the services shared library.
3838     *
3839     * @return The library host package.
3840     *
3841     * @hide
3842     */
3843    public abstract @NonNull String getServicesSystemSharedLibraryPackageName();
3844
3845    /**
3846     * Get the name of the package hosting the shared components shared library.
3847     *
3848     * @return The library host package.
3849     *
3850     * @hide
3851     */
3852    public abstract @NonNull String getSharedSystemSharedLibraryPackageName();
3853
3854    /**
3855     * Returns the names of the packages that have been changed
3856     * [eg. added, removed or updated] since the given sequence
3857     * number.
3858     * <p>If no packages have been changed, returns <code>null</code>.
3859     * <p>The sequence number starts at <code>0</code> and is
3860     * reset every boot.
3861     */
3862    public abstract @Nullable ChangedPackages getChangedPackages(
3863            @IntRange(from=0) int sequenceNumber);
3864
3865    /**
3866     * Get a list of features that are available on the
3867     * system.
3868     *
3869     * @return An array of FeatureInfo classes describing the features
3870     * that are available on the system, or null if there are none(!!).
3871     */
3872    public abstract FeatureInfo[] getSystemAvailableFeatures();
3873
3874    /**
3875     * Check whether the given feature name is one of the available features as
3876     * returned by {@link #getSystemAvailableFeatures()}. This tests for the
3877     * presence of <em>any</em> version of the given feature name; use
3878     * {@link #hasSystemFeature(String, int)} to check for a minimum version.
3879     *
3880     * @return Returns true if the devices supports the feature, else false.
3881     */
3882    public abstract boolean hasSystemFeature(String name);
3883
3884    /**
3885     * Check whether the given feature name and version is one of the available
3886     * features as returned by {@link #getSystemAvailableFeatures()}. Since
3887     * features are defined to always be backwards compatible, this returns true
3888     * if the available feature version is greater than or equal to the
3889     * requested version.
3890     *
3891     * @return Returns true if the devices supports the feature, else false.
3892     */
3893    public abstract boolean hasSystemFeature(String name, int version);
3894
3895    /**
3896     * Determine the best action to perform for a given Intent. This is how
3897     * {@link Intent#resolveActivity} finds an activity if a class has not been
3898     * explicitly specified.
3899     * <p>
3900     * <em>Note:</em> if using an implicit Intent (without an explicit
3901     * ComponentName specified), be sure to consider whether to set the
3902     * {@link #MATCH_DEFAULT_ONLY} only flag. You need to do so to resolve the
3903     * activity in the same way that
3904     * {@link android.content.Context#startActivity(Intent)} and
3905     * {@link android.content.Intent#resolveActivity(PackageManager)
3906     * Intent.resolveActivity(PackageManager)} do.
3907     * </p>
3908     *
3909     * @param intent An intent containing all of the desired specification
3910     *            (action, data, type, category, and/or component).
3911     * @param flags Additional option flags. Use any combination of
3912     *            {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER},
3913     *            {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL},
3914     *            {@link #MATCH_DISABLED_COMPONENTS},
3915     *            {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
3916     *            {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_DIRECT_BOOT_AWARE},
3917     *            {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY}
3918     *            or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data
3919     *            returned. The most important is {@link #MATCH_DEFAULT_ONLY},
3920     *            to limit the resolution to only those activities that support
3921     *            the {@link android.content.Intent#CATEGORY_DEFAULT}.
3922     * @return Returns a ResolveInfo object containing the final activity intent
3923     *         that was determined to be the best action. Returns null if no
3924     *         matching activity was found. If multiple matching activities are
3925     *         found and there is no default set, returns a ResolveInfo object
3926     *         containing something else, such as the activity resolver.
3927     * @see #GET_META_DATA
3928     * @see #GET_RESOLVED_FILTER
3929     * @see #GET_SHARED_LIBRARY_FILES
3930     * @see #MATCH_ALL
3931     * @see #MATCH_DISABLED_COMPONENTS
3932     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
3933     * @see #MATCH_DEFAULT_ONLY
3934     * @see #MATCH_DIRECT_BOOT_AWARE
3935     * @see #MATCH_DIRECT_BOOT_UNAWARE
3936     * @see #MATCH_SYSTEM_ONLY
3937     * @see #MATCH_UNINSTALLED_PACKAGES
3938     */
3939    public abstract ResolveInfo resolveActivity(Intent intent, @ResolveInfoFlags int flags);
3940
3941    /**
3942     * Determine the best action to perform for a given Intent for a given user.
3943     * This is how {@link Intent#resolveActivity} finds an activity if a class
3944     * has not been explicitly specified.
3945     * <p>
3946     * <em>Note:</em> if using an implicit Intent (without an explicit
3947     * ComponentName specified), be sure to consider whether to set the
3948     * {@link #MATCH_DEFAULT_ONLY} only flag. You need to do so to resolve the
3949     * activity in the same way that
3950     * {@link android.content.Context#startActivity(Intent)} and
3951     * {@link android.content.Intent#resolveActivity(PackageManager)
3952     * Intent.resolveActivity(PackageManager)} do.
3953     * </p>
3954     *
3955     * @param intent An intent containing all of the desired specification
3956     *            (action, data, type, category, and/or component).
3957     * @param flags Additional option flags. Use any combination of
3958     *            {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER},
3959     *            {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL},
3960     *            {@link #MATCH_DISABLED_COMPONENTS},
3961     *            {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
3962     *            {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_DIRECT_BOOT_AWARE},
3963     *            {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY}
3964     *            or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data
3965     *            returned. The most important is {@link #MATCH_DEFAULT_ONLY},
3966     *            to limit the resolution to only those activities that support
3967     *            the {@link android.content.Intent#CATEGORY_DEFAULT}.
3968     * @param userId The user id.
3969     * @return Returns a ResolveInfo object containing the final activity intent
3970     *         that was determined to be the best action. Returns null if no
3971     *         matching activity was found. If multiple matching activities are
3972     *         found and there is no default set, returns a ResolveInfo object
3973     *         containing something else, such as the activity resolver.
3974     * @see #GET_META_DATA
3975     * @see #GET_RESOLVED_FILTER
3976     * @see #GET_SHARED_LIBRARY_FILES
3977     * @see #MATCH_ALL
3978     * @see #MATCH_DISABLED_COMPONENTS
3979     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
3980     * @see #MATCH_DEFAULT_ONLY
3981     * @see #MATCH_DIRECT_BOOT_AWARE
3982     * @see #MATCH_DIRECT_BOOT_UNAWARE
3983     * @see #MATCH_SYSTEM_ONLY
3984     * @see #MATCH_UNINSTALLED_PACKAGES
3985     * @hide
3986     */
3987    public abstract ResolveInfo resolveActivityAsUser(Intent intent, @ResolveInfoFlags int flags,
3988            @UserIdInt int userId);
3989
3990    /**
3991     * Retrieve all activities that can be performed for the given intent.
3992     *
3993     * @param intent The desired intent as per resolveActivity().
3994     * @param flags Additional option flags. Use any combination of
3995     *            {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER},
3996     *            {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL},
3997     *            {@link #MATCH_DISABLED_COMPONENTS},
3998     *            {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
3999     *            {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_DIRECT_BOOT_AWARE},
4000     *            {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY}
4001     *            or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data
4002     *            returned. The most important is {@link #MATCH_DEFAULT_ONLY},
4003     *            to limit the resolution to only those activities that support
4004     *            the {@link android.content.Intent#CATEGORY_DEFAULT}. Or, set
4005     *            {@link #MATCH_ALL} to prevent any filtering of the results.
4006     * @return Returns a List of ResolveInfo objects containing one entry for
4007     *         each matching activity, ordered from best to worst. In other
4008     *         words, the first item is what would be returned by
4009     *         {@link #resolveActivity}. If there are no matching activities, an
4010     *         empty list is returned.
4011     * @see #GET_META_DATA
4012     * @see #GET_RESOLVED_FILTER
4013     * @see #GET_SHARED_LIBRARY_FILES
4014     * @see #MATCH_ALL
4015     * @see #MATCH_DISABLED_COMPONENTS
4016     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
4017     * @see #MATCH_DEFAULT_ONLY
4018     * @see #MATCH_DIRECT_BOOT_AWARE
4019     * @see #MATCH_DIRECT_BOOT_UNAWARE
4020     * @see #MATCH_SYSTEM_ONLY
4021     * @see #MATCH_UNINSTALLED_PACKAGES
4022     */
4023    public abstract List<ResolveInfo> queryIntentActivities(Intent intent,
4024            @ResolveInfoFlags int flags);
4025
4026    /**
4027     * Retrieve all activities that can be performed for the given intent, for a
4028     * specific user.
4029     *
4030     * @param intent The desired intent as per resolveActivity().
4031     * @param flags Additional option flags. Use any combination of
4032     *            {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER},
4033     *            {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL},
4034     *            {@link #MATCH_DISABLED_COMPONENTS},
4035     *            {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
4036     *            {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_DIRECT_BOOT_AWARE},
4037     *            {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY}
4038     *            or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data
4039     *            returned. The most important is {@link #MATCH_DEFAULT_ONLY},
4040     *            to limit the resolution to only those activities that support
4041     *            the {@link android.content.Intent#CATEGORY_DEFAULT}. Or, set
4042     *            {@link #MATCH_ALL} to prevent any filtering of the results.
4043     * @return Returns a List of ResolveInfo objects containing one entry for
4044     *         each matching activity, ordered from best to worst. In other
4045     *         words, the first item is what would be returned by
4046     *         {@link #resolveActivity}. If there are no matching activities, an
4047     *         empty list is returned.
4048     * @see #GET_META_DATA
4049     * @see #GET_RESOLVED_FILTER
4050     * @see #GET_SHARED_LIBRARY_FILES
4051     * @see #MATCH_ALL
4052     * @see #MATCH_DISABLED_COMPONENTS
4053     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
4054     * @see #MATCH_DEFAULT_ONLY
4055     * @see #MATCH_DIRECT_BOOT_AWARE
4056     * @see #MATCH_DIRECT_BOOT_UNAWARE
4057     * @see #MATCH_SYSTEM_ONLY
4058     * @see #MATCH_UNINSTALLED_PACKAGES
4059     * @hide
4060     */
4061    public abstract List<ResolveInfo> queryIntentActivitiesAsUser(Intent intent,
4062            @ResolveInfoFlags int flags, @UserIdInt int userId);
4063
4064    /**
4065     * Retrieve a set of activities that should be presented to the user as
4066     * similar options. This is like {@link #queryIntentActivities}, except it
4067     * also allows you to supply a list of more explicit Intents that you would
4068     * like to resolve to particular options, and takes care of returning the
4069     * final ResolveInfo list in a reasonable order, with no duplicates, based
4070     * on those inputs.
4071     *
4072     * @param caller The class name of the activity that is making the request.
4073     *            This activity will never appear in the output list. Can be
4074     *            null.
4075     * @param specifics An array of Intents that should be resolved to the first
4076     *            specific results. Can be null.
4077     * @param intent The desired intent as per resolveActivity().
4078     * @param flags Additional option flags. Use any combination of
4079     *            {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER},
4080     *            {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL},
4081     *            {@link #MATCH_DISABLED_COMPONENTS},
4082     *            {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
4083     *            {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_DIRECT_BOOT_AWARE},
4084     *            {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY}
4085     *            or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data
4086     *            returned. The most important is {@link #MATCH_DEFAULT_ONLY},
4087     *            to limit the resolution to only those activities that support
4088     *            the {@link android.content.Intent#CATEGORY_DEFAULT}.
4089     * @return Returns a List of ResolveInfo objects containing one entry for
4090     *         each matching activity. The list is ordered first by all of the
4091     *         intents resolved in <var>specifics</var> and then any additional
4092     *         activities that can handle <var>intent</var> but did not get
4093     *         included by one of the <var>specifics</var> intents. If there are
4094     *         no matching activities, an empty list is returned.
4095     * @see #GET_META_DATA
4096     * @see #GET_RESOLVED_FILTER
4097     * @see #GET_SHARED_LIBRARY_FILES
4098     * @see #MATCH_ALL
4099     * @see #MATCH_DISABLED_COMPONENTS
4100     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
4101     * @see #MATCH_DEFAULT_ONLY
4102     * @see #MATCH_DIRECT_BOOT_AWARE
4103     * @see #MATCH_DIRECT_BOOT_UNAWARE
4104     * @see #MATCH_SYSTEM_ONLY
4105     * @see #MATCH_UNINSTALLED_PACKAGES
4106     */
4107    public abstract List<ResolveInfo> queryIntentActivityOptions(
4108            ComponentName caller, Intent[] specifics, Intent intent, @ResolveInfoFlags int flags);
4109
4110    /**
4111     * Retrieve all receivers that can handle a broadcast of the given intent.
4112     *
4113     * @param intent The desired intent as per resolveActivity().
4114     * @param flags Additional option flags. Use any combination of
4115     *            {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER},
4116     *            {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL},
4117     *            {@link #MATCH_DISABLED_COMPONENTS},
4118     *            {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
4119     *            {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_DIRECT_BOOT_AWARE},
4120     *            {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY}
4121     *            or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data
4122     *            returned.
4123     * @return Returns a List of ResolveInfo objects containing one entry for
4124     *         each matching receiver, ordered from best to worst. If there are
4125     *         no matching receivers, an empty list or null is returned.
4126     * @see #GET_META_DATA
4127     * @see #GET_RESOLVED_FILTER
4128     * @see #GET_SHARED_LIBRARY_FILES
4129     * @see #MATCH_ALL
4130     * @see #MATCH_DISABLED_COMPONENTS
4131     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
4132     * @see #MATCH_DEFAULT_ONLY
4133     * @see #MATCH_DIRECT_BOOT_AWARE
4134     * @see #MATCH_DIRECT_BOOT_UNAWARE
4135     * @see #MATCH_SYSTEM_ONLY
4136     * @see #MATCH_UNINSTALLED_PACKAGES
4137     */
4138    public abstract List<ResolveInfo> queryBroadcastReceivers(Intent intent,
4139            @ResolveInfoFlags int flags);
4140
4141    /**
4142     * Retrieve all receivers that can handle a broadcast of the given intent,
4143     * for a specific user.
4144     *
4145     * @param intent The desired intent as per resolveActivity().
4146     * @param flags Additional option flags. Use any combination of
4147     *            {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER},
4148     *            {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL},
4149     *            {@link #MATCH_DISABLED_COMPONENTS},
4150     *            {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
4151     *            {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_DIRECT_BOOT_AWARE},
4152     *            {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY}
4153     *            or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data
4154     *            returned.
4155     * @param userHandle UserHandle of the user being queried.
4156     * @return Returns a List of ResolveInfo objects containing one entry for
4157     *         each matching receiver, ordered from best to worst. If there are
4158     *         no matching receivers, an empty list or null is returned.
4159     * @see #GET_META_DATA
4160     * @see #GET_RESOLVED_FILTER
4161     * @see #GET_SHARED_LIBRARY_FILES
4162     * @see #MATCH_ALL
4163     * @see #MATCH_DISABLED_COMPONENTS
4164     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
4165     * @see #MATCH_DEFAULT_ONLY
4166     * @see #MATCH_DIRECT_BOOT_AWARE
4167     * @see #MATCH_DIRECT_BOOT_UNAWARE
4168     * @see #MATCH_SYSTEM_ONLY
4169     * @see #MATCH_UNINSTALLED_PACKAGES
4170     * @hide
4171     */
4172    @SystemApi
4173    public List<ResolveInfo> queryBroadcastReceiversAsUser(Intent intent,
4174            @ResolveInfoFlags int flags, UserHandle userHandle) {
4175        return queryBroadcastReceiversAsUser(intent, flags, userHandle.getIdentifier());
4176    }
4177
4178    /**
4179     * @hide
4180     */
4181    public abstract List<ResolveInfo> queryBroadcastReceiversAsUser(Intent intent,
4182            @ResolveInfoFlags int flags, @UserIdInt int userId);
4183
4184
4185    /** {@hide} */
4186    @Deprecated
4187    public List<ResolveInfo> queryBroadcastReceivers(Intent intent,
4188            @ResolveInfoFlags int flags, @UserIdInt int userId) {
4189        Log.w(TAG, "STAHP USING HIDDEN APIS KTHX");
4190        return queryBroadcastReceiversAsUser(intent, flags, userId);
4191    }
4192
4193    /**
4194     * Determine the best service to handle for a given Intent.
4195     *
4196     * @param intent An intent containing all of the desired specification
4197     *            (action, data, type, category, and/or component).
4198     * @param flags Additional option flags. Use any combination of
4199     *            {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER},
4200     *            {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL},
4201     *            {@link #MATCH_DISABLED_COMPONENTS},
4202     *            {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
4203     *            {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_DIRECT_BOOT_AWARE},
4204     *            {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY}
4205     *            or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data
4206     *            returned.
4207     * @return Returns a ResolveInfo object containing the final service intent
4208     *         that was determined to be the best action. Returns null if no
4209     *         matching service was found.
4210     * @see #GET_META_DATA
4211     * @see #GET_RESOLVED_FILTER
4212     * @see #GET_SHARED_LIBRARY_FILES
4213     * @see #MATCH_ALL
4214     * @see #MATCH_DISABLED_COMPONENTS
4215     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
4216     * @see #MATCH_DEFAULT_ONLY
4217     * @see #MATCH_DIRECT_BOOT_AWARE
4218     * @see #MATCH_DIRECT_BOOT_UNAWARE
4219     * @see #MATCH_SYSTEM_ONLY
4220     * @see #MATCH_UNINSTALLED_PACKAGES
4221     */
4222    public abstract ResolveInfo resolveService(Intent intent, @ResolveInfoFlags int flags);
4223
4224    /**
4225     * Retrieve all services that can match the given intent.
4226     *
4227     * @param intent The desired intent as per resolveService().
4228     * @param flags Additional option flags. Use any combination of
4229     *            {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER},
4230     *            {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL},
4231     *            {@link #MATCH_DISABLED_COMPONENTS},
4232     *            {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
4233     *            {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_DIRECT_BOOT_AWARE},
4234     *            {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY}
4235     *            or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data
4236     *            returned.
4237     * @return Returns a List of ResolveInfo objects containing one entry for
4238     *         each matching service, ordered from best to worst. In other
4239     *         words, the first item is what would be returned by
4240     *         {@link #resolveService}. If there are no matching services, an
4241     *         empty list or null is returned.
4242     * @see #GET_META_DATA
4243     * @see #GET_RESOLVED_FILTER
4244     * @see #GET_SHARED_LIBRARY_FILES
4245     * @see #MATCH_ALL
4246     * @see #MATCH_DISABLED_COMPONENTS
4247     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
4248     * @see #MATCH_DEFAULT_ONLY
4249     * @see #MATCH_DIRECT_BOOT_AWARE
4250     * @see #MATCH_DIRECT_BOOT_UNAWARE
4251     * @see #MATCH_SYSTEM_ONLY
4252     * @see #MATCH_UNINSTALLED_PACKAGES
4253     */
4254    public abstract List<ResolveInfo> queryIntentServices(Intent intent,
4255            @ResolveInfoFlags int flags);
4256
4257    /**
4258     * Retrieve all services that can match the given intent for a given user.
4259     *
4260     * @param intent The desired intent as per resolveService().
4261     * @param flags Additional option flags. Use any combination of
4262     *            {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER},
4263     *            {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL},
4264     *            {@link #MATCH_DISABLED_COMPONENTS},
4265     *            {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
4266     *            {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_DIRECT_BOOT_AWARE},
4267     *            {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY}
4268     *            or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data
4269     *            returned.
4270     * @param userId The user id.
4271     * @return Returns a List of ResolveInfo objects containing one entry for
4272     *         each matching service, ordered from best to worst. In other
4273     *         words, the first item is what would be returned by
4274     *         {@link #resolveService}. If there are no matching services, an
4275     *         empty list or null is returned.
4276     * @see #GET_META_DATA
4277     * @see #GET_RESOLVED_FILTER
4278     * @see #GET_SHARED_LIBRARY_FILES
4279     * @see #MATCH_ALL
4280     * @see #MATCH_DISABLED_COMPONENTS
4281     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
4282     * @see #MATCH_DEFAULT_ONLY
4283     * @see #MATCH_DIRECT_BOOT_AWARE
4284     * @see #MATCH_DIRECT_BOOT_UNAWARE
4285     * @see #MATCH_SYSTEM_ONLY
4286     * @see #MATCH_UNINSTALLED_PACKAGES
4287     * @hide
4288     */
4289    public abstract List<ResolveInfo> queryIntentServicesAsUser(Intent intent,
4290            @ResolveInfoFlags int flags, @UserIdInt int userId);
4291
4292    /**
4293     * Retrieve all providers that can match the given intent.
4294     *
4295     * @param intent An intent containing all of the desired specification
4296     *            (action, data, type, category, and/or component).
4297     * @param flags Additional option flags. Use any combination of
4298     *            {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER},
4299     *            {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL},
4300     *            {@link #MATCH_DISABLED_COMPONENTS},
4301     *            {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
4302     *            {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_DIRECT_BOOT_AWARE},
4303     *            {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY}
4304     *            or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data
4305     *            returned.
4306     * @param userId The user id.
4307     * @return Returns a List of ResolveInfo objects containing one entry for
4308     *         each matching provider, ordered from best to worst. If there are
4309     *         no matching services, an empty list or null is returned.
4310     * @see #GET_META_DATA
4311     * @see #GET_RESOLVED_FILTER
4312     * @see #GET_SHARED_LIBRARY_FILES
4313     * @see #MATCH_ALL
4314     * @see #MATCH_DISABLED_COMPONENTS
4315     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
4316     * @see #MATCH_DEFAULT_ONLY
4317     * @see #MATCH_DIRECT_BOOT_AWARE
4318     * @see #MATCH_DIRECT_BOOT_UNAWARE
4319     * @see #MATCH_SYSTEM_ONLY
4320     * @see #MATCH_UNINSTALLED_PACKAGES
4321     * @hide
4322     */
4323    public abstract List<ResolveInfo> queryIntentContentProvidersAsUser(
4324            Intent intent, @ResolveInfoFlags int flags, @UserIdInt int userId);
4325
4326    /**
4327     * Retrieve all providers that can match the given intent.
4328     *
4329     * @param intent An intent containing all of the desired specification
4330     *            (action, data, type, category, and/or component).
4331     * @param flags Additional option flags. Use any combination of
4332     *            {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER},
4333     *            {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL},
4334     *            {@link #MATCH_DISABLED_COMPONENTS},
4335     *            {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
4336     *            {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_DIRECT_BOOT_AWARE},
4337     *            {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY}
4338     *            or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data
4339     *            returned.
4340     * @return Returns a List of ResolveInfo objects containing one entry for
4341     *         each matching provider, ordered from best to worst. If there are
4342     *         no matching services, an empty list or null is returned.
4343     * @see #GET_META_DATA
4344     * @see #GET_RESOLVED_FILTER
4345     * @see #GET_SHARED_LIBRARY_FILES
4346     * @see #MATCH_ALL
4347     * @see #MATCH_DISABLED_COMPONENTS
4348     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
4349     * @see #MATCH_DEFAULT_ONLY
4350     * @see #MATCH_DIRECT_BOOT_AWARE
4351     * @see #MATCH_DIRECT_BOOT_UNAWARE
4352     * @see #MATCH_SYSTEM_ONLY
4353     * @see #MATCH_UNINSTALLED_PACKAGES
4354     */
4355    public abstract List<ResolveInfo> queryIntentContentProviders(Intent intent,
4356            @ResolveInfoFlags int flags);
4357
4358    /**
4359     * Find a single content provider by its base path name.
4360     *
4361     * @param name The name of the provider to find.
4362     * @param flags Additional option flags. Use any combination of
4363     *            {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
4364     *            {@link #MATCH_ALL}, {@link #MATCH_DEFAULT_ONLY},
4365     *            {@link #MATCH_DISABLED_COMPONENTS},
4366     *            {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
4367     *            {@link #MATCH_DIRECT_BOOT_AWARE},
4368     *            {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY}
4369     *            or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data
4370     *            returned.
4371     * @return A {@link ProviderInfo} object containing information about the
4372     *         provider. If a provider was not found, returns null.
4373     * @see #GET_META_DATA
4374     * @see #GET_SHARED_LIBRARY_FILES
4375     * @see #MATCH_ALL
4376     * @see #MATCH_DEBUG_TRIAGED_MISSING
4377     * @see #MATCH_DEFAULT_ONLY
4378     * @see #MATCH_DISABLED_COMPONENTS
4379     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
4380     * @see #MATCH_DIRECT_BOOT_AWARE
4381     * @see #MATCH_DIRECT_BOOT_UNAWARE
4382     * @see #MATCH_SYSTEM_ONLY
4383     * @see #MATCH_UNINSTALLED_PACKAGES
4384     */
4385    public abstract ProviderInfo resolveContentProvider(String name,
4386            @ComponentInfoFlags int flags);
4387
4388    /**
4389     * Find a single content provider by its base path name.
4390     *
4391     * @param name The name of the provider to find.
4392     * @param flags Additional option flags. Use any combination of
4393     *            {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
4394     *            {@link #MATCH_ALL}, {@link #MATCH_DEFAULT_ONLY},
4395     *            {@link #MATCH_DISABLED_COMPONENTS},
4396     *            {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
4397     *            {@link #MATCH_DIRECT_BOOT_AWARE},
4398     *            {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY}
4399     *            or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data
4400     *            returned.
4401     * @param userId The user id.
4402     * @return A {@link ProviderInfo} object containing information about the
4403     *         provider. If a provider was not found, returns null.
4404     * @see #GET_META_DATA
4405     * @see #GET_SHARED_LIBRARY_FILES
4406     * @see #MATCH_ALL
4407     * @see #MATCH_DEBUG_TRIAGED_MISSING
4408     * @see #MATCH_DEFAULT_ONLY
4409     * @see #MATCH_DISABLED_COMPONENTS
4410     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
4411     * @see #MATCH_DIRECT_BOOT_AWARE
4412     * @see #MATCH_DIRECT_BOOT_UNAWARE
4413     * @see #MATCH_SYSTEM_ONLY
4414     * @see #MATCH_UNINSTALLED_PACKAGES
4415     * @hide
4416     */
4417    public abstract ProviderInfo resolveContentProviderAsUser(String name,
4418            @ComponentInfoFlags int flags, @UserIdInt int userId);
4419
4420    /**
4421     * Retrieve content provider information.
4422     * <p>
4423     * <em>Note: unlike most other methods, an empty result set is indicated
4424     * by a null return instead of an empty list.</em>
4425     *
4426     * @param processName If non-null, limits the returned providers to only
4427     *            those that are hosted by the given process. If null, all
4428     *            content providers are returned.
4429     * @param uid If <var>processName</var> is non-null, this is the required
4430     *            uid owning the requested content providers.
4431     * @param flags Additional option flags. Use any combination of
4432     *            {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
4433     *            {@link #MATCH_ALL}, {@link #MATCH_DEFAULT_ONLY},
4434     *            {@link #MATCH_DISABLED_COMPONENTS},
4435     *            {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
4436     *            {@link #MATCH_DIRECT_BOOT_AWARE},
4437     *            {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY}
4438     *            or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data
4439     *            returned.
4440     * @return A list of {@link ProviderInfo} objects containing one entry for
4441     *         each provider either matching <var>processName</var> or, if
4442     *         <var>processName</var> is null, all known content providers.
4443     *         <em>If there are no matching providers, null is returned.</em>
4444     * @see #GET_META_DATA
4445     * @see #GET_SHARED_LIBRARY_FILES
4446     * @see #MATCH_ALL
4447     * @see #MATCH_DEBUG_TRIAGED_MISSING
4448     * @see #MATCH_DEFAULT_ONLY
4449     * @see #MATCH_DISABLED_COMPONENTS
4450     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
4451     * @see #MATCH_DIRECT_BOOT_AWARE
4452     * @see #MATCH_DIRECT_BOOT_UNAWARE
4453     * @see #MATCH_SYSTEM_ONLY
4454     * @see #MATCH_UNINSTALLED_PACKAGES
4455     */
4456    public abstract List<ProviderInfo> queryContentProviders(
4457            String processName, int uid, @ComponentInfoFlags int flags);
4458
4459    /**
4460     * Retrieve all of the information we know about a particular
4461     * instrumentation class.
4462     *
4463     * @param className The full name (i.e.
4464     *                  com.google.apps.contacts.InstrumentList) of an
4465     *                  Instrumentation class.
4466     * @param flags Additional option flags. Use any combination of
4467     *         {@link #GET_META_DATA}
4468     *         to modify the data returned.
4469     *
4470     * @return An {@link InstrumentationInfo} object containing information about the
4471     *         instrumentation.
4472     * @throws NameNotFoundException if a package with the given name cannot be
4473     *             found on the system.
4474     *
4475     * @see #GET_META_DATA
4476     */
4477    public abstract InstrumentationInfo getInstrumentationInfo(ComponentName className,
4478            @InstrumentationInfoFlags int flags) throws NameNotFoundException;
4479
4480    /**
4481     * Retrieve information about available instrumentation code.  May be used
4482     * to retrieve either all instrumentation code, or only the code targeting
4483     * a particular package.
4484     *
4485     * @param targetPackage If null, all instrumentation is returned; only the
4486     *                      instrumentation targeting this package name is
4487     *                      returned.
4488     * @param flags Additional option flags. Use any combination of
4489     *         {@link #GET_META_DATA}
4490     *         to modify the data returned.
4491     *
4492     * @return A list of {@link InstrumentationInfo} objects containing one
4493     *         entry for each matching instrumentation. If there are no
4494     *         instrumentation available, returns an empty list.
4495     *
4496     * @see #GET_META_DATA
4497     */
4498    public abstract List<InstrumentationInfo> queryInstrumentation(String targetPackage,
4499            @InstrumentationInfoFlags int flags);
4500
4501    /**
4502     * Retrieve an image from a package.  This is a low-level API used by
4503     * the various package manager info structures (such as
4504     * {@link ComponentInfo} to implement retrieval of their associated
4505     * icon.
4506     *
4507     * @param packageName The name of the package that this icon is coming from.
4508     * Cannot be null.
4509     * @param resid The resource identifier of the desired image.  Cannot be 0.
4510     * @param appInfo Overall information about <var>packageName</var>.  This
4511     * may be null, in which case the application information will be retrieved
4512     * for you if needed; if you already have this information around, it can
4513     * be much more efficient to supply it here.
4514     *
4515     * @return Returns a Drawable holding the requested image.  Returns null if
4516     * an image could not be found for any reason.
4517     */
4518    public abstract Drawable getDrawable(String packageName, @DrawableRes int resid,
4519            ApplicationInfo appInfo);
4520
4521    /**
4522     * Retrieve the icon associated with an activity.  Given the full name of
4523     * an activity, retrieves the information about it and calls
4524     * {@link ComponentInfo#loadIcon ComponentInfo.loadIcon()} to return its icon.
4525     * If the activity cannot be found, NameNotFoundException is thrown.
4526     *
4527     * @param activityName Name of the activity whose icon is to be retrieved.
4528     *
4529     * @return Returns the image of the icon, or the default activity icon if
4530     * it could not be found.  Does not return null.
4531     * @throws NameNotFoundException Thrown if the resources for the given
4532     * activity could not be loaded.
4533     *
4534     * @see #getActivityIcon(Intent)
4535     */
4536    public abstract Drawable getActivityIcon(ComponentName activityName)
4537            throws NameNotFoundException;
4538
4539    /**
4540     * Retrieve the icon associated with an Intent.  If intent.getClassName() is
4541     * set, this simply returns the result of
4542     * getActivityIcon(intent.getClassName()).  Otherwise it resolves the intent's
4543     * component and returns the icon associated with the resolved component.
4544     * If intent.getClassName() cannot be found or the Intent cannot be resolved
4545     * to a component, NameNotFoundException is thrown.
4546     *
4547     * @param intent The intent for which you would like to retrieve an icon.
4548     *
4549     * @return Returns the image of the icon, or the default activity icon if
4550     * it could not be found.  Does not return null.
4551     * @throws NameNotFoundException Thrown if the resources for application
4552     * matching the given intent could not be loaded.
4553     *
4554     * @see #getActivityIcon(ComponentName)
4555     */
4556    public abstract Drawable getActivityIcon(Intent intent)
4557            throws NameNotFoundException;
4558
4559    /**
4560     * Retrieve the banner associated with an activity. Given the full name of
4561     * an activity, retrieves the information about it and calls
4562     * {@link ComponentInfo#loadIcon ComponentInfo.loadIcon()} to return its
4563     * banner. If the activity cannot be found, NameNotFoundException is thrown.
4564     *
4565     * @param activityName Name of the activity whose banner is to be retrieved.
4566     * @return Returns the image of the banner, or null if the activity has no
4567     *         banner specified.
4568     * @throws NameNotFoundException Thrown if the resources for the given
4569     *             activity could not be loaded.
4570     * @see #getActivityBanner(Intent)
4571     */
4572    public abstract Drawable getActivityBanner(ComponentName activityName)
4573            throws NameNotFoundException;
4574
4575    /**
4576     * Retrieve the banner associated with an Intent. If intent.getClassName()
4577     * is set, this simply returns the result of
4578     * getActivityBanner(intent.getClassName()). Otherwise it resolves the
4579     * intent's component and returns the banner associated with the resolved
4580     * component. If intent.getClassName() cannot be found or the Intent cannot
4581     * be resolved to a component, NameNotFoundException is thrown.
4582     *
4583     * @param intent The intent for which you would like to retrieve a banner.
4584     * @return Returns the image of the banner, or null if the activity has no
4585     *         banner specified.
4586     * @throws NameNotFoundException Thrown if the resources for application
4587     *             matching the given intent could not be loaded.
4588     * @see #getActivityBanner(ComponentName)
4589     */
4590    public abstract Drawable getActivityBanner(Intent intent)
4591            throws NameNotFoundException;
4592
4593    /**
4594     * Return the generic icon for an activity that is used when no specific
4595     * icon is defined.
4596     *
4597     * @return Drawable Image of the icon.
4598     */
4599    public abstract Drawable getDefaultActivityIcon();
4600
4601    /**
4602     * Retrieve the icon associated with an application.  If it has not defined
4603     * an icon, the default app icon is returned.  Does not return null.
4604     *
4605     * @param info Information about application being queried.
4606     *
4607     * @return Returns the image of the icon, or the default application icon
4608     * if it could not be found.
4609     *
4610     * @see #getApplicationIcon(String)
4611     */
4612    public abstract Drawable getApplicationIcon(ApplicationInfo info);
4613
4614    /**
4615     * Retrieve the icon associated with an application.  Given the name of the
4616     * application's package, retrieves the information about it and calls
4617     * getApplicationIcon() to return its icon. If the application cannot be
4618     * found, NameNotFoundException is thrown.
4619     *
4620     * @param packageName Name of the package whose application icon is to be
4621     *                    retrieved.
4622     *
4623     * @return Returns the image of the icon, or the default application icon
4624     * if it could not be found.  Does not return null.
4625     * @throws NameNotFoundException Thrown if the resources for the given
4626     * application could not be loaded.
4627     *
4628     * @see #getApplicationIcon(ApplicationInfo)
4629     */
4630    public abstract Drawable getApplicationIcon(String packageName)
4631            throws NameNotFoundException;
4632
4633    /**
4634     * Retrieve the banner associated with an application.
4635     *
4636     * @param info Information about application being queried.
4637     * @return Returns the image of the banner or null if the application has no
4638     *         banner specified.
4639     * @see #getApplicationBanner(String)
4640     */
4641    public abstract Drawable getApplicationBanner(ApplicationInfo info);
4642
4643    /**
4644     * Retrieve the banner associated with an application. Given the name of the
4645     * application's package, retrieves the information about it and calls
4646     * getApplicationIcon() to return its banner. If the application cannot be
4647     * found, NameNotFoundException is thrown.
4648     *
4649     * @param packageName Name of the package whose application banner is to be
4650     *            retrieved.
4651     * @return Returns the image of the banner or null if the application has no
4652     *         banner specified.
4653     * @throws NameNotFoundException Thrown if the resources for the given
4654     *             application could not be loaded.
4655     * @see #getApplicationBanner(ApplicationInfo)
4656     */
4657    public abstract Drawable getApplicationBanner(String packageName)
4658            throws NameNotFoundException;
4659
4660    /**
4661     * Retrieve the logo associated with an activity. Given the full name of an
4662     * activity, retrieves the information about it and calls
4663     * {@link ComponentInfo#loadLogo ComponentInfo.loadLogo()} to return its
4664     * logo. If the activity cannot be found, NameNotFoundException is thrown.
4665     *
4666     * @param activityName Name of the activity whose logo is to be retrieved.
4667     * @return Returns the image of the logo or null if the activity has no logo
4668     *         specified.
4669     * @throws NameNotFoundException Thrown if the resources for the given
4670     *             activity could not be loaded.
4671     * @see #getActivityLogo(Intent)
4672     */
4673    public abstract Drawable getActivityLogo(ComponentName activityName)
4674            throws NameNotFoundException;
4675
4676    /**
4677     * Retrieve the logo associated with an Intent.  If intent.getClassName() is
4678     * set, this simply returns the result of
4679     * getActivityLogo(intent.getClassName()).  Otherwise it resolves the intent's
4680     * component and returns the logo associated with the resolved component.
4681     * If intent.getClassName() cannot be found or the Intent cannot be resolved
4682     * to a component, NameNotFoundException is thrown.
4683     *
4684     * @param intent The intent for which you would like to retrieve a logo.
4685     *
4686     * @return Returns the image of the logo, or null if the activity has no
4687     * logo specified.
4688     *
4689     * @throws NameNotFoundException Thrown if the resources for application
4690     * matching the given intent could not be loaded.
4691     *
4692     * @see #getActivityLogo(ComponentName)
4693     */
4694    public abstract Drawable getActivityLogo(Intent intent)
4695            throws NameNotFoundException;
4696
4697    /**
4698     * Retrieve the logo associated with an application.  If it has not specified
4699     * a logo, this method returns null.
4700     *
4701     * @param info Information about application being queried.
4702     *
4703     * @return Returns the image of the logo, or null if no logo is specified
4704     * by the application.
4705     *
4706     * @see #getApplicationLogo(String)
4707     */
4708    public abstract Drawable getApplicationLogo(ApplicationInfo info);
4709
4710    /**
4711     * Retrieve the logo associated with an application.  Given the name of the
4712     * application's package, retrieves the information about it and calls
4713     * getApplicationLogo() to return its logo. If the application cannot be
4714     * found, NameNotFoundException is thrown.
4715     *
4716     * @param packageName Name of the package whose application logo is to be
4717     *                    retrieved.
4718     *
4719     * @return Returns the image of the logo, or null if no application logo
4720     * has been specified.
4721     *
4722     * @throws NameNotFoundException Thrown if the resources for the given
4723     * application could not be loaded.
4724     *
4725     * @see #getApplicationLogo(ApplicationInfo)
4726     */
4727    public abstract Drawable getApplicationLogo(String packageName)
4728            throws NameNotFoundException;
4729
4730    /**
4731     * If the target user is a managed profile, then this returns a badged copy of the given icon
4732     * to be able to distinguish it from the original icon. For badging an arbitrary drawable use
4733     * {@link #getUserBadgedDrawableForDensity(
4734     * android.graphics.drawable.Drawable, UserHandle, android.graphics.Rect, int)}.
4735     * <p>
4736     * If the original drawable is a BitmapDrawable and the backing bitmap is
4737     * mutable as per {@link android.graphics.Bitmap#isMutable()}, the badging
4738     * is performed in place and the original drawable is returned.
4739     * </p>
4740     *
4741     * @param icon The icon to badge.
4742     * @param user The target user.
4743     * @return A drawable that combines the original icon and a badge as
4744     *         determined by the system.
4745     */
4746    public abstract Drawable getUserBadgedIcon(Drawable icon, UserHandle user);
4747
4748    /**
4749     * If the target user is a managed profile of the calling user or the caller
4750     * is itself a managed profile, then this returns a badged copy of the given
4751     * drawable allowing the user to distinguish it from the original drawable.
4752     * The caller can specify the location in the bounds of the drawable to be
4753     * badged where the badge should be applied as well as the density of the
4754     * badge to be used.
4755     * <p>
4756     * If the original drawable is a BitmapDrawable and the backing bitmap is
4757     * mutable as per {@link android.graphics.Bitmap#isMutable()}, the badging
4758     * is performed in place and the original drawable is returned.
4759     * </p>
4760     *
4761     * @param drawable The drawable to badge.
4762     * @param user The target user.
4763     * @param badgeLocation Where in the bounds of the badged drawable to place
4764     *         the badge. If it's {@code null}, the badge is applied on top of the entire
4765     *         drawable being badged.
4766     * @param badgeDensity The optional desired density for the badge as per
4767     *         {@link android.util.DisplayMetrics#densityDpi}. If it's not positive,
4768     *         the density of the display is used.
4769     * @return A drawable that combines the original drawable and a badge as
4770     *         determined by the system.
4771     */
4772    public abstract Drawable getUserBadgedDrawableForDensity(Drawable drawable,
4773            UserHandle user, Rect badgeLocation, int badgeDensity);
4774
4775    /**
4776     * If the target user is a managed profile of the calling user or the caller
4777     * is itself a managed profile, then this returns a drawable to use as a small
4778     * icon to include in a view to distinguish it from the original icon.
4779     *
4780     * @param user The target user.
4781     * @param density The optional desired density for the badge as per
4782     *         {@link android.util.DisplayMetrics#densityDpi}. If not provided
4783     *         the density of the current display is used.
4784     * @return the drawable or null if no drawable is required.
4785     * @hide
4786     */
4787    public abstract Drawable getUserBadgeForDensity(UserHandle user, int density);
4788
4789    /**
4790     * If the target user is a managed profile of the calling user or the caller
4791     * is itself a managed profile, then this returns a drawable to use as a small
4792     * icon to include in a view to distinguish it from the original icon. This version
4793     * doesn't have background protection and should be used over a light background instead of
4794     * a badge.
4795     *
4796     * @param user The target user.
4797     * @param density The optional desired density for the badge as per
4798     *         {@link android.util.DisplayMetrics#densityDpi}. If not provided
4799     *         the density of the current display is used.
4800     * @return the drawable or null if no drawable is required.
4801     * @hide
4802     */
4803    public abstract Drawable getUserBadgeForDensityNoBackground(UserHandle user, int density);
4804
4805    /**
4806     * If the target user is a managed profile of the calling user or the caller
4807     * is itself a managed profile, then this returns a copy of the label with
4808     * badging for accessibility services like talkback. E.g. passing in "Email"
4809     * and it might return "Work Email" for Email in the work profile.
4810     *
4811     * @param label The label to change.
4812     * @param user The target user.
4813     * @return A label that combines the original label and a badge as
4814     *         determined by the system.
4815     */
4816    public abstract CharSequence getUserBadgedLabel(CharSequence label, UserHandle user);
4817
4818    /**
4819     * Retrieve text from a package.  This is a low-level API used by
4820     * the various package manager info structures (such as
4821     * {@link ComponentInfo} to implement retrieval of their associated
4822     * labels and other text.
4823     *
4824     * @param packageName The name of the package that this text is coming from.
4825     * Cannot be null.
4826     * @param resid The resource identifier of the desired text.  Cannot be 0.
4827     * @param appInfo Overall information about <var>packageName</var>.  This
4828     * may be null, in which case the application information will be retrieved
4829     * for you if needed; if you already have this information around, it can
4830     * be much more efficient to supply it here.
4831     *
4832     * @return Returns a CharSequence holding the requested text.  Returns null
4833     * if the text could not be found for any reason.
4834     */
4835    public abstract CharSequence getText(String packageName, @StringRes int resid,
4836            ApplicationInfo appInfo);
4837
4838    /**
4839     * Retrieve an XML file from a package.  This is a low-level API used to
4840     * retrieve XML meta data.
4841     *
4842     * @param packageName The name of the package that this xml is coming from.
4843     * Cannot be null.
4844     * @param resid The resource identifier of the desired xml.  Cannot be 0.
4845     * @param appInfo Overall information about <var>packageName</var>.  This
4846     * may be null, in which case the application information will be retrieved
4847     * for you if needed; if you already have this information around, it can
4848     * be much more efficient to supply it here.
4849     *
4850     * @return Returns an XmlPullParser allowing you to parse out the XML
4851     * data.  Returns null if the xml resource could not be found for any
4852     * reason.
4853     */
4854    public abstract XmlResourceParser getXml(String packageName, @XmlRes int resid,
4855            ApplicationInfo appInfo);
4856
4857    /**
4858     * Return the label to use for this application.
4859     *
4860     * @return Returns the label associated with this application, or null if
4861     * it could not be found for any reason.
4862     * @param info The application to get the label of.
4863     */
4864    public abstract CharSequence getApplicationLabel(ApplicationInfo info);
4865
4866    /**
4867     * Retrieve the resources associated with an activity.  Given the full
4868     * name of an activity, retrieves the information about it and calls
4869     * getResources() to return its application's resources.  If the activity
4870     * cannot be found, NameNotFoundException is thrown.
4871     *
4872     * @param activityName Name of the activity whose resources are to be
4873     *                     retrieved.
4874     *
4875     * @return Returns the application's Resources.
4876     * @throws NameNotFoundException Thrown if the resources for the given
4877     * application could not be loaded.
4878     *
4879     * @see #getResourcesForApplication(ApplicationInfo)
4880     */
4881    public abstract Resources getResourcesForActivity(ComponentName activityName)
4882            throws NameNotFoundException;
4883
4884    /**
4885     * Retrieve the resources for an application.  Throws NameNotFoundException
4886     * if the package is no longer installed.
4887     *
4888     * @param app Information about the desired application.
4889     *
4890     * @return Returns the application's Resources.
4891     * @throws NameNotFoundException Thrown if the resources for the given
4892     * application could not be loaded (most likely because it was uninstalled).
4893     */
4894    public abstract Resources getResourcesForApplication(ApplicationInfo app)
4895            throws NameNotFoundException;
4896
4897    /**
4898     * Retrieve the resources associated with an application.  Given the full
4899     * package name of an application, retrieves the information about it and
4900     * calls getResources() to return its application's resources.  If the
4901     * appPackageName cannot be found, NameNotFoundException is thrown.
4902     *
4903     * @param appPackageName Package name of the application whose resources
4904     *                       are to be retrieved.
4905     *
4906     * @return Returns the application's Resources.
4907     * @throws NameNotFoundException Thrown if the resources for the given
4908     * application could not be loaded.
4909     *
4910     * @see #getResourcesForApplication(ApplicationInfo)
4911     */
4912    public abstract Resources getResourcesForApplication(String appPackageName)
4913            throws NameNotFoundException;
4914
4915    /** @hide */
4916    public abstract Resources getResourcesForApplicationAsUser(String appPackageName,
4917            @UserIdInt int userId) throws NameNotFoundException;
4918
4919    /**
4920     * Retrieve overall information about an application package defined
4921     * in a package archive file
4922     *
4923     * @param archiveFilePath The path to the archive file
4924     * @param flags Additional option flags. Use any combination of
4925     *         {@link #GET_ACTIVITIES}, {@link #GET_CONFIGURATIONS},
4926     *         {@link #GET_GIDS}, {@link #GET_INSTRUMENTATION},
4927     *         {@link #GET_INTENT_FILTERS}, {@link #GET_META_DATA},
4928     *         {@link #GET_PERMISSIONS}, {@link #GET_PROVIDERS},
4929     *         {@link #GET_RECEIVERS}, {@link #GET_SERVICES},
4930     *         {@link #GET_SHARED_LIBRARY_FILES}, {@link #GET_SIGNATURES},
4931     *         {@link #GET_URI_PERMISSION_PATTERNS}, {@link #GET_UNINSTALLED_PACKAGES},
4932     *         {@link #MATCH_DISABLED_COMPONENTS}, {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
4933     *         {@link #MATCH_UNINSTALLED_PACKAGES}
4934     *         to modify the data returned.
4935     *
4936     * @return A PackageInfo object containing information about the
4937     *         package archive. If the package could not be parsed,
4938     *         returns null.
4939     *
4940     * @see #GET_ACTIVITIES
4941     * @see #GET_CONFIGURATIONS
4942     * @see #GET_GIDS
4943     * @see #GET_INSTRUMENTATION
4944     * @see #GET_INTENT_FILTERS
4945     * @see #GET_META_DATA
4946     * @see #GET_PERMISSIONS
4947     * @see #GET_PROVIDERS
4948     * @see #GET_RECEIVERS
4949     * @see #GET_SERVICES
4950     * @see #GET_SHARED_LIBRARY_FILES
4951     * @see #GET_SIGNATURES
4952     * @see #GET_URI_PERMISSION_PATTERNS
4953     * @see #MATCH_DISABLED_COMPONENTS
4954     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
4955     * @see #MATCH_UNINSTALLED_PACKAGES
4956     *
4957     */
4958    public PackageInfo getPackageArchiveInfo(String archiveFilePath, @PackageInfoFlags int flags) {
4959        final PackageParser parser = new PackageParser();
4960        final File apkFile = new File(archiveFilePath);
4961        try {
4962            if ((flags & (MATCH_DIRECT_BOOT_UNAWARE | MATCH_DIRECT_BOOT_AWARE)) != 0) {
4963                // Caller expressed an explicit opinion about what encryption
4964                // aware/unaware components they want to see, so fall through and
4965                // give them what they want
4966            } else {
4967                // Caller expressed no opinion, so match everything
4968                flags |= MATCH_DIRECT_BOOT_AWARE | MATCH_DIRECT_BOOT_UNAWARE;
4969            }
4970
4971            PackageParser.Package pkg = parser.parseMonolithicPackage(apkFile, 0);
4972            if ((flags & GET_SIGNATURES) != 0) {
4973                PackageParser.collectCertificates(pkg, 0);
4974            }
4975            PackageUserState state = new PackageUserState();
4976            return PackageParser.generatePackageInfo(pkg, null, flags, 0, 0, null, state);
4977        } catch (PackageParserException e) {
4978            return null;
4979        }
4980    }
4981
4982    /**
4983     * @deprecated replaced by {@link PackageInstaller}
4984     * @hide
4985     */
4986    @Deprecated
4987    public abstract void installPackage(
4988            Uri packageURI,
4989            IPackageInstallObserver observer,
4990            @InstallFlags int flags,
4991            String installerPackageName);
4992    /**
4993     * @deprecated replaced by {@link PackageInstaller}
4994     * @hide
4995     */
4996    @Deprecated
4997    public abstract void installPackage(
4998            Uri packageURI,
4999            PackageInstallObserver observer,
5000            @InstallFlags int flags,
5001            String installerPackageName);
5002
5003    /**
5004     * If there is already an application with the given package name installed
5005     * on the system for other users, also install it for the calling user.
5006     * @hide
5007     */
5008    public abstract int installExistingPackage(String packageName) throws NameNotFoundException;
5009
5010    /**
5011     * If there is already an application with the given package name installed
5012     * on the system for other users, also install it for the specified user.
5013     * @hide
5014     */
5015     @RequiresPermission(anyOf = {
5016            Manifest.permission.INSTALL_PACKAGES,
5017            Manifest.permission.INTERACT_ACROSS_USERS_FULL})
5018    public abstract int installExistingPackageAsUser(String packageName, @UserIdInt int userId)
5019            throws NameNotFoundException;
5020
5021    /**
5022     * Allows a package listening to the
5023     * {@link Intent#ACTION_PACKAGE_NEEDS_VERIFICATION package verification
5024     * broadcast} to respond to the package manager. The response must include
5025     * the {@code verificationCode} which is one of
5026     * {@link PackageManager#VERIFICATION_ALLOW} or
5027     * {@link PackageManager#VERIFICATION_REJECT}.
5028     *
5029     * @param id pending package identifier as passed via the
5030     *            {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra.
5031     * @param verificationCode either {@link PackageManager#VERIFICATION_ALLOW}
5032     *            or {@link PackageManager#VERIFICATION_REJECT}.
5033     * @throws SecurityException if the caller does not have the
5034     *            PACKAGE_VERIFICATION_AGENT permission.
5035     */
5036    public abstract void verifyPendingInstall(int id, int verificationCode);
5037
5038    /**
5039     * Allows a package listening to the
5040     * {@link Intent#ACTION_PACKAGE_NEEDS_VERIFICATION package verification
5041     * broadcast} to extend the default timeout for a response and declare what
5042     * action to perform after the timeout occurs. The response must include
5043     * the {@code verificationCodeAtTimeout} which is one of
5044     * {@link PackageManager#VERIFICATION_ALLOW} or
5045     * {@link PackageManager#VERIFICATION_REJECT}.
5046     *
5047     * This method may only be called once per package id. Additional calls
5048     * will have no effect.
5049     *
5050     * @param id pending package identifier as passed via the
5051     *            {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra.
5052     * @param verificationCodeAtTimeout either
5053     *            {@link PackageManager#VERIFICATION_ALLOW} or
5054     *            {@link PackageManager#VERIFICATION_REJECT}. If
5055     *            {@code verificationCodeAtTimeout} is neither
5056     *            {@link PackageManager#VERIFICATION_ALLOW} or
5057     *            {@link PackageManager#VERIFICATION_REJECT}, then
5058     *            {@code verificationCodeAtTimeout} will default to
5059     *            {@link PackageManager#VERIFICATION_REJECT}.
5060     * @param millisecondsToDelay the amount of time requested for the timeout.
5061     *            Must be positive and less than
5062     *            {@link PackageManager#MAXIMUM_VERIFICATION_TIMEOUT}. If
5063     *            {@code millisecondsToDelay} is out of bounds,
5064     *            {@code millisecondsToDelay} will be set to the closest in
5065     *            bounds value; namely, 0 or
5066     *            {@link PackageManager#MAXIMUM_VERIFICATION_TIMEOUT}.
5067     * @throws SecurityException if the caller does not have the
5068     *            PACKAGE_VERIFICATION_AGENT permission.
5069     */
5070    public abstract void extendVerificationTimeout(int id,
5071            int verificationCodeAtTimeout, long millisecondsToDelay);
5072
5073    /**
5074     * Allows a package listening to the
5075     * {@link Intent#ACTION_INTENT_FILTER_NEEDS_VERIFICATION} intent filter verification
5076     * broadcast to respond to the package manager. The response must include
5077     * the {@code verificationCode} which is one of
5078     * {@link PackageManager#INTENT_FILTER_VERIFICATION_SUCCESS} or
5079     * {@link PackageManager#INTENT_FILTER_VERIFICATION_FAILURE}.
5080     *
5081     * @param verificationId pending package identifier as passed via the
5082     *            {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra.
5083     * @param verificationCode either {@link PackageManager#INTENT_FILTER_VERIFICATION_SUCCESS}
5084     *            or {@link PackageManager#INTENT_FILTER_VERIFICATION_FAILURE}.
5085     * @param failedDomains a list of failed domains if the verificationCode is
5086     *            {@link PackageManager#INTENT_FILTER_VERIFICATION_FAILURE}, otherwise null;
5087     * @throws SecurityException if the caller does not have the
5088     *            INTENT_FILTER_VERIFICATION_AGENT permission.
5089     *
5090     * @hide
5091     */
5092    @SystemApi
5093    public abstract void verifyIntentFilter(int verificationId, int verificationCode,
5094            List<String> failedDomains);
5095
5096    /**
5097     * Get the status of a Domain Verification Result for an IntentFilter. This is
5098     * related to the {@link android.content.IntentFilter#setAutoVerify(boolean)} and
5099     * {@link android.content.IntentFilter#getAutoVerify()}
5100     *
5101     * This is used by the ResolverActivity to change the status depending on what the User select
5102     * in the Disambiguation Dialog and also used by the Settings App for changing the default App
5103     * for a domain.
5104     *
5105     * @param packageName The package name of the Activity associated with the IntentFilter.
5106     * @param userId The user id.
5107     *
5108     * @return The status to set to. This can be
5109     *              {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK} or
5110     *              {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS} or
5111     *              {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER} or
5112     *              {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_UNDEFINED}
5113     *
5114     * @hide
5115     */
5116    @SystemApi
5117    public abstract int getIntentVerificationStatusAsUser(String packageName, @UserIdInt int userId);
5118
5119    /**
5120     * Allow to change the status of a Intent Verification status for all IntentFilter of an App.
5121     * This is related to the {@link android.content.IntentFilter#setAutoVerify(boolean)} and
5122     * {@link android.content.IntentFilter#getAutoVerify()}
5123     *
5124     * This is used by the ResolverActivity to change the status depending on what the User select
5125     * in the Disambiguation Dialog and also used by the Settings App for changing the default App
5126     * for a domain.
5127     *
5128     * @param packageName The package name of the Activity associated with the IntentFilter.
5129     * @param status The status to set to. This can be
5130     *              {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK} or
5131     *              {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS} or
5132     *              {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER}
5133     * @param userId The user id.
5134     *
5135     * @return true if the status has been set. False otherwise.
5136     *
5137     * @hide
5138     */
5139    @SystemApi
5140    public abstract boolean updateIntentVerificationStatusAsUser(String packageName, int status,
5141            @UserIdInt int userId);
5142
5143    /**
5144     * Get the list of IntentFilterVerificationInfo for a specific package and User.
5145     *
5146     * @param packageName the package name. When this parameter is set to a non null value,
5147     *                    the results will be filtered by the package name provided.
5148     *                    Otherwise, there will be no filtering and it will return a list
5149     *                    corresponding for all packages
5150     *
5151     * @return a list of IntentFilterVerificationInfo for a specific package.
5152     *
5153     * @hide
5154     */
5155    @SystemApi
5156    public abstract List<IntentFilterVerificationInfo> getIntentFilterVerifications(
5157            String packageName);
5158
5159    /**
5160     * Get the list of IntentFilter for a specific package.
5161     *
5162     * @param packageName the package name. This parameter is set to a non null value,
5163     *                    the list will contain all the IntentFilter for that package.
5164     *                    Otherwise, the list will be empty.
5165     *
5166     * @return a list of IntentFilter for a specific package.
5167     *
5168     * @hide
5169     */
5170    @SystemApi
5171    public abstract List<IntentFilter> getAllIntentFilters(String packageName);
5172
5173    /**
5174     * Get the default Browser package name for a specific user.
5175     *
5176     * @param userId The user id.
5177     *
5178     * @return the package name of the default Browser for the specified user. If the user id passed
5179     *         is -1 (all users) it will return a null value.
5180     *
5181     * @hide
5182     */
5183    @TestApi
5184    @SystemApi
5185    public abstract String getDefaultBrowserPackageNameAsUser(@UserIdInt int userId);
5186
5187    /**
5188     * Set the default Browser package name for a specific user.
5189     *
5190     * @param packageName The package name of the default Browser.
5191     * @param userId The user id.
5192     *
5193     * @return true if the default Browser for the specified user has been set,
5194     *         otherwise return false. If the user id passed is -1 (all users) this call will not
5195     *         do anything and just return false.
5196     *
5197     * @hide
5198     */
5199    @SystemApi
5200    public abstract boolean setDefaultBrowserPackageNameAsUser(String packageName,
5201            @UserIdInt int userId);
5202
5203    /**
5204     * Change the installer associated with a given package.  There are limitations
5205     * on how the installer package can be changed; in particular:
5206     * <ul>
5207     * <li> A SecurityException will be thrown if <var>installerPackageName</var>
5208     * is not signed with the same certificate as the calling application.
5209     * <li> A SecurityException will be thrown if <var>targetPackage</var> already
5210     * has an installer package, and that installer package is not signed with
5211     * the same certificate as the calling application.
5212     * </ul>
5213     *
5214     * @param targetPackage The installed package whose installer will be changed.
5215     * @param installerPackageName The package name of the new installer.  May be
5216     * null to clear the association.
5217     */
5218    public abstract void setInstallerPackageName(String targetPackage,
5219            String installerPackageName);
5220
5221    /**
5222     * Attempts to delete a package. Since this may take a little while, the
5223     * result will be posted back to the given observer. A deletion will fail if
5224     * the calling context lacks the
5225     * {@link android.Manifest.permission#DELETE_PACKAGES} permission, if the
5226     * named package cannot be found, or if the named package is a system
5227     * package.
5228     *
5229     * @param packageName The name of the package to delete
5230     * @param observer An observer callback to get notified when the package
5231     *            deletion is complete.
5232     *            {@link android.content.pm.IPackageDeleteObserver#packageDeleted}
5233     *            will be called when that happens. observer may be null to
5234     *            indicate that no callback is desired.
5235     * @hide
5236     */
5237    @RequiresPermission(Manifest.permission.DELETE_PACKAGES)
5238    public abstract void deletePackage(String packageName, IPackageDeleteObserver observer,
5239            @DeleteFlags int flags);
5240
5241    /**
5242     * Attempts to delete a package. Since this may take a little while, the
5243     * result will be posted back to the given observer. A deletion will fail if
5244     * the named package cannot be found, or if the named package is a system
5245     * package.
5246     *
5247     * @param packageName The name of the package to delete
5248     * @param observer An observer callback to get notified when the package
5249     *            deletion is complete.
5250     *            {@link android.content.pm.IPackageDeleteObserver#packageDeleted}
5251     *            will be called when that happens. observer may be null to
5252     *            indicate that no callback is desired.
5253     * @param userId The user Id
5254     * @hide
5255     */
5256    @RequiresPermission(anyOf = {
5257            Manifest.permission.DELETE_PACKAGES,
5258            Manifest.permission.INTERACT_ACROSS_USERS_FULL})
5259    public abstract void deletePackageAsUser(@NonNull String packageName,
5260            IPackageDeleteObserver observer, @DeleteFlags int flags, @UserIdInt int userId);
5261
5262    /**
5263     * Retrieve the package name of the application that installed a package. This identifies
5264     * which market the package came from.
5265     *
5266     * @param packageName The name of the package to query
5267     */
5268    public abstract String getInstallerPackageName(String packageName);
5269
5270    /**
5271     * Attempts to clear the user data directory of an application.
5272     * Since this may take a little while, the result will
5273     * be posted back to the given observer.  A deletion will fail if the
5274     * named package cannot be found, or if the named package is a "system package".
5275     *
5276     * @param packageName The name of the package
5277     * @param observer An observer callback to get notified when the operation is finished
5278     * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)}
5279     * will be called when that happens.  observer may be null to indicate that
5280     * no callback is desired.
5281     *
5282     * @hide
5283     */
5284    public abstract void clearApplicationUserData(String packageName,
5285            IPackageDataObserver observer);
5286    /**
5287     * Attempts to delete the cache files associated with an application.
5288     * Since this may take a little while, the result will
5289     * be posted back to the given observer.  A deletion will fail if the calling context
5290     * lacks the {@link android.Manifest.permission#DELETE_CACHE_FILES} permission, if the
5291     * named package cannot be found, or if the named package is a "system package".
5292     *
5293     * @param packageName The name of the package to delete
5294     * @param observer An observer callback to get notified when the cache file deletion
5295     * is complete.
5296     * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)}
5297     * will be called when that happens.  observer may be null to indicate that
5298     * no callback is desired.
5299     *
5300     * @hide
5301     */
5302    public abstract void deleteApplicationCacheFiles(String packageName,
5303            IPackageDataObserver observer);
5304
5305    /**
5306     * Attempts to delete the cache files associated with an application for a given user. Since
5307     * this may take a little while, the result will be posted back to the given observer. A
5308     * deletion will fail if the calling context lacks the
5309     * {@link android.Manifest.permission#DELETE_CACHE_FILES} permission, if the named package
5310     * cannot be found, or if the named package is a "system package". If {@code userId} does not
5311     * belong to the calling user, the caller must have
5312     * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} permission.
5313     *
5314     * @param packageName The name of the package to delete
5315     * @param userId the user for which the cache files needs to be deleted
5316     * @param observer An observer callback to get notified when the cache file deletion is
5317     *            complete.
5318     *            {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)}
5319     *            will be called when that happens. observer may be null to indicate that no
5320     *            callback is desired.
5321     * @hide
5322     */
5323    public abstract void deleteApplicationCacheFilesAsUser(String packageName, int userId,
5324            IPackageDataObserver observer);
5325
5326    /**
5327     * Free storage by deleting LRU sorted list of cache files across
5328     * all applications. If the currently available free storage
5329     * on the device is greater than or equal to the requested
5330     * free storage, no cache files are cleared. If the currently
5331     * available storage on the device is less than the requested
5332     * free storage, some or all of the cache files across
5333     * all applications are deleted (based on last accessed time)
5334     * to increase the free storage space on the device to
5335     * the requested value. There is no guarantee that clearing all
5336     * the cache files from all applications will clear up
5337     * enough storage to achieve the desired value.
5338     * @param freeStorageSize The number of bytes of storage to be
5339     * freed by the system. Say if freeStorageSize is XX,
5340     * and the current free storage is YY,
5341     * if XX is less than YY, just return. if not free XX-YY number
5342     * of bytes if possible.
5343     * @param observer call back used to notify when
5344     * the operation is completed
5345     *
5346     * @hide
5347     */
5348    public void freeStorageAndNotify(long freeStorageSize, IPackageDataObserver observer) {
5349        freeStorageAndNotify(null, freeStorageSize, observer);
5350    }
5351
5352    /** {@hide} */
5353    public abstract void freeStorageAndNotify(String volumeUuid, long freeStorageSize,
5354            IPackageDataObserver observer);
5355
5356    /**
5357     * Free storage by deleting LRU sorted list of cache files across
5358     * all applications. If the currently available free storage
5359     * on the device is greater than or equal to the requested
5360     * free storage, no cache files are cleared. If the currently
5361     * available storage on the device is less than the requested
5362     * free storage, some or all of the cache files across
5363     * all applications are deleted (based on last accessed time)
5364     * to increase the free storage space on the device to
5365     * the requested value. There is no guarantee that clearing all
5366     * the cache files from all applications will clear up
5367     * enough storage to achieve the desired value.
5368     * @param freeStorageSize The number of bytes of storage to be
5369     * freed by the system. Say if freeStorageSize is XX,
5370     * and the current free storage is YY,
5371     * if XX is less than YY, just return. if not free XX-YY number
5372     * of bytes if possible.
5373     * @param pi IntentSender call back used to
5374     * notify when the operation is completed.May be null
5375     * to indicate that no call back is desired.
5376     *
5377     * @hide
5378     */
5379    public void freeStorage(long freeStorageSize, IntentSender pi) {
5380        freeStorage(null, freeStorageSize, pi);
5381    }
5382
5383    /** {@hide} */
5384    public abstract void freeStorage(String volumeUuid, long freeStorageSize, IntentSender pi);
5385
5386    /**
5387     * Retrieve the size information for a package.
5388     * Since this may take a little while, the result will
5389     * be posted back to the given observer.  The calling context
5390     * should have the {@link android.Manifest.permission#GET_PACKAGE_SIZE} permission.
5391     *
5392     * @param packageName The name of the package whose size information is to be retrieved
5393     * @param userId The user whose size information should be retrieved.
5394     * @param observer An observer callback to get notified when the operation
5395     * is complete.
5396     * {@link android.content.pm.IPackageStatsObserver#onGetStatsCompleted(PackageStats, boolean)}
5397     * The observer's callback is invoked with a PackageStats object(containing the
5398     * code, data and cache sizes of the package) and a boolean value representing
5399     * the status of the operation. observer may be null to indicate that
5400     * no callback is desired.
5401     *
5402     * @hide
5403     */
5404    public abstract void getPackageSizeInfoAsUser(String packageName, @UserIdInt int userId,
5405            IPackageStatsObserver observer);
5406
5407    /**
5408     * Like {@link #getPackageSizeInfoAsUser(String, int, IPackageStatsObserver)}, but
5409     * returns the size for the calling user.
5410     *
5411     * @hide
5412     */
5413    public void getPackageSizeInfo(String packageName, IPackageStatsObserver observer) {
5414        getPackageSizeInfoAsUser(packageName, UserHandle.myUserId(), observer);
5415    }
5416
5417    /**
5418     * @deprecated This function no longer does anything; it was an old
5419     * approach to managing preferred activities, which has been superseded
5420     * by (and conflicts with) the modern activity-based preferences.
5421     */
5422    @Deprecated
5423    public abstract void addPackageToPreferred(String packageName);
5424
5425    /**
5426     * @deprecated This function no longer does anything; it was an old
5427     * approach to managing preferred activities, which has been superseded
5428     * by (and conflicts with) the modern activity-based preferences.
5429     */
5430    @Deprecated
5431    public abstract void removePackageFromPreferred(String packageName);
5432
5433    /**
5434     * Retrieve the list of all currently configured preferred packages.  The
5435     * first package on the list is the most preferred, the last is the
5436     * least preferred.
5437     *
5438     * @param flags Additional option flags. Use any combination of
5439     *         {@link #GET_ACTIVITIES}, {@link #GET_CONFIGURATIONS},
5440     *         {@link #GET_GIDS}, {@link #GET_INSTRUMENTATION},
5441     *         {@link #GET_INTENT_FILTERS}, {@link #GET_META_DATA},
5442     *         {@link #GET_PERMISSIONS}, {@link #GET_PROVIDERS},
5443     *         {@link #GET_RECEIVERS}, {@link #GET_SERVICES},
5444     *         {@link #GET_SHARED_LIBRARY_FILES}, {@link #GET_SIGNATURES},
5445     *         {@link #GET_URI_PERMISSION_PATTERNS}, {@link #GET_UNINSTALLED_PACKAGES},
5446     *         {@link #MATCH_DISABLED_COMPONENTS}, {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
5447     *         {@link #MATCH_UNINSTALLED_PACKAGES}
5448     *         to modify the data returned.
5449     *
5450     * @return A List of PackageInfo objects, one for each preferred application,
5451     *         in order of preference.
5452     *
5453     * @see #GET_ACTIVITIES
5454     * @see #GET_CONFIGURATIONS
5455     * @see #GET_GIDS
5456     * @see #GET_INSTRUMENTATION
5457     * @see #GET_INTENT_FILTERS
5458     * @see #GET_META_DATA
5459     * @see #GET_PERMISSIONS
5460     * @see #GET_PROVIDERS
5461     * @see #GET_RECEIVERS
5462     * @see #GET_SERVICES
5463     * @see #GET_SHARED_LIBRARY_FILES
5464     * @see #GET_SIGNATURES
5465     * @see #GET_URI_PERMISSION_PATTERNS
5466     * @see #MATCH_DISABLED_COMPONENTS
5467     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
5468     * @see #MATCH_UNINSTALLED_PACKAGES
5469     */
5470    public abstract List<PackageInfo> getPreferredPackages(@PackageInfoFlags int flags);
5471
5472    /**
5473     * @deprecated This is a protected API that should not have been available
5474     * to third party applications.  It is the platform's responsibility for
5475     * assigning preferred activities and this cannot be directly modified.
5476     *
5477     * Add a new preferred activity mapping to the system.  This will be used
5478     * to automatically select the given activity component when
5479     * {@link Context#startActivity(Intent) Context.startActivity()} finds
5480     * multiple matching activities and also matches the given filter.
5481     *
5482     * @param filter The set of intents under which this activity will be
5483     * made preferred.
5484     * @param match The IntentFilter match category that this preference
5485     * applies to.
5486     * @param set The set of activities that the user was picking from when
5487     * this preference was made.
5488     * @param activity The component name of the activity that is to be
5489     * preferred.
5490     */
5491    @Deprecated
5492    public abstract void addPreferredActivity(IntentFilter filter, int match,
5493            ComponentName[] set, ComponentName activity);
5494
5495    /**
5496     * Same as {@link #addPreferredActivity(IntentFilter, int,
5497            ComponentName[], ComponentName)}, but with a specific userId to apply the preference
5498            to.
5499     * @hide
5500     */
5501    public void addPreferredActivityAsUser(IntentFilter filter, int match,
5502            ComponentName[] set, ComponentName activity, @UserIdInt int userId) {
5503        throw new RuntimeException("Not implemented. Must override in a subclass.");
5504    }
5505
5506    /**
5507     * @deprecated This is a protected API that should not have been available
5508     * to third party applications.  It is the platform's responsibility for
5509     * assigning preferred activities and this cannot be directly modified.
5510     *
5511     * Replaces an existing preferred activity mapping to the system, and if that were not present
5512     * adds a new preferred activity.  This will be used
5513     * to automatically select the given activity component when
5514     * {@link Context#startActivity(Intent) Context.startActivity()} finds
5515     * multiple matching activities and also matches the given filter.
5516     *
5517     * @param filter The set of intents under which this activity will be
5518     * made preferred.
5519     * @param match The IntentFilter match category that this preference
5520     * applies to.
5521     * @param set The set of activities that the user was picking from when
5522     * this preference was made.
5523     * @param activity The component name of the activity that is to be
5524     * preferred.
5525     * @hide
5526     */
5527    @Deprecated
5528    public abstract void replacePreferredActivity(IntentFilter filter, int match,
5529            ComponentName[] set, ComponentName activity);
5530
5531    /**
5532     * @hide
5533     */
5534    @Deprecated
5535    public void replacePreferredActivityAsUser(IntentFilter filter, int match,
5536           ComponentName[] set, ComponentName activity, @UserIdInt int userId) {
5537        throw new RuntimeException("Not implemented. Must override in a subclass.");
5538    }
5539
5540    /**
5541     * Remove all preferred activity mappings, previously added with
5542     * {@link #addPreferredActivity}, from the
5543     * system whose activities are implemented in the given package name.
5544     * An application can only clear its own package(s).
5545     *
5546     * @param packageName The name of the package whose preferred activity
5547     * mappings are to be removed.
5548     */
5549    public abstract void clearPackagePreferredActivities(String packageName);
5550
5551    /**
5552     * Retrieve all preferred activities, previously added with
5553     * {@link #addPreferredActivity}, that are
5554     * currently registered with the system.
5555     *
5556     * @param outFilters A required list in which to place the filters of all of the
5557     * preferred activities.
5558     * @param outActivities A required list in which to place the component names of
5559     * all of the preferred activities.
5560     * @param packageName An optional package in which you would like to limit
5561     * the list.  If null, all activities will be returned; if non-null, only
5562     * those activities in the given package are returned.
5563     *
5564     * @return Returns the total number of registered preferred activities
5565     * (the number of distinct IntentFilter records, not the number of unique
5566     * activity components) that were found.
5567     */
5568    public abstract int getPreferredActivities(@NonNull List<IntentFilter> outFilters,
5569            @NonNull List<ComponentName> outActivities, String packageName);
5570
5571    /**
5572     * Ask for the set of available 'home' activities and the current explicit
5573     * default, if any.
5574     * @hide
5575     */
5576    public abstract ComponentName getHomeActivities(List<ResolveInfo> outActivities);
5577
5578    /**
5579     * Set the enabled setting for a package component (activity, receiver, service, provider).
5580     * This setting will override any enabled state which may have been set by the component in its
5581     * manifest.
5582     *
5583     * @param componentName The component to enable
5584     * @param newState The new enabled state for the component.  The legal values for this state
5585     *                 are:
5586     *                   {@link #COMPONENT_ENABLED_STATE_ENABLED},
5587     *                   {@link #COMPONENT_ENABLED_STATE_DISABLED}
5588     *                   and
5589     *                   {@link #COMPONENT_ENABLED_STATE_DEFAULT}
5590     *                 The last one removes the setting, thereby restoring the component's state to
5591     *                 whatever was set in it's manifest (or enabled, by default).
5592     * @param flags Optional behavior flags: {@link #DONT_KILL_APP} or 0.
5593     */
5594    public abstract void setComponentEnabledSetting(ComponentName componentName,
5595            int newState, int flags);
5596
5597    /**
5598     * Return the enabled setting for a package component (activity,
5599     * receiver, service, provider).  This returns the last value set by
5600     * {@link #setComponentEnabledSetting(ComponentName, int, int)}; in most
5601     * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since
5602     * the value originally specified in the manifest has not been modified.
5603     *
5604     * @param componentName The component to retrieve.
5605     * @return Returns the current enabled state for the component.  May
5606     * be one of {@link #COMPONENT_ENABLED_STATE_ENABLED},
5607     * {@link #COMPONENT_ENABLED_STATE_DISABLED}, or
5608     * {@link #COMPONENT_ENABLED_STATE_DEFAULT}.  The last one means the
5609     * component's enabled state is based on the original information in
5610     * the manifest as found in {@link ComponentInfo}.
5611     */
5612    public abstract int getComponentEnabledSetting(ComponentName componentName);
5613
5614    /**
5615     * Set the enabled setting for an application
5616     * This setting will override any enabled state which may have been set by the application in
5617     * its manifest.  It also overrides the enabled state set in the manifest for any of the
5618     * application's components.  It does not override any enabled state set by
5619     * {@link #setComponentEnabledSetting} for any of the application's components.
5620     *
5621     * @param packageName The package name of the application to enable
5622     * @param newState The new enabled state for the component.  The legal values for this state
5623     *                 are:
5624     *                   {@link #COMPONENT_ENABLED_STATE_ENABLED},
5625     *                   {@link #COMPONENT_ENABLED_STATE_DISABLED}
5626     *                   and
5627     *                   {@link #COMPONENT_ENABLED_STATE_DEFAULT}
5628     *                 The last one removes the setting, thereby restoring the applications's state to
5629     *                 whatever was set in its manifest (or enabled, by default).
5630     * @param flags Optional behavior flags: {@link #DONT_KILL_APP} or 0.
5631     */
5632    public abstract void setApplicationEnabledSetting(String packageName,
5633            int newState, int flags);
5634
5635    /**
5636     * Return the enabled setting for an application. This returns
5637     * the last value set by
5638     * {@link #setApplicationEnabledSetting(String, int, int)}; in most
5639     * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since
5640     * the value originally specified in the manifest has not been modified.
5641     *
5642     * @param packageName The package name of the application to retrieve.
5643     * @return Returns the current enabled state for the application.  May
5644     * be one of {@link #COMPONENT_ENABLED_STATE_ENABLED},
5645     * {@link #COMPONENT_ENABLED_STATE_DISABLED}, or
5646     * {@link #COMPONENT_ENABLED_STATE_DEFAULT}.  The last one means the
5647     * application's enabled state is based on the original information in
5648     * the manifest as found in {@link ApplicationInfo}.
5649     * @throws IllegalArgumentException if the named package does not exist.
5650     */
5651    public abstract int getApplicationEnabledSetting(String packageName);
5652
5653    /**
5654     * Flush the package restrictions for a given user to disk. This forces the package restrictions
5655     * like component and package enabled settings to be written to disk and avoids the delay that
5656     * is otherwise present when changing those settings.
5657     *
5658     * @param userId Ther userId of the user whose restrictions are to be flushed.
5659     * @hide
5660     */
5661    public abstract void flushPackageRestrictionsAsUser(int userId);
5662
5663    /**
5664     * Puts the package in a hidden state, which is almost like an uninstalled state,
5665     * making the package unavailable, but it doesn't remove the data or the actual
5666     * package file. Application can be unhidden by either resetting the hidden state
5667     * or by installing it, such as with {@link #installExistingPackage(String)}
5668     * @hide
5669     */
5670    public abstract boolean setApplicationHiddenSettingAsUser(String packageName, boolean hidden,
5671            UserHandle userHandle);
5672
5673    /**
5674     * Returns the hidden state of a package.
5675     * @see #setApplicationHiddenSettingAsUser(String, boolean, UserHandle)
5676     * @hide
5677     */
5678    public abstract boolean getApplicationHiddenSettingAsUser(String packageName,
5679            UserHandle userHandle);
5680
5681    /**
5682     * Return whether the device has been booted into safe mode.
5683     */
5684    public abstract boolean isSafeMode();
5685
5686    /**
5687     * Adds a listener for permission changes for installed packages.
5688     *
5689     * @param listener The listener to add.
5690     *
5691     * @hide
5692     */
5693    @SystemApi
5694    @RequiresPermission(Manifest.permission.OBSERVE_GRANT_REVOKE_PERMISSIONS)
5695    public abstract void addOnPermissionsChangeListener(OnPermissionsChangedListener listener);
5696
5697    /**
5698     * Remvoes a listener for permission changes for installed packages.
5699     *
5700     * @param listener The listener to remove.
5701     *
5702     * @hide
5703     */
5704    @SystemApi
5705    public abstract void removeOnPermissionsChangeListener(OnPermissionsChangedListener listener);
5706
5707    /**
5708     * Return the {@link KeySet} associated with the String alias for this
5709     * application.
5710     *
5711     * @param alias The alias for a given {@link KeySet} as defined in the
5712     *        application's AndroidManifest.xml.
5713     * @hide
5714     */
5715    public abstract KeySet getKeySetByAlias(String packageName, String alias);
5716
5717    /** Return the signing {@link KeySet} for this application.
5718     * @hide
5719     */
5720    public abstract KeySet getSigningKeySet(String packageName);
5721
5722    /**
5723     * Return whether the package denoted by packageName has been signed by all
5724     * of the keys specified by the {@link KeySet} ks.  This will return true if
5725     * the package has been signed by additional keys (a superset) as well.
5726     * Compare to {@link #isSignedByExactly(String packageName, KeySet ks)}.
5727     * @hide
5728     */
5729    public abstract boolean isSignedBy(String packageName, KeySet ks);
5730
5731    /**
5732     * Return whether the package denoted by packageName has been signed by all
5733     * of, and only, the keys specified by the {@link KeySet} ks. Compare to
5734     * {@link #isSignedBy(String packageName, KeySet ks)}.
5735     * @hide
5736     */
5737    public abstract boolean isSignedByExactly(String packageName, KeySet ks);
5738
5739    /**
5740     * Puts the package in a suspended state, where attempts at starting activities are denied.
5741     *
5742     * <p>It doesn't remove the data or the actual package file. The application notifications
5743     * will be hidden, the application will not show up in recents, will not be able to show
5744     * toasts or dialogs or ring the device.
5745     *
5746     * <p>The package must already be installed. If the package is uninstalled while suspended
5747     * the package will no longer be suspended.
5748     *
5749     * @param packageNames The names of the packages to set the suspended status.
5750     * @param suspended If set to {@code true} than the packages will be suspended, if set to
5751     * {@code false} the packages will be unsuspended.
5752     * @param userId The user id.
5753     *
5754     * @return an array of package names for which the suspended status is not set as requested in
5755     * this method.
5756     *
5757     * @hide
5758     */
5759    public abstract String[] setPackagesSuspendedAsUser(
5760            String[] packageNames, boolean suspended, @UserIdInt int userId);
5761
5762    /**
5763     * @see #setPackageSuspendedAsUser(String, boolean, int)
5764     * @param packageName The name of the package to get the suspended status of.
5765     * @param userId The user id.
5766     * @return {@code true} if the package is suspended or {@code false} if the package is not
5767     * suspended or could not be found.
5768     * @hide
5769     */
5770    public abstract boolean isPackageSuspendedForUser(String packageName, int userId);
5771
5772    /**
5773     * Provide a hint of what the {@link ApplicationInfo#category} value should
5774     * be for the given package.
5775     * <p>
5776     * This hint can only be set by the app which installed this package, as
5777     * determined by {@link #getInstallerPackageName(String)}.
5778     */
5779    public abstract void setApplicationCategoryHint(String packageName,
5780            @ApplicationInfo.Category int categoryHint);
5781
5782    /** {@hide} */
5783    public static boolean isMoveStatusFinished(int status) {
5784        return (status < 0 || status > 100);
5785    }
5786
5787    /** {@hide} */
5788    public static abstract class MoveCallback {
5789        public void onCreated(int moveId, Bundle extras) {}
5790        public abstract void onStatusChanged(int moveId, int status, long estMillis);
5791    }
5792
5793    /** {@hide} */
5794    public abstract int getMoveStatus(int moveId);
5795
5796    /** {@hide} */
5797    public abstract void registerMoveCallback(MoveCallback callback, Handler handler);
5798    /** {@hide} */
5799    public abstract void unregisterMoveCallback(MoveCallback callback);
5800
5801    /** {@hide} */
5802    public abstract int movePackage(String packageName, VolumeInfo vol);
5803    /** {@hide} */
5804    public abstract @Nullable VolumeInfo getPackageCurrentVolume(ApplicationInfo app);
5805    /** {@hide} */
5806    public abstract @NonNull List<VolumeInfo> getPackageCandidateVolumes(ApplicationInfo app);
5807
5808    /** {@hide} */
5809    public abstract int movePrimaryStorage(VolumeInfo vol);
5810    /** {@hide} */
5811    public abstract @Nullable VolumeInfo getPrimaryStorageCurrentVolume();
5812    /** {@hide} */
5813    public abstract @NonNull List<VolumeInfo> getPrimaryStorageCandidateVolumes();
5814
5815    /**
5816     * Returns the device identity that verifiers can use to associate their scheme to a particular
5817     * device. This should not be used by anything other than a package verifier.
5818     *
5819     * @return identity that uniquely identifies current device
5820     * @hide
5821     */
5822    public abstract VerifierDeviceIdentity getVerifierDeviceIdentity();
5823
5824    /**
5825     * Returns true if the device is upgrading, such as first boot after OTA.
5826     *
5827     * @hide
5828     */
5829    public abstract boolean isUpgrade();
5830
5831    /**
5832     * Return interface that offers the ability to install, upgrade, and remove
5833     * applications on the device.
5834     */
5835    public abstract @NonNull PackageInstaller getPackageInstaller();
5836
5837    /**
5838     * Adds a {@code CrossProfileIntentFilter}. After calling this method all
5839     * intents sent from the user with id sourceUserId can also be be resolved
5840     * by activities in the user with id targetUserId if they match the
5841     * specified intent filter.
5842     *
5843     * @param filter The {@link IntentFilter} the intent has to match
5844     * @param sourceUserId The source user id.
5845     * @param targetUserId The target user id.
5846     * @param flags The possible values are {@link #SKIP_CURRENT_PROFILE} and
5847     *            {@link #ONLY_IF_NO_MATCH_FOUND}.
5848     * @hide
5849     */
5850    public abstract void addCrossProfileIntentFilter(IntentFilter filter, int sourceUserId,
5851            int targetUserId, int flags);
5852
5853    /**
5854     * Clearing {@code CrossProfileIntentFilter}s which have the specified user
5855     * as their source, and have been set by the app calling this method.
5856     *
5857     * @param sourceUserId The source user id.
5858     * @hide
5859     */
5860    public abstract void clearCrossProfileIntentFilters(int sourceUserId);
5861
5862    /**
5863     * @hide
5864     */
5865    public abstract Drawable loadItemIcon(PackageItemInfo itemInfo, ApplicationInfo appInfo);
5866
5867    /**
5868     * @hide
5869     */
5870    public abstract Drawable loadUnbadgedItemIcon(PackageItemInfo itemInfo, ApplicationInfo appInfo);
5871
5872    /** {@hide} */
5873    public abstract boolean isPackageAvailable(String packageName);
5874
5875    /** {@hide} */
5876    public static String installStatusToString(int status, String msg) {
5877        final String str = installStatusToString(status);
5878        if (msg != null) {
5879            return str + ": " + msg;
5880        } else {
5881            return str;
5882        }
5883    }
5884
5885    /** {@hide} */
5886    public static String installStatusToString(int status) {
5887        switch (status) {
5888            case INSTALL_SUCCEEDED: return "INSTALL_SUCCEEDED";
5889            case INSTALL_FAILED_ALREADY_EXISTS: return "INSTALL_FAILED_ALREADY_EXISTS";
5890            case INSTALL_FAILED_INVALID_APK: return "INSTALL_FAILED_INVALID_APK";
5891            case INSTALL_FAILED_INVALID_URI: return "INSTALL_FAILED_INVALID_URI";
5892            case INSTALL_FAILED_INSUFFICIENT_STORAGE: return "INSTALL_FAILED_INSUFFICIENT_STORAGE";
5893            case INSTALL_FAILED_DUPLICATE_PACKAGE: return "INSTALL_FAILED_DUPLICATE_PACKAGE";
5894            case INSTALL_FAILED_NO_SHARED_USER: return "INSTALL_FAILED_NO_SHARED_USER";
5895            case INSTALL_FAILED_UPDATE_INCOMPATIBLE: return "INSTALL_FAILED_UPDATE_INCOMPATIBLE";
5896            case INSTALL_FAILED_SHARED_USER_INCOMPATIBLE: return "INSTALL_FAILED_SHARED_USER_INCOMPATIBLE";
5897            case INSTALL_FAILED_MISSING_SHARED_LIBRARY: return "INSTALL_FAILED_MISSING_SHARED_LIBRARY";
5898            case INSTALL_FAILED_REPLACE_COULDNT_DELETE: return "INSTALL_FAILED_REPLACE_COULDNT_DELETE";
5899            case INSTALL_FAILED_DEXOPT: return "INSTALL_FAILED_DEXOPT";
5900            case INSTALL_FAILED_OLDER_SDK: return "INSTALL_FAILED_OLDER_SDK";
5901            case INSTALL_FAILED_CONFLICTING_PROVIDER: return "INSTALL_FAILED_CONFLICTING_PROVIDER";
5902            case INSTALL_FAILED_NEWER_SDK: return "INSTALL_FAILED_NEWER_SDK";
5903            case INSTALL_FAILED_TEST_ONLY: return "INSTALL_FAILED_TEST_ONLY";
5904            case INSTALL_FAILED_CPU_ABI_INCOMPATIBLE: return "INSTALL_FAILED_CPU_ABI_INCOMPATIBLE";
5905            case INSTALL_FAILED_MISSING_FEATURE: return "INSTALL_FAILED_MISSING_FEATURE";
5906            case INSTALL_FAILED_CONTAINER_ERROR: return "INSTALL_FAILED_CONTAINER_ERROR";
5907            case INSTALL_FAILED_INVALID_INSTALL_LOCATION: return "INSTALL_FAILED_INVALID_INSTALL_LOCATION";
5908            case INSTALL_FAILED_MEDIA_UNAVAILABLE: return "INSTALL_FAILED_MEDIA_UNAVAILABLE";
5909            case INSTALL_FAILED_VERIFICATION_TIMEOUT: return "INSTALL_FAILED_VERIFICATION_TIMEOUT";
5910            case INSTALL_FAILED_VERIFICATION_FAILURE: return "INSTALL_FAILED_VERIFICATION_FAILURE";
5911            case INSTALL_FAILED_PACKAGE_CHANGED: return "INSTALL_FAILED_PACKAGE_CHANGED";
5912            case INSTALL_FAILED_UID_CHANGED: return "INSTALL_FAILED_UID_CHANGED";
5913            case INSTALL_FAILED_VERSION_DOWNGRADE: return "INSTALL_FAILED_VERSION_DOWNGRADE";
5914            case INSTALL_PARSE_FAILED_NOT_APK: return "INSTALL_PARSE_FAILED_NOT_APK";
5915            case INSTALL_PARSE_FAILED_BAD_MANIFEST: return "INSTALL_PARSE_FAILED_BAD_MANIFEST";
5916            case INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION: return "INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION";
5917            case INSTALL_PARSE_FAILED_NO_CERTIFICATES: return "INSTALL_PARSE_FAILED_NO_CERTIFICATES";
5918            case INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES: return "INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES";
5919            case INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING: return "INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING";
5920            case INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME: return "INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME";
5921            case INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID: return "INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID";
5922            case INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: return "INSTALL_PARSE_FAILED_MANIFEST_MALFORMED";
5923            case INSTALL_PARSE_FAILED_MANIFEST_EMPTY: return "INSTALL_PARSE_FAILED_MANIFEST_EMPTY";
5924            case INSTALL_FAILED_INTERNAL_ERROR: return "INSTALL_FAILED_INTERNAL_ERROR";
5925            case INSTALL_FAILED_USER_RESTRICTED: return "INSTALL_FAILED_USER_RESTRICTED";
5926            case INSTALL_FAILED_DUPLICATE_PERMISSION: return "INSTALL_FAILED_DUPLICATE_PERMISSION";
5927            case INSTALL_FAILED_NO_MATCHING_ABIS: return "INSTALL_FAILED_NO_MATCHING_ABIS";
5928            case INSTALL_FAILED_ABORTED: return "INSTALL_FAILED_ABORTED";
5929            default: return Integer.toString(status);
5930        }
5931    }
5932
5933    /** {@hide} */
5934    public static int installStatusToPublicStatus(int status) {
5935        switch (status) {
5936            case INSTALL_SUCCEEDED: return PackageInstaller.STATUS_SUCCESS;
5937            case INSTALL_FAILED_ALREADY_EXISTS: return PackageInstaller.STATUS_FAILURE_CONFLICT;
5938            case INSTALL_FAILED_INVALID_APK: return PackageInstaller.STATUS_FAILURE_INVALID;
5939            case INSTALL_FAILED_INVALID_URI: return PackageInstaller.STATUS_FAILURE_INVALID;
5940            case INSTALL_FAILED_INSUFFICIENT_STORAGE: return PackageInstaller.STATUS_FAILURE_STORAGE;
5941            case INSTALL_FAILED_DUPLICATE_PACKAGE: return PackageInstaller.STATUS_FAILURE_CONFLICT;
5942            case INSTALL_FAILED_NO_SHARED_USER: return PackageInstaller.STATUS_FAILURE_CONFLICT;
5943            case INSTALL_FAILED_UPDATE_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_CONFLICT;
5944            case INSTALL_FAILED_SHARED_USER_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_CONFLICT;
5945            case INSTALL_FAILED_MISSING_SHARED_LIBRARY: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
5946            case INSTALL_FAILED_REPLACE_COULDNT_DELETE: return PackageInstaller.STATUS_FAILURE_CONFLICT;
5947            case INSTALL_FAILED_DEXOPT: return PackageInstaller.STATUS_FAILURE_INVALID;
5948            case INSTALL_FAILED_OLDER_SDK: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
5949            case INSTALL_FAILED_CONFLICTING_PROVIDER: return PackageInstaller.STATUS_FAILURE_CONFLICT;
5950            case INSTALL_FAILED_NEWER_SDK: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
5951            case INSTALL_FAILED_TEST_ONLY: return PackageInstaller.STATUS_FAILURE_INVALID;
5952            case INSTALL_FAILED_CPU_ABI_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
5953            case INSTALL_FAILED_MISSING_FEATURE: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
5954            case INSTALL_FAILED_CONTAINER_ERROR: return PackageInstaller.STATUS_FAILURE_STORAGE;
5955            case INSTALL_FAILED_INVALID_INSTALL_LOCATION: return PackageInstaller.STATUS_FAILURE_STORAGE;
5956            case INSTALL_FAILED_MEDIA_UNAVAILABLE: return PackageInstaller.STATUS_FAILURE_STORAGE;
5957            case INSTALL_FAILED_VERIFICATION_TIMEOUT: return PackageInstaller.STATUS_FAILURE_ABORTED;
5958            case INSTALL_FAILED_VERIFICATION_FAILURE: return PackageInstaller.STATUS_FAILURE_ABORTED;
5959            case INSTALL_FAILED_PACKAGE_CHANGED: return PackageInstaller.STATUS_FAILURE_INVALID;
5960            case INSTALL_FAILED_UID_CHANGED: return PackageInstaller.STATUS_FAILURE_INVALID;
5961            case INSTALL_FAILED_VERSION_DOWNGRADE: return PackageInstaller.STATUS_FAILURE_INVALID;
5962            case INSTALL_FAILED_PERMISSION_MODEL_DOWNGRADE: return PackageInstaller.STATUS_FAILURE_INVALID;
5963            case INSTALL_PARSE_FAILED_NOT_APK: return PackageInstaller.STATUS_FAILURE_INVALID;
5964            case INSTALL_PARSE_FAILED_BAD_MANIFEST: return PackageInstaller.STATUS_FAILURE_INVALID;
5965            case INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION: return PackageInstaller.STATUS_FAILURE_INVALID;
5966            case INSTALL_PARSE_FAILED_NO_CERTIFICATES: return PackageInstaller.STATUS_FAILURE_INVALID;
5967            case INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES: return PackageInstaller.STATUS_FAILURE_INVALID;
5968            case INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING: return PackageInstaller.STATUS_FAILURE_INVALID;
5969            case INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME: return PackageInstaller.STATUS_FAILURE_INVALID;
5970            case INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID: return PackageInstaller.STATUS_FAILURE_INVALID;
5971            case INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: return PackageInstaller.STATUS_FAILURE_INVALID;
5972            case INSTALL_PARSE_FAILED_MANIFEST_EMPTY: return PackageInstaller.STATUS_FAILURE_INVALID;
5973            case INSTALL_FAILED_INTERNAL_ERROR: return PackageInstaller.STATUS_FAILURE;
5974            case INSTALL_FAILED_USER_RESTRICTED: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
5975            case INSTALL_FAILED_DUPLICATE_PERMISSION: return PackageInstaller.STATUS_FAILURE_CONFLICT;
5976            case INSTALL_FAILED_NO_MATCHING_ABIS: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
5977            case INSTALL_FAILED_ABORTED: return PackageInstaller.STATUS_FAILURE_ABORTED;
5978            default: return PackageInstaller.STATUS_FAILURE;
5979        }
5980    }
5981
5982    /** {@hide} */
5983    public static String deleteStatusToString(int status, String msg) {
5984        final String str = deleteStatusToString(status);
5985        if (msg != null) {
5986            return str + ": " + msg;
5987        } else {
5988            return str;
5989        }
5990    }
5991
5992    /** {@hide} */
5993    public static String deleteStatusToString(int status) {
5994        switch (status) {
5995            case DELETE_SUCCEEDED: return "DELETE_SUCCEEDED";
5996            case DELETE_FAILED_INTERNAL_ERROR: return "DELETE_FAILED_INTERNAL_ERROR";
5997            case DELETE_FAILED_DEVICE_POLICY_MANAGER: return "DELETE_FAILED_DEVICE_POLICY_MANAGER";
5998            case DELETE_FAILED_USER_RESTRICTED: return "DELETE_FAILED_USER_RESTRICTED";
5999            case DELETE_FAILED_OWNER_BLOCKED: return "DELETE_FAILED_OWNER_BLOCKED";
6000            case DELETE_FAILED_ABORTED: return "DELETE_FAILED_ABORTED";
6001            case DELETE_FAILED_USED_SHARED_LIBRARY: return "DELETE_FAILED_USED_SHARED_LIBRARY";
6002            default: return Integer.toString(status);
6003        }
6004    }
6005
6006    /** {@hide} */
6007    public static int deleteStatusToPublicStatus(int status) {
6008        switch (status) {
6009            case DELETE_SUCCEEDED: return PackageInstaller.STATUS_SUCCESS;
6010            case DELETE_FAILED_INTERNAL_ERROR: return PackageInstaller.STATUS_FAILURE;
6011            case DELETE_FAILED_DEVICE_POLICY_MANAGER: return PackageInstaller.STATUS_FAILURE_BLOCKED;
6012            case DELETE_FAILED_USER_RESTRICTED: return PackageInstaller.STATUS_FAILURE_BLOCKED;
6013            case DELETE_FAILED_OWNER_BLOCKED: return PackageInstaller.STATUS_FAILURE_BLOCKED;
6014            case DELETE_FAILED_ABORTED: return PackageInstaller.STATUS_FAILURE_ABORTED;
6015            case DELETE_FAILED_USED_SHARED_LIBRARY: return PackageInstaller.STATUS_FAILURE_CONFLICT;
6016            default: return PackageInstaller.STATUS_FAILURE;
6017        }
6018    }
6019
6020    /** {@hide} */
6021    public static String permissionFlagToString(int flag) {
6022        switch (flag) {
6023            case FLAG_PERMISSION_GRANTED_BY_DEFAULT: return "GRANTED_BY_DEFAULT";
6024            case FLAG_PERMISSION_POLICY_FIXED: return "POLICY_FIXED";
6025            case FLAG_PERMISSION_SYSTEM_FIXED: return "SYSTEM_FIXED";
6026            case FLAG_PERMISSION_USER_SET: return "USER_SET";
6027            case FLAG_PERMISSION_REVOKE_ON_UPGRADE: return "REVOKE_ON_UPGRADE";
6028            case FLAG_PERMISSION_USER_FIXED: return "USER_FIXED";
6029            case FLAG_PERMISSION_REVIEW_REQUIRED: return "REVIEW_REQUIRED";
6030            default: return Integer.toString(flag);
6031        }
6032    }
6033
6034    /** {@hide} */
6035    public static class LegacyPackageInstallObserver extends PackageInstallObserver {
6036        private final IPackageInstallObserver mLegacy;
6037
6038        public LegacyPackageInstallObserver(IPackageInstallObserver legacy) {
6039            mLegacy = legacy;
6040        }
6041
6042        @Override
6043        public void onPackageInstalled(String basePackageName, int returnCode, String msg,
6044                Bundle extras) {
6045            if (mLegacy == null) return;
6046            try {
6047                mLegacy.packageInstalled(basePackageName, returnCode);
6048            } catch (RemoteException ignored) {
6049            }
6050        }
6051    }
6052
6053    /** {@hide} */
6054    public static class LegacyPackageDeleteObserver extends PackageDeleteObserver {
6055        private final IPackageDeleteObserver mLegacy;
6056
6057        public LegacyPackageDeleteObserver(IPackageDeleteObserver legacy) {
6058            mLegacy = legacy;
6059        }
6060
6061        @Override
6062        public void onPackageDeleted(String basePackageName, int returnCode, String msg) {
6063            if (mLegacy == null) return;
6064            try {
6065                mLegacy.packageDeleted(basePackageName, returnCode);
6066            } catch (RemoteException ignored) {
6067            }
6068        }
6069    }
6070
6071    /**
6072     * Return the install reason that was recorded when a package was first installed for a specific
6073     * user. Requesting the install reason for another user will require the permission
6074     * INTERACT_ACROSS_USERS_FULL.
6075     *
6076     * @param packageName The package for which to retrieve the install reason
6077     * @param user The user for whom to retrieve the install reason
6078     *
6079     * @return The install reason, currently one of {@code INSTALL_REASON_UNKNOWN} and
6080     *         {@code INSTALL_REASON_POLICY}. If the package is not installed for the given user,
6081     *         {@code INSTALL_REASON_UNKNOWN} is returned.
6082     *
6083     * @see #INSTALL_REASON_UNKNOWN
6084     * @see #INSTALL_REASON_POLICY
6085     *
6086     * @hide
6087     */
6088    @TestApi
6089    public abstract @InstallReason int getInstallReason(String packageName,
6090            @NonNull UserHandle user);
6091
6092    /**
6093     * Checks whether the calling package is allowed to request package installs through package
6094     * installer. Apps are encouraged to call this api before launching the package installer via
6095     * intent {@link android.content.Intent#ACTION_INSTALL_PACKAGE}. Starting from Android O, the
6096     * user can explicitly choose what external sources they trust to install apps on the device.
6097     * If this api returns false, the install request will be blocked by the package installer and
6098     * a dialog will be shown to the user with an option to launch settings to change their
6099     * preference. An application must target Android O or higher and declare permission
6100     * {@link android.Manifest.permission#REQUEST_INSTALL_PACKAGES} in order to use this api.
6101     *
6102     * @return true if the calling package is trusted by the user to request install packages on
6103     * the device, false otherwise.
6104     * @see {@link android.content.Intent#ACTION_INSTALL_PACKAGE}
6105     * @see {@link android.provider.Settings#ACTION_MANAGE_EXTERNAL_SOURCES}
6106     */
6107    public abstract boolean canRequestPackageInstalls();
6108}
6109