blob: 7253e77580087a3ec7f6176dd60a41ab51cfcca9 [file] [log] [blame]
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001/*
2 * Copyright (C) 2006 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package android.content.pm;
18
Svetoslavf7c06eb2015-06-10 18:43:22 -070019import android.Manifest;
Tor Norbye1c2bf032015-03-02 10:57:08 -080020import android.annotation.CheckResult;
Tor Norbye7b9c9122013-05-30 16:48:33 -070021import android.annotation.DrawableRes;
Tor Norbyed9273d62013-05-30 15:59:53 -070022import android.annotation.IntDef;
Todd Kennedy9106c642017-02-08 14:16:53 -080023import android.annotation.IntRange;
Jeff Sharkey16c8e3f2014-07-24 17:08:17 -070024import android.annotation.NonNull;
Jeff Sharkeye2d45be2015-04-15 17:14:12 -070025import android.annotation.Nullable;
Svetoslavf7c06eb2015-06-10 18:43:22 -070026import android.annotation.RequiresPermission;
Xavier Ducrohet3274b9b2009-12-14 17:52:20 -080027import android.annotation.SdkConstant;
28import android.annotation.SdkConstant.SdkConstantType;
Tor Norbye7b9c9122013-05-30 16:48:33 -070029import android.annotation.StringRes;
Jeff Sharkeybb580672014-07-10 12:10:25 -070030import android.annotation.SystemApi;
Jeff Sharkeya73b8fd2016-01-06 17:02:08 -070031import android.annotation.TestApi;
Jeff Sharkeybd940222016-01-08 11:07:13 -070032import android.annotation.UserIdInt;
Tor Norbye7b9c9122013-05-30 16:48:33 -070033import android.annotation.XmlRes;
Dianne Hackborn2a103f12017-08-08 15:50:31 -070034import android.app.ActivityManager;
Jeff Sharkey6c0b9da2014-08-07 22:07:11 -070035import android.app.PackageDeleteObserver;
Christopher Tatef1977b42014-03-24 16:25:51 -070036import android.app.PackageInstallObserver;
Amith Yamasani1d653272014-09-11 17:56:05 -070037import android.app.admin.DevicePolicyManager;
Jeff Sharkey60f95aa2017-03-08 13:57:15 -070038import android.app.usage.StorageStatsManager;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080039import android.content.ComponentName;
40import android.content.Context;
41import android.content.Intent;
42import android.content.IntentFilter;
Suchi Amalapurapu1ccac752009-06-12 10:09:58 -070043import android.content.IntentSender;
Jeff Sharkeyc4858a22014-06-16 10:51:20 -070044import android.content.pm.PackageParser.PackageParserException;
Calin Juravle45f8b292017-11-07 18:49:43 -080045import android.content.pm.dex.ArtManager;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080046import android.content.res.Resources;
47import android.content.res.XmlResourceParser;
Svetoslavc7d62f02014-09-04 15:39:54 -070048import android.graphics.Rect;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080049import android.graphics.drawable.Drawable;
Peter Qiu3d615e42017-08-07 20:13:32 +000050import android.net.wifi.WifiManager;
Jeff Sharkey6f4b2a32017-03-21 14:13:41 -060051import android.os.Build;
Jeff Sharkeybb580672014-07-10 12:10:25 -070052import android.os.Bundle;
Jeff Sharkey620b32b2015-04-23 19:36:02 -070053import android.os.Handler;
Suprabh Shukla021b57a2018-03-08 18:21:50 -080054import android.os.PersistableBundle;
Jeff Sharkey6c0b9da2014-08-07 22:07:11 -070055import android.os.RemoteException;
Dianne Hackborn0c380492012-08-20 17:23:30 -070056import android.os.UserHandle;
Jeff Sharkey8a372a02016-03-16 16:25:45 -060057import android.os.UserManager;
Jeff Sharkey683bcd32017-03-18 17:54:51 -060058import android.os.storage.StorageManager;
Jeff Sharkeyb2b9ab82015-04-05 21:10:42 -070059import android.os.storage.VolumeInfo;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080060import android.util.AndroidException;
Jeff Sharkeybd940222016-01-08 11:07:13 -070061import android.util.Log;
Jeff Sharkeyb2b9ab82015-04-05 21:10:42 -070062
Svetoslavc6d1c342015-02-26 14:44:43 -080063import com.android.internal.util.ArrayUtils;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080064
Jeff Sharkey6f4b2a32017-03-21 14:13:41 -060065import dalvik.system.VMRuntime;
66
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080067import java.io.File;
Tor Norbyed9273d62013-05-30 15:59:53 -070068import java.lang.annotation.Retention;
69import java.lang.annotation.RetentionPolicy;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080070import java.util.List;
Suprabh Shukla3e03ab92018-04-11 16:03:49 -070071import java.util.Locale;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080072
73/**
74 * Class for retrieving various kinds of information related to the application
75 * packages that are currently installed on the device.
76 *
77 * You can find this class through {@link Context#getPackageManager}.
78 */
79public abstract class PackageManager {
Jeff Sharkeybd940222016-01-08 11:07:13 -070080 private static final String TAG = "PackageManager";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080081
Jeff Sharkeye4697132016-02-06 19:46:15 -070082 /** {@hide} */
Jeff Sharkey8a372a02016-03-16 16:25:45 -060083 public static final boolean APPLY_DEFAULT_TO_DEVICE_PROTECTED_STORAGE = true;
Jeff Sharkeye4697132016-02-06 19:46:15 -070084
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080085 /**
86 * This exception is thrown when a given package, application, or component
kmccormick30498b42013-03-27 17:39:17 -070087 * name cannot be found.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080088 */
89 public static class NameNotFoundException extends AndroidException {
90 public NameNotFoundException() {
91 }
92
93 public NameNotFoundException(String name) {
94 super(name);
95 }
96 }
97
98 /**
Svetoslavf7c06eb2015-06-10 18:43:22 -070099 * Listener for changes in permissions granted to a UID.
100 *
101 * @hide
102 */
103 @SystemApi
104 public interface OnPermissionsChangedListener {
105
106 /**
107 * Called when the permissions for a UID change.
108 * @param uid The UID with a change.
109 */
110 public void onPermissionsChanged(int uid);
111 }
112
113 /**
Jeff Sharkey2f3e3532015-12-21 14:16:43 -0700114 * As a guiding principle:
115 * <p>
116 * {@code GET_} flags are used to request additional data that may have been
117 * elided to save wire space.
118 * <p>
119 * {@code MATCH_} flags are used to include components or packages that
120 * would have otherwise been omitted from a result set by current system
121 * state.
122 */
123
124 /** @hide */
Jeff Sharkey4347f812017-04-21 12:08:39 -0600125 @IntDef(flag = true, prefix = { "GET_", "MATCH_" }, value = {
Jeff Sharkey2f3e3532015-12-21 14:16:43 -0700126 GET_ACTIVITIES,
Todd Kennedy6b9bfa12016-01-08 13:44:51 -0800127 GET_CONFIGURATIONS,
128 GET_GIDS,
Jeff Sharkey2f3e3532015-12-21 14:16:43 -0700129 GET_INSTRUMENTATION,
130 GET_INTENT_FILTERS,
Jeff Sharkey2f3e3532015-12-21 14:16:43 -0700131 GET_META_DATA,
Jeff Sharkey2f3e3532015-12-21 14:16:43 -0700132 GET_PERMISSIONS,
Todd Kennedy6b9bfa12016-01-08 13:44:51 -0800133 GET_PROVIDERS,
134 GET_RECEIVERS,
135 GET_SERVICES,
136 GET_SHARED_LIBRARY_FILES,
137 GET_SIGNATURES,
Daniel Cashman5cdda342018-01-19 07:22:52 -0800138 GET_SIGNING_CERTIFICATES,
Todd Kennedy6b9bfa12016-01-08 13:44:51 -0800139 GET_URI_PERMISSION_PATTERNS,
Jeff Sharkey2f3e3532015-12-21 14:16:43 -0700140 MATCH_UNINSTALLED_PACKAGES,
141 MATCH_DISABLED_COMPONENTS,
142 MATCH_DISABLED_UNTIL_USED_COMPONENTS,
Jeff Sharkeyc5967e92016-01-07 18:50:29 -0700143 MATCH_SYSTEM_ONLY,
Todd Kennedyd6ee0ba2016-03-31 15:11:11 -0700144 MATCH_FACTORY_ONLY,
Jeff Sharkey2f3e3532015-12-21 14:16:43 -0700145 MATCH_DEBUG_TRIAGED_MISSING,
Todd Kennedy9c9fdf22017-03-06 10:58:27 -0800146 MATCH_INSTANT,
Todd Kennedy1f397f42016-06-28 12:14:11 -0700147 GET_DISABLED_COMPONENTS,
148 GET_DISABLED_UNTIL_USED_COMPONENTS,
149 GET_UNINSTALLED_PACKAGES,
Jeff Sharkey2f3e3532015-12-21 14:16:43 -0700150 })
151 @Retention(RetentionPolicy.SOURCE)
152 public @interface PackageInfoFlags {}
153
154 /** @hide */
Jeff Sharkey4347f812017-04-21 12:08:39 -0600155 @IntDef(flag = true, prefix = { "GET_", "MATCH_" }, value = {
Jeff Sharkey2f3e3532015-12-21 14:16:43 -0700156 GET_META_DATA,
157 GET_SHARED_LIBRARY_FILES,
158 MATCH_UNINSTALLED_PACKAGES,
159 MATCH_SYSTEM_ONLY,
160 MATCH_DEBUG_TRIAGED_MISSING,
Todd Kennedy24522022017-03-27 16:32:20 -0700161 MATCH_DISABLED_COMPONENTS,
Todd Kennedy5a32c6c2016-07-07 14:29:06 -0700162 MATCH_DISABLED_UNTIL_USED_COMPONENTS,
Todd Kennedy9c9fdf22017-03-06 10:58:27 -0800163 MATCH_INSTANT,
Svet Ganov9e779772017-05-11 14:36:50 -0700164 MATCH_STATIC_SHARED_LIBRARIES,
Todd Kennedy5a32c6c2016-07-07 14:29:06 -0700165 GET_DISABLED_UNTIL_USED_COMPONENTS,
Todd Kennedy1f397f42016-06-28 12:14:11 -0700166 GET_UNINSTALLED_PACKAGES,
Jeff Sharkey2f3e3532015-12-21 14:16:43 -0700167 })
168 @Retention(RetentionPolicy.SOURCE)
169 public @interface ApplicationInfoFlags {}
170
171 /** @hide */
Jeff Sharkey4347f812017-04-21 12:08:39 -0600172 @IntDef(flag = true, prefix = { "GET_", "MATCH_" }, value = {
Jeff Sharkey2f3e3532015-12-21 14:16:43 -0700173 GET_META_DATA,
174 GET_SHARED_LIBRARY_FILES,
Todd Kennedy6b9bfa12016-01-08 13:44:51 -0800175 MATCH_ALL,
176 MATCH_DEBUG_TRIAGED_MISSING,
177 MATCH_DEFAULT_ONLY,
Jeff Sharkey2f3e3532015-12-21 14:16:43 -0700178 MATCH_DISABLED_COMPONENTS,
179 MATCH_DISABLED_UNTIL_USED_COMPONENTS,
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600180 MATCH_DIRECT_BOOT_AWARE,
181 MATCH_DIRECT_BOOT_UNAWARE,
Jeff Sharkey2f3e3532015-12-21 14:16:43 -0700182 MATCH_SYSTEM_ONLY,
Todd Kennedy6b9bfa12016-01-08 13:44:51 -0800183 MATCH_UNINSTALLED_PACKAGES,
Todd Kennedy9c9fdf22017-03-06 10:58:27 -0800184 MATCH_INSTANT,
Svet Ganov9e779772017-05-11 14:36:50 -0700185 MATCH_STATIC_SHARED_LIBRARIES,
Todd Kennedy1f397f42016-06-28 12:14:11 -0700186 GET_DISABLED_COMPONENTS,
187 GET_DISABLED_UNTIL_USED_COMPONENTS,
188 GET_UNINSTALLED_PACKAGES,
Jeff Sharkey2f3e3532015-12-21 14:16:43 -0700189 })
190 @Retention(RetentionPolicy.SOURCE)
191 public @interface ComponentInfoFlags {}
192
193 /** @hide */
Jeff Sharkey4347f812017-04-21 12:08:39 -0600194 @IntDef(flag = true, prefix = { "GET_", "MATCH_" }, value = {
Jeff Sharkey2f3e3532015-12-21 14:16:43 -0700195 GET_META_DATA,
Jeff Sharkey2f3e3532015-12-21 14:16:43 -0700196 GET_RESOLVED_FILTER,
Todd Kennedy6b9bfa12016-01-08 13:44:51 -0800197 GET_SHARED_LIBRARY_FILES,
198 MATCH_ALL,
199 MATCH_DEBUG_TRIAGED_MISSING,
Jeff Sharkey2f3e3532015-12-21 14:16:43 -0700200 MATCH_DISABLED_COMPONENTS,
201 MATCH_DISABLED_UNTIL_USED_COMPONENTS,
Jeff Sharkey2f3e3532015-12-21 14:16:43 -0700202 MATCH_DEFAULT_ONLY,
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600203 MATCH_DIRECT_BOOT_AWARE,
204 MATCH_DIRECT_BOOT_UNAWARE,
Jeff Sharkey2f3e3532015-12-21 14:16:43 -0700205 MATCH_SYSTEM_ONLY,
Todd Kennedy6b9bfa12016-01-08 13:44:51 -0800206 MATCH_UNINSTALLED_PACKAGES,
Todd Kennedy9c9fdf22017-03-06 10:58:27 -0800207 MATCH_INSTANT,
Todd Kennedy1f397f42016-06-28 12:14:11 -0700208 GET_DISABLED_COMPONENTS,
209 GET_DISABLED_UNTIL_USED_COMPONENTS,
210 GET_UNINSTALLED_PACKAGES,
Jeff Sharkey2f3e3532015-12-21 14:16:43 -0700211 })
212 @Retention(RetentionPolicy.SOURCE)
213 public @interface ResolveInfoFlags {}
214
215 /** @hide */
Jeff Sharkey4347f812017-04-21 12:08:39 -0600216 @IntDef(flag = true, prefix = { "GET_", "MATCH_" }, value = {
Jeff Sharkey2f3e3532015-12-21 14:16:43 -0700217 GET_META_DATA,
218 })
219 @Retention(RetentionPolicy.SOURCE)
220 public @interface PermissionInfoFlags {}
221
222 /** @hide */
Jeff Sharkey4347f812017-04-21 12:08:39 -0600223 @IntDef(flag = true, prefix = { "GET_", "MATCH_" }, value = {
Jeff Sharkey2f3e3532015-12-21 14:16:43 -0700224 GET_META_DATA,
225 })
226 @Retention(RetentionPolicy.SOURCE)
227 public @interface PermissionGroupInfoFlags {}
228
229 /** @hide */
Jeff Sharkey4347f812017-04-21 12:08:39 -0600230 @IntDef(flag = true, prefix = { "GET_", "MATCH_" }, value = {
Jeff Sharkey2f3e3532015-12-21 14:16:43 -0700231 GET_META_DATA,
232 })
233 @Retention(RetentionPolicy.SOURCE)
234 public @interface InstrumentationInfoFlags {}
235
236 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800237 * {@link PackageInfo} flag: return information about
238 * activities in the package in {@link PackageInfo#activities}.
239 */
240 public static final int GET_ACTIVITIES = 0x00000001;
241
242 /**
243 * {@link PackageInfo} flag: return information about
244 * intent receivers in the package in
245 * {@link PackageInfo#receivers}.
246 */
247 public static final int GET_RECEIVERS = 0x00000002;
248
249 /**
250 * {@link PackageInfo} flag: return information about
251 * services in the package in {@link PackageInfo#services}.
252 */
253 public static final int GET_SERVICES = 0x00000004;
254
255 /**
256 * {@link PackageInfo} flag: return information about
257 * content providers in the package in
258 * {@link PackageInfo#providers}.
259 */
260 public static final int GET_PROVIDERS = 0x00000008;
261
262 /**
263 * {@link PackageInfo} flag: return information about
264 * instrumentation in the package in
265 * {@link PackageInfo#instrumentation}.
266 */
267 public static final int GET_INSTRUMENTATION = 0x00000010;
268
269 /**
270 * {@link PackageInfo} flag: return information about the
271 * intent filters supported by the activity.
272 */
273 public static final int GET_INTENT_FILTERS = 0x00000020;
274
275 /**
276 * {@link PackageInfo} flag: return information about the
277 * signatures included in the package.
Daniel Cashman5cdda342018-01-19 07:22:52 -0800278 *
279 * @deprecated use {@code GET_SIGNING_CERTIFICATES} instead
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800280 */
Daniel Cashman5cdda342018-01-19 07:22:52 -0800281 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800282 public static final int GET_SIGNATURES = 0x00000040;
283
284 /**
285 * {@link ResolveInfo} flag: return the IntentFilter that
286 * was matched for a particular ResolveInfo in
287 * {@link ResolveInfo#filter}.
288 */
289 public static final int GET_RESOLVED_FILTER = 0x00000040;
290
291 /**
292 * {@link ComponentInfo} flag: return the {@link ComponentInfo#metaData}
293 * data {@link android.os.Bundle}s that are associated with a component.
294 * This applies for any API returning a ComponentInfo subclass.
295 */
296 public static final int GET_META_DATA = 0x00000080;
297
298 /**
299 * {@link PackageInfo} flag: return the
300 * {@link PackageInfo#gids group ids} that are associated with an
301 * application.
Ken Wakasaf76a50c2012-03-09 19:56:35 +0900302 * This applies for any API returning a PackageInfo class, either
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800303 * directly or nested inside of another.
304 */
305 public static final int GET_GIDS = 0x00000100;
306
307 /**
Jeff Sharkey2f3e3532015-12-21 14:16:43 -0700308 * @deprecated replaced with {@link #MATCH_DISABLED_COMPONENTS}
309 */
310 @Deprecated
311 public static final int GET_DISABLED_COMPONENTS = 0x00000200;
312
313 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800314 * {@link PackageInfo} flag: include disabled components in the returned info.
315 */
Jeff Sharkey2f3e3532015-12-21 14:16:43 -0700316 public static final int MATCH_DISABLED_COMPONENTS = 0x00000200;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800317
318 /**
319 * {@link ApplicationInfo} flag: return the
320 * {@link ApplicationInfo#sharedLibraryFiles paths to the shared libraries}
321 * that are associated with an application.
322 * This applies for any API returning an ApplicationInfo class, either
323 * directly or nested inside of another.
324 */
325 public static final int GET_SHARED_LIBRARY_FILES = 0x00000400;
326
327 /**
328 * {@link ProviderInfo} flag: return the
329 * {@link ProviderInfo#uriPermissionPatterns URI permission patterns}
330 * that are associated with a content provider.
Ken Wakasaf76a50c2012-03-09 19:56:35 +0900331 * This applies for any API returning a ProviderInfo class, either
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800332 * directly or nested inside of another.
333 */
334 public static final int GET_URI_PERMISSION_PATTERNS = 0x00000800;
335 /**
336 * {@link PackageInfo} flag: return information about
337 * permissions in the package in
338 * {@link PackageInfo#permissions}.
339 */
340 public static final int GET_PERMISSIONS = 0x00001000;
Amith Yamasani4b2e9342011-03-31 12:38:53 -0700341
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800342 /**
Jeff Sharkey2f3e3532015-12-21 14:16:43 -0700343 * @deprecated replaced with {@link #MATCH_UNINSTALLED_PACKAGES}
344 */
345 @Deprecated
346 public static final int GET_UNINSTALLED_PACKAGES = 0x00002000;
347
348 /**
Kenny Root685f4902011-11-03 10:13:29 -0700349 * Flag parameter to retrieve some information about all applications (even
350 * uninstalled ones) which have data directories. This state could have
351 * resulted if applications have been deleted with flag
352 * {@code DONT_DELETE_DATA} with a possibility of being replaced or
353 * reinstalled in future.
354 * <p>
355 * Note: this flag may cause less information about currently installed
356 * applications to be returned.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800357 */
Jeff Sharkey2f3e3532015-12-21 14:16:43 -0700358 public static final int MATCH_UNINSTALLED_PACKAGES = 0x00002000;
Amith Yamasani4b2e9342011-03-31 12:38:53 -0700359
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800360 /**
361 * {@link PackageInfo} flag: return information about
Dianne Hackborn49237342009-08-27 20:08:01 -0700362 * hardware preferences in
Adam Lesinskid3edfde2014-08-08 17:32:44 -0700363 * {@link PackageInfo#configPreferences PackageInfo.configPreferences},
364 * and requested features in {@link PackageInfo#reqFeatures} and
365 * {@link PackageInfo#featureGroups}.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800366 */
367 public static final int GET_CONFIGURATIONS = 0x00004000;
368
369 /**
Jeff Sharkey2f3e3532015-12-21 14:16:43 -0700370 * @deprecated replaced with {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}.
371 */
372 @Deprecated
373 public static final int GET_DISABLED_UNTIL_USED_COMPONENTS = 0x00008000;
374
375 /**
Dianne Hackbornfd7aded2013-01-22 17:10:23 -0800376 * {@link PackageInfo} flag: include disabled components which are in
377 * that state only because of {@link #COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED}
378 * in the returned info. Note that if you set this flag, applications
379 * that are in this disabled state will be reported as enabled.
380 */
Jeff Sharkey2f3e3532015-12-21 14:16:43 -0700381 public static final int MATCH_DISABLED_UNTIL_USED_COMPONENTS = 0x00008000;
Dianne Hackbornfd7aded2013-01-22 17:10:23 -0800382
383 /**
Dianne Hackborn1655be42009-05-08 14:29:01 -0700384 * Resolution and querying flag: if set, only filters that support the
385 * {@link android.content.Intent#CATEGORY_DEFAULT} will be considered for
386 * matching. This is a synonym for including the CATEGORY_DEFAULT in your
387 * supplied Intent.
388 */
Fabrice Di Meglio9f7e39f2015-04-10 20:40:16 -0700389 public static final int MATCH_DEFAULT_ONLY = 0x00010000;
390
391 /**
Jeff Sharkey2f3e3532015-12-21 14:16:43 -0700392 * Querying flag: if set and if the platform is doing any filtering of the
393 * results, then the filtering will not happen. This is a synonym for saying
394 * that all results should be returned.
395 * <p>
396 * <em>This flag should be used with extreme care.</em>
Fabrice Di Meglio9f7e39f2015-04-10 20:40:16 -0700397 */
398 public static final int MATCH_ALL = 0x00020000;
Dianne Hackborn1655be42009-05-08 14:29:01 -0700399
Nicolas Prevot63798c52014-05-27 13:22:38 +0100400 /**
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600401 * Querying flag: match components which are direct boot <em>unaware</em> in
Jeff Sharkey2f3e3532015-12-21 14:16:43 -0700402 * the returned info, regardless of the current user state.
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600403 * <p>
404 * When neither {@link #MATCH_DIRECT_BOOT_AWARE} nor
405 * {@link #MATCH_DIRECT_BOOT_UNAWARE} are specified, the default behavior is
406 * to match only runnable components based on the user state. For example,
407 * when a user is started but credentials have not been presented yet, the
408 * user is running "locked" and only {@link #MATCH_DIRECT_BOOT_AWARE}
409 * components are returned. Once the user credentials have been presented,
410 * the user is running "unlocked" and both {@link #MATCH_DIRECT_BOOT_AWARE}
411 * and {@link #MATCH_DIRECT_BOOT_UNAWARE} components are returned.
412 *
413 * @see UserManager#isUserUnlocked()
Jeff Sharkeye17ac152015-11-06 22:40:29 -0800414 */
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600415 public static final int MATCH_DIRECT_BOOT_UNAWARE = 0x00040000;
416
417 /**
418 * Querying flag: match components which are direct boot <em>aware</em> in
419 * the returned info, regardless of the current user state.
420 * <p>
421 * When neither {@link #MATCH_DIRECT_BOOT_AWARE} nor
422 * {@link #MATCH_DIRECT_BOOT_UNAWARE} are specified, the default behavior is
423 * to match only runnable components based on the user state. For example,
424 * when a user is started but credentials have not been presented yet, the
425 * user is running "locked" and only {@link #MATCH_DIRECT_BOOT_AWARE}
426 * components are returned. Once the user credentials have been presented,
427 * the user is running "unlocked" and both {@link #MATCH_DIRECT_BOOT_AWARE}
428 * and {@link #MATCH_DIRECT_BOOT_UNAWARE} components are returned.
429 *
430 * @see UserManager#isUserUnlocked()
431 */
432 public static final int MATCH_DIRECT_BOOT_AWARE = 0x00080000;
433
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -0700434 /**
Jeff Sharkey2f3e3532015-12-21 14:16:43 -0700435 * Querying flag: include only components from applications that are marked
436 * with {@link ApplicationInfo#FLAG_SYSTEM}.
Jeff Sharkey5217cac2015-12-20 15:34:01 -0700437 */
438 public static final int MATCH_SYSTEM_ONLY = 0x00100000;
439
440 /**
Todd Kennedyd6ee0ba2016-03-31 15:11:11 -0700441 * Internal {@link PackageInfo} flag: include only components on the system image.
442 * This will not return information on any unbundled update to system components.
443 * @hide
444 */
Todd Kennedy49084962017-03-27 16:20:37 -0700445 @SystemApi
Fyodor Kupolove5698042018-01-26 14:24:37 -0800446 @TestApi
Todd Kennedyd6ee0ba2016-03-31 15:11:11 -0700447 public static final int MATCH_FACTORY_ONLY = 0x00200000;
448
449 /**
Amith Yamasani0d1fd8d2016-10-12 14:21:51 -0700450 * Allows querying of packages installed for any user, not just the specific one. This flag
Amith Yamasani475f9a32016-12-08 09:46:15 -0800451 * is only meant for use by apps that have INTERACT_ACROSS_USERS permission.
Amith Yamasani0d1fd8d2016-10-12 14:21:51 -0700452 * @hide
453 */
Amith Yamasani475f9a32016-12-08 09:46:15 -0800454 @SystemApi
Amith Yamasani0d1fd8d2016-10-12 14:21:51 -0700455 public static final int MATCH_ANY_USER = 0x00400000;
456
457 /**
458 * Combination of MATCH_ANY_USER and MATCH_UNINSTALLED_PACKAGES to mean any known
459 * package.
460 * @hide
461 */
Todd Kennedyef9acb62018-05-29 15:18:06 -0700462 @TestApi
Amith Yamasani0d1fd8d2016-10-12 14:21:51 -0700463 public static final int MATCH_KNOWN_PACKAGES = MATCH_UNINSTALLED_PACKAGES | MATCH_ANY_USER;
464
465 /**
Todd Kennedy7bc3a702016-12-08 14:54:48 -0800466 * Internal {@link PackageInfo} flag: include components that are part of an
Todd Kennedybe0b8892017-02-15 14:13:52 -0800467 * instant app. By default, instant app components are not matched.
Todd Kennedy7bc3a702016-12-08 14:54:48 -0800468 * @hide
469 */
Todd Kennedy9c9fdf22017-03-06 10:58:27 -0800470 @SystemApi
Todd Kennedybe0b8892017-02-15 14:13:52 -0800471 public static final int MATCH_INSTANT = 0x00800000;
Todd Kennedy7bc3a702016-12-08 14:54:48 -0800472
473 /**
474 * Internal {@link PackageInfo} flag: include only components that are exposed to
Todd Kennedyc05f5d12017-04-25 11:11:40 -0700475 * instant apps. Matched components may have been either explicitly or implicitly
476 * exposed.
Todd Kennedy7bc3a702016-12-08 14:54:48 -0800477 * @hide
478 */
Todd Kennedybe0b8892017-02-15 14:13:52 -0800479 public static final int MATCH_VISIBLE_TO_INSTANT_APP_ONLY = 0x01000000;
Todd Kennedy7bc3a702016-12-08 14:54:48 -0800480
481 /**
Todd Kennedyc05f5d12017-04-25 11:11:40 -0700482 * Internal {@link PackageInfo} flag: include only components that have been
483 * explicitly exposed to instant apps.
484 * @hide
485 */
486 public static final int MATCH_EXPLICITLY_VISIBLE_ONLY = 0x02000000;
487
488 /**
Svet Ganov9e779772017-05-11 14:36:50 -0700489 * Internal {@link PackageInfo} flag: include static shared libraries.
490 * Apps that depend on static shared libs can always access the version
491 * of the lib they depend on. System/shell/root can access all shared
492 * libs regardless of dependency but need to explicitly ask for them
493 * via this flag.
494 * @hide
495 */
496 public static final int MATCH_STATIC_SHARED_LIBRARIES = 0x04000000;
497
498 /**
Daniel Cashman5cdda342018-01-19 07:22:52 -0800499 * {@link PackageInfo} flag: return the signing certificates associated with
500 * this package. Each entry is a signing certificate that the package
501 * has proven it is authorized to use, usually a past signing certificate from
502 * which it has rotated.
503 */
504 public static final int GET_SIGNING_CERTIFICATES = 0x08000000;
505
506 /**
Jeff Sharkey2f3e3532015-12-21 14:16:43 -0700507 * Internal flag used to indicate that a system component has done their
508 * homework and verified that they correctly handle packages and components
509 * that come and go over time. In particular:
510 * <ul>
511 * <li>Apps installed on external storage, which will appear to be
512 * uninstalled while the the device is ejected.
513 * <li>Apps with encryption unaware components, which will appear to not
514 * exist while the device is locked.
515 * </ul>
Jeff Sharkeye17ac152015-11-06 22:40:29 -0800516 *
Jeff Sharkey2f3e3532015-12-21 14:16:43 -0700517 * @see #MATCH_UNINSTALLED_PACKAGES
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600518 * @see #MATCH_DIRECT_BOOT_AWARE
519 * @see #MATCH_DIRECT_BOOT_UNAWARE
Jeff Sharkeye17ac152015-11-06 22:40:29 -0800520 * @hide
521 */
Jeff Sharkey2f3e3532015-12-21 14:16:43 -0700522 public static final int MATCH_DEBUG_TRIAGED_MISSING = 0x10000000;
Jeff Sharkeye17ac152015-11-06 22:40:29 -0800523
524 /**
Jeff Sharkey5aa86932016-01-08 19:07:49 -0700525 * Flag for {@link #addCrossProfileIntentFilter}: if this flag is set: when
526 * resolving an intent that matches the {@code CrossProfileIntentFilter},
527 * the current profile will be skipped. Only activities in the target user
528 * can respond to the intent.
529 *
Nicolas Prevot63798c52014-05-27 13:22:38 +0100530 * @hide
531 */
532 public static final int SKIP_CURRENT_PROFILE = 0x00000002;
533
Tony Mak807e01c2015-12-01 20:19:03 +0000534 /**
Jeff Sharkey5aa86932016-01-08 19:07:49 -0700535 * Flag for {@link #addCrossProfileIntentFilter}: if this flag is set:
Tony Mak807e01c2015-12-01 20:19:03 +0000536 * activities in the other profiles can respond to the intent only if no activity with
537 * non-negative priority in current profile can respond to the intent.
538 * @hide
539 */
540 public static final int ONLY_IF_NO_MATCH_FOUND = 0x00000004;
541
Tor Norbyed9273d62013-05-30 15:59:53 -0700542 /** @hide */
Jeff Sharkey4347f812017-04-21 12:08:39 -0600543 @IntDef(prefix = { "PERMISSION_" }, value = {
544 PERMISSION_GRANTED,
545 PERMISSION_DENIED
546 })
Tor Norbyed9273d62013-05-30 15:59:53 -0700547 @Retention(RetentionPolicy.SOURCE)
548 public @interface PermissionResult {}
549
Dianne Hackborn1655be42009-05-08 14:29:01 -0700550 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800551 * Permission check result: this is returned by {@link #checkPermission}
552 * if the permission has been granted to the given package.
553 */
554 public static final int PERMISSION_GRANTED = 0;
555
556 /**
557 * Permission check result: this is returned by {@link #checkPermission}
558 * if the permission has not been granted to the given package.
559 */
560 public static final int PERMISSION_DENIED = -1;
561
Jeff Sharkey30e06bb2017-04-24 11:18:03 -0600562 /** @hide */
563 @IntDef(prefix = { "SIGNATURE_" }, value = {
564 SIGNATURE_MATCH,
565 SIGNATURE_NEITHER_SIGNED,
566 SIGNATURE_FIRST_NOT_SIGNED,
567 SIGNATURE_SECOND_NOT_SIGNED,
568 SIGNATURE_NO_MATCH,
569 SIGNATURE_UNKNOWN_PACKAGE,
570 })
571 @Retention(RetentionPolicy.SOURCE)
572 public @interface SignatureResult {}
573
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800574 /**
575 * Signature check result: this is returned by {@link #checkSignatures}
Chris Palmer09f33602010-09-13 14:27:18 -0700576 * if all signatures on the two packages match.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800577 */
578 public static final int SIGNATURE_MATCH = 0;
579
580 /**
581 * Signature check result: this is returned by {@link #checkSignatures}
582 * if neither of the two packages is signed.
583 */
584 public static final int SIGNATURE_NEITHER_SIGNED = 1;
585
586 /**
587 * Signature check result: this is returned by {@link #checkSignatures}
Chris Palmer09f33602010-09-13 14:27:18 -0700588 * if the first package is not signed but the second is.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800589 */
590 public static final int SIGNATURE_FIRST_NOT_SIGNED = -1;
591
592 /**
593 * Signature check result: this is returned by {@link #checkSignatures}
Chris Palmer09f33602010-09-13 14:27:18 -0700594 * if the second package is not signed but the first is.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800595 */
596 public static final int SIGNATURE_SECOND_NOT_SIGNED = -2;
597
598 /**
599 * Signature check result: this is returned by {@link #checkSignatures}
Chris Palmer09f33602010-09-13 14:27:18 -0700600 * if not all signatures on both packages match.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800601 */
602 public static final int SIGNATURE_NO_MATCH = -3;
603
604 /**
605 * Signature check result: this is returned by {@link #checkSignatures}
Chris Palmer09f33602010-09-13 14:27:18 -0700606 * if either of the packages are not valid.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800607 */
608 public static final int SIGNATURE_UNKNOWN_PACKAGE = -4;
609
Jeff Sharkey30e06bb2017-04-24 11:18:03 -0600610 /** @hide */
611 @IntDef(prefix = { "COMPONENT_ENABLED_STATE_" }, value = {
612 COMPONENT_ENABLED_STATE_DEFAULT,
613 COMPONENT_ENABLED_STATE_ENABLED,
614 COMPONENT_ENABLED_STATE_DISABLED,
615 COMPONENT_ENABLED_STATE_DISABLED_USER,
616 COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED,
617 })
618 @Retention(RetentionPolicy.SOURCE)
619 public @interface EnabledState {}
620
Dianne Hackborn0ac30312011-06-17 14:49:23 -0700621 /**
Jeff Sharkey30e06bb2017-04-24 11:18:03 -0600622 * Flag for {@link #setApplicationEnabledSetting(String, int, int)} and
623 * {@link #setComponentEnabledSetting(ComponentName, int, int)}: This
624 * component or application is in its default enabled state (as specified in
625 * its manifest).
626 * <p>
627 * Explicitly setting the component state to this value restores it's
628 * enabled state to whatever is set in the manifest.
Dianne Hackborn0ac30312011-06-17 14:49:23 -0700629 */
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800630 public static final int COMPONENT_ENABLED_STATE_DEFAULT = 0;
Dianne Hackborn0ac30312011-06-17 14:49:23 -0700631
632 /**
633 * Flag for {@link #setApplicationEnabledSetting(String, int, int)}
634 * and {@link #setComponentEnabledSetting(ComponentName, int, int)}: This
635 * component or application has been explictily enabled, regardless of
636 * what it has specified in its manifest.
637 */
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800638 public static final int COMPONENT_ENABLED_STATE_ENABLED = 1;
Dianne Hackborn0ac30312011-06-17 14:49:23 -0700639
640 /**
641 * Flag for {@link #setApplicationEnabledSetting(String, int, int)}
642 * and {@link #setComponentEnabledSetting(ComponentName, int, int)}: This
643 * component or application has been explicitly disabled, regardless of
644 * what it has specified in its manifest.
645 */
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800646 public static final int COMPONENT_ENABLED_STATE_DISABLED = 2;
647
648 /**
Dianne Hackborn0ac30312011-06-17 14:49:23 -0700649 * Flag for {@link #setApplicationEnabledSetting(String, int, int)} only: The
650 * user has explicitly disabled the application, regardless of what it has
651 * specified in its manifest. Because this is due to the user's request,
652 * they may re-enable it if desired through the appropriate system UI. This
kmccormick30498b42013-03-27 17:39:17 -0700653 * option currently <strong>cannot</strong> be used with
Dianne Hackborn0ac30312011-06-17 14:49:23 -0700654 * {@link #setComponentEnabledSetting(ComponentName, int, int)}.
655 */
656 public static final int COMPONENT_ENABLED_STATE_DISABLED_USER = 3;
657
658 /**
Dianne Hackbornfd7aded2013-01-22 17:10:23 -0800659 * Flag for {@link #setApplicationEnabledSetting(String, int, int)} only: This
660 * application should be considered, until the point where the user actually
661 * wants to use it. This means that it will not normally show up to the user
662 * (such as in the launcher), but various parts of the user interface can
663 * use {@link #GET_DISABLED_UNTIL_USED_COMPONENTS} to still see it and allow
664 * the user to select it (as for example an IME, device admin, etc). Such code,
665 * once the user has selected the app, should at that point also make it enabled.
666 * This option currently <strong>can not</strong> be used with
667 * {@link #setComponentEnabledSetting(ComponentName, int, int)}.
668 */
669 public static final int COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED = 4;
670
Jeff Sharkey5aa86932016-01-08 19:07:49 -0700671 /** @hide */
Jeff Sharkey4347f812017-04-21 12:08:39 -0600672 @IntDef(flag = true, prefix = { "INSTALL_" }, value = {
Jeff Sharkey5aa86932016-01-08 19:07:49 -0700673 INSTALL_FORWARD_LOCK,
674 INSTALL_REPLACE_EXISTING,
675 INSTALL_ALLOW_TEST,
676 INSTALL_EXTERNAL,
677 INSTALL_INTERNAL,
678 INSTALL_FROM_ADB,
679 INSTALL_ALL_USERS,
680 INSTALL_ALLOW_DOWNGRADE,
681 INSTALL_GRANT_RUNTIME_PERMISSIONS,
682 INSTALL_FORCE_VOLUME_UUID,
683 INSTALL_FORCE_PERMISSION_PROMPT,
Todd Kennedybe0b8892017-02-15 14:13:52 -0800684 INSTALL_INSTANT_APP,
Todd Kennedy39bfee52016-02-24 10:28:21 -0800685 INSTALL_DONT_KILL_APP,
Jeff Sharkey683bcd32017-03-18 17:54:51 -0600686 INSTALL_FORCE_SDK,
687 INSTALL_FULL_APP,
688 INSTALL_ALLOCATE_AGGRESSIVE,
Jeff Sharkey5aa86932016-01-08 19:07:49 -0700689 })
690 @Retention(RetentionPolicy.SOURCE)
691 public @interface InstallFlags {}
692
Dianne Hackbornfd7aded2013-01-22 17:10:23 -0800693 /**
Jeff Sharkey5aa86932016-01-08 19:07:49 -0700694 * Flag parameter for {@link #installPackage} to indicate that this package
695 * should be installed as forward locked, i.e. only the app itself should
696 * have access to its code and non-resource assets.
697 *
Jeff Sharkey8c61e392017-02-24 09:22:48 -0700698 * @deprecated new installs into ASEC containers are no longer supported.
Dianne Hackbornade3eca2009-05-11 18:54:45 -0700699 * @hide
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800700 */
Jeff Sharkey8c61e392017-02-24 09:22:48 -0700701 @Deprecated
Dianne Hackbornade3eca2009-05-11 18:54:45 -0700702 public static final int INSTALL_FORWARD_LOCK = 0x00000001;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800703
704 /**
Jeff Sharkey5aa86932016-01-08 19:07:49 -0700705 * Flag parameter for {@link #installPackage} to indicate that you want to
706 * replace an already installed package, if one exists.
707 *
Dianne Hackbornade3eca2009-05-11 18:54:45 -0700708 * @hide
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800709 */
Dianne Hackbornade3eca2009-05-11 18:54:45 -0700710 public static final int INSTALL_REPLACE_EXISTING = 0x00000002;
711
712 /**
Amith Yamasani4b2e9342011-03-31 12:38:53 -0700713 * Flag parameter for {@link #installPackage} to indicate that you want to
Dianne Hackbornade3eca2009-05-11 18:54:45 -0700714 * allow test packages (those that have set android:testOnly in their
715 * manifest) to be installed.
716 * @hide
717 */
718 public static final int INSTALL_ALLOW_TEST = 0x00000004;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800719
720 /**
Jeff Sharkeyb2b9ab82015-04-05 21:10:42 -0700721 * Flag parameter for {@link #installPackage} to indicate that this package
722 * must be installed to an ASEC on a {@link VolumeInfo#TYPE_PUBLIC}.
723 *
Jeff Sharkey8c61e392017-02-24 09:22:48 -0700724 * @deprecated new installs into ASEC containers are no longer supported;
725 * use adoptable storage instead.
Suchi Amalapurapuaf8e9f42010-01-12 10:17:28 -0800726 * @hide
727 */
Jeff Sharkey8c61e392017-02-24 09:22:48 -0700728 @Deprecated
Suchi Amalapurapu5b993ce2010-02-12 09:43:29 -0800729 public static final int INSTALL_EXTERNAL = 0x00000008;
Oscar Montemayor539d3c42010-01-29 15:27:00 -0800730
731 /**
Kenny Root5ab21572011-07-27 11:11:19 -0700732 * Flag parameter for {@link #installPackage} to indicate that this package
Jeff Sharkeyb2b9ab82015-04-05 21:10:42 -0700733 * must be installed to internal storage.
734 *
Kenny Root5ab21572011-07-27 11:11:19 -0700735 * @hide
736 */
737 public static final int INSTALL_INTERNAL = 0x00000010;
738
739 /**
740 * Flag parameter for {@link #installPackage} to indicate that this install
741 * was initiated via ADB.
742 *
743 * @hide
744 */
745 public static final int INSTALL_FROM_ADB = 0x00000020;
Suchi Amalapurapu14b6abd2010-03-17 08:37:04 -0700746
747 /**
Dianne Hackborn7767eac2012-08-23 18:25:40 -0700748 * Flag parameter for {@link #installPackage} to indicate that this install
749 * should immediately be visible to all users.
750 *
751 * @hide
752 */
753 public static final int INSTALL_ALL_USERS = 0x00000040;
754
755 /**
756 * Flag parameter for {@link #installPackage} to indicate that it is okay
757 * to install an update to an app where the newly installed app has a lower
Alex Klyubin921dd752016-02-24 13:21:41 -0800758 * version code than the currently installed app. This is permitted only if
759 * the currently installed app is marked debuggable.
Dianne Hackborn7767eac2012-08-23 18:25:40 -0700760 *
761 * @hide
762 */
763 public static final int INSTALL_ALLOW_DOWNGRADE = 0x00000080;
764
765 /**
Svet Ganov95c1ade2015-03-19 09:38:52 -0700766 * Flag parameter for {@link #installPackage} to indicate that all runtime
767 * permissions should be granted to the package. If {@link #INSTALL_ALL_USERS}
768 * is set the runtime permissions will be granted to all users, otherwise
769 * only to the owner.
770 *
771 * @hide
772 */
773 public static final int INSTALL_GRANT_RUNTIME_PERMISSIONS = 0x00000100;
774
Jeff Sharkeyab234092015-06-09 21:42:22 -0700775 /** {@hide} */
776 public static final int INSTALL_FORCE_VOLUME_UUID = 0x00000200;
777
Svet Ganov95c1ade2015-03-19 09:38:52 -0700778 /**
Todd Kennedya1d12cf2015-09-29 15:43:00 -0700779 * Flag parameter for {@link #installPackage} to indicate that we always want to force
780 * the prompt for permission approval. This overrides any special behaviour for internal
781 * components.
782 *
783 * @hide
784 */
785 public static final int INSTALL_FORCE_PERMISSION_PROMPT = 0x00000400;
786
787 /**
Todd Kennedy27c24fb2015-09-17 16:49:25 -0700788 * Flag parameter for {@link #installPackage} to indicate that this package is
Todd Kennedy2699f062015-11-20 13:07:17 -0800789 * to be installed as a lightweight "ephemeral" app.
790 *
791 * @hide
792 */
Todd Kennedybe0b8892017-02-15 14:13:52 -0800793 public static final int INSTALL_INSTANT_APP = 0x00000800;
794
795 /**
Todd Kennedy39bfee52016-02-24 10:28:21 -0800796 * Flag parameter for {@link #installPackage} to indicate that this package contains
797 * a feature split to an existing application and the existing application should not
798 * be killed during the installation process.
799 *
800 * @hide
801 */
802 public static final int INSTALL_DONT_KILL_APP = 0x00001000;
803
804 /**
Todd Kennedyb1072712016-04-26 15:41:20 -0700805 * Flag parameter for {@link #installPackage} to indicate that this package is an
Patrick Baumannccb20b82018-01-08 13:22:46 -0800806 * upgrade to a package that refers to the SDK via release letter or is targeting an SDK via
807 * release letter that the current build does not support.
Todd Kennedyb1072712016-04-26 15:41:20 -0700808 *
809 * @hide
810 */
811 public static final int INSTALL_FORCE_SDK = 0x00002000;
812
813 /**
Jeff Sharkey683bcd32017-03-18 17:54:51 -0600814 * Flag parameter for {@link #installPackage} to indicate that this package is
815 * to be installed as a heavy weight app. This is fundamentally the opposite of
816 * {@link #INSTALL_INSTANT_APP}.
817 *
818 * @hide
819 */
820 public static final int INSTALL_FULL_APP = 0x00004000;
821
822 /**
823 * Flag parameter for {@link #installPackage} to indicate that this package
824 * is critical to system health or security, meaning the system should use
825 * {@link StorageManager#FLAG_ALLOCATE_AGGRESSIVE} internally.
826 *
827 * @hide
828 */
829 public static final int INSTALL_ALLOCATE_AGGRESSIVE = 0x00008000;
830
Todd Kennedy78a72502017-07-19 12:49:30 -0700831 /**
832 * Flag parameter for {@link #installPackage} to indicate that this package
833 * is a virtual preload.
834 *
835 * @hide
836 */
837 public static final int INSTALL_VIRTUAL_PRELOAD = 0x00010000;
838
Jeff Sharkey30e06bb2017-04-24 11:18:03 -0600839 /** @hide */
840 @IntDef(flag = true, prefix = { "DONT_KILL_APP" }, value = {
841 DONT_KILL_APP
842 })
843 @Retention(RetentionPolicy.SOURCE)
844 public @interface EnabledFlags {}
845
Jeff Sharkey683bcd32017-03-18 17:54:51 -0600846 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800847 * Flag parameter for
848 * {@link #setComponentEnabledSetting(android.content.ComponentName, int, int)} to indicate
849 * that you don't want to kill the app containing the component. Be careful when you set this
850 * since changing component states can make the containing application's behavior unpredictable.
851 */
852 public static final int DONT_KILL_APP = 0x00000001;
853
Bartosz Fabianowskia34f53f2017-01-11 18:08:47 +0100854 /** @hide */
Jeff Sharkey4347f812017-04-21 12:08:39 -0600855 @IntDef(prefix = { "INSTALL_REASON_" }, value = {
856 INSTALL_REASON_UNKNOWN,
857 INSTALL_REASON_POLICY,
858 INSTALL_REASON_DEVICE_RESTORE,
859 INSTALL_REASON_DEVICE_SETUP,
860 INSTALL_REASON_USER
861 })
Bartosz Fabianowskia34f53f2017-01-11 18:08:47 +0100862 @Retention(RetentionPolicy.SOURCE)
863 public @interface InstallReason {}
864
865 /**
866 * Code indicating that the reason for installing this package is unknown.
867 */
868 public static final int INSTALL_REASON_UNKNOWN = 0;
869
870 /**
871 * Code indicating that this package was installed due to enterprise policy.
872 */
873 public static final int INSTALL_REASON_POLICY = 1;
874
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800875 /**
Sunny Goyal80af6a22017-03-02 08:32:33 -0800876 * Code indicating that this package was installed as part of restoring from another device.
877 */
878 public static final int INSTALL_REASON_DEVICE_RESTORE = 2;
879
880 /**
881 * Code indicating that this package was installed as part of device setup.
882 */
883 public static final int INSTALL_REASON_DEVICE_SETUP = 3;
884
885 /**
886 * Code indicating that the package installation was initiated by the user.
887 */
888 public static final int INSTALL_REASON_USER = 4;
889
890 /**
Philip P. Moltmannb13f1532017-11-14 08:34:06 -0800891 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
892 * on success.
Jeff Sharkey5aa86932016-01-08 19:07:49 -0700893 *
Dianne Hackbornade3eca2009-05-11 18:54:45 -0700894 * @hide
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800895 */
Jeff Brownd5a5b5a2014-06-05 17:14:39 -0700896 @SystemApi
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800897 public static final int INSTALL_SUCCEEDED = 1;
898
899 /**
Philip P. Moltmannb13f1532017-11-14 08:34:06 -0800900 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
901 * if the package is already installed.
Jeff Sharkey5aa86932016-01-08 19:07:49 -0700902 *
Dianne Hackbornade3eca2009-05-11 18:54:45 -0700903 * @hide
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800904 */
Jeff Brownd5a5b5a2014-06-05 17:14:39 -0700905 @SystemApi
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800906 public static final int INSTALL_FAILED_ALREADY_EXISTS = -1;
907
908 /**
Philip P. Moltmannb13f1532017-11-14 08:34:06 -0800909 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
910 * if the package archive file is invalid.
Jeff Sharkey5aa86932016-01-08 19:07:49 -0700911 *
Dianne Hackbornade3eca2009-05-11 18:54:45 -0700912 * @hide
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800913 */
Jeff Brownd5a5b5a2014-06-05 17:14:39 -0700914 @SystemApi
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800915 public static final int INSTALL_FAILED_INVALID_APK = -2;
916
917 /**
Philip P. Moltmannb13f1532017-11-14 08:34:06 -0800918 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
919 * if the URI passed in is invalid.
Jeff Sharkey5aa86932016-01-08 19:07:49 -0700920 *
Dianne Hackbornade3eca2009-05-11 18:54:45 -0700921 * @hide
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800922 */
Jeff Brownd5a5b5a2014-06-05 17:14:39 -0700923 @SystemApi
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800924 public static final int INSTALL_FAILED_INVALID_URI = -3;
925
926 /**
Philip P. Moltmannb13f1532017-11-14 08:34:06 -0800927 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
928 * if the package manager service found that the device didn't have enough storage space to
929 * install the app.
Jeff Sharkey5aa86932016-01-08 19:07:49 -0700930 *
Dianne Hackbornade3eca2009-05-11 18:54:45 -0700931 * @hide
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800932 */
Jeff Brownd5a5b5a2014-06-05 17:14:39 -0700933 @SystemApi
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800934 public static final int INSTALL_FAILED_INSUFFICIENT_STORAGE = -4;
935
936 /**
Philip P. Moltmannb13f1532017-11-14 08:34:06 -0800937 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
938 * if a package is already installed with the same name.
Jeff Sharkey5aa86932016-01-08 19:07:49 -0700939 *
Dianne Hackbornade3eca2009-05-11 18:54:45 -0700940 * @hide
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800941 */
Jeff Brownd5a5b5a2014-06-05 17:14:39 -0700942 @SystemApi
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800943 public static final int INSTALL_FAILED_DUPLICATE_PACKAGE = -5;
944
945 /**
Philip P. Moltmannb13f1532017-11-14 08:34:06 -0800946 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
947 * if the requested shared user does not exist.
Jeff Sharkey5aa86932016-01-08 19:07:49 -0700948 *
Dianne Hackbornade3eca2009-05-11 18:54:45 -0700949 * @hide
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800950 */
Jeff Brownd5a5b5a2014-06-05 17:14:39 -0700951 @SystemApi
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800952 public static final int INSTALL_FAILED_NO_SHARED_USER = -6;
953
954 /**
Philip P. Moltmannb13f1532017-11-14 08:34:06 -0800955 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
956 * if a previously installed package of the same name has a different signature than the new
957 * package (and the old package's data was not removed).
Jeff Sharkey5aa86932016-01-08 19:07:49 -0700958 *
Dianne Hackbornade3eca2009-05-11 18:54:45 -0700959 * @hide
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800960 */
Jeff Brownd5a5b5a2014-06-05 17:14:39 -0700961 @SystemApi
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800962 public static final int INSTALL_FAILED_UPDATE_INCOMPATIBLE = -7;
963
964 /**
Philip P. Moltmannb13f1532017-11-14 08:34:06 -0800965 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
966 * if the new package is requested a shared user which is already installed on the device and
967 * does not have matching signature.
Jeff Sharkey5aa86932016-01-08 19:07:49 -0700968 *
Dianne Hackbornade3eca2009-05-11 18:54:45 -0700969 * @hide
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800970 */
Jeff Brownd5a5b5a2014-06-05 17:14:39 -0700971 @SystemApi
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800972 public static final int INSTALL_FAILED_SHARED_USER_INCOMPATIBLE = -8;
973
974 /**
Philip P. Moltmannb13f1532017-11-14 08:34:06 -0800975 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
976 * if the new package uses a shared library that is not available.
Jeff Sharkey5aa86932016-01-08 19:07:49 -0700977 *
Dianne Hackbornade3eca2009-05-11 18:54:45 -0700978 * @hide
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800979 */
Jeff Brownd5a5b5a2014-06-05 17:14:39 -0700980 @SystemApi
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800981 public static final int INSTALL_FAILED_MISSING_SHARED_LIBRARY = -9;
982
983 /**
Philip P. Moltmannb13f1532017-11-14 08:34:06 -0800984 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
985 * if the new package uses a shared library that is not available.
Jeff Sharkey5aa86932016-01-08 19:07:49 -0700986 *
Dianne Hackbornade3eca2009-05-11 18:54:45 -0700987 * @hide
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800988 */
Jeff Brownd5a5b5a2014-06-05 17:14:39 -0700989 @SystemApi
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800990 public static final int INSTALL_FAILED_REPLACE_COULDNT_DELETE = -10;
991
992 /**
Philip P. Moltmannb13f1532017-11-14 08:34:06 -0800993 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
994 * if the new package failed while optimizing and validating its dex files, either because there
995 * was not enough storage or the validation failed.
Jeff Sharkey5aa86932016-01-08 19:07:49 -0700996 *
Dianne Hackbornade3eca2009-05-11 18:54:45 -0700997 * @hide
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800998 */
Jeff Brownd5a5b5a2014-06-05 17:14:39 -0700999 @SystemApi
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001000 public static final int INSTALL_FAILED_DEXOPT = -11;
1001
1002 /**
Philip P. Moltmannb13f1532017-11-14 08:34:06 -08001003 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
1004 * if the new package failed because the current SDK version is older than that required by the
1005 * package.
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001006 *
Dianne Hackbornade3eca2009-05-11 18:54:45 -07001007 * @hide
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001008 */
Jeff Brownd5a5b5a2014-06-05 17:14:39 -07001009 @SystemApi
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001010 public static final int INSTALL_FAILED_OLDER_SDK = -12;
1011
1012 /**
Philip P. Moltmannb13f1532017-11-14 08:34:06 -08001013 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
1014 * if the new package failed because it contains a content provider with the same authority as a
1015 * provider already installed in the system.
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001016 *
Dianne Hackbornade3eca2009-05-11 18:54:45 -07001017 * @hide
The Android Open Source Project10592532009-03-18 17:39:46 -07001018 */
Jeff Brownd5a5b5a2014-06-05 17:14:39 -07001019 @SystemApi
The Android Open Source Project10592532009-03-18 17:39:46 -07001020 public static final int INSTALL_FAILED_CONFLICTING_PROVIDER = -13;
1021
1022 /**
Philip P. Moltmannb13f1532017-11-14 08:34:06 -08001023 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
1024 * if the new package failed because the current SDK version is newer than that required by the
1025 * package.
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001026 *
Dianne Hackbornade3eca2009-05-11 18:54:45 -07001027 * @hide
Dianne Hackborn851a5412009-05-08 12:06:44 -07001028 */
Jeff Brownd5a5b5a2014-06-05 17:14:39 -07001029 @SystemApi
Dianne Hackborn851a5412009-05-08 12:06:44 -07001030 public static final int INSTALL_FAILED_NEWER_SDK = -14;
1031
1032 /**
Philip P. Moltmannb13f1532017-11-14 08:34:06 -08001033 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
1034 * if the new package failed because it has specified that it is a test-only package and the
1035 * caller has not supplied the {@link #INSTALL_ALLOW_TEST} flag.
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001036 *
Dianne Hackbornade3eca2009-05-11 18:54:45 -07001037 * @hide
1038 */
Jeff Brownd5a5b5a2014-06-05 17:14:39 -07001039 @SystemApi
Dianne Hackbornade3eca2009-05-11 18:54:45 -07001040 public static final int INSTALL_FAILED_TEST_ONLY = -15;
1041
1042 /**
Philip P. Moltmannb13f1532017-11-14 08:34:06 -08001043 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
1044 * if the package being installed contains native code, but none that is compatible with the
1045 * device's CPU_ABI.
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001046 *
Dianne Hackbornb1811182009-05-21 15:45:42 -07001047 * @hide
1048 */
Jeff Brownd5a5b5a2014-06-05 17:14:39 -07001049 @SystemApi
Dianne Hackbornb1811182009-05-21 15:45:42 -07001050 public static final int INSTALL_FAILED_CPU_ABI_INCOMPATIBLE = -16;
1051
1052 /**
Philip P. Moltmannb13f1532017-11-14 08:34:06 -08001053 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
1054 * if the new package uses a feature that is not available.
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001055 *
Dianne Hackborn49237342009-08-27 20:08:01 -07001056 * @hide
1057 */
Jeff Brownd5a5b5a2014-06-05 17:14:39 -07001058 @SystemApi
Dianne Hackborn49237342009-08-27 20:08:01 -07001059 public static final int INSTALL_FAILED_MISSING_FEATURE = -17;
1060
Suchi Amalapurapuaf8e9f42010-01-12 10:17:28 -08001061 // ------ Errors related to sdcard
1062 /**
Philip P. Moltmannb13f1532017-11-14 08:34:06 -08001063 * Installation return code: this is passed in the
1064 * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if a secure container mount point couldn't be
1065 * accessed on external media.
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001066 *
Suchi Amalapurapuaf8e9f42010-01-12 10:17:28 -08001067 * @hide
1068 */
Jeff Brownd5a5b5a2014-06-05 17:14:39 -07001069 @SystemApi
Suchi Amalapurapuaf8e9f42010-01-12 10:17:28 -08001070 public static final int INSTALL_FAILED_CONTAINER_ERROR = -18;
1071
Dianne Hackborn49237342009-08-27 20:08:01 -07001072 /**
Philip P. Moltmannb13f1532017-11-14 08:34:06 -08001073 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
1074 * if the new package couldn't be installed in the specified install location.
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001075 *
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08001076 * @hide
1077 */
Jeff Brownd5a5b5a2014-06-05 17:14:39 -07001078 @SystemApi
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08001079 public static final int INSTALL_FAILED_INVALID_INSTALL_LOCATION = -19;
1080
1081 /**
Philip P. Moltmannb13f1532017-11-14 08:34:06 -08001082 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
1083 * if the new package couldn't be installed in the specified install location because the media
1084 * is not available.
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001085 *
Suchi Amalapurapu8a9ab242010-03-11 16:49:16 -08001086 * @hide
1087 */
Jeff Brownd5a5b5a2014-06-05 17:14:39 -07001088 @SystemApi
Suchi Amalapurapu8a9ab242010-03-11 16:49:16 -08001089 public static final int INSTALL_FAILED_MEDIA_UNAVAILABLE = -20;
1090
1091 /**
Philip P. Moltmannb13f1532017-11-14 08:34:06 -08001092 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
1093 * if the new package couldn't be installed because the verification timed out.
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001094 *
Kenny Root5ab21572011-07-27 11:11:19 -07001095 * @hide
1096 */
Jeff Brownd5a5b5a2014-06-05 17:14:39 -07001097 @SystemApi
Kenny Root5ab21572011-07-27 11:11:19 -07001098 public static final int INSTALL_FAILED_VERIFICATION_TIMEOUT = -21;
1099
1100 /**
Philip P. Moltmannb13f1532017-11-14 08:34:06 -08001101 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
1102 * if the new package couldn't be installed because the verification did not succeed.
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001103 *
Kenny Root5ab21572011-07-27 11:11:19 -07001104 * @hide
1105 */
Jeff Brownd5a5b5a2014-06-05 17:14:39 -07001106 @SystemApi
Kenny Root5ab21572011-07-27 11:11:19 -07001107 public static final int INSTALL_FAILED_VERIFICATION_FAILURE = -22;
1108
1109 /**
Philip P. Moltmannb13f1532017-11-14 08:34:06 -08001110 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
1111 * if the package changed from what the calling program expected.
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001112 *
Kenny Root5ab21572011-07-27 11:11:19 -07001113 * @hide
1114 */
Jeff Brownd5a5b5a2014-06-05 17:14:39 -07001115 @SystemApi
Kenny Root5ab21572011-07-27 11:11:19 -07001116 public static final int INSTALL_FAILED_PACKAGE_CHANGED = -23;
1117
1118 /**
Philip P. Moltmannb13f1532017-11-14 08:34:06 -08001119 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
1120 * if the new package is assigned a different UID than it previously held.
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001121 *
Dianne Hackbornd0c5f512012-06-07 16:53:59 -07001122 * @hide
1123 */
1124 public static final int INSTALL_FAILED_UID_CHANGED = -24;
1125
1126 /**
Philip P. Moltmannb13f1532017-11-14 08:34:06 -08001127 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
1128 * if the new package has an older version code than the currently installed package.
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001129 *
Dianne Hackborn7767eac2012-08-23 18:25:40 -07001130 * @hide
1131 */
1132 public static final int INSTALL_FAILED_VERSION_DOWNGRADE = -25;
1133
1134 /**
Philip P. Moltmannb13f1532017-11-14 08:34:06 -08001135 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
1136 * if the old package has target SDK high enough to support runtime permission and the new
1137 * package has target SDK low enough to not support runtime permissions.
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001138 *
Svetoslavd9653702015-05-13 18:02:46 -07001139 * @hide
1140 */
1141 @SystemApi
1142 public static final int INSTALL_FAILED_PERMISSION_MODEL_DOWNGRADE = -26;
1143
1144 /**
Philip P. Moltmannb13f1532017-11-14 08:34:06 -08001145 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
1146 * if the new package attempts to downgrade the target sandbox version of the app.
Chad Brubaker34573b22017-03-07 15:27:35 -08001147 *
1148 * @hide
1149 */
1150 @SystemApi
1151 public static final int INSTALL_FAILED_SANDBOX_VERSION_DOWNGRADE = -27;
1152
1153 /**
Philip P. Moltmannb13f1532017-11-14 08:34:06 -08001154 * Installation parse return code: this is passed in the
1155 * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the parser was given a path that is not a
1156 * file, or does not end with the expected '.apk' extension.
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001157 *
Dianne Hackbornade3eca2009-05-11 18:54:45 -07001158 * @hide
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001159 */
Jeff Brownd5a5b5a2014-06-05 17:14:39 -07001160 @SystemApi
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001161 public static final int INSTALL_PARSE_FAILED_NOT_APK = -100;
1162
1163 /**
Philip P. Moltmannb13f1532017-11-14 08:34:06 -08001164 * Installation parse return code: this is passed in the
1165 * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the parser was unable to retrieve the
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001166 * AndroidManifest.xml file.
1167 *
Dianne Hackbornade3eca2009-05-11 18:54:45 -07001168 * @hide
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001169 */
Jeff Brownd5a5b5a2014-06-05 17:14:39 -07001170 @SystemApi
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001171 public static final int INSTALL_PARSE_FAILED_BAD_MANIFEST = -101;
1172
1173 /**
Philip P. Moltmannb13f1532017-11-14 08:34:06 -08001174 * Installation parse return code: this is passed in the
1175 * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the parser encountered an unexpected
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001176 * exception.
1177 *
Dianne Hackbornade3eca2009-05-11 18:54:45 -07001178 * @hide
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001179 */
Jeff Brownd5a5b5a2014-06-05 17:14:39 -07001180 @SystemApi
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001181 public static final int INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION = -102;
1182
1183 /**
Philip P. Moltmannb13f1532017-11-14 08:34:06 -08001184 * Installation parse return code: this is passed in the
1185 * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the parser did not find any certificates in
1186 * the .apk.
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001187 *
Dianne Hackbornade3eca2009-05-11 18:54:45 -07001188 * @hide
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001189 */
Jeff Brownd5a5b5a2014-06-05 17:14:39 -07001190 @SystemApi
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001191 public static final int INSTALL_PARSE_FAILED_NO_CERTIFICATES = -103;
1192
1193 /**
Philip P. Moltmannb13f1532017-11-14 08:34:06 -08001194 * Installation parse return code: this is passed in the
1195 * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the parser found inconsistent certificates on
1196 * the files in the .apk.
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001197 *
Dianne Hackbornade3eca2009-05-11 18:54:45 -07001198 * @hide
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001199 */
Jeff Brownd5a5b5a2014-06-05 17:14:39 -07001200 @SystemApi
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001201 public static final int INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES = -104;
1202
1203 /**
Philip P. Moltmannb13f1532017-11-14 08:34:06 -08001204 * Installation parse return code: this is passed in the
1205 * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the parser encountered a
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001206 * CertificateEncodingException in one of the files in the .apk.
1207 *
Dianne Hackbornade3eca2009-05-11 18:54:45 -07001208 * @hide
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001209 */
Jeff Brownd5a5b5a2014-06-05 17:14:39 -07001210 @SystemApi
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001211 public static final int INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING = -105;
1212
1213 /**
Philip P. Moltmannb13f1532017-11-14 08:34:06 -08001214 * Installation parse return code: this is passed in the
1215 * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the parser encountered a bad or missing
1216 * package name in the manifest.
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001217 *
Dianne Hackbornade3eca2009-05-11 18:54:45 -07001218 * @hide
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001219 */
Jeff Brownd5a5b5a2014-06-05 17:14:39 -07001220 @SystemApi
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001221 public static final int INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME = -106;
1222
1223 /**
Philip P. Moltmannb13f1532017-11-14 08:34:06 -08001224 * Installation parse return code: tthis is passed in the
1225 * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the parser encountered a bad shared user id
1226 * name in the manifest.
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001227 *
Dianne Hackbornade3eca2009-05-11 18:54:45 -07001228 * @hide
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001229 */
Jeff Brownd5a5b5a2014-06-05 17:14:39 -07001230 @SystemApi
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001231 public static final int INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID = -107;
1232
1233 /**
Philip P. Moltmannb13f1532017-11-14 08:34:06 -08001234 * Installation parse return code: this is passed in the
1235 * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the parser encountered some structural
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001236 * problem in the manifest.
1237 *
Dianne Hackbornade3eca2009-05-11 18:54:45 -07001238 * @hide
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001239 */
Jeff Brownd5a5b5a2014-06-05 17:14:39 -07001240 @SystemApi
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001241 public static final int INSTALL_PARSE_FAILED_MANIFEST_MALFORMED = -108;
1242
1243 /**
Philip P. Moltmannb13f1532017-11-14 08:34:06 -08001244 * Installation parse return code: this is passed in the
1245 * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the parser did not find any actionable tags
1246 * (instrumentation or application) in the manifest.
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001247 *
Dianne Hackbornade3eca2009-05-11 18:54:45 -07001248 * @hide
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001249 */
Jeff Brownd5a5b5a2014-06-05 17:14:39 -07001250 @SystemApi
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001251 public static final int INSTALL_PARSE_FAILED_MANIFEST_EMPTY = -109;
1252
1253 /**
Philip P. Moltmannb13f1532017-11-14 08:34:06 -08001254 * Installation failed return code: this is passed in the
1255 * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the system failed to install the package
1256 * because of system issues.
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001257 *
Suchi Amalapurapu5b993ce2010-02-12 09:43:29 -08001258 * @hide
1259 */
Jeff Brownd5a5b5a2014-06-05 17:14:39 -07001260 @SystemApi
Suchi Amalapurapu5b993ce2010-02-12 09:43:29 -08001261 public static final int INSTALL_FAILED_INTERNAL_ERROR = -110;
1262
1263 /**
Philip P. Moltmannb13f1532017-11-14 08:34:06 -08001264 * Installation failed return code: this is passed in the
1265 * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the system failed to install the package
1266 * because the user is restricted from installing apps.
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001267 *
Amith Yamasanie4cf7342012-12-17 11:12:09 -08001268 * @hide
1269 */
1270 public static final int INSTALL_FAILED_USER_RESTRICTED = -111;
1271
1272 /**
Philip P. Moltmannb13f1532017-11-14 08:34:06 -08001273 * Installation failed return code: this is passed in the
1274 * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the system failed to install the package
1275 * because it is attempting to define a permission that is already defined by some existing
1276 * package.
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001277 * <p>
Philip P. Moltmannb13f1532017-11-14 08:34:06 -08001278 * The package name of the app which has already defined the permission is passed to a
1279 * {@link PackageInstallObserver}, if any, as the {@link #EXTRA_FAILURE_EXISTING_PACKAGE} string
1280 * extra; and the name of the permission being redefined is passed in the
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001281 * {@link #EXTRA_FAILURE_EXISTING_PERMISSION} string extra.
Christopher Tatef1977b42014-03-24 16:25:51 -07001282 *
Christopher Tatef1977b42014-03-24 16:25:51 -07001283 * @hide
1284 */
1285 public static final int INSTALL_FAILED_DUPLICATE_PERMISSION = -112;
1286
1287 /**
Philip P. Moltmannb13f1532017-11-14 08:34:06 -08001288 * Installation failed return code: this is passed in the
1289 * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the system failed to install the package
1290 * because its packaged native code did not match any of the ABIs supported by the system.
Ramin Zaghi1378aba2014-02-28 15:03:19 +00001291 *
1292 * @hide
1293 */
Narayan Kamathd11f2232014-04-10 10:37:17 +01001294 public static final int INSTALL_FAILED_NO_MATCHING_ABIS = -113;
Ramin Zaghi1378aba2014-02-28 15:03:19 +00001295
1296 /**
1297 * Internal return code for NativeLibraryHelper methods to indicate that the package
1298 * being processed did not contain any native code. This is placed here only so that
1299 * it can belong to the same value space as the other install failure codes.
1300 *
1301 * @hide
1302 */
Narayan Kamathd11f2232014-04-10 10:37:17 +01001303 public static final int NO_NATIVE_LIBRARIES = -114;
Ramin Zaghi1378aba2014-02-28 15:03:19 +00001304
Jeff Sharkey7328a1b2014-08-07 14:01:43 -07001305 /** {@hide} */
Jeff Sharkeyf0600952014-08-07 17:31:53 -07001306 public static final int INSTALL_FAILED_ABORTED = -115;
Jeff Sharkey7328a1b2014-08-07 14:01:43 -07001307
Ramin Zaghi1378aba2014-02-28 15:03:19 +00001308 /**
Todd Kennedybe0b8892017-02-15 14:13:52 -08001309 * Installation failed return code: instant app installs are incompatible with some
Todd Kennedy2699f062015-11-20 13:07:17 -08001310 * other installation flags supplied for the operation; or other circumstances such
Todd Kennedybe0b8892017-02-15 14:13:52 -08001311 * as trying to upgrade a system app via an instant app install.
Todd Kennedy2699f062015-11-20 13:07:17 -08001312 * @hide
1313 */
Todd Kennedybe0b8892017-02-15 14:13:52 -08001314 public static final int INSTALL_FAILED_INSTANT_APP_INVALID = -116;
Todd Kennedy2699f062015-11-20 13:07:17 -08001315
Calin Juravle3fc56c32017-12-11 18:26:13 -08001316 /**
1317 * Installation parse return code: this is passed in the
1318 * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the dex metadata file is invalid or
1319 * if there was no matching apk file for a dex metadata file.
1320 *
1321 * @hide
1322 */
1323 public static final int INSTALL_FAILED_BAD_DEX_METADATA = -117;
1324
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001325 /** @hide */
Jeff Sharkey4347f812017-04-21 12:08:39 -06001326 @IntDef(flag = true, prefix = { "DELETE_" }, value = {
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001327 DELETE_KEEP_DATA,
1328 DELETE_ALL_USERS,
1329 DELETE_SYSTEM_APP,
Todd Kennedy39bfee52016-02-24 10:28:21 -08001330 DELETE_DONT_KILL_APP,
Todd Kennedy232d29e2017-11-06 14:45:53 -08001331 DELETE_CHATTY,
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001332 })
1333 @Retention(RetentionPolicy.SOURCE)
1334 public @interface DeleteFlags {}
1335
Todd Kennedy2699f062015-11-20 13:07:17 -08001336 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001337 * Flag parameter for {@link #deletePackage} to indicate that you don't want to delete the
1338 * package's data directory.
1339 *
1340 * @hide
1341 */
Dianne Hackborn7767eac2012-08-23 18:25:40 -07001342 public static final int DELETE_KEEP_DATA = 0x00000001;
1343
1344 /**
1345 * Flag parameter for {@link #deletePackage} to indicate that you want the
1346 * package deleted for all users.
1347 *
1348 * @hide
1349 */
1350 public static final int DELETE_ALL_USERS = 0x00000002;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001351
1352 /**
Dianne Hackbornc895be72013-03-11 17:48:43 -07001353 * Flag parameter for {@link #deletePackage} to indicate that, if you are calling
1354 * uninstall on a system that has been updated, then don't do the normal process
1355 * of uninstalling the update and rolling back to the older system version (which
1356 * needs to happen for all users); instead, just mark the app as uninstalled for
1357 * the current user.
1358 *
1359 * @hide
1360 */
1361 public static final int DELETE_SYSTEM_APP = 0x00000004;
1362
1363 /**
Todd Kennedy39bfee52016-02-24 10:28:21 -08001364 * Flag parameter for {@link #deletePackage} to indicate that, if you are calling
1365 * uninstall on a package that is replaced to provide new feature splits, the
1366 * existing application should not be killed during the removal process.
1367 *
1368 * @hide
1369 */
1370 public static final int DELETE_DONT_KILL_APP = 0x00000008;
1371
1372 /**
Todd Kennedy232d29e2017-11-06 14:45:53 -08001373 * Flag parameter for {@link #deletePackage} to indicate that package deletion
1374 * should be chatty.
1375 *
1376 * @hide
1377 */
1378 public static final int DELETE_CHATTY = 0x80000000;
1379
1380 /**
Kenny Rootc39bb4a2011-02-28 13:27:19 -08001381 * Return code for when package deletion succeeds. This is passed to the
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001382 * {@link IPackageDeleteObserver} if the system succeeded in deleting the
1383 * package.
Amith Yamasani4b2e9342011-03-31 12:38:53 -07001384 *
Kenny Rootc39bb4a2011-02-28 13:27:19 -08001385 * @hide
1386 */
1387 public static final int DELETE_SUCCEEDED = 1;
1388
1389 /**
1390 * Deletion failed return code: this is passed to the
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001391 * {@link IPackageDeleteObserver} if the system failed to delete the package
1392 * for an unspecified reason.
Amith Yamasani4b2e9342011-03-31 12:38:53 -07001393 *
Kenny Rootc39bb4a2011-02-28 13:27:19 -08001394 * @hide
1395 */
1396 public static final int DELETE_FAILED_INTERNAL_ERROR = -1;
1397
1398 /**
1399 * Deletion failed return code: this is passed to the
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001400 * {@link IPackageDeleteObserver} if the system failed to delete the package
1401 * because it is the active DevicePolicy manager.
Amith Yamasani4b2e9342011-03-31 12:38:53 -07001402 *
Kenny Rootc39bb4a2011-02-28 13:27:19 -08001403 * @hide
1404 */
1405 public static final int DELETE_FAILED_DEVICE_POLICY_MANAGER = -2;
1406
1407 /**
Amith Yamasanie4cf7342012-12-17 11:12:09 -08001408 * Deletion failed return code: this is passed to the
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001409 * {@link IPackageDeleteObserver} if the system failed to delete the package
1410 * since the user is restricted.
Amith Yamasanie4cf7342012-12-17 11:12:09 -08001411 *
1412 * @hide
1413 */
1414 public static final int DELETE_FAILED_USER_RESTRICTED = -3;
1415
1416 /**
Kenny Guy1b88da52014-07-10 16:33:49 +01001417 * Deletion failed return code: this is passed to the
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001418 * {@link IPackageDeleteObserver} if the system failed to delete the package
1419 * because a profile or device owner has marked the package as
1420 * uninstallable.
Kenny Guyc13053b2014-05-29 14:17:17 +01001421 *
1422 * @hide
1423 */
Jeff Sharkeyf0600952014-08-07 17:31:53 -07001424 public static final int DELETE_FAILED_OWNER_BLOCKED = -4;
1425
1426 /** {@hide} */
1427 public static final int DELETE_FAILED_ABORTED = -5;
Kenny Guyc13053b2014-05-29 14:17:17 +01001428
1429 /**
Svet Ganov67882122016-12-11 16:36:34 -08001430 * Deletion failed return code: this is passed to the
1431 * {@link IPackageDeleteObserver} if the system failed to delete the package
1432 * because the packge is a shared library used by other installed packages.
1433 * {@hide} */
1434 public static final int DELETE_FAILED_USED_SHARED_LIBRARY = -6;
1435
1436 /**
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001437 * Return code that is passed to the {@link IPackageMoveObserver} when the
Kenny Rootc39bb4a2011-02-28 13:27:19 -08001438 * package has been successfully moved by the system.
Amith Yamasani4b2e9342011-03-31 12:38:53 -07001439 *
Suchi Amalapurapu8946dd32010-02-19 09:19:34 -08001440 * @hide
1441 */
Jeff Sharkey620b32b2015-04-23 19:36:02 -07001442 public static final int MOVE_SUCCEEDED = -100;
1443
Suchi Amalapurapu8946dd32010-02-19 09:19:34 -08001444 /**
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001445 * Error code that is passed to the {@link IPackageMoveObserver} when the
1446 * package hasn't been successfully moved by the system because of
1447 * insufficient memory on specified media.
1448 *
Suchi Amalapurapu8946dd32010-02-19 09:19:34 -08001449 * @hide
1450 */
1451 public static final int MOVE_FAILED_INSUFFICIENT_STORAGE = -1;
1452
1453 /**
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001454 * Error code that is passed to the {@link IPackageMoveObserver} if the
1455 * specified package doesn't exist.
1456 *
Suchi Amalapurapu8946dd32010-02-19 09:19:34 -08001457 * @hide
1458 */
1459 public static final int MOVE_FAILED_DOESNT_EXIST = -2;
1460
1461 /**
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001462 * Error code that is passed to the {@link IPackageMoveObserver} if the
1463 * specified package cannot be moved since its a system package.
1464 *
Suchi Amalapurapu8946dd32010-02-19 09:19:34 -08001465 * @hide
1466 */
1467 public static final int MOVE_FAILED_SYSTEM_PACKAGE = -3;
1468
1469 /**
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001470 * Error code that is passed to the {@link IPackageMoveObserver} if the
1471 * specified package cannot be moved since its forward locked.
1472 *
Suchi Amalapurapu8946dd32010-02-19 09:19:34 -08001473 * @hide
1474 */
1475 public static final int MOVE_FAILED_FORWARD_LOCKED = -4;
1476
1477 /**
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001478 * Error code that is passed to the {@link IPackageMoveObserver} if the
1479 * specified package cannot be moved to the specified location.
1480 *
Suchi Amalapurapu8946dd32010-02-19 09:19:34 -08001481 * @hide
1482 */
1483 public static final int MOVE_FAILED_INVALID_LOCATION = -5;
1484
1485 /**
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001486 * Error code that is passed to the {@link IPackageMoveObserver} if the
1487 * specified package cannot be moved to the specified location.
1488 *
Suchi Amalapurapu8a9ab242010-03-11 16:49:16 -08001489 * @hide
1490 */
1491 public static final int MOVE_FAILED_INTERNAL_ERROR = -6;
1492
1493 /**
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001494 * Error code that is passed to the {@link IPackageMoveObserver} if the
1495 * specified package already has an operation pending in the queue.
Amith Yamasani4b2e9342011-03-31 12:38:53 -07001496 *
Kenny Rootdeb11262010-08-02 11:36:21 -07001497 * @hide
1498 */
1499 public static final int MOVE_FAILED_OPERATION_PENDING = -7;
1500
1501 /**
Makoto Onukif34db0a2016-02-17 11:17:15 -08001502 * Error code that is passed to the {@link IPackageMoveObserver} if the
1503 * specified package cannot be moved since it contains a device admin.
1504 *
1505 * @hide
1506 */
1507 public static final int MOVE_FAILED_DEVICE_ADMIN = -8;
1508
1509 /**
Yao Chen022b8ea2016-12-16 11:03:28 -08001510 * Error code that is passed to the {@link IPackageMoveObserver} if system does not allow
1511 * non-system apps to be moved to internal storage.
1512 *
1513 * @hide
1514 */
1515 public static final int MOVE_FAILED_3RD_PARTY_NOT_ALLOWED_ON_INTERNAL = -9;
1516
Jeff Sharkeya65e6492017-06-21 13:45:11 -06001517 /** @hide */
1518 public static final int MOVE_FAILED_LOCKED_USER = -10;
1519
Yao Chen022b8ea2016-12-16 11:03:28 -08001520 /**
Suchi Amalapurapu8946dd32010-02-19 09:19:34 -08001521 * Flag parameter for {@link #movePackage} to indicate that
1522 * the package should be moved to internal storage if its
1523 * been installed on external media.
1524 * @hide
1525 */
Jeff Sharkey620b32b2015-04-23 19:36:02 -07001526 @Deprecated
Suchi Amalapurapu8946dd32010-02-19 09:19:34 -08001527 public static final int MOVE_INTERNAL = 0x00000001;
1528
1529 /**
1530 * Flag parameter for {@link #movePackage} to indicate that
1531 * the package should be moved to external media.
1532 * @hide
1533 */
Jeff Sharkey620b32b2015-04-23 19:36:02 -07001534 @Deprecated
Suchi Amalapurapu8946dd32010-02-19 09:19:34 -08001535 public static final int MOVE_EXTERNAL_MEDIA = 0x00000002;
1536
Jeff Sharkey620b32b2015-04-23 19:36:02 -07001537 /** {@hide} */
1538 public static final String EXTRA_MOVE_ID = "android.content.pm.extra.MOVE_ID";
1539
Suchi Amalapurapu8946dd32010-02-19 09:19:34 -08001540 /**
Kenny Root05ca4c92011-09-15 10:36:25 -07001541 * Usable by the required verifier as the {@code verificationCode} argument
1542 * for {@link PackageManager#verifyPendingInstall} to indicate that it will
1543 * allow the installation to proceed without any of the optional verifiers
1544 * needing to vote.
1545 *
1546 * @hide
1547 */
1548 public static final int VERIFICATION_ALLOW_WITHOUT_SUFFICIENT = 2;
1549
1550 /**
Kenny Root3a9b5fb2011-09-20 14:15:38 -07001551 * Used as the {@code verificationCode} argument for
1552 * {@link PackageManager#verifyPendingInstall} to indicate that the calling
1553 * package verifier allows the installation to proceed.
1554 */
1555 public static final int VERIFICATION_ALLOW = 1;
1556
1557 /**
1558 * Used as the {@code verificationCode} argument for
1559 * {@link PackageManager#verifyPendingInstall} to indicate the calling
1560 * package verifier does not vote to allow the installation to proceed.
1561 */
1562 public static final int VERIFICATION_REJECT = -1;
1563
1564 /**
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -08001565 * Used as the {@code verificationCode} argument for
1566 * {@link PackageManager#verifyIntentFilter} to indicate that the calling
1567 * IntentFilter Verifier confirms that the IntentFilter is verified.
1568 *
1569 * @hide
1570 */
Todd Kennedydfa93ab2016-03-03 15:24:33 -08001571 @SystemApi
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -08001572 public static final int INTENT_FILTER_VERIFICATION_SUCCESS = 1;
1573
1574 /**
1575 * Used as the {@code verificationCode} argument for
1576 * {@link PackageManager#verifyIntentFilter} to indicate that the calling
1577 * IntentFilter Verifier confirms that the IntentFilter is NOT verified.
1578 *
1579 * @hide
1580 */
Todd Kennedydfa93ab2016-03-03 15:24:33 -08001581 @SystemApi
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -08001582 public static final int INTENT_FILTER_VERIFICATION_FAILURE = -1;
1583
1584 /**
1585 * Internal status code to indicate that an IntentFilter verification result is not specified.
1586 *
1587 * @hide
1588 */
Jeff Schumacher6fd90ed2017-01-20 13:58:34 -08001589 @SystemApi
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -08001590 public static final int INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_UNDEFINED = 0;
1591
1592 /**
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001593 * Used as the {@code status} argument for
1594 * {@link #updateIntentVerificationStatusAsUser} to indicate that the User
1595 * will always be prompted the Intent Disambiguation Dialog if there are two
1596 * or more Intent resolved for the IntentFilter's domain(s).
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -08001597 *
1598 * @hide
1599 */
Jeff Schumacher6fd90ed2017-01-20 13:58:34 -08001600 @SystemApi
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -08001601 public static final int INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK = 1;
1602
1603 /**
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001604 * Used as the {@code status} argument for
1605 * {@link #updateIntentVerificationStatusAsUser} to indicate that the User
1606 * will never be prompted the Intent Disambiguation Dialog if there are two
1607 * or more resolution of the Intent. The default App for the domain(s)
1608 * specified in the IntentFilter will also ALWAYS be used.
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -08001609 *
1610 * @hide
1611 */
Jeff Schumacher6fd90ed2017-01-20 13:58:34 -08001612 @SystemApi
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -08001613 public static final int INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS = 2;
1614
1615 /**
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001616 * Used as the {@code status} argument for
1617 * {@link #updateIntentVerificationStatusAsUser} to indicate that the User
1618 * may be prompted the Intent Disambiguation Dialog if there are two or more
1619 * Intent resolved. The default App for the domain(s) specified in the
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -08001620 * IntentFilter will also NEVER be presented to the User.
1621 *
1622 * @hide
1623 */
Jeff Schumacher6fd90ed2017-01-20 13:58:34 -08001624 @SystemApi
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -08001625 public static final int INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER = 3;
1626
1627 /**
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001628 * Used as the {@code status} argument for
1629 * {@link #updateIntentVerificationStatusAsUser} to indicate that this app
1630 * should always be considered as an ambiguous candidate for handling the
1631 * matching Intent even if there are other candidate apps in the "always"
1632 * state. Put another way: if there are any 'always ask' apps in a set of
1633 * more than one candidate app, then a disambiguation is *always* presented
1634 * even if there is another candidate app with the 'always' state.
Christopher Tate56f0ff32015-08-13 16:29:33 -07001635 *
1636 * @hide
1637 */
Jeff Schumacher6fd90ed2017-01-20 13:58:34 -08001638 @SystemApi
Christopher Tate56f0ff32015-08-13 16:29:33 -07001639 public static final int INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS_ASK = 4;
1640
1641 /**
rich canningsd9ef3e52012-08-22 14:28:05 -07001642 * Can be used as the {@code millisecondsToDelay} argument for
1643 * {@link PackageManager#extendVerificationTimeout}. This is the
1644 * maximum time {@code PackageManager} waits for the verification
1645 * agent to return (in milliseconds).
1646 */
1647 public static final long MAXIMUM_VERIFICATION_TIMEOUT = 60*60*1000;
1648
1649 /**
Amith Yamasani0b285492011-04-14 17:35:23 -07001650 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device's
1651 * audio pipeline is low-latency, more suitable for audio applications sensitive to delays or
1652 * lag in sound input or output.
Dan Morrill898e1e82010-09-26 17:28:30 -07001653 */
1654 @SdkConstant(SdkConstantType.FEATURE)
1655 public static final String FEATURE_AUDIO_LOW_LATENCY = "android.hardware.audio.low_latency";
1656
1657 /**
1658 * Feature for {@link #getSystemAvailableFeatures} and
Unsuk Jung50909f62014-09-02 18:25:49 -07001659 * {@link #hasSystemFeature}: The device includes at least one form of audio
Glenn Kasten0a111ad2018-05-16 14:11:09 -07001660 * output, as defined in the Android Compatibility Definition Document (CDD)
1661 * <a href="https://source.android.com/compatibility/android-cdd#7_8_audio">section 7.8 Audio</a>.
Unsuk Jung50909f62014-09-02 18:25:49 -07001662 */
1663 @SdkConstant(SdkConstantType.FEATURE)
1664 public static final String FEATURE_AUDIO_OUTPUT = "android.hardware.audio.output";
1665
1666 /**
Glenn Kastencdcb5772015-05-06 15:54:49 -07001667 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
Glenn Kasten7587edc2015-10-30 17:45:52 -07001668 * The device has professional audio level of functionality and performance.
Glenn Kastencdcb5772015-05-06 15:54:49 -07001669 */
1670 @SdkConstant(SdkConstantType.FEATURE)
1671 public static final String FEATURE_AUDIO_PRO = "android.hardware.audio.pro";
1672
1673 /**
Unsuk Jung50909f62014-09-02 18:25:49 -07001674 * Feature for {@link #getSystemAvailableFeatures} and
Dan Morrill50ab63f2010-03-05 16:16:19 -08001675 * {@link #hasSystemFeature}: The device is capable of communicating with
1676 * other devices via Bluetooth.
1677 */
1678 @SdkConstant(SdkConstantType.FEATURE)
1679 public static final String FEATURE_BLUETOOTH = "android.hardware.bluetooth";
1680
1681 /**
1682 * Feature for {@link #getSystemAvailableFeatures} and
Matthew Xiea7227722013-04-18 15:25:59 -07001683 * {@link #hasSystemFeature}: The device is capable of communicating with
1684 * other devices via Bluetooth Low Energy radio.
1685 */
1686 @SdkConstant(SdkConstantType.FEATURE)
1687 public static final String FEATURE_BLUETOOTH_LE = "android.hardware.bluetooth_le";
1688
1689 /**
1690 * Feature for {@link #getSystemAvailableFeatures} and
Dianne Hackborn08ee42c2009-11-19 17:08:01 -08001691 * {@link #hasSystemFeature}: The device has a camera facing away
1692 * from the screen.
1693 */
Xavier Ducrohet3274b9b2009-12-14 17:52:20 -08001694 @SdkConstant(SdkConstantType.FEATURE)
Dianne Hackborn08ee42c2009-11-19 17:08:01 -08001695 public static final String FEATURE_CAMERA = "android.hardware.camera";
Dan Morrill50ab63f2010-03-05 16:16:19 -08001696
Dianne Hackborn08ee42c2009-11-19 17:08:01 -08001697 /**
1698 * Feature for {@link #getSystemAvailableFeatures} and
1699 * {@link #hasSystemFeature}: The device's camera supports auto-focus.
1700 */
Xavier Ducrohet3274b9b2009-12-14 17:52:20 -08001701 @SdkConstant(SdkConstantType.FEATURE)
Dianne Hackborn08ee42c2009-11-19 17:08:01 -08001702 public static final String FEATURE_CAMERA_AUTOFOCUS = "android.hardware.camera.autofocus";
Dan Morrill50ab63f2010-03-05 16:16:19 -08001703
Dianne Hackborn08ee42c2009-11-19 17:08:01 -08001704 /**
1705 * Feature for {@link #getSystemAvailableFeatures} and
Eino-Ville Talvala752af832012-09-18 14:45:37 -07001706 * {@link #hasSystemFeature}: The device has at least one camera pointing in
Eino-Ville Talvala9131da22014-05-08 11:39:53 -07001707 * some direction, or can support an external camera being connected to it.
Eino-Ville Talvala752af832012-09-18 14:45:37 -07001708 */
1709 @SdkConstant(SdkConstantType.FEATURE)
1710 public static final String FEATURE_CAMERA_ANY = "android.hardware.camera.any";
1711
1712 /**
1713 * Feature for {@link #getSystemAvailableFeatures} and
Eino-Ville Talvala9131da22014-05-08 11:39:53 -07001714 * {@link #hasSystemFeature}: The device can support having an external camera connected to it.
1715 * The external camera may not always be connected or available to applications to use.
1716 */
1717 @SdkConstant(SdkConstantType.FEATURE)
1718 public static final String FEATURE_CAMERA_EXTERNAL = "android.hardware.camera.external";
1719
1720 /**
1721 * Feature for {@link #getSystemAvailableFeatures} and
Dianne Hackborn08ee42c2009-11-19 17:08:01 -08001722 * {@link #hasSystemFeature}: The device's camera supports flash.
1723 */
Xavier Ducrohet3274b9b2009-12-14 17:52:20 -08001724 @SdkConstant(SdkConstantType.FEATURE)
Dianne Hackborn08ee42c2009-11-19 17:08:01 -08001725 public static final String FEATURE_CAMERA_FLASH = "android.hardware.camera.flash";
Dan Morrill50ab63f2010-03-05 16:16:19 -08001726
1727 /**
1728 * Feature for {@link #getSystemAvailableFeatures} and
Chih-Chung Changde1057c2010-06-14 19:15:00 +08001729 * {@link #hasSystemFeature}: The device has a front facing camera.
1730 */
1731 @SdkConstant(SdkConstantType.FEATURE)
1732 public static final String FEATURE_CAMERA_FRONT = "android.hardware.camera.front";
1733
1734 /**
Eino-Ville Talvala611fece2014-07-10 17:29:38 -07001735 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: At least one
1736 * of the cameras on the device supports the
1737 * {@link android.hardware.camera2.CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL full hardware}
1738 * capability level.
1739 */
1740 @SdkConstant(SdkConstantType.FEATURE)
1741 public static final String FEATURE_CAMERA_LEVEL_FULL = "android.hardware.camera.level.full";
1742
1743 /**
1744 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: At least one
1745 * of the cameras on the device supports the
1746 * {@link android.hardware.camera2.CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_MANUAL_SENSOR manual sensor}
1747 * capability level.
1748 */
1749 @SdkConstant(SdkConstantType.FEATURE)
1750 public static final String FEATURE_CAMERA_CAPABILITY_MANUAL_SENSOR =
1751 "android.hardware.camera.capability.manual_sensor";
1752
1753 /**
1754 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: At least one
1755 * of the cameras on the device supports the
1756 * {@link android.hardware.camera2.CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_MANUAL_POST_PROCESSING manual post-processing}
1757 * capability level.
1758 */
1759 @SdkConstant(SdkConstantType.FEATURE)
1760 public static final String FEATURE_CAMERA_CAPABILITY_MANUAL_POST_PROCESSING =
1761 "android.hardware.camera.capability.manual_post_processing";
1762
1763 /**
1764 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: At least one
1765 * of the cameras on the device supports the
1766 * {@link android.hardware.camera2.CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_RAW RAW}
1767 * capability level.
1768 */
1769 @SdkConstant(SdkConstantType.FEATURE)
1770 public static final String FEATURE_CAMERA_CAPABILITY_RAW =
1771 "android.hardware.camera.capability.raw";
1772
1773 /**
Eino-Ville Talvaladfa0c2a2018-01-10 12:01:08 -08001774 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: At least one
1775 * of the cameras on the device supports the
1776 * {@link android.hardware.camera2.CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_MOTION_TRACKING
1777 * MOTION_TRACKING} capability level.
1778 */
1779 @SdkConstant(SdkConstantType.FEATURE)
1780 public static final String FEATURE_CAMERA_AR =
1781 "android.hardware.camera.ar";
1782
1783 /**
Chih-Chung Changde1057c2010-06-14 19:15:00 +08001784 * Feature for {@link #getSystemAvailableFeatures} and
Alex Ray0c9d61f2013-10-03 12:17:54 -07001785 * {@link #hasSystemFeature}: The device is capable of communicating with
1786 * consumer IR devices.
1787 */
1788 @SdkConstant(SdkConstantType.FEATURE)
1789 public static final String FEATURE_CONSUMER_IR = "android.hardware.consumerir";
1790
Sam Lin90e258b2017-04-03 20:57:45 -07001791 /** {@hide} */
1792 @SdkConstant(SdkConstantType.FEATURE)
1793 public static final String FEATURE_CTS = "android.software.cts";
1794
Alex Ray0c9d61f2013-10-03 12:17:54 -07001795 /**
1796 * Feature for {@link #getSystemAvailableFeatures} and
Dan Morrill50ab63f2010-03-05 16:16:19 -08001797 * {@link #hasSystemFeature}: The device supports one or more methods of
1798 * reporting current location.
1799 */
1800 @SdkConstant(SdkConstantType.FEATURE)
1801 public static final String FEATURE_LOCATION = "android.hardware.location";
1802
1803 /**
1804 * Feature for {@link #getSystemAvailableFeatures} and
1805 * {@link #hasSystemFeature}: The device has a Global Positioning System
1806 * receiver and can report precise location.
1807 */
1808 @SdkConstant(SdkConstantType.FEATURE)
1809 public static final String FEATURE_LOCATION_GPS = "android.hardware.location.gps";
1810
1811 /**
1812 * Feature for {@link #getSystemAvailableFeatures} and
1813 * {@link #hasSystemFeature}: The device can report location with coarse
1814 * accuracy using a network-based geolocation system.
1815 */
1816 @SdkConstant(SdkConstantType.FEATURE)
1817 public static final String FEATURE_LOCATION_NETWORK = "android.hardware.location.network";
1818
1819 /**
1820 * Feature for {@link #getSystemAvailableFeatures} and
Dianne Hackborn2a103f12017-08-08 15:50:31 -07001821 * {@link #hasSystemFeature}: The device's
1822 * {@link ActivityManager#isLowRamDevice() ActivityManager.isLowRamDevice()} method returns
1823 * true.
1824 */
1825 @SdkConstant(SdkConstantType.FEATURE)
1826 public static final String FEATURE_RAM_LOW = "android.hardware.ram.low";
1827
1828 /**
1829 * Feature for {@link #getSystemAvailableFeatures} and
1830 * {@link #hasSystemFeature}: The device's
1831 * {@link ActivityManager#isLowRamDevice() ActivityManager.isLowRamDevice()} method returns
1832 * false.
1833 */
1834 @SdkConstant(SdkConstantType.FEATURE)
1835 public static final String FEATURE_RAM_NORMAL = "android.hardware.ram.normal";
1836
1837 /**
1838 * Feature for {@link #getSystemAvailableFeatures} and
Dan Morrill50ab63f2010-03-05 16:16:19 -08001839 * {@link #hasSystemFeature}: The device can record audio via a
1840 * microphone.
1841 */
1842 @SdkConstant(SdkConstantType.FEATURE)
1843 public static final String FEATURE_MICROPHONE = "android.hardware.microphone";
1844
1845 /**
1846 * Feature for {@link #getSystemAvailableFeatures} and
Dan Morrill76437d32010-09-01 11:17:20 -07001847 * {@link #hasSystemFeature}: The device can communicate using Near-Field
1848 * Communications (NFC).
1849 */
1850 @SdkConstant(SdkConstantType.FEATURE)
1851 public static final String FEATURE_NFC = "android.hardware.nfc";
1852
1853 /**
1854 * Feature for {@link #getSystemAvailableFeatures} and
Martijn Coenenf4bf1582013-07-22 12:01:19 -07001855 * {@link #hasSystemFeature}: The device supports host-
1856 * based NFC card emulation.
Martijn Coenendf4d1d62013-08-28 11:18:58 -07001857 *
1858 * TODO remove when depending apps have moved to new constant.
1859 * @hide
1860 * @deprecated
Martijn Coenenf4bf1582013-07-22 12:01:19 -07001861 */
Jose Lima970417c2014-04-10 10:42:19 -07001862 @Deprecated
Martijn Coenenf4bf1582013-07-22 12:01:19 -07001863 @SdkConstant(SdkConstantType.FEATURE)
1864 public static final String FEATURE_NFC_HCE = "android.hardware.nfc.hce";
1865
1866 /**
1867 * Feature for {@link #getSystemAvailableFeatures} and
Martijn Coenendf4d1d62013-08-28 11:18:58 -07001868 * {@link #hasSystemFeature}: The device supports host-
1869 * based NFC card emulation.
1870 */
1871 @SdkConstant(SdkConstantType.FEATURE)
1872 public static final String FEATURE_NFC_HOST_CARD_EMULATION = "android.hardware.nfc.hce";
1873
1874 /**
1875 * Feature for {@link #getSystemAvailableFeatures} and
Yoshinobu Itoc52adfe2016-01-22 18:14:18 +09001876 * {@link #hasSystemFeature}: The device supports host-
1877 * based NFC-F card emulation.
1878 */
1879 @SdkConstant(SdkConstantType.FEATURE)
1880 public static final String FEATURE_NFC_HOST_CARD_EMULATION_NFCF = "android.hardware.nfc.hcef";
1881
1882 /**
1883 * Feature for {@link #getSystemAvailableFeatures} and
Martijn Coenen441d61b2017-04-12 13:52:40 -07001884 * {@link #hasSystemFeature}: The device supports any
1885 * one of the {@link #FEATURE_NFC}, {@link #FEATURE_NFC_HOST_CARD_EMULATION},
1886 * or {@link #FEATURE_NFC_HOST_CARD_EMULATION_NFCF} features.
1887 *
1888 * @hide
1889 */
1890 @SdkConstant(SdkConstantType.FEATURE)
1891 public static final String FEATURE_NFC_ANY = "android.hardware.nfc.any";
1892
1893 /**
1894 * Feature for {@link #getSystemAvailableFeatures} and
Jesse Hall7f517062014-07-18 11:54:41 -07001895 * {@link #hasSystemFeature}: The device supports the OpenGL ES
1896 * <a href="http://www.khronos.org/registry/gles/extensions/ANDROID/ANDROID_extension_pack_es31a.txt">
1897 * Android Extension Pack</a>.
1898 */
1899 @SdkConstant(SdkConstantType.FEATURE)
1900 public static final String FEATURE_OPENGLES_EXTENSION_PACK = "android.hardware.opengles.aep";
1901
1902 /**
1903 * Feature for {@link #getSystemAvailableFeatures} and
Jesse Hall39ceeb52016-03-10 09:04:26 -08001904 * {@link #hasSystemFeature(String, int)}: If this feature is supported, the Vulkan native API
1905 * will enumerate at least one {@code VkPhysicalDevice}, and the feature version will indicate
1906 * what level of optional hardware features limits it supports.
Jesse Hallf77a34f2016-02-04 18:41:33 -08001907 * <p>
1908 * Level 0 includes the base Vulkan requirements as well as:
1909 * <ul><li>{@code VkPhysicalDeviceFeatures::textureCompressionETC2}</li></ul>
1910 * <p>
1911 * Level 1 additionally includes:
1912 * <ul>
1913 * <li>{@code VkPhysicalDeviceFeatures::fullDrawIndexUint32}</li>
1914 * <li>{@code VkPhysicalDeviceFeatures::imageCubeArray}</li>
1915 * <li>{@code VkPhysicalDeviceFeatures::independentBlend}</li>
1916 * <li>{@code VkPhysicalDeviceFeatures::geometryShader}</li>
1917 * <li>{@code VkPhysicalDeviceFeatures::tessellationShader}</li>
1918 * <li>{@code VkPhysicalDeviceFeatures::sampleRateShading}</li>
1919 * <li>{@code VkPhysicalDeviceFeatures::textureCompressionASTC_LDR}</li>
1920 * <li>{@code VkPhysicalDeviceFeatures::fragmentStoresAndAtomics}</li>
1921 * <li>{@code VkPhysicalDeviceFeatures::shaderImageGatherExtended}</li>
1922 * <li>{@code VkPhysicalDeviceFeatures::shaderUniformBufferArrayDynamicIndexing}</li>
1923 * <li>{@code VkPhysicalDeviceFeatures::shaderSampledImageArrayDynamicIndexing}</li>
1924 * </ul>
1925 */
1926 @SdkConstant(SdkConstantType.FEATURE)
1927 public static final String FEATURE_VULKAN_HARDWARE_LEVEL = "android.hardware.vulkan.level";
1928
1929 /**
1930 * Feature for {@link #getSystemAvailableFeatures} and
Jesse Hall1cd7e932017-02-05 19:58:15 -08001931 * {@link #hasSystemFeature(String, int)}: If this feature is supported, the Vulkan native API
1932 * will enumerate at least one {@code VkPhysicalDevice}, and the feature version will indicate
Jesse Hall54fc6092017-08-22 07:19:56 -07001933 * what level of optional compute features that device supports beyond the Vulkan 1.0
1934 * requirements.
Jesse Hall1cd7e932017-02-05 19:58:15 -08001935 * <p>
Jesse Hall54fc6092017-08-22 07:19:56 -07001936 * Compute level 0 indicates:
1937 * <ul>
1938 * <li>The {@code VK_KHR_variable_pointers} extension and
1939 * {@code VkPhysicalDeviceVariablePointerFeaturesKHR::variablePointers} feature are
1940 supported.</li>
1941 * <li>{@code VkPhysicalDeviceLimits::maxPerStageDescriptorStorageBuffers} is at least 16.</li>
1942 * </ul>
Jesse Hall1cd7e932017-02-05 19:58:15 -08001943 */
1944 @SdkConstant(SdkConstantType.FEATURE)
1945 public static final String FEATURE_VULKAN_HARDWARE_COMPUTE = "android.hardware.vulkan.compute";
1946
1947 /**
1948 * Feature for {@link #getSystemAvailableFeatures} and
Jesse Hall39ceeb52016-03-10 09:04:26 -08001949 * {@link #hasSystemFeature(String, int)}: The version of this feature indicates the highest
Jesse Hallf77a34f2016-02-04 18:41:33 -08001950 * {@code VkPhysicalDeviceProperties::apiVersion} supported by the physical devices that support
1951 * the hardware level indicated by {@link #FEATURE_VULKAN_HARDWARE_LEVEL}. The feature version
1952 * uses the same encoding as Vulkan version numbers:
1953 * <ul>
1954 * <li>Major version number in bits 31-22</li>
1955 * <li>Minor version number in bits 21-12</li>
1956 * <li>Patch version number in bits 11-0</li>
1957 * </ul>
Jesse Hall239373f2018-01-26 11:35:10 +08001958 * A version of 1.1.0 or higher also indicates:
1959 * <ul>
Jesse Hall239373f2018-01-26 11:35:10 +08001960 * <li>{@code SYNC_FD} external semaphore and fence handles are supported.</li>
1961 * <li>{@code VkPhysicalDeviceSamplerYcbcrConversionFeatures::samplerYcbcrConversion} is
1962 * supported.</li>
1963 * </ul>
Jesse Hallf77a34f2016-02-04 18:41:33 -08001964 */
1965 @SdkConstant(SdkConstantType.FEATURE)
1966 public static final String FEATURE_VULKAN_HARDWARE_VERSION = "android.hardware.vulkan.version";
1967
1968 /**
Tomasz Wasilczyk05392d62017-07-10 19:33:22 -07001969 * Feature for {@link #getSystemAvailableFeatures} and
1970 * {@link #hasSystemFeature}: The device includes broadcast radio tuner.
1971 * @hide
Tomasz Wasilczyk347192e2017-04-04 11:13:44 -07001972 */
Tomasz Wasilczyk05392d62017-07-10 19:33:22 -07001973 @SystemApi
Tomasz Wasilczyk347192e2017-04-04 11:13:44 -07001974 @SdkConstant(SdkConstantType.FEATURE)
Tomasz Wasilczyk05392d62017-07-10 19:33:22 -07001975 public static final String FEATURE_BROADCAST_RADIO = "android.hardware.broadcastradio";
Tomasz Wasilczyk347192e2017-04-04 11:13:44 -07001976
1977 /**
Jesse Hallf77a34f2016-02-04 18:41:33 -08001978 * Feature for {@link #getSystemAvailableFeatures} and
Dan Morrill5744bb42010-09-01 19:18:57 -07001979 * {@link #hasSystemFeature}: The device includes an accelerometer.
1980 */
1981 @SdkConstant(SdkConstantType.FEATURE)
1982 public static final String FEATURE_SENSOR_ACCELEROMETER = "android.hardware.sensor.accelerometer";
1983
1984 /**
1985 * Feature for {@link #getSystemAvailableFeatures} and
1986 * {@link #hasSystemFeature}: The device includes a barometer (air
1987 * pressure sensor.)
1988 */
1989 @SdkConstant(SdkConstantType.FEATURE)
1990 public static final String FEATURE_SENSOR_BAROMETER = "android.hardware.sensor.barometer";
1991
1992 /**
1993 * Feature for {@link #getSystemAvailableFeatures} and
Dan Morrill50ab63f2010-03-05 16:16:19 -08001994 * {@link #hasSystemFeature}: The device includes a magnetometer (compass).
1995 */
1996 @SdkConstant(SdkConstantType.FEATURE)
1997 public static final String FEATURE_SENSOR_COMPASS = "android.hardware.sensor.compass";
1998
1999 /**
2000 * Feature for {@link #getSystemAvailableFeatures} and
Dan Morrill5744bb42010-09-01 19:18:57 -07002001 * {@link #hasSystemFeature}: The device includes a gyroscope.
Dan Morrill50ab63f2010-03-05 16:16:19 -08002002 */
2003 @SdkConstant(SdkConstantType.FEATURE)
Dan Morrill5744bb42010-09-01 19:18:57 -07002004 public static final String FEATURE_SENSOR_GYROSCOPE = "android.hardware.sensor.gyroscope";
Dan Morrill50ab63f2010-03-05 16:16:19 -08002005
Dianne Hackborn08ee42c2009-11-19 17:08:01 -08002006 /**
2007 * Feature for {@link #getSystemAvailableFeatures} and
2008 * {@link #hasSystemFeature}: The device includes a light sensor.
2009 */
Xavier Ducrohet3274b9b2009-12-14 17:52:20 -08002010 @SdkConstant(SdkConstantType.FEATURE)
Dianne Hackborn08ee42c2009-11-19 17:08:01 -08002011 public static final String FEATURE_SENSOR_LIGHT = "android.hardware.sensor.light";
Dan Morrill50ab63f2010-03-05 16:16:19 -08002012
Dianne Hackborn08ee42c2009-11-19 17:08:01 -08002013 /**
2014 * Feature for {@link #getSystemAvailableFeatures} and
2015 * {@link #hasSystemFeature}: The device includes a proximity sensor.
2016 */
Xavier Ducrohet3274b9b2009-12-14 17:52:20 -08002017 @SdkConstant(SdkConstantType.FEATURE)
Dianne Hackborn08ee42c2009-11-19 17:08:01 -08002018 public static final String FEATURE_SENSOR_PROXIMITY = "android.hardware.sensor.proximity";
Amith Yamasani4b2e9342011-03-31 12:38:53 -07002019
Dianne Hackborn08ee42c2009-11-19 17:08:01 -08002020 /**
2021 * Feature for {@link #getSystemAvailableFeatures} and
Aravind Akella068b0c02013-10-12 17:39:15 -07002022 * {@link #hasSystemFeature}: The device includes a hardware step counter.
2023 */
2024 @SdkConstant(SdkConstantType.FEATURE)
2025 public static final String FEATURE_SENSOR_STEP_COUNTER = "android.hardware.sensor.stepcounter";
2026
2027 /**
2028 * Feature for {@link #getSystemAvailableFeatures} and
2029 * {@link #hasSystemFeature}: The device includes a hardware step detector.
2030 */
2031 @SdkConstant(SdkConstantType.FEATURE)
2032 public static final String FEATURE_SENSOR_STEP_DETECTOR = "android.hardware.sensor.stepdetector";
2033
2034 /**
2035 * Feature for {@link #getSystemAvailableFeatures} and
Vinod Krishnan8afb23c2014-04-30 11:11:39 -07002036 * {@link #hasSystemFeature}: The device includes a heart rate monitor.
2037 */
2038 @SdkConstant(SdkConstantType.FEATURE)
2039 public static final String FEATURE_SENSOR_HEART_RATE = "android.hardware.sensor.heartrate";
2040
2041 /**
2042 * Feature for {@link #getSystemAvailableFeatures} and
Trevor Johns682c24e2016-04-12 10:13:47 -07002043 * {@link #hasSystemFeature}: The heart rate sensor on this device is an Electrocardiogram.
Vinod Krishnan1ab76892014-08-20 11:11:55 -07002044 */
2045 @SdkConstant(SdkConstantType.FEATURE)
2046 public static final String FEATURE_SENSOR_HEART_RATE_ECG =
2047 "android.hardware.sensor.heartrate.ecg";
2048
2049 /**
2050 * Feature for {@link #getSystemAvailableFeatures} and
Aravind Akella8b8e74b2014-07-09 11:52:39 -07002051 * {@link #hasSystemFeature}: The device includes a relative humidity sensor.
2052 */
2053 @SdkConstant(SdkConstantType.FEATURE)
2054 public static final String FEATURE_SENSOR_RELATIVE_HUMIDITY =
2055 "android.hardware.sensor.relative_humidity";
2056
2057 /**
2058 * Feature for {@link #getSystemAvailableFeatures} and
2059 * {@link #hasSystemFeature}: The device includes an ambient temperature sensor.
2060 */
2061 @SdkConstant(SdkConstantType.FEATURE)
2062 public static final String FEATURE_SENSOR_AMBIENT_TEMPERATURE =
2063 "android.hardware.sensor.ambient_temperature";
2064
2065 /**
2066 * Feature for {@link #getSystemAvailableFeatures} and
Ashutosh Joshieae371b2015-04-09 10:30:07 -07002067 * {@link #hasSystemFeature}: The device supports high fidelity sensor processing
2068 * capabilities.
2069 */
2070 @SdkConstant(SdkConstantType.FEATURE)
2071 public static final String FEATURE_HIFI_SENSORS =
2072 "android.hardware.sensor.hifi_sensors";
2073
2074 /**
Philip Quinnb6bd3012018-02-09 17:56:40 -08002075 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
2076 * The device supports a hardware mechanism for invoking an assist gesture.
2077 * @see android.provider.Settings.Secure#ASSIST_GESTURE_ENABLED
2078 * @hide
2079 */
2080 @SdkConstant(SdkConstantType.FEATURE)
2081 public static final String FEATURE_ASSIST_GESTURE = "android.hardware.sensor.assist";
2082
2083 /**
Ashutosh Joshieae371b2015-04-09 10:30:07 -07002084 * Feature for {@link #getSystemAvailableFeatures} and
Dianne Hackborn08ee42c2009-11-19 17:08:01 -08002085 * {@link #hasSystemFeature}: The device has a telephony radio with data
2086 * communication support.
2087 */
Xavier Ducrohet3274b9b2009-12-14 17:52:20 -08002088 @SdkConstant(SdkConstantType.FEATURE)
Dianne Hackborn08ee42c2009-11-19 17:08:01 -08002089 public static final String FEATURE_TELEPHONY = "android.hardware.telephony";
Amith Yamasani4b2e9342011-03-31 12:38:53 -07002090
Dianne Hackborn08ee42c2009-11-19 17:08:01 -08002091 /**
2092 * Feature for {@link #getSystemAvailableFeatures} and
2093 * {@link #hasSystemFeature}: The device has a CDMA telephony stack.
2094 */
Xavier Ducrohet3274b9b2009-12-14 17:52:20 -08002095 @SdkConstant(SdkConstantType.FEATURE)
Dianne Hackborn08ee42c2009-11-19 17:08:01 -08002096 public static final String FEATURE_TELEPHONY_CDMA = "android.hardware.telephony.cdma";
Amith Yamasani4b2e9342011-03-31 12:38:53 -07002097
Dianne Hackborn08ee42c2009-11-19 17:08:01 -08002098 /**
2099 * Feature for {@link #getSystemAvailableFeatures} and
2100 * {@link #hasSystemFeature}: The device has a GSM telephony stack.
2101 */
Xavier Ducrohet3274b9b2009-12-14 17:52:20 -08002102 @SdkConstant(SdkConstantType.FEATURE)
Dianne Hackborn08ee42c2009-11-19 17:08:01 -08002103 public static final String FEATURE_TELEPHONY_GSM = "android.hardware.telephony.gsm";
Hung-ying Tyan3424c022010-08-27 18:08:19 +08002104
2105 /**
Polina Bondarenko80909ce2017-01-12 21:10:38 +01002106 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
2107 * The device supports telephony carrier restriction mechanism.
2108 *
2109 * <p>Devices declaring this feature must have an implementation of the
2110 * {@link android.telephony.TelephonyManager#getAllowedCarriers} and
2111 * {@link android.telephony.TelephonyManager#setAllowedCarriers}.
2112 * @hide
2113 */
2114 @SystemApi
2115 @SdkConstant(SdkConstantType.FEATURE)
2116 public static final String FEATURE_TELEPHONY_CARRIERLOCK =
2117 "android.hardware.telephony.carrierlock";
2118
2119 /**
Jeff Davidson35cda392017-02-27 09:46:00 -08002120 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device
2121 * supports embedded subscriptions on eUICCs.
Jeff Davidson35cda392017-02-27 09:46:00 -08002122 */
2123 @SdkConstant(SdkConstantType.FEATURE)
2124 public static final String FEATURE_TELEPHONY_EUICC = "android.hardware.telephony.euicc";
2125
2126 /**
Hall Liuc6703d92017-11-17 11:31:57 -08002127 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device
2128 * supports cell-broadcast reception using the MBMS APIs.
2129 */
2130 @SdkConstant(SdkConstantType.FEATURE)
2131 public static final String FEATURE_TELEPHONY_MBMS = "android.hardware.telephony.mbms";
2132
2133 /**
Hung-ying Tyan3424c022010-08-27 18:08:19 +08002134 * Feature for {@link #getSystemAvailableFeatures} and
Mike Lockwoodf4ca2472011-02-27 11:23:25 -08002135 * {@link #hasSystemFeature}: The device supports connecting to USB devices
2136 * as the USB host.
2137 */
2138 @SdkConstant(SdkConstantType.FEATURE)
2139 public static final String FEATURE_USB_HOST = "android.hardware.usb.host";
2140
2141 /**
2142 * Feature for {@link #getSystemAvailableFeatures} and
2143 * {@link #hasSystemFeature}: The device supports connecting to USB accessories.
2144 */
2145 @SdkConstant(SdkConstantType.FEATURE)
2146 public static final String FEATURE_USB_ACCESSORY = "android.hardware.usb.accessory";
2147
2148 /**
2149 * Feature for {@link #getSystemAvailableFeatures} and
Hung-ying Tyan3424c022010-08-27 18:08:19 +08002150 * {@link #hasSystemFeature}: The SIP API is enabled on the device.
2151 */
2152 @SdkConstant(SdkConstantType.FEATURE)
2153 public static final String FEATURE_SIP = "android.software.sip";
2154
2155 /**
2156 * Feature for {@link #getSystemAvailableFeatures} and
2157 * {@link #hasSystemFeature}: The device supports SIP-based VOIP.
2158 */
2159 @SdkConstant(SdkConstantType.FEATURE)
2160 public static final String FEATURE_SIP_VOIP = "android.software.sip.voip";
2161
Dianne Hackborn08ee42c2009-11-19 17:08:01 -08002162 /**
2163 * Feature for {@link #getSystemAvailableFeatures} and
Ihab Awad1ec68882014-09-12 11:09:01 -07002164 * {@link #hasSystemFeature}: The Connection Service API is enabled on the device.
2165 */
2166 @SdkConstant(SdkConstantType.FEATURE)
2167 public static final String FEATURE_CONNECTION_SERVICE = "android.software.connectionservice";
2168
2169 /**
2170 * Feature for {@link #getSystemAvailableFeatures} and
Dan Morrillb0fe0332010-04-05 14:43:58 -07002171 * {@link #hasSystemFeature}: The device's display has a touch screen.
2172 */
2173 @SdkConstant(SdkConstantType.FEATURE)
2174 public static final String FEATURE_TOUCHSCREEN = "android.hardware.touchscreen";
Amith Yamasani4b2e9342011-03-31 12:38:53 -07002175
Dan Morrillb0fe0332010-04-05 14:43:58 -07002176 /**
2177 * Feature for {@link #getSystemAvailableFeatures} and
Dan Morrill50ab63f2010-03-05 16:16:19 -08002178 * {@link #hasSystemFeature}: The device's touch screen supports
2179 * multitouch sufficient for basic two-finger gesture detection.
Dianne Hackborn08ee42c2009-11-19 17:08:01 -08002180 */
Xavier Ducrohet3274b9b2009-12-14 17:52:20 -08002181 @SdkConstant(SdkConstantType.FEATURE)
Dianne Hackborn08ee42c2009-11-19 17:08:01 -08002182 public static final String FEATURE_TOUCHSCREEN_MULTITOUCH = "android.hardware.touchscreen.multitouch";
Amith Yamasani4b2e9342011-03-31 12:38:53 -07002183
Dianne Hackborn08ee42c2009-11-19 17:08:01 -08002184 /**
2185 * Feature for {@link #getSystemAvailableFeatures} and
Dan Morrill50ab63f2010-03-05 16:16:19 -08002186 * {@link #hasSystemFeature}: The device's touch screen is capable of
2187 * tracking two or more fingers fully independently.
2188 */
2189 @SdkConstant(SdkConstantType.FEATURE)
2190 public static final String FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT = "android.hardware.touchscreen.multitouch.distinct";
2191
2192 /**
2193 * Feature for {@link #getSystemAvailableFeatures} and
Dan Morrill6993d3d2010-09-03 14:30:14 -07002194 * {@link #hasSystemFeature}: The device's touch screen is capable of
2195 * tracking a full hand of fingers fully independently -- that is, 5 or
2196 * more simultaneous independent pointers.
2197 */
2198 @SdkConstant(SdkConstantType.FEATURE)
2199 public static final String FEATURE_TOUCHSCREEN_MULTITOUCH_JAZZHAND = "android.hardware.touchscreen.multitouch.jazzhand";
2200
2201 /**
2202 * Feature for {@link #getSystemAvailableFeatures} and
Dan Morrilla5376872011-01-23 13:15:53 -08002203 * {@link #hasSystemFeature}: The device does not have a touch screen, but
2204 * does support touch emulation for basic events. For instance, the
2205 * device might use a mouse or remote control to drive a cursor, and
2206 * emulate basic touch pointer events like down, up, drag, etc. All
2207 * devices that support android.hardware.touchscreen or a sub-feature are
2208 * presumed to also support faketouch.
2209 */
2210 @SdkConstant(SdkConstantType.FEATURE)
2211 public static final String FEATURE_FAKETOUCH = "android.hardware.faketouch";
2212
2213 /**
2214 * Feature for {@link #getSystemAvailableFeatures} and
Dianne Hackborne22fe932011-06-08 20:24:29 -07002215 * {@link #hasSystemFeature}: The device does not have a touch screen, but
2216 * does support touch emulation for basic events that supports distinct
2217 * tracking of two or more fingers. This is an extension of
2218 * {@link #FEATURE_FAKETOUCH} for input devices with this capability. Note
2219 * that unlike a distinct multitouch screen as defined by
2220 * {@link #FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT}, these kinds of input
2221 * devices will not actually provide full two-finger gestures since the
2222 * input is being transformed to cursor movement on the screen. That is,
2223 * single finger gestures will move a cursor; two-finger swipes will
2224 * result in single-finger touch events; other two-finger gestures will
2225 * result in the corresponding two-finger touch event.
2226 */
2227 @SdkConstant(SdkConstantType.FEATURE)
2228 public static final String FEATURE_FAKETOUCH_MULTITOUCH_DISTINCT = "android.hardware.faketouch.multitouch.distinct";
2229
2230 /**
2231 * Feature for {@link #getSystemAvailableFeatures} and
2232 * {@link #hasSystemFeature}: The device does not have a touch screen, but
2233 * does support touch emulation for basic events that supports tracking
2234 * a hand of fingers (5 or more fingers) fully independently.
2235 * This is an extension of
2236 * {@link #FEATURE_FAKETOUCH} for input devices with this capability. Note
2237 * that unlike a multitouch screen as defined by
2238 * {@link #FEATURE_TOUCHSCREEN_MULTITOUCH_JAZZHAND}, not all two finger
2239 * gestures can be detected due to the limitations described for
2240 * {@link #FEATURE_FAKETOUCH_MULTITOUCH_DISTINCT}.
2241 */
2242 @SdkConstant(SdkConstantType.FEATURE)
2243 public static final String FEATURE_FAKETOUCH_MULTITOUCH_JAZZHAND = "android.hardware.faketouch.multitouch.jazzhand";
2244
2245 /**
2246 * Feature for {@link #getSystemAvailableFeatures} and
Jim Millerd9b9d412015-07-22 19:51:40 -07002247 * {@link #hasSystemFeature}: The device has biometric hardware to detect a fingerprint.
2248 */
2249 @SdkConstant(SdkConstantType.FEATURE)
2250 public static final String FEATURE_FINGERPRINT = "android.hardware.fingerprint";
2251
2252 /**
2253 * Feature for {@link #getSystemAvailableFeatures} and
Dianne Hackborne289bff2011-06-13 19:33:22 -07002254 * {@link #hasSystemFeature}: The device supports portrait orientation
2255 * screens. For backwards compatibility, you can assume that if neither
2256 * this nor {@link #FEATURE_SCREEN_LANDSCAPE} is set then the device supports
2257 * both portrait and landscape.
2258 */
2259 @SdkConstant(SdkConstantType.FEATURE)
2260 public static final String FEATURE_SCREEN_PORTRAIT = "android.hardware.screen.portrait";
2261
2262 /**
2263 * Feature for {@link #getSystemAvailableFeatures} and
2264 * {@link #hasSystemFeature}: The device supports landscape orientation
2265 * screens. For backwards compatibility, you can assume that if neither
2266 * this nor {@link #FEATURE_SCREEN_PORTRAIT} is set then the device supports
2267 * both portrait and landscape.
2268 */
2269 @SdkConstant(SdkConstantType.FEATURE)
2270 public static final String FEATURE_SCREEN_LANDSCAPE = "android.hardware.screen.landscape";
2271
2272 /**
2273 * Feature for {@link #getSystemAvailableFeatures} and
Dianne Hackborn08ee42c2009-11-19 17:08:01 -08002274 * {@link #hasSystemFeature}: The device supports live wallpapers.
2275 */
Xavier Ducrohet3274b9b2009-12-14 17:52:20 -08002276 @SdkConstant(SdkConstantType.FEATURE)
Dianne Hackborn08ee42c2009-11-19 17:08:01 -08002277 public static final String FEATURE_LIVE_WALLPAPER = "android.software.live_wallpaper";
Oscar Montemayor1228d0a2010-01-28 12:01:44 -08002278 /**
Dan Morrill50ab63f2010-03-05 16:16:19 -08002279 * Feature for {@link #getSystemAvailableFeatures} and
Dianne Hackborn119bbc32013-03-22 17:27:25 -07002280 * {@link #hasSystemFeature}: The device supports app widgets.
2281 */
2282 @SdkConstant(SdkConstantType.FEATURE)
2283 public static final String FEATURE_APP_WIDGETS = "android.software.app_widgets";
Dianne Hackbornc8e4fad2018-05-04 11:31:09 -07002284 /**
2285 * Feature for {@link #getSystemAvailableFeatures} and
2286 * {@link #hasSystemFeature}: The device supports the
2287 * {@link android.R.attr#cantSaveState} API.
2288 */
2289 @SdkConstant(SdkConstantType.FEATURE)
2290 public static final String FEATURE_CANT_SAVE_STATE = "android.software.cant_save_state";
Dianne Hackborn119bbc32013-03-22 17:27:25 -07002291
2292 /**
Dianne Hackborn91097de2014-04-04 18:02:06 -07002293 * @hide
2294 * Feature for {@link #getSystemAvailableFeatures} and
2295 * {@link #hasSystemFeature}: The device supports
2296 * {@link android.service.voice.VoiceInteractionService} and
2297 * {@link android.app.VoiceInteractor}.
2298 */
2299 @SdkConstant(SdkConstantType.FEATURE)
2300 public static final String FEATURE_VOICE_RECOGNIZERS = "android.software.voice_recognizers";
2301
2302
2303 /**
Dianne Hackborn119bbc32013-03-22 17:27:25 -07002304 * Feature for {@link #getSystemAvailableFeatures} and
2305 * {@link #hasSystemFeature}: The device supports a home screen that is replaceable
2306 * by third party applications.
2307 */
2308 @SdkConstant(SdkConstantType.FEATURE)
2309 public static final String FEATURE_HOME_SCREEN = "android.software.home_screen";
2310
2311 /**
2312 * Feature for {@link #getSystemAvailableFeatures} and
2313 * {@link #hasSystemFeature}: The device supports adding new input methods implemented
2314 * with the {@link android.inputmethodservice.InputMethodService} API.
2315 */
2316 @SdkConstant(SdkConstantType.FEATURE)
2317 public static final String FEATURE_INPUT_METHODS = "android.software.input_methods";
2318
2319 /**
2320 * Feature for {@link #getSystemAvailableFeatures} and
Amith Yamasani44a01b72013-09-16 10:44:57 -07002321 * {@link #hasSystemFeature}: The device supports device policy enforcement via device admins.
2322 */
2323 @SdkConstant(SdkConstantType.FEATURE)
2324 public static final String FEATURE_DEVICE_ADMIN = "android.software.device_admin";
2325
2326 /**
2327 * Feature for {@link #getSystemAvailableFeatures} and
Tim Kilbournf94b6a92014-03-07 15:13:48 -08002328 * {@link #hasSystemFeature}: The device supports leanback UI. This is
2329 * typically used in a living room television experience, but is a software
2330 * feature unlike {@link #FEATURE_TELEVISION}. Devices running with this
2331 * feature will use resources associated with the "television" UI mode.
2332 */
2333 @SdkConstant(SdkConstantType.FEATURE)
2334 public static final String FEATURE_LEANBACK = "android.software.leanback";
2335
2336 /**
2337 * Feature for {@link #getSystemAvailableFeatures} and
2338 * {@link #hasSystemFeature}: The device supports only leanback UI. Only
2339 * applications designed for this experience should be run, though this is
2340 * not enforced by the system.
Tim Kilbournf94b6a92014-03-07 15:13:48 -08002341 */
2342 @SdkConstant(SdkConstantType.FEATURE)
2343 public static final String FEATURE_LEANBACK_ONLY = "android.software.leanback_only";
2344
2345 /**
2346 * Feature for {@link #getSystemAvailableFeatures} and
Jae Seocfd861e2014-08-27 14:02:15 -07002347 * {@link #hasSystemFeature}: The device supports live TV and can display
2348 * contents from TV inputs implemented with the
2349 * {@link android.media.tv.TvInputService} API.
2350 */
2351 @SdkConstant(SdkConstantType.FEATURE)
2352 public static final String FEATURE_LIVE_TV = "android.software.live_tv";
2353
2354 /**
2355 * Feature for {@link #getSystemAvailableFeatures} and
Dan Morrill50ab63f2010-03-05 16:16:19 -08002356 * {@link #hasSystemFeature}: The device supports WiFi (802.11) networking.
2357 */
2358 @SdkConstant(SdkConstantType.FEATURE)
2359 public static final String FEATURE_WIFI = "android.hardware.wifi";
2360
2361 /**
Irfan Sheriff45b8b462011-09-07 11:24:16 -07002362 * Feature for {@link #getSystemAvailableFeatures} and
2363 * {@link #hasSystemFeature}: The device supports Wi-Fi Direct networking.
2364 */
2365 @SdkConstant(SdkConstantType.FEATURE)
2366 public static final String FEATURE_WIFI_DIRECT = "android.hardware.wifi.direct";
2367
2368 /**
Dianne Hackborn0cf2c8a2012-05-17 17:29:49 -07002369 * Feature for {@link #getSystemAvailableFeatures} and
Etan Cohen04133272016-10-26 11:22:06 -07002370 * {@link #hasSystemFeature}: The device supports Wi-Fi Aware.
Etan Cohen20d329b2015-09-29 13:49:02 -07002371 */
2372 @SdkConstant(SdkConstantType.FEATURE)
Etan Cohen04133272016-10-26 11:22:06 -07002373 public static final String FEATURE_WIFI_AWARE = "android.hardware.wifi.aware";
Etan Cohen20d329b2015-09-29 13:49:02 -07002374
2375 /**
2376 * Feature for {@link #getSystemAvailableFeatures} and
Peter Qiu3d615e42017-08-07 20:13:32 +00002377 * {@link #hasSystemFeature}: The device supports Wi-Fi Passpoint and all
2378 * Passpoint related APIs in {@link WifiManager} are supported. Refer to
2379 * {@link WifiManager#addOrUpdatePasspointConfiguration} for more info.
Peter Qiub99fe312017-05-05 13:48:47 -07002380 */
2381 @SdkConstant(SdkConstantType.FEATURE)
2382 public static final String FEATURE_WIFI_PASSPOINT = "android.hardware.wifi.passpoint";
2383
2384 /**
2385 * Feature for {@link #getSystemAvailableFeatures} and
Etan Cohen692e68e2017-09-14 15:42:01 -07002386 * {@link #hasSystemFeature}: The device supports Wi-Fi RTT (IEEE 802.11mc).
Etan Cohen692e68e2017-09-14 15:42:01 -07002387 */
2388 @SdkConstant(SdkConstantType.FEATURE)
2389 public static final String FEATURE_WIFI_RTT = "android.hardware.wifi.rtt";
2390
2391
2392 /**
2393 * Feature for {@link #getSystemAvailableFeatures} and
Robert Quattlebaum87a71042017-05-15 15:45:20 -07002394 * {@link #hasSystemFeature}: The device supports LoWPAN networking.
2395 * @hide
2396 */
2397 @SdkConstant(SdkConstantType.FEATURE)
2398 public static final String FEATURE_LOWPAN = "android.hardware.lowpan";
2399
2400 /**
2401 * Feature for {@link #getSystemAvailableFeatures} and
Dianne Hackborn0cf2c8a2012-05-17 17:29:49 -07002402 * {@link #hasSystemFeature}: This is a device dedicated to showing UI
Todd Kennedy7f95a002015-04-22 14:28:25 -07002403 * on a vehicle headunit. A headunit here is defined to be inside a
2404 * vehicle that may or may not be moving. A headunit uses either a
2405 * primary display in the center console and/or additional displays in
2406 * the instrument cluster or elsewhere in the vehicle. Headunit display(s)
2407 * have limited size and resolution. The user will likely be focused on
2408 * driving so limiting driver distraction is a primary concern. User input
2409 * can be a variety of hard buttons, touch, rotary controllers and even mouse-
2410 * like interfaces.
2411 */
2412 @SdkConstant(SdkConstantType.FEATURE)
2413 public static final String FEATURE_AUTOMOTIVE = "android.hardware.type.automotive";
2414
2415 /**
2416 * Feature for {@link #getSystemAvailableFeatures} and
2417 * {@link #hasSystemFeature}: This is a device dedicated to showing UI
Dianne Hackborn0cf2c8a2012-05-17 17:29:49 -07002418 * on a television. Television here is defined to be a typical living
2419 * room television experience: displayed on a big screen, where the user
2420 * is sitting far away from it, and the dominant form of input will be
2421 * something like a DPAD, not through touch or mouse.
Tim Kilbournf94b6a92014-03-07 15:13:48 -08002422 * @deprecated use {@link #FEATURE_LEANBACK} instead.
Dianne Hackborn0cf2c8a2012-05-17 17:29:49 -07002423 */
Jose Lima970417c2014-04-10 10:42:19 -07002424 @Deprecated
Dianne Hackborn0cf2c8a2012-05-17 17:29:49 -07002425 @SdkConstant(SdkConstantType.FEATURE)
2426 public static final String FEATURE_TELEVISION = "android.hardware.type.television";
2427
2428 /**
Justin Kohb5731f091c2014-02-13 16:06:59 -08002429 * Feature for {@link #getSystemAvailableFeatures} and
2430 * {@link #hasSystemFeature}: This is a device dedicated to showing UI
2431 * on a watch. A watch here is defined to be a device worn on the body, perhaps on
2432 * the wrist. The user is very close when interacting with the device.
2433 */
2434 @SdkConstant(SdkConstantType.FEATURE)
2435 public static final String FEATURE_WATCH = "android.hardware.type.watch";
2436
2437 /**
Ralph Nathanb8e0dee2017-01-24 15:24:59 -08002438 * Feature for {@link #getSystemAvailableFeatures} and
2439 * {@link #hasSystemFeature}: This is a device for IoT and may not have an UI. An embedded
2440 * device is defined as a full stack Android device with or without a display and no
2441 * user-installable apps.
2442 */
2443 @SdkConstant(SdkConstantType.FEATURE)
2444 public static final String FEATURE_EMBEDDED = "android.hardware.type.embedded";
2445
2446 /**
Dennis Kempin7345ed52017-04-14 16:40:56 -07002447 * Feature for {@link #getSystemAvailableFeatures} and
2448 * {@link #hasSystemFeature}: This is a device dedicated to be primarily used
2449 * with keyboard, mouse or touchpad. This includes traditional desktop
2450 * computers, laptops and variants such as convertibles or detachables.
2451 * Due to the larger screen, the device will most likely use the
2452 * {@link #FEATURE_FREEFORM_WINDOW_MANAGEMENT} feature as well.
2453 */
2454 @SdkConstant(SdkConstantType.FEATURE)
2455 public static final String FEATURE_PC = "android.hardware.type.pc";
2456
2457 /**
Adam Lesinski3d9bcb92014-02-18 14:05:14 -08002458 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
2459 * The device supports printing.
2460 */
2461 @SdkConstant(SdkConstantType.FEATURE)
2462 public static final String FEATURE_PRINTING = "android.software.print";
2463
2464 /**
2465 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
Eugene Susla7c3eef22017-03-10 14:25:58 -08002466 * The device supports {@link android.companion.CompanionDeviceManager#associate associating}
2467 * with devices via {@link android.companion.CompanionDeviceManager}.
2468 */
2469 @SdkConstant(SdkConstantType.FEATURE)
2470 public static final String FEATURE_COMPANION_DEVICE_SETUP
2471 = "android.software.companion_device_setup";
2472
2473 /**
2474 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
Adam Lesinski3d9bcb92014-02-18 14:05:14 -08002475 * The device can perform backup and restore operations on installed applications.
2476 */
2477 @SdkConstant(SdkConstantType.FEATURE)
2478 public static final String FEATURE_BACKUP = "android.software.backup";
2479
2480 /**
Vladislav Kaznacheevd303b252015-10-27 17:30:58 -07002481 * Feature for {@link #getSystemAvailableFeatures} and
2482 * {@link #hasSystemFeature}: The device supports freeform window management.
2483 * Windows have title bars and can be moved and resized.
2484 */
Filip Gruszczynski811dc3b2015-11-23 12:34:22 -08002485 // If this feature is present, you also need to set
2486 // com.android.internal.R.config_freeformWindowManagement to true in your configuration overlay.
Vladislav Kaznacheevd303b252015-10-27 17:30:58 -07002487 @SdkConstant(SdkConstantType.FEATURE)
2488 public static final String FEATURE_FREEFORM_WINDOW_MANAGEMENT
2489 = "android.software.freeform_window_management";
2490
2491 /**
Adam Connors23cc04e2014-04-01 12:12:20 +01002492 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
Wale Ogunwalefbe12c42015-12-06 16:23:50 -08002493 * The device supports picture-in-picture multi-window mode.
2494 */
2495 @SdkConstant(SdkConstantType.FEATURE)
2496 public static final String FEATURE_PICTURE_IN_PICTURE = "android.software.picture_in_picture";
2497
2498 /**
2499 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
Andrii Kulian1981f5f2017-04-07 16:23:12 -07002500 * The device supports running activities on secondary displays.
2501 */
2502 @SdkConstant(SdkConstantType.FEATURE)
2503 public static final String FEATURE_ACTIVITIES_ON_SECONDARY_DISPLAYS
2504 = "android.software.activities_on_secondary_displays";
2505
2506 /**
2507 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
Amith Yamasani1d653272014-09-11 17:56:05 -07002508 * The device supports creating secondary users and managed profiles via
2509 * {@link DevicePolicyManager}.
Adam Connors23cc04e2014-04-01 12:12:20 +01002510 */
2511 @SdkConstant(SdkConstantType.FEATURE)
Amith Yamasani1d653272014-09-11 17:56:05 -07002512 public static final String FEATURE_MANAGED_USERS = "android.software.managed_users";
2513
2514 /**
2515 * @hide
2516 * TODO: Remove after dependencies updated b/17392243
2517 */
2518 public static final String FEATURE_MANAGED_PROFILES = "android.software.managed_users";
Adam Connors23cc04e2014-04-01 12:12:20 +01002519
2520 /**
Ben Murdochf564c7f2014-05-20 18:58:06 +01002521 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
Adam Connors19ccb5f2014-09-08 17:31:50 +01002522 * The device supports verified boot.
2523 */
2524 @SdkConstant(SdkConstantType.FEATURE)
2525 public static final String FEATURE_VERIFIED_BOOT = "android.software.verified_boot";
2526
2527 /**
2528 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
2529 * The device supports secure removal of users. When a user is deleted the data associated
2530 * with that user is securely deleted and no longer available.
2531 */
2532 @SdkConstant(SdkConstantType.FEATURE)
2533 public static final String FEATURE_SECURELY_REMOVES_USERS
2534 = "android.software.securely_removes_users";
2535
Jeff Sharkeyb92b05b2016-01-28 09:50:00 -07002536 /** {@hide} */
Jeff Sharkey8eb783b2018-01-04 16:46:48 -07002537 @TestApi
Jeff Sharkeyb92b05b2016-01-28 09:50:00 -07002538 @SdkConstant(SdkConstantType.FEATURE)
2539 public static final String FEATURE_FILE_BASED_ENCRYPTION
2540 = "android.software.file_based_encryption";
2541
Jeff Sharkey8eb783b2018-01-04 16:46:48 -07002542 /** {@hide} */
2543 @TestApi
2544 @SdkConstant(SdkConstantType.FEATURE)
2545 public static final String FEATURE_ADOPTABLE_STORAGE
2546 = "android.software.adoptable_storage";
2547
Adam Connors19ccb5f2014-09-08 17:31:50 +01002548 /**
2549 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
Ben Murdoch422c7a52014-05-16 13:45:47 +01002550 * The device has a full implementation of the android.webkit.* APIs. Devices
2551 * lacking this feature will not have a functioning WebView implementation.
2552 */
2553 @SdkConstant(SdkConstantType.FEATURE)
2554 public static final String FEATURE_WEBVIEW = "android.software.webview";
2555
2556 /**
Joe LaPenna4bb015d2014-07-04 17:15:54 -07002557 * Feature for {@link #getSystemAvailableFeatures} and
2558 * {@link #hasSystemFeature}: This device supports ethernet.
Joe LaPenna4bb015d2014-07-04 17:15:54 -07002559 */
2560 @SdkConstant(SdkConstantType.FEATURE)
2561 public static final String FEATURE_ETHERNET = "android.hardware.ethernet";
2562
2563 /**
Yuncheol Heoa0c4a062014-07-10 20:49:27 +09002564 * Feature for {@link #getSystemAvailableFeatures} and
2565 * {@link #hasSystemFeature}: This device supports HDMI-CEC.
2566 * @hide
2567 */
2568 @SdkConstant(SdkConstantType.FEATURE)
2569 public static final String FEATURE_HDMI_CEC = "android.hardware.hdmi.cec";
2570
2571 /**
Michael Wright6faa6752014-09-05 17:57:44 -07002572 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
2573 * The device has all of the inputs necessary to be considered a compatible game controller, or
2574 * includes a compatible game controller in the box.
2575 */
2576 @SdkConstant(SdkConstantType.FEATURE)
2577 public static final String FEATURE_GAMEPAD = "android.hardware.gamepad";
2578
Mike Lockwood5781cd52015-03-27 13:23:41 -07002579 /**
2580 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
2581 * The device has a full implementation of the android.media.midi.* APIs.
2582 */
2583 @SdkConstant(SdkConstantType.FEATURE)
2584 public static final String FEATURE_MIDI = "android.software.midi";
Michael Wright6faa6752014-09-05 17:57:44 -07002585
2586 /**
Ruben Brunkdd18a0b2015-12-04 16:16:31 -08002587 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
Ruben Brunk927d3452016-05-02 19:30:51 -07002588 * The device implements an optimized mode for virtual reality (VR) applications that handles
2589 * stereoscopic rendering of notifications, and disables most monocular system UI components
2590 * while a VR application has user focus.
2591 * Devices declaring this feature must include an application implementing a
2592 * {@link android.service.vr.VrListenerService} that can be targeted by VR applications via
2593 * {@link android.app.Activity#setVrModeEnabled}.
Craig Donnerc6f9c852017-12-27 17:15:19 -08002594 * @deprecated use {@link #FEATURE_VR_MODE_HIGH_PERFORMANCE} instead.
Ruben Brunkdd18a0b2015-12-04 16:16:31 -08002595 */
Craig Donnerc6f9c852017-12-27 17:15:19 -08002596 @Deprecated
Ruben Brunkdd18a0b2015-12-04 16:16:31 -08002597 @SdkConstant(SdkConstantType.FEATURE)
2598 public static final String FEATURE_VR_MODE = "android.software.vr.mode";
2599
2600 /**
Ruben Brunk31d80ea2016-01-25 20:14:08 -08002601 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
Craig Donnerc6f9c852017-12-27 17:15:19 -08002602 * The device implements an optimized mode for virtual reality (VR) applications that handles
2603 * stereoscopic rendering of notifications, disables most monocular system UI components
2604 * while a VR application has user focus and meets extra CDD requirements to provide a
2605 * high-quality VR experience.
2606 * Devices declaring this feature must include an application implementing a
2607 * {@link android.service.vr.VrListenerService} that can be targeted by VR applications via
2608 * {@link android.app.Activity#setVrModeEnabled}.
2609 * and must meet CDD requirements to provide a high-quality VR experience.
Ruben Brunk31d80ea2016-01-25 20:14:08 -08002610 */
2611 @SdkConstant(SdkConstantType.FEATURE)
2612 public static final String FEATURE_VR_MODE_HIGH_PERFORMANCE
2613 = "android.hardware.vr.high_performance";
2614
2615 /**
Craig Donner279dd662017-03-15 17:10:50 -07002616 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
Svet Ganov43574b02017-04-12 09:25:20 -07002617 * The device supports autofill of user credentials, addresses, credit cards, etc
2618 * via integration with {@link android.service.autofill.AutofillService autofill
2619 * providers}.
2620 */
2621 @SdkConstant(SdkConstantType.FEATURE)
2622 public static final String FEATURE_AUTOFILL = "android.software.autofill";
2623
2624 /**
2625 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
Craig Donner279dd662017-03-15 17:10:50 -07002626 * The device implements headtracking suitable for a VR device.
2627 */
2628 @SdkConstant(SdkConstantType.FEATURE)
2629 public static final String FEATURE_VR_HEADTRACKING = "android.hardware.vr.headtracking";
2630
2631 /**
Frank Salimea5e0382018-01-23 22:42:29 -08002632 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
2633 * The device has a StrongBox hardware-backed Keystore.
2634 */
2635 @SdkConstant(SdkConstantType.FEATURE)
2636 public static final String FEATURE_STRONGBOX_KEYSTORE =
2637 "android.hardware.strongbox_keystore";
2638
2639 /**
Eran Messeriadaf68c2018-03-27 19:34:03 +01002640 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
2641 * The device has a Keymaster implementation that supports Device ID attestation.
2642 *
2643 * @see DevicePolicyManager#isDeviceIdAttestationSupported
2644 * @hide
2645 */
2646 @SdkConstant(SdkConstantType.FEATURE)
2647 public static final String FEATURE_DEVICE_ID_ATTESTATION =
2648 "android.software.device_id_attestation";
2649
2650 /**
Dianne Hackborne83cefce2010-02-04 17:38:14 -08002651 * Action to external storage service to clean out removed apps.
2652 * @hide
2653 */
2654 public static final String ACTION_CLEAN_EXTERNAL_STORAGE
2655 = "android.content.pm.CLEAN_EXTERNAL_STORAGE";
Oscar Montemayor1228d0a2010-01-28 12:01:44 -08002656
Dianne Hackborn08ee42c2009-11-19 17:08:01 -08002657 /**
Kenny Root5ab21572011-07-27 11:11:19 -07002658 * Extra field name for the URI to a verification file. Passed to a package
2659 * verifier.
2660 *
2661 * @hide
2662 */
2663 public static final String EXTRA_VERIFICATION_URI = "android.content.pm.extra.VERIFICATION_URI";
2664
2665 /**
2666 * Extra field name for the ID of a package pending verification. Passed to
2667 * a package verifier and is used to call back to
Kenny Root3a9b5fb2011-09-20 14:15:38 -07002668 * {@link PackageManager#verifyPendingInstall(int, int)}
Kenny Root5ab21572011-07-27 11:11:19 -07002669 */
2670 public static final String EXTRA_VERIFICATION_ID = "android.content.pm.extra.VERIFICATION_ID";
2671
2672 /**
2673 * Extra field name for the package identifier which is trying to install
2674 * the package.
2675 *
2676 * @hide
2677 */
2678 public static final String EXTRA_VERIFICATION_INSTALLER_PACKAGE
2679 = "android.content.pm.extra.VERIFICATION_INSTALLER_PACKAGE";
2680
2681 /**
2682 * Extra field name for the requested install flags for a package pending
2683 * verification. Passed to a package verifier.
2684 *
2685 * @hide
2686 */
2687 public static final String EXTRA_VERIFICATION_INSTALL_FLAGS
2688 = "android.content.pm.extra.VERIFICATION_INSTALL_FLAGS";
2689
2690 /**
rich cannings13d428e2012-09-13 13:43:07 -07002691 * Extra field name for the uid of who is requesting to install
2692 * the package.
2693 *
2694 * @hide
2695 */
2696 public static final String EXTRA_VERIFICATION_INSTALLER_UID
2697 = "android.content.pm.extra.VERIFICATION_INSTALLER_UID";
2698
2699 /**
2700 * Extra field name for the package name of a package pending verification.
2701 *
2702 * @hide
2703 */
2704 public static final String EXTRA_VERIFICATION_PACKAGE_NAME
2705 = "android.content.pm.extra.VERIFICATION_PACKAGE_NAME";
2706 /**
rich canningsd1b5cfc2012-08-29 14:49:51 -07002707 * Extra field name for the result of a verification, either
2708 * {@link #VERIFICATION_ALLOW}, or {@link #VERIFICATION_REJECT}.
2709 * Passed to package verifiers after a package is verified.
2710 */
2711 public static final String EXTRA_VERIFICATION_RESULT
2712 = "android.content.pm.extra.VERIFICATION_RESULT";
2713
2714 /**
rich cannings13d428e2012-09-13 13:43:07 -07002715 * Extra field name for the version code of a package pending verification.
Dianne Hackborn3accca02013-09-20 09:32:11 -07002716 * @deprecated Use {@link #EXTRA_VERIFICATION_LONG_VERSION_CODE} instead.
2717 * @hide
2718 */
2719 @Deprecated
2720 public static final String EXTRA_VERIFICATION_VERSION_CODE
2721 = "android.content.pm.extra.VERIFICATION_VERSION_CODE";
2722
2723 /**
2724 * Extra field name for the long version code of a package pending verification.
rich cannings13d428e2012-09-13 13:43:07 -07002725 *
2726 * @hide
2727 */
Dianne Hackborn3accca02013-09-20 09:32:11 -07002728 public static final String EXTRA_VERIFICATION_LONG_VERSION_CODE =
2729 "android.content.pm.extra.VERIFICATION_LONG_VERSION_CODE";
rich cannings13d428e2012-09-13 13:43:07 -07002730
2731 /**
Jeff Sharkey5aa86932016-01-08 19:07:49 -07002732 * Extra field name for the ID of a intent filter pending verification.
2733 * Passed to an intent filter verifier and is used to call back to
2734 * {@link #verifyIntentFilter}
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -08002735 *
2736 * @hide
2737 */
2738 public static final String EXTRA_INTENT_FILTER_VERIFICATION_ID
2739 = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_ID";
2740
2741 /**
2742 * Extra field name for the scheme used for an intent filter pending verification. Passed to
2743 * an intent filter verifier and is used to construct the URI to verify against.
2744 *
2745 * Usually this is "https"
2746 *
2747 * @hide
2748 */
2749 public static final String EXTRA_INTENT_FILTER_VERIFICATION_URI_SCHEME
2750 = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_URI_SCHEME";
2751
2752 /**
2753 * Extra field name for the host names to be used for an intent filter pending verification.
2754 * Passed to an intent filter verifier and is used to construct the URI to verify the
2755 * intent filter.
2756 *
2757 * This is a space delimited list of hosts.
2758 *
2759 * @hide
2760 */
2761 public static final String EXTRA_INTENT_FILTER_VERIFICATION_HOSTS
2762 = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_HOSTS";
2763
2764 /**
2765 * Extra field name for the package name to be used for an intent filter pending verification.
2766 * Passed to an intent filter verifier and is used to check the verification responses coming
2767 * from the hosts. Each host response will need to include the package name of APK containing
2768 * the intent filter.
2769 *
2770 * @hide
2771 */
2772 public static final String EXTRA_INTENT_FILTER_VERIFICATION_PACKAGE_NAME
2773 = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_PACKAGE_NAME";
2774
2775 /**
2776 * The action used to request that the user approve a permission request
2777 * from the application.
Nick Kralevich035f80d2013-03-27 15:20:08 -07002778 *
2779 * @hide
2780 */
Svetoslavc6d1c342015-02-26 14:44:43 -08002781 @SystemApi
2782 public static final String ACTION_REQUEST_PERMISSIONS =
2783 "android.content.pm.action.REQUEST_PERMISSIONS";
Nick Kralevich035f80d2013-03-27 15:20:08 -07002784
2785 /**
Svetoslavc6d1c342015-02-26 14:44:43 -08002786 * The names of the requested permissions.
2787 * <p>
2788 * <strong>Type:</strong> String[]
2789 * </p>
2790 *
2791 * @hide
2792 */
2793 @SystemApi
2794 public static final String EXTRA_REQUEST_PERMISSIONS_NAMES =
2795 "android.content.pm.extra.REQUEST_PERMISSIONS_NAMES";
2796
2797 /**
2798 * The results from the permissions request.
2799 * <p>
2800 * <strong>Type:</strong> int[] of #PermissionResult
2801 * </p>
2802 *
2803 * @hide
2804 */
2805 @SystemApi
2806 public static final String EXTRA_REQUEST_PERMISSIONS_RESULTS
2807 = "android.content.pm.extra.REQUEST_PERMISSIONS_RESULTS";
Nick Kralevich035f80d2013-03-27 15:20:08 -07002808
2809 /**
Jeff Sharkeybb580672014-07-10 12:10:25 -07002810 * String extra for {@link PackageInstallObserver} in the 'extras' Bundle in case of
Christopher Tatef1977b42014-03-24 16:25:51 -07002811 * {@link #INSTALL_FAILED_DUPLICATE_PERMISSION}. This extra names the package which provides
2812 * the existing definition for the permission.
2813 * @hide
2814 */
2815 public static final String EXTRA_FAILURE_EXISTING_PACKAGE
2816 = "android.content.pm.extra.FAILURE_EXISTING_PACKAGE";
2817
2818 /**
Jeff Sharkeybb580672014-07-10 12:10:25 -07002819 * String extra for {@link PackageInstallObserver} in the 'extras' Bundle in case of
Christopher Tatef1977b42014-03-24 16:25:51 -07002820 * {@link #INSTALL_FAILED_DUPLICATE_PERMISSION}. This extra names the permission that is
2821 * being redundantly defined by the package being installed.
2822 * @hide
2823 */
2824 public static final String EXTRA_FAILURE_EXISTING_PERMISSION
2825 = "android.content.pm.extra.FAILURE_EXISTING_PERMISSION";
2826
Svet Ganov8c7f7002015-05-07 10:48:44 -07002827 /**
2828 * Permission flag: The permission is set in its current state
2829 * by the user and apps can still request it at runtime.
2830 *
2831 * @hide
2832 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08002833 @SystemApi
Svet Ganov8c7f7002015-05-07 10:48:44 -07002834 public static final int FLAG_PERMISSION_USER_SET = 1 << 0;
2835
2836 /**
2837 * Permission flag: The permission is set in its current state
2838 * by the user and it is fixed, i.e. apps can no longer request
2839 * this permission.
2840 *
2841 * @hide
2842 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08002843 @SystemApi
Svet Ganov8c7f7002015-05-07 10:48:44 -07002844 public static final int FLAG_PERMISSION_USER_FIXED = 1 << 1;
2845
2846 /**
2847 * Permission flag: The permission is set in its current state
2848 * by device policy and neither apps nor the user can change
2849 * its state.
2850 *
2851 * @hide
2852 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08002853 @SystemApi
Svet Ganov8c7f7002015-05-07 10:48:44 -07002854 public static final int FLAG_PERMISSION_POLICY_FIXED = 1 << 2;
2855
2856 /**
2857 * Permission flag: The permission is set in a granted state but
2858 * access to resources it guards is restricted by other means to
2859 * enable revoking a permission on legacy apps that do not support
2860 * runtime permissions. If this permission is upgraded to runtime
2861 * because the app was updated to support runtime permissions, the
2862 * the permission will be revoked in the upgrade process.
2863 *
2864 * @hide
2865 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08002866 @SystemApi
Svet Ganov8c7f7002015-05-07 10:48:44 -07002867 public static final int FLAG_PERMISSION_REVOKE_ON_UPGRADE = 1 << 3;
2868
Svet Ganovb3f22b42015-05-12 11:01:24 -07002869 /**
2870 * Permission flag: The permission is set in its current state
2871 * because the app is a component that is a part of the system.
2872 *
2873 * @hide
2874 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08002875 @SystemApi
Svet Ganovb3f22b42015-05-12 11:01:24 -07002876 public static final int FLAG_PERMISSION_SYSTEM_FIXED = 1 << 4;
Svet Ganov8c7f7002015-05-07 10:48:44 -07002877
Svet Ganov77ab6a82015-07-03 12:03:02 -07002878 /**
2879 * Permission flag: The permission is granted by default because it
2880 * enables app functionality that is expected to work out-of-the-box
2881 * for providing a smooth user experience. For example, the phone app
2882 * is expected to have the phone permission.
2883 *
2884 * @hide
2885 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08002886 @SystemApi
Svet Ganov77ab6a82015-07-03 12:03:02 -07002887 public static final int FLAG_PERMISSION_GRANTED_BY_DEFAULT = 1 << 5;
2888
Svet Ganov8c7f7002015-05-07 10:48:44 -07002889 /**
Svet Ganov9c165d72015-12-01 19:52:26 -08002890 * Permission flag: The permission has to be reviewed before any of
2891 * the app components can run.
2892 *
2893 * @hide
2894 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08002895 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08002896 public static final int FLAG_PERMISSION_REVIEW_REQUIRED = 1 << 6;
2897
2898 /**
Svet Ganov8c7f7002015-05-07 10:48:44 -07002899 * Mask for all permission flags.
2900 *
2901 * @hide
2902 */
2903 @SystemApi
Svet Ganovb3f22b42015-05-12 11:01:24 -07002904 public static final int MASK_PERMISSION_FLAGS = 0xFF;
Svet Ganov8c7f7002015-05-07 10:48:44 -07002905
Christopher Tatef1977b42014-03-24 16:25:51 -07002906 /**
Svet Ganovd7b1f4112016-02-09 18:49:23 -08002907 * This is a library that contains components apps can invoke. For
2908 * example, a services for apps to bind to, or standard chooser UI,
2909 * etc. This library is versioned and backwards compatible. Clients
2910 * should check its version via {@link android.ext.services.Version
2911 * #getVersionCode()} and avoid calling APIs added in later versions.
2912 *
2913 * @hide
2914 */
2915 public static final String SYSTEM_SHARED_LIBRARY_SERVICES = "android.ext.services";
2916
2917 /**
2918 * This is a library that contains components apps can dynamically
2919 * load. For example, new widgets, helper classes, etc. This library
2920 * is versioned and backwards compatible. Clients should check its
2921 * version via {@link android.ext.shared.Version#getVersionCode()}
2922 * and avoid calling APIs added in later versions.
2923 *
2924 * @hide
2925 */
2926 public static final String SYSTEM_SHARED_LIBRARY_SHARED = "android.ext.shared";
2927
2928 /**
Brian Carlstromca82e612016-04-19 23:16:08 -07002929 * Used when starting a process for an Activity.
2930 *
2931 * @hide
2932 */
2933 public static final int NOTIFY_PACKAGE_USE_ACTIVITY = 0;
2934
2935 /**
2936 * Used when starting a process for a Service.
2937 *
2938 * @hide
2939 */
2940 public static final int NOTIFY_PACKAGE_USE_SERVICE = 1;
2941
2942 /**
2943 * Used when moving a Service to the foreground.
2944 *
2945 * @hide
2946 */
2947 public static final int NOTIFY_PACKAGE_USE_FOREGROUND_SERVICE = 2;
2948
2949 /**
2950 * Used when starting a process for a BroadcastReceiver.
2951 *
2952 * @hide
2953 */
2954 public static final int NOTIFY_PACKAGE_USE_BROADCAST_RECEIVER = 3;
2955
2956 /**
2957 * Used when starting a process for a ContentProvider.
2958 *
2959 * @hide
2960 */
2961 public static final int NOTIFY_PACKAGE_USE_CONTENT_PROVIDER = 4;
2962
2963 /**
2964 * Used when starting a process for a BroadcastReceiver.
2965 *
2966 * @hide
2967 */
2968 public static final int NOTIFY_PACKAGE_USE_BACKUP = 5;
2969
2970 /**
2971 * Used with Context.getClassLoader() across Android packages.
2972 *
2973 * @hide
2974 */
2975 public static final int NOTIFY_PACKAGE_USE_CROSS_PACKAGE = 6;
2976
2977 /**
2978 * Used when starting a package within a process for Instrumentation.
2979 *
2980 * @hide
2981 */
2982 public static final int NOTIFY_PACKAGE_USE_INSTRUMENTATION = 7;
2983
2984 /**
2985 * Total number of usage reasons.
2986 *
2987 * @hide
2988 */
2989 public static final int NOTIFY_PACKAGE_USE_REASONS_COUNT = 8;
2990
2991 /**
Svet Ganov67882122016-12-11 16:36:34 -08002992 * Constant for specifying the highest installed package version code.
2993 */
2994 public static final int VERSION_CODE_HIGHEST = -1;
2995
Jeff Sharkeyad357d12018-02-02 13:25:31 -07002996 /** {@hide} */
2997 public int getUserId() {
2998 return UserHandle.myUserId();
2999 }
3000
Svet Ganov67882122016-12-11 16:36:34 -08003001 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003002 * Retrieve overall information about an application package that is
3003 * installed on the system.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003004 *
3005 * @param packageName The full name (i.e. com.google.apps.contacts) of the
Jeff Sharkey4347f812017-04-21 12:08:39 -06003006 * desired package.
3007 * @param flags Additional option flags to modify the data returned.
3008 * @return A PackageInfo object containing information about the package. If
3009 * flag {@code MATCH_UNINSTALLED_PACKAGES} is set and if the package
3010 * is not found in the list of installed applications, the package
3011 * information is retrieved from the list of uninstalled
kmccormick30498b42013-03-27 17:39:17 -07003012 * applications (which includes installed applications as well as
3013 * applications with data directory i.e. applications which had been
3014 * deleted with {@code DONT_DELETE_DATA} flag set).
Jeff Sharkey8588bc12016-01-06 16:47:42 -07003015 * @throws NameNotFoundException if a package with the given name cannot be
3016 * found on the system.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003017 */
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07003018 public abstract PackageInfo getPackageInfo(String packageName, @PackageInfoFlags int flags)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003019 throws NameNotFoundException;
3020
3021 /**
Svet Ganov67882122016-12-11 16:36:34 -08003022 * Retrieve overall information about an application package that is
3023 * installed on the system. This method can be used for retrieving
Jeff Sharkey4347f812017-04-21 12:08:39 -06003024 * information about packages for which multiple versions can be installed
3025 * at the time. Currently only packages hosting static shared libraries can
3026 * have multiple installed versions. The method can also be used to get info
3027 * for a package that has a single version installed by passing
3028 * {@link #VERSION_CODE_HIGHEST} in the {@link VersionedPackage}
Svet Ganov67882122016-12-11 16:36:34 -08003029 * constructor.
3030 *
Svetoslav Ganov345ffa52017-04-18 16:08:41 -07003031 * @param versionedPackage The versioned package for which to query.
Jeff Sharkey4347f812017-04-21 12:08:39 -06003032 * @param flags Additional option flags to modify the data returned.
3033 * @return A PackageInfo object containing information about the package. If
3034 * flag {@code MATCH_UNINSTALLED_PACKAGES} is set and if the package
3035 * is not found in the list of installed applications, the package
3036 * information is retrieved from the list of uninstalled
Svet Ganov67882122016-12-11 16:36:34 -08003037 * applications (which includes installed applications as well as
3038 * applications with data directory i.e. applications which had been
3039 * deleted with {@code DONT_DELETE_DATA} flag set).
3040 * @throws NameNotFoundException if a package with the given name cannot be
3041 * found on the system.
Svet Ganov67882122016-12-11 16:36:34 -08003042 */
3043 public abstract PackageInfo getPackageInfo(VersionedPackage versionedPackage,
3044 @PackageInfoFlags int flags) throws NameNotFoundException;
3045
3046 /**
Nicolas Prevot9a80e532015-09-23 15:49:28 +01003047 * Retrieve overall information about an application package that is
3048 * installed on the system.
Nicolas Prevot9a80e532015-09-23 15:49:28 +01003049 *
3050 * @param packageName The full name (i.e. com.google.apps.contacts) of the
Jeff Sharkey4347f812017-04-21 12:08:39 -06003051 * desired package.
3052 * @param flags Additional option flags to modify the data returned.
Nicolas Prevot9a80e532015-09-23 15:49:28 +01003053 * @param userId The user id.
Jeff Sharkey4347f812017-04-21 12:08:39 -06003054 * @return A PackageInfo object containing information about the package. If
3055 * flag {@code MATCH_UNINSTALLED_PACKAGES} is set and if the package
3056 * is not found in the list of installed applications, the package
3057 * information is retrieved from the list of uninstalled
Nicolas Prevot9a80e532015-09-23 15:49:28 +01003058 * applications (which includes installed applications as well as
3059 * applications with data directory i.e. applications which had been
3060 * deleted with {@code DONT_DELETE_DATA} flag set).
Jeff Sharkey8588bc12016-01-06 16:47:42 -07003061 * @throws NameNotFoundException if a package with the given name cannot be
3062 * found on the system.
Svet Ganov67882122016-12-11 16:36:34 -08003063 * @hide
Nicolas Prevot9a80e532015-09-23 15:49:28 +01003064 */
3065 @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS)
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07003066 public abstract PackageInfo getPackageInfoAsUser(String packageName,
Jeff Sharkey8588bc12016-01-06 16:47:42 -07003067 @PackageInfoFlags int flags, @UserIdInt int userId) throws NameNotFoundException;
Nicolas Prevot9a80e532015-09-23 15:49:28 +01003068
3069 /**
Dianne Hackborn47096932010-02-11 15:57:09 -08003070 * Map from the current package names in use on the device to whatever
3071 * the current canonical name of that package is.
3072 * @param names Array of current names to be mapped.
3073 * @return Returns an array of the same size as the original, containing
3074 * the canonical name for each package.
3075 */
3076 public abstract String[] currentToCanonicalPackageNames(String[] names);
Amith Yamasani4b2e9342011-03-31 12:38:53 -07003077
Dianne Hackborn47096932010-02-11 15:57:09 -08003078 /**
3079 * Map from a packages canonical name to the current name in use on the device.
3080 * @param names Array of new names to be mapped.
3081 * @return Returns an array of the same size as the original, containing
3082 * the current name for each package.
3083 */
3084 public abstract String[] canonicalToCurrentPackageNames(String[] names);
Amith Yamasani4b2e9342011-03-31 12:38:53 -07003085
Dianne Hackborn47096932010-02-11 15:57:09 -08003086 /**
Andrew Solovay5ae13352014-06-06 12:23:09 -07003087 * Returns a "good" intent to launch a front-door activity in a package.
3088 * This is used, for example, to implement an "open" button when browsing
3089 * through packages. The current implementation looks first for a main
3090 * activity in the category {@link Intent#CATEGORY_INFO}, and next for a
3091 * main activity in the category {@link Intent#CATEGORY_LAUNCHER}. Returns
3092 * <code>null</code> if neither are found.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003093 *
3094 * @param packageName The name of the package to inspect.
Amith Yamasani4b2e9342011-03-31 12:38:53 -07003095 *
Andrew Solovay5ae13352014-06-06 12:23:09 -07003096 * @return A fully-qualified {@link Intent} that can be used to launch the
3097 * main activity in the package. Returns <code>null</code> if the package
3098 * does not contain such an activity, or if <em>packageName</em> is not
Ihab Awad1ec68882014-09-12 11:09:01 -07003099 * recognized.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003100 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06003101 public abstract @Nullable Intent getLaunchIntentForPackage(@NonNull String packageName);
Mihai Predaeae850c2009-05-13 10:13:48 +02003102
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003103 /**
Jose Lima970417c2014-04-10 10:42:19 -07003104 * Return a "good" intent to launch a front-door Leanback activity in a
3105 * package, for use for example to implement an "open" button when browsing
3106 * through packages. The current implementation will look for a main
3107 * activity in the category {@link Intent#CATEGORY_LEANBACK_LAUNCHER}, or
3108 * return null if no main leanback activities are found.
Adam Connors551c0782014-06-05 12:13:03 +01003109 *
Jose Lima970417c2014-04-10 10:42:19 -07003110 * @param packageName The name of the package to inspect.
3111 * @return Returns either a fully-qualified Intent that can be used to launch
3112 * the main Leanback activity in the package, or null if the package
3113 * does not contain such an activity.
3114 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06003115 public abstract @Nullable Intent getLeanbackLaunchIntentForPackage(@NonNull String packageName);
Jose Lima970417c2014-04-10 10:42:19 -07003116
3117 /**
Roberto Perez7ee1a7a2017-12-04 17:14:33 -08003118 * Return a "good" intent to launch a front-door Car activity in a
3119 * package, for use for example to implement an "open" button when browsing
3120 * through packages. The current implementation will look for a main
3121 * activity in the category {@link Intent#CATEGORY_CAR_LAUNCHER}, or
3122 * return null if no main car activities are found.
3123 *
3124 * @param packageName The name of the package to inspect.
3125 * @return Returns either a fully-qualified Intent that can be used to launch
3126 * the main Car activity in the package, or null if the package
3127 * does not contain such an activity.
3128 * @hide
3129 */
3130 public abstract @Nullable Intent getCarLaunchIntentForPackage(@NonNull String packageName);
3131
3132 /**
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06003133 * Return an array of all of the POSIX secondary group IDs that have been
3134 * assigned to the given package.
3135 * <p>
3136 * Note that the same package may have different GIDs under different
3137 * {@link UserHandle} on the same device.
Adam Connors551c0782014-06-05 12:13:03 +01003138 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003139 * @param packageName The full name (i.e. com.google.apps.contacts) of the
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06003140 * desired package.
3141 * @return Returns an int array of the assigned GIDs, or null if there are
Jose Lima970417c2014-04-10 10:42:19 -07003142 * none.
Jeff Sharkey8588bc12016-01-06 16:47:42 -07003143 * @throws NameNotFoundException if a package with the given name cannot be
3144 * found on the system.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003145 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06003146 public abstract int[] getPackageGids(@NonNull String packageName)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003147 throws NameNotFoundException;
3148
3149 /**
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06003150 * Return an array of all of the POSIX secondary group IDs that have been
3151 * assigned to the given package.
3152 * <p>
3153 * Note that the same package may have different GIDs under different
3154 * {@link UserHandle} on the same device.
Dianne Hackborna06de0f2012-12-11 16:34:47 -08003155 *
3156 * @param packageName The full name (i.e. com.google.apps.contacts) of the
Jeff Sharkey8588bc12016-01-06 16:47:42 -07003157 * desired package.
3158 * @return Returns an int array of the assigned gids, or null if there are
3159 * none.
3160 * @throws NameNotFoundException if a package with the given name cannot be
3161 * found on the system.
Dianne Hackborna06de0f2012-12-11 16:34:47 -08003162 */
Jeff Sharkey8588bc12016-01-06 16:47:42 -07003163 public abstract int[] getPackageGids(String packageName, @PackageInfoFlags int flags)
Dianne Hackborna06de0f2012-12-11 16:34:47 -08003164 throws NameNotFoundException;
3165
3166 /**
Jeff Sharkey8588bc12016-01-06 16:47:42 -07003167 * Return the UID associated with the given package name.
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06003168 * <p>
3169 * Note that the same package will have different UIDs under different
3170 * {@link UserHandle} on the same device.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003171 *
Jeff Sharkey8588bc12016-01-06 16:47:42 -07003172 * @param packageName The full name (i.e. com.google.apps.contacts) of the
3173 * desired package.
3174 * @return Returns an integer UID who owns the given package name.
3175 * @throws NameNotFoundException if a package with the given name can not be
3176 * found on the system.
3177 */
3178 public abstract int getPackageUid(String packageName, @PackageInfoFlags int flags)
3179 throws NameNotFoundException;
3180
3181 /**
3182 * Return the UID associated with the given package name.
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06003183 * <p>
3184 * Note that the same package will have different UIDs under different
3185 * {@link UserHandle} on the same device.
Jeff Sharkey8588bc12016-01-06 16:47:42 -07003186 *
3187 * @param packageName The full name (i.e. com.google.apps.contacts) of the
3188 * desired package.
3189 * @param userId The user handle identifier to look up the package under.
3190 * @return Returns an integer UID who owns the given package name.
3191 * @throws NameNotFoundException if a package with the given name can not be
3192 * found on the system.
3193 * @hide
3194 */
3195 public abstract int getPackageUidAsUser(String packageName, @UserIdInt int userId)
3196 throws NameNotFoundException;
3197
3198 /**
3199 * Return the UID associated with the given package name.
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06003200 * <p>
3201 * Note that the same package will have different UIDs under different
3202 * {@link UserHandle} on the same device.
Jeff Sharkey8588bc12016-01-06 16:47:42 -07003203 *
3204 * @param packageName The full name (i.e. com.google.apps.contacts) of the
3205 * desired package.
3206 * @param userId The user handle identifier to look up the package under.
3207 * @return Returns an integer UID who owns the given package name.
3208 * @throws NameNotFoundException if a package with the given name can not be
3209 * found on the system.
3210 * @hide
3211 */
3212 public abstract int getPackageUidAsUser(String packageName, @PackageInfoFlags int flags,
3213 @UserIdInt int userId) throws NameNotFoundException;
3214
3215 /**
3216 * Retrieve all of the information we know about a particular permission.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003217 *
3218 * @param name The fully qualified name (i.e. com.google.permission.LOGIN)
Jeff Sharkey4347f812017-04-21 12:08:39 -06003219 * of the permission you are interested in.
3220 * @param flags Additional option flags to modify the data returned.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003221 * @return Returns a {@link PermissionInfo} containing information about the
3222 * permission.
Jeff Sharkey8588bc12016-01-06 16:47:42 -07003223 * @throws NameNotFoundException if a package with the given name cannot be
3224 * found on the system.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003225 */
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07003226 public abstract PermissionInfo getPermissionInfo(String name, @PermissionInfoFlags int flags)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003227 throws NameNotFoundException;
3228
3229 /**
3230 * Query for all of the permissions associated with a particular group.
3231 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003232 * @param group The fully qualified name (i.e. com.google.permission.LOGIN)
Jeff Sharkey4347f812017-04-21 12:08:39 -06003233 * of the permission group you are interested in. Use null to
3234 * find all of the permissions not associated with a group.
3235 * @param flags Additional option flags to modify the data returned.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003236 * @return Returns a list of {@link PermissionInfo} containing information
Jeff Sharkey4347f812017-04-21 12:08:39 -06003237 * about all of the permissions in the given group.
Jeff Sharkey8588bc12016-01-06 16:47:42 -07003238 * @throws NameNotFoundException if a package with the given name cannot be
3239 * found on the system.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003240 */
3241 public abstract List<PermissionInfo> queryPermissionsByGroup(String group,
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07003242 @PermissionInfoFlags int flags) throws NameNotFoundException;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003243
3244 /**
Paul Navin7b89a7b2017-01-26 23:56:08 +00003245 * Returns true if Permission Review Mode is enabled, false otherwise.
3246 *
3247 * @hide
3248 */
3249 @TestApi
3250 public abstract boolean isPermissionReviewModeEnabled();
3251
3252 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003253 * Retrieve all of the information we know about a particular group of
3254 * permissions.
3255 *
Jeff Sharkey4347f812017-04-21 12:08:39 -06003256 * @param name The fully qualified name (i.e.
3257 * com.google.permission_group.APPS) of the permission you are
3258 * interested in.
3259 * @param flags Additional option flags to modify the data returned.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003260 * @return Returns a {@link PermissionGroupInfo} containing information
Todd Kennedy6b9bfa12016-01-08 13:44:51 -08003261 * about the permission.
Jeff Sharkey8588bc12016-01-06 16:47:42 -07003262 * @throws NameNotFoundException if a package with the given name cannot be
3263 * found on the system.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003264 */
3265 public abstract PermissionGroupInfo getPermissionGroupInfo(String name,
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07003266 @PermissionGroupInfoFlags int flags) throws NameNotFoundException;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003267
3268 /**
3269 * Retrieve all of the known permission groups in the system.
3270 *
Jeff Sharkey4347f812017-04-21 12:08:39 -06003271 * @param flags Additional option flags to modify the data returned.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003272 * @return Returns a list of {@link PermissionGroupInfo} containing
Todd Kennedy6b9bfa12016-01-08 13:44:51 -08003273 * information about all of the known permission groups.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003274 */
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07003275 public abstract List<PermissionGroupInfo> getAllPermissionGroups(
3276 @PermissionGroupInfoFlags int flags);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003277
3278 /**
3279 * Retrieve all of the information we know about a particular
3280 * package/application.
3281 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003282 * @param packageName The full name (i.e. com.google.apps.contacts) of an
Jeff Sharkey4347f812017-04-21 12:08:39 -06003283 * application.
3284 * @param flags Additional option flags to modify the data returned.
Todd Kennedy6b9bfa12016-01-08 13:44:51 -08003285 * @return An {@link ApplicationInfo} containing information about the
Jeff Sharkey4347f812017-04-21 12:08:39 -06003286 * package. If flag {@code MATCH_UNINSTALLED_PACKAGES} is set and if
3287 * the package is not found in the list of installed applications,
3288 * the application information is retrieved from the list of
3289 * uninstalled applications (which includes installed applications
3290 * as well as applications with data directory i.e. applications
3291 * which had been deleted with {@code DONT_DELETE_DATA} flag set).
Jeff Sharkey8588bc12016-01-06 16:47:42 -07003292 * @throws NameNotFoundException if a package with the given name cannot be
3293 * found on the system.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003294 */
3295 public abstract ApplicationInfo getApplicationInfo(String packageName,
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07003296 @ApplicationInfoFlags int flags) throws NameNotFoundException;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003297
Jeff Sharkeycd654482016-01-08 17:42:11 -07003298 /** {@hide} */
3299 public abstract ApplicationInfo getApplicationInfoAsUser(String packageName,
3300 @ApplicationInfoFlags int flags, @UserIdInt int userId) throws NameNotFoundException;
3301
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003302 /**
3303 * Retrieve all of the information we know about a particular activity
3304 * class.
3305 *
Dianne Hackborn361199b2010-08-30 17:42:07 -07003306 * @param component The full component name (i.e.
Jeff Sharkey8a372a02016-03-16 16:25:45 -06003307 * com.google.apps.contacts/com.google.apps.contacts.
3308 * ContactsList) of an Activity class.
Jeff Sharkey4347f812017-04-21 12:08:39 -06003309 * @param flags Additional option flags to modify the data returned.
Jeff Sharkey8a372a02016-03-16 16:25:45 -06003310 * @return An {@link ActivityInfo} containing information about the
3311 * activity.
Jeff Sharkey8588bc12016-01-06 16:47:42 -07003312 * @throws NameNotFoundException if a package with the given name cannot be
3313 * found on the system.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003314 */
Dianne Hackborn361199b2010-08-30 17:42:07 -07003315 public abstract ActivityInfo getActivityInfo(ComponentName component,
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07003316 @ComponentInfoFlags int flags) throws NameNotFoundException;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003317
3318 /**
3319 * Retrieve all of the information we know about a particular receiver
3320 * class.
3321 *
Dianne Hackborn361199b2010-08-30 17:42:07 -07003322 * @param component The full component name (i.e.
Jeff Sharkey8a372a02016-03-16 16:25:45 -06003323 * com.google.apps.calendar/com.google.apps.calendar.
3324 * CalendarAlarm) of a Receiver class.
Jeff Sharkey4347f812017-04-21 12:08:39 -06003325 * @param flags Additional option flags to modify the data returned.
Jeff Sharkey8a372a02016-03-16 16:25:45 -06003326 * @return An {@link ActivityInfo} containing information about the
3327 * receiver.
Jeff Sharkey8588bc12016-01-06 16:47:42 -07003328 * @throws NameNotFoundException if a package with the given name cannot be
3329 * found on the system.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003330 */
Dianne Hackborn361199b2010-08-30 17:42:07 -07003331 public abstract ActivityInfo getReceiverInfo(ComponentName component,
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07003332 @ComponentInfoFlags int flags) throws NameNotFoundException;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003333
3334 /**
Jeff Sharkey8a372a02016-03-16 16:25:45 -06003335 * Retrieve all of the information we know about a particular service class.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003336 *
Dianne Hackborn361199b2010-08-30 17:42:07 -07003337 * @param component The full component name (i.e.
Jeff Sharkey8a372a02016-03-16 16:25:45 -06003338 * com.google.apps.media/com.google.apps.media.
3339 * BackgroundPlayback) of a Service class.
Jeff Sharkey4347f812017-04-21 12:08:39 -06003340 * @param flags Additional option flags to modify the data returned.
Jeff Sharkey8a372a02016-03-16 16:25:45 -06003341 * @return A {@link ServiceInfo} object containing information about the
3342 * service.
Jeff Sharkey8588bc12016-01-06 16:47:42 -07003343 * @throws NameNotFoundException if a package with the given name cannot be
3344 * found on the system.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003345 */
Dianne Hackborn361199b2010-08-30 17:42:07 -07003346 public abstract ServiceInfo getServiceInfo(ComponentName component,
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07003347 @ComponentInfoFlags int flags) throws NameNotFoundException;
Dianne Hackborn361199b2010-08-30 17:42:07 -07003348
3349 /**
3350 * Retrieve all of the information we know about a particular content
3351 * provider class.
3352 *
Dianne Hackborn361199b2010-08-30 17:42:07 -07003353 * @param component The full component name (i.e.
Jeff Sharkey8a372a02016-03-16 16:25:45 -06003354 * com.google.providers.media/com.google.providers.media.
3355 * MediaProvider) of a ContentProvider class.
Jeff Sharkey4347f812017-04-21 12:08:39 -06003356 * @param flags Additional option flags to modify the data returned.
Jeff Sharkey8a372a02016-03-16 16:25:45 -06003357 * @return A {@link ProviderInfo} object containing information about the
3358 * provider.
Jeff Sharkey8588bc12016-01-06 16:47:42 -07003359 * @throws NameNotFoundException if a package with the given name cannot be
3360 * found on the system.
Dianne Hackborn361199b2010-08-30 17:42:07 -07003361 */
3362 public abstract ProviderInfo getProviderInfo(ComponentName component,
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07003363 @ComponentInfoFlags int flags) throws NameNotFoundException;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003364
3365 /**
Ricky Wai9964f702018-04-12 17:01:20 +01003366 * Return a List of all packages that are installed for the current user.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003367 *
Jeff Sharkey4347f812017-04-21 12:08:39 -06003368 * @param flags Additional option flags to modify the data returned.
Todd Kennedy6b9bfa12016-01-08 13:44:51 -08003369 * @return A List of PackageInfo objects, one for each installed package,
Jeff Sharkey4347f812017-04-21 12:08:39 -06003370 * containing information about the package. In the unlikely case
Todd Kennedy6b9bfa12016-01-08 13:44:51 -08003371 * there are no installed packages, an empty list is returned. If
3372 * flag {@code MATCH_UNINSTALLED_PACKAGES} is set, the package
3373 * information is retrieved from the list of uninstalled
3374 * applications (which includes installed applications as well as
3375 * applications with data directory i.e. applications which had been
3376 * deleted with {@code DONT_DELETE_DATA} flag set).
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003377 */
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07003378 public abstract List<PackageInfo> getInstalledPackages(@PackageInfoFlags int flags);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003379
3380 /**
Jeff Sharkey4347f812017-04-21 12:08:39 -06003381 * Return a List of all installed packages that are currently holding any of
3382 * the given permissions.
Dianne Hackborne7991752013-01-16 17:56:46 -08003383 *
Jeff Sharkey4347f812017-04-21 12:08:39 -06003384 * @param flags Additional option flags to modify the data returned.
Todd Kennedy6b9bfa12016-01-08 13:44:51 -08003385 * @return A List of PackageInfo objects, one for each installed package
3386 * that holds any of the permissions that were provided, containing
3387 * information about the package. If no installed packages hold any
3388 * of the permissions, an empty list is returned. If flag
Jeff Sharkey4347f812017-04-21 12:08:39 -06003389 * {@code MATCH_UNINSTALLED_PACKAGES} is set, the package
3390 * information is retrieved from the list of uninstalled
3391 * applications (which includes installed applications as well as
3392 * applications with data directory i.e. applications which had been
3393 * deleted with {@code DONT_DELETE_DATA} flag set).
Dianne Hackborne7991752013-01-16 17:56:46 -08003394 */
3395 public abstract List<PackageInfo> getPackagesHoldingPermissions(
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07003396 String[] permissions, @PackageInfoFlags int flags);
Dianne Hackborne7991752013-01-16 17:56:46 -08003397
3398 /**
Jeff Sharkey4347f812017-04-21 12:08:39 -06003399 * Return a List of all packages that are installed on the device, for a
Jeff Sharkeyd86b8fe2017-06-02 17:36:26 -06003400 * specific user.
Todd Kennedy6b9bfa12016-01-08 13:44:51 -08003401 *
Jeff Sharkey4347f812017-04-21 12:08:39 -06003402 * @param flags Additional option flags to modify the data returned.
Amith Yamasani151ec4c2012-09-07 19:25:16 -07003403 * @param userId The user for whom the installed packages are to be listed
Todd Kennedy6b9bfa12016-01-08 13:44:51 -08003404 * @return A List of PackageInfo objects, one for each installed package,
Jeff Sharkey4347f812017-04-21 12:08:39 -06003405 * containing information about the package. In the unlikely case
Todd Kennedy6b9bfa12016-01-08 13:44:51 -08003406 * there are no installed packages, an empty list is returned. If
3407 * flag {@code MATCH_UNINSTALLED_PACKAGES} is set, the package
3408 * information is retrieved from the list of uninstalled
3409 * applications (which includes installed applications as well as
3410 * applications with data directory i.e. applications which had been
3411 * deleted with {@code DONT_DELETE_DATA} flag set).
Amith Yamasani151ec4c2012-09-07 19:25:16 -07003412 * @hide
3413 */
Todd Kennedyef9acb62018-05-29 15:18:06 -07003414 @TestApi
Svet Ganovae0e03a2016-02-25 18:22:10 -08003415 @SystemApi
Jeff Sharkeyd86b8fe2017-06-02 17:36:26 -06003416 @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS_FULL)
Jeff Sharkeye06b4d12016-01-06 14:51:50 -07003417 public abstract List<PackageInfo> getInstalledPackagesAsUser(@PackageInfoFlags int flags,
Jeff Sharkey8588bc12016-01-06 16:47:42 -07003418 @UserIdInt int userId);
Amith Yamasani151ec4c2012-09-07 19:25:16 -07003419
3420 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003421 * Check whether a particular package has been granted a particular
3422 * permission.
3423 *
Svet Ganovad3b2972015-07-07 22:49:17 -07003424 * @param permName The name of the permission you are checking for.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003425 * @param pkgName The name of the package you are checking against.
3426 *
3427 * @return If the package has the permission, PERMISSION_GRANTED is
3428 * returned. If it does not have the permission, PERMISSION_DENIED
3429 * is returned.
3430 *
3431 * @see #PERMISSION_GRANTED
3432 * @see #PERMISSION_DENIED
3433 */
Tor Norbye1c2bf032015-03-02 10:57:08 -08003434 @CheckResult
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06003435 public abstract @PermissionResult int checkPermission(String permName, String pkgName);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003436
3437 /**
Svet Ganovad3b2972015-07-07 22:49:17 -07003438 * Checks whether a particular permissions has been revoked for a
3439 * package by policy. Typically the device owner or the profile owner
3440 * may apply such a policy. The user cannot grant policy revoked
3441 * permissions, hence the only way for an app to get such a permission
3442 * is by a policy change.
3443 *
3444 * @param permName The name of the permission you are checking for.
3445 * @param pkgName The name of the package you are checking against.
3446 *
3447 * @return Whether the permission is restricted by policy.
3448 */
3449 @CheckResult
Svet Ganovf1b7f202015-07-29 08:33:42 -07003450 public abstract boolean isPermissionRevokedByPolicy(@NonNull String permName,
3451 @NonNull String pkgName);
3452
3453 /**
3454 * Gets the package name of the component controlling runtime permissions.
3455 *
3456 * @return The package name.
3457 *
3458 * @hide
3459 */
Philip P. Moltmanneb0a0ae2017-06-30 10:55:51 -07003460 @TestApi
Svet Ganovf1b7f202015-07-29 08:33:42 -07003461 public abstract String getPermissionControllerPackageName();
Svet Ganovad3b2972015-07-07 22:49:17 -07003462
3463 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003464 * Add a new dynamic permission to the system. For this to work, your
3465 * package must have defined a permission tree through the
3466 * {@link android.R.styleable#AndroidManifestPermissionTree
3467 * &lt;permission-tree&gt;} tag in its manifest. A package can only add
3468 * permissions to trees that were defined by either its own package or
3469 * another with the same user id; a permission is in a tree if it
3470 * matches the name of the permission tree + ".": for example,
3471 * "com.foo.bar" is a member of the permission tree "com.foo".
3472 *
3473 * <p>It is good to make your permission tree name descriptive, because you
3474 * are taking possession of that entire set of permission names. Thus, it
3475 * must be under a domain you control, with a suffix that will not match
3476 * any normal permissions that may be declared in any applications that
3477 * are part of that domain.
3478 *
3479 * <p>New permissions must be added before
3480 * any .apks are installed that use those permissions. Permissions you
3481 * add through this method are remembered across reboots of the device.
3482 * If the given permission already exists, the info you supply here
3483 * will be used to update it.
3484 *
3485 * @param info Description of the permission to be added.
3486 *
3487 * @return Returns true if a new permission was created, false if an
3488 * existing one was updated.
3489 *
3490 * @throws SecurityException if you are not allowed to add the
3491 * given permission name.
3492 *
3493 * @see #removePermission(String)
3494 */
3495 public abstract boolean addPermission(PermissionInfo info);
3496
3497 /**
Dianne Hackbornd7c09682010-03-30 10:42:20 -07003498 * Like {@link #addPermission(PermissionInfo)} but asynchronously
3499 * persists the package manager state after returning from the call,
3500 * allowing it to return quicker and batch a series of adds at the
3501 * expense of no guarantee the added permission will be retained if
3502 * the device is rebooted before it is written.
3503 */
3504 public abstract boolean addPermissionAsync(PermissionInfo info);
Amith Yamasani4b2e9342011-03-31 12:38:53 -07003505
Dianne Hackbornd7c09682010-03-30 10:42:20 -07003506 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003507 * Removes a permission that was previously added with
3508 * {@link #addPermission(PermissionInfo)}. The same ownership rules apply
3509 * -- you are only allowed to remove permissions that you are allowed
3510 * to add.
3511 *
3512 * @param name The name of the permission to remove.
3513 *
3514 * @throws SecurityException if you are not allowed to remove the
3515 * given permission name.
3516 *
3517 * @see #addPermission(PermissionInfo)
3518 */
3519 public abstract void removePermission(String name);
3520
Svet Ganov8c7f7002015-05-07 10:48:44 -07003521 /**
3522 * Permission flags set when granting or revoking a permission.
3523 *
3524 * @hide
3525 */
3526 @SystemApi
Jeff Sharkey4347f812017-04-21 12:08:39 -06003527 @IntDef(prefix = { "FLAG_PERMISSION_" }, value = {
3528 FLAG_PERMISSION_USER_SET,
Svet Ganov8c7f7002015-05-07 10:48:44 -07003529 FLAG_PERMISSION_USER_FIXED,
3530 FLAG_PERMISSION_POLICY_FIXED,
Svet Ganovb3f22b42015-05-12 11:01:24 -07003531 FLAG_PERMISSION_REVOKE_ON_UPGRADE,
Svet Ganov77ab6a82015-07-03 12:03:02 -07003532 FLAG_PERMISSION_SYSTEM_FIXED,
Jeff Sharkey4347f812017-04-21 12:08:39 -06003533 FLAG_PERMISSION_GRANTED_BY_DEFAULT
3534 })
Svet Ganov8c7f7002015-05-07 10:48:44 -07003535 @Retention(RetentionPolicy.SOURCE)
3536 public @interface PermissionFlags {}
3537
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003538 /**
Svetoslavc6d1c342015-02-26 14:44:43 -08003539 * Grant a runtime permission to an application which the application does not
3540 * already have. The permission must have been requested by the application.
3541 * If the application is not allowed to hold the permission, a {@link
Ruben Brunk12ab5e12016-11-10 15:27:30 -08003542 * java.lang.SecurityException} is thrown. If the package or permission is
3543 * invalid, a {@link java.lang.IllegalArgumentException} is thrown.
Svetoslavc6d1c342015-02-26 14:44:43 -08003544 * <p>
3545 * <strong>Note: </strong>Using this API requires holding
Todd Kennedya8eb6a82016-07-28 16:35:42 -07003546 * android.permission.GRANT_RUNTIME_PERMISSIONS and if the user id is
Svetoslavc6d1c342015-02-26 14:44:43 -08003547 * not the current user android.permission.INTERACT_ACROSS_USERS_FULL.
3548 * </p>
Nick Kralevich035f80d2013-03-27 15:20:08 -07003549 *
Svetoslavc6d1c342015-02-26 14:44:43 -08003550 * @param packageName The package to which to grant the permission.
3551 * @param permissionName The permission name to grant.
3552 * @param user The user for which to grant the permission.
3553 *
Svet Ganov8c7f7002015-05-07 10:48:44 -07003554 * @see #revokeRuntimePermission(String, String, android.os.UserHandle)
Svetoslavc6d1c342015-02-26 14:44:43 -08003555 *
3556 * @hide
Nick Kralevich035f80d2013-03-27 15:20:08 -07003557 */
Svetoslavc6d1c342015-02-26 14:44:43 -08003558 @SystemApi
Jeff Sharkeyd86b8fe2017-06-02 17:36:26 -06003559 @RequiresPermission(android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS)
Svet Ganov8c7f7002015-05-07 10:48:44 -07003560 public abstract void grantRuntimePermission(@NonNull String packageName,
Svetoslavc6d1c342015-02-26 14:44:43 -08003561 @NonNull String permissionName, @NonNull UserHandle user);
Nick Kralevich035f80d2013-03-27 15:20:08 -07003562
Svetoslavc6d1c342015-02-26 14:44:43 -08003563 /**
3564 * Revoke a runtime permission that was previously granted by {@link
Svet Ganov8c7f7002015-05-07 10:48:44 -07003565 * #grantRuntimePermission(String, String, android.os.UserHandle)}. The
3566 * permission must have been requested by and granted to the application.
3567 * If the application is not allowed to hold the permission, a {@link
Ruben Brunk12ab5e12016-11-10 15:27:30 -08003568 * java.lang.SecurityException} is thrown. If the package or permission is
3569 * invalid, a {@link java.lang.IllegalArgumentException} is thrown.
Svetoslavc6d1c342015-02-26 14:44:43 -08003570 * <p>
3571 * <strong>Note: </strong>Using this API requires holding
Todd Kennedya8eb6a82016-07-28 16:35:42 -07003572 * android.permission.REVOKE_RUNTIME_PERMISSIONS and if the user id is
Svetoslavc6d1c342015-02-26 14:44:43 -08003573 * not the current user android.permission.INTERACT_ACROSS_USERS_FULL.
3574 * </p>
3575 *
3576 * @param packageName The package from which to revoke the permission.
3577 * @param permissionName The permission name to revoke.
3578 * @param user The user for which to revoke the permission.
3579 *
Svet Ganov8c7f7002015-05-07 10:48:44 -07003580 * @see #grantRuntimePermission(String, String, android.os.UserHandle)
Svetoslavc6d1c342015-02-26 14:44:43 -08003581 *
3582 * @hide
3583 */
3584 @SystemApi
Jeff Sharkeyd86b8fe2017-06-02 17:36:26 -06003585 @RequiresPermission(android.Manifest.permission.REVOKE_RUNTIME_PERMISSIONS)
Svet Ganov8c7f7002015-05-07 10:48:44 -07003586 public abstract void revokeRuntimePermission(@NonNull String packageName,
Svetoslavc6d1c342015-02-26 14:44:43 -08003587 @NonNull String permissionName, @NonNull UserHandle user);
3588
3589 /**
Svet Ganov8c7f7002015-05-07 10:48:44 -07003590 * Gets the state flags associated with a permission.
3591 *
3592 * @param permissionName The permission for which to get the flags.
3593 * @param packageName The package name for which to get the flags.
3594 * @param user The user for which to get permission flags.
3595 * @return The permission flags.
3596 *
3597 * @hide
3598 */
3599 @SystemApi
Jeff Sharkeyd86b8fe2017-06-02 17:36:26 -06003600 @RequiresPermission(anyOf = {
3601 android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS,
3602 android.Manifest.permission.REVOKE_RUNTIME_PERMISSIONS
3603 })
Svet Ganov8c7f7002015-05-07 10:48:44 -07003604 public abstract @PermissionFlags int getPermissionFlags(String permissionName,
3605 String packageName, @NonNull UserHandle user);
3606
3607 /**
3608 * Updates the flags associated with a permission by replacing the flags in
3609 * the specified mask with the provided flag values.
3610 *
3611 * @param permissionName The permission for which to update the flags.
3612 * @param packageName The package name for which to update the flags.
3613 * @param flagMask The flags which to replace.
3614 * @param flagValues The flags with which to replace.
3615 * @param user The user for which to update the permission flags.
3616 *
3617 * @hide
3618 */
3619 @SystemApi
Jeff Sharkeyd86b8fe2017-06-02 17:36:26 -06003620 @RequiresPermission(anyOf = {
3621 android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS,
3622 android.Manifest.permission.REVOKE_RUNTIME_PERMISSIONS
3623 })
Svet Ganov8c7f7002015-05-07 10:48:44 -07003624 public abstract void updatePermissionFlags(String permissionName,
Jeff Sharkey4347f812017-04-21 12:08:39 -06003625 String packageName, @PermissionFlags int flagMask, @PermissionFlags int flagValues,
Svet Ganov8c7f7002015-05-07 10:48:44 -07003626 @NonNull UserHandle user);
3627
3628 /**
Svetoslav20770dd2015-05-29 15:43:04 -07003629 * Gets whether you should show UI with rationale for requesting a permission.
3630 * You should do this only if you do not have the permission and the context in
3631 * which the permission is requested does not clearly communicate to the user
3632 * what would be the benefit from grating this permission.
3633 *
3634 * @param permission A permission your app wants to request.
3635 * @return Whether you can show permission rationale UI.
3636 *
3637 * @hide
3638 */
3639 public abstract boolean shouldShowRequestPermissionRationale(String permission);
3640
3641 /**
Svetoslavc6d1c342015-02-26 14:44:43 -08003642 * Returns an {@link android.content.Intent} suitable for passing to
3643 * {@link android.app.Activity#startActivityForResult(android.content.Intent, int)}
3644 * which prompts the user to grant permissions to this application.
3645 *
3646 * @throws NullPointerException if {@code permissions} is {@code null} or empty.
3647 *
3648 * @hide
3649 */
3650 public Intent buildRequestPermissionsIntent(@NonNull String[] permissions) {
3651 if (ArrayUtils.isEmpty(permissions)) {
Svet Ganovf66381c2016-02-18 20:02:36 -08003652 throw new IllegalArgumentException("permission cannot be null or empty");
Svetoslavc6d1c342015-02-26 14:44:43 -08003653 }
3654 Intent intent = new Intent(ACTION_REQUEST_PERMISSIONS);
3655 intent.putExtra(EXTRA_REQUEST_PERMISSIONS_NAMES, permissions);
Svet Ganovf1b7f202015-07-29 08:33:42 -07003656 intent.setPackage(getPermissionControllerPackageName());
Svetoslavc6d1c342015-02-26 14:44:43 -08003657 return intent;
Nick Kralevich035f80d2013-03-27 15:20:08 -07003658 }
3659
3660 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003661 * Compare the signatures of two packages to determine if the same
3662 * signature appears in both of them. If they do contain the same
3663 * signature, then they are allowed special privileges when working
3664 * with each other: they can share the same user-id, run instrumentation
3665 * against each other, etc.
3666 *
3667 * @param pkg1 First package name whose signature will be compared.
3668 * @param pkg2 Second package name whose signature will be compared.
Chris Palmer09f33602010-09-13 14:27:18 -07003669 *
3670 * @return Returns an integer indicating whether all signatures on the
3671 * two packages match. The value is >= 0 ({@link #SIGNATURE_MATCH}) if
3672 * all signatures match or < 0 if there is not a match ({@link
3673 * #SIGNATURE_NO_MATCH} or {@link #SIGNATURE_UNKNOWN_PACKAGE}).
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003674 *
Dianne Hackborn766cbfe2009-08-12 18:33:39 -07003675 * @see #checkSignatures(int, int)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003676 */
Tor Norbye1c2bf032015-03-02 10:57:08 -08003677 @CheckResult
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06003678 public abstract @SignatureResult int checkSignatures(String pkg1, String pkg2);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003679
3680 /**
Dianne Hackborn766cbfe2009-08-12 18:33:39 -07003681 * Like {@link #checkSignatures(String, String)}, but takes UIDs of
3682 * the two packages to be checked. This can be useful, for example,
3683 * when doing the check in an IPC, where the UID is the only identity
3684 * available. It is functionally identical to determining the package
3685 * associated with the UIDs and checking their signatures.
3686 *
Joe Onorato25660ec2009-08-12 22:40:37 -07003687 * @param uid1 First UID whose signature will be compared.
3688 * @param uid2 Second UID whose signature will be compared.
Dianne Hackborn766cbfe2009-08-12 18:33:39 -07003689 *
Chris Palmer09f33602010-09-13 14:27:18 -07003690 * @return Returns an integer indicating whether all signatures on the
3691 * two packages match. The value is >= 0 ({@link #SIGNATURE_MATCH}) if
3692 * all signatures match or < 0 if there is not a match ({@link
3693 * #SIGNATURE_NO_MATCH} or {@link #SIGNATURE_UNKNOWN_PACKAGE}).
3694 *
3695 * @see #checkSignatures(String, String)
Dianne Hackborn766cbfe2009-08-12 18:33:39 -07003696 */
Tor Norbye1c2bf032015-03-02 10:57:08 -08003697 @CheckResult
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06003698 public abstract @SignatureResult int checkSignatures(int uid1, int uid2);
Dianne Hackborn766cbfe2009-08-12 18:33:39 -07003699
3700 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003701 * Retrieve the names of all packages that are associated with a particular
3702 * user id. In most cases, this will be a single package name, the package
3703 * that has been assigned that user id. Where there are multiple packages
3704 * sharing the same user id through the "sharedUserId" mechanism, all
3705 * packages with that id will be returned.
3706 *
3707 * @param uid The user id for which you would like to retrieve the
3708 * associated packages.
3709 *
3710 * @return Returns an array of one or more packages assigned to the user
3711 * id, or null if there are no known packages with the given id.
3712 */
Jeff Sharkey377ded0f2016-01-10 13:15:41 -07003713 public abstract @Nullable String[] getPackagesForUid(int uid);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003714
3715 /**
Michal Karpinskicb67dc92016-12-13 18:20:23 +00003716 * Retrieve the official name associated with a uid. This name is
Jonathan Basseri7ea3a332015-05-12 19:39:22 -07003717 * guaranteed to never change, though it is possible for the underlying
Michal Karpinskicb67dc92016-12-13 18:20:23 +00003718 * uid to be changed. That is, if you are storing information about
3719 * uids in persistent storage, you should use the string returned
3720 * by this function instead of the raw uid.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003721 *
Michal Karpinskicb67dc92016-12-13 18:20:23 +00003722 * @param uid The uid for which you would like to retrieve a name.
3723 * @return Returns a unique name for the given uid, or null if the
3724 * uid is not currently assigned.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003725 */
Jeff Sharkey377ded0f2016-01-10 13:15:41 -07003726 public abstract @Nullable String getNameForUid(int uid);
Amith Yamasani4b2e9342011-03-31 12:38:53 -07003727
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003728 /**
Todd Kennedy9da8b8a72017-07-25 15:38:39 -07003729 * Retrieves the official names associated with each given uid.
3730 * @see #getNameForUid(int)
3731 *
3732 * @hide
3733 */
Philip P. Moltmannabeb04e2018-03-26 10:15:23 -07003734 @TestApi
Todd Kennedy9da8b8a72017-07-25 15:38:39 -07003735 public abstract @Nullable String[] getNamesForUids(int[] uids);
3736
3737 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003738 * Return the user id associated with a shared user name. Multiple
3739 * applications can specify a shared user name in their manifest and thus
3740 * end up using a common uid. This might be used for new applications
3741 * that use an existing shared user name and need to know the uid of the
3742 * shared user.
3743 *
3744 * @param sharedUserName The shared user name whose uid is to be retrieved.
Jeff Sharkey8588bc12016-01-06 16:47:42 -07003745 * @return Returns the UID associated with the shared user.
3746 * @throws NameNotFoundException if a package with the given name cannot be
3747 * found on the system.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003748 * @hide
3749 */
3750 public abstract int getUidForSharedUser(String sharedUserName)
3751 throws NameNotFoundException;
3752
3753 /**
Ricky Wai9964f702018-04-12 17:01:20 +01003754 * Return a List of all application packages that are installed for the
3755 * current user. If flag GET_UNINSTALLED_PACKAGES has been set, a list of all
Jeff Sharkey4347f812017-04-21 12:08:39 -06003756 * applications including those deleted with {@code DONT_DELETE_DATA}
3757 * (partially installed apps with data directory) will be returned.
Amith Yamasani4b2e9342011-03-31 12:38:53 -07003758 *
Jeff Sharkey4347f812017-04-21 12:08:39 -06003759 * @param flags Additional option flags to modify the data returned.
3760 * @return A List of ApplicationInfo objects, one for each installed
3761 * application. In the unlikely case there are no installed
3762 * packages, an empty list is returned. If flag
3763 * {@code MATCH_UNINSTALLED_PACKAGES} is set, the application
3764 * information is retrieved from the list of uninstalled
Todd Kennedy6b9bfa12016-01-08 13:44:51 -08003765 * applications (which includes installed applications as well as
3766 * applications with data directory i.e. applications which had been
3767 * deleted with {@code DONT_DELETE_DATA} flag set).
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003768 */
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07003769 public abstract List<ApplicationInfo> getInstalledApplications(@ApplicationInfoFlags int flags);
Amith Yamasani4b2e9342011-03-31 12:38:53 -07003770
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003771 /**
Jeff Sharkey4347f812017-04-21 12:08:39 -06003772 * Return a List of all application packages that are installed on the
3773 * device, for a specific user. If flag GET_UNINSTALLED_PACKAGES has been
3774 * set, a list of all applications including those deleted with
3775 * {@code DONT_DELETE_DATA} (partially installed apps with data directory)
Bartosz Fabianowski11334242016-11-17 20:49:16 +01003776 * will be returned.
3777 *
Jeff Sharkey4347f812017-04-21 12:08:39 -06003778 * @param flags Additional option flags to modify the data returned.
3779 * @param userId The user for whom the installed applications are to be
3780 * listed
3781 * @return A List of ApplicationInfo objects, one for each installed
3782 * application. In the unlikely case there are no installed
3783 * packages, an empty list is returned. If flag
3784 * {@code MATCH_UNINSTALLED_PACKAGES} is set, the application
3785 * information is retrieved from the list of uninstalled
Bartosz Fabianowski11334242016-11-17 20:49:16 +01003786 * applications (which includes installed applications as well as
3787 * applications with data directory i.e. applications which had been
3788 * deleted with {@code DONT_DELETE_DATA} flag set).
3789 * @hide
Bartosz Fabianowski11334242016-11-17 20:49:16 +01003790 */
Hongming Jin83e16262018-05-18 10:47:57 -07003791 @TestApi
Bartosz Fabianowski11334242016-11-17 20:49:16 +01003792 public abstract List<ApplicationInfo> getInstalledApplicationsAsUser(
3793 @ApplicationInfoFlags int flags, @UserIdInt int userId);
3794
3795 /**
Jeff Sharkey910e0812017-04-21 16:29:27 -06003796 * Gets the instant applications the user recently used.
Svet Ganov2acf0632015-11-24 19:10:59 -08003797 *
Svetoslav Ganov096d3042017-01-30 16:34:13 -08003798 * @return The instant app list.
Svet Ganov2acf0632015-11-24 19:10:59 -08003799 *
3800 * @hide
3801 */
Todd Kennedy9c9fdf22017-03-06 10:58:27 -08003802 @SystemApi
Svetoslav Ganov096d3042017-01-30 16:34:13 -08003803 @RequiresPermission(Manifest.permission.ACCESS_INSTANT_APPS)
3804 public abstract @NonNull List<InstantAppInfo> getInstantApps();
Svet Ganov2acf0632015-11-24 19:10:59 -08003805
3806 /**
Svetoslav Ganov096d3042017-01-30 16:34:13 -08003807 * Gets the icon for an instant application.
Svet Ganov2acf0632015-11-24 19:10:59 -08003808 *
3809 * @param packageName The app package name.
3810 *
3811 * @hide
3812 */
Todd Kennedy9c9fdf22017-03-06 10:58:27 -08003813 @SystemApi
Svetoslav Ganov096d3042017-01-30 16:34:13 -08003814 @RequiresPermission(Manifest.permission.ACCESS_INSTANT_APPS)
3815 public abstract @Nullable Drawable getInstantAppIcon(String packageName);
Svet Ganov2acf0632015-11-24 19:10:59 -08003816
3817 /**
David Christie31a16552017-03-01 15:08:45 -08003818 * Gets whether this application is an instant app.
Svet Ganov2acf0632015-11-24 19:10:59 -08003819 *
Svetoslav Ganov096d3042017-01-30 16:34:13 -08003820 * @return Whether caller is an instant app.
Svet Ganov2acf0632015-11-24 19:10:59 -08003821 *
David Christie31a16552017-03-01 15:08:45 -08003822 * @see #isInstantApp(String)
Svetoslav Ganov345ffa52017-04-18 16:08:41 -07003823 * @see #updateInstantAppCookie(byte[])
Svetoslav Ganov096d3042017-01-30 16:34:13 -08003824 * @see #getInstantAppCookie()
Svetoslav Ganov345ffa52017-04-18 16:08:41 -07003825 * @see #getInstantAppCookieMaxBytes()
Svet Ganov2acf0632015-11-24 19:10:59 -08003826 */
Svetoslav Ganov096d3042017-01-30 16:34:13 -08003827 public abstract boolean isInstantApp();
Svet Ganov2acf0632015-11-24 19:10:59 -08003828
3829 /**
David Christie31a16552017-03-01 15:08:45 -08003830 * Gets whether the given package is an instant app.
3831 *
3832 * @param packageName The package to check
3833 * @return Whether the given package is an instant app.
3834 *
3835 * @see #isInstantApp()
Svetoslav Ganov345ffa52017-04-18 16:08:41 -07003836 * @see #updateInstantAppCookie(byte[])
David Christie31a16552017-03-01 15:08:45 -08003837 * @see #getInstantAppCookie()
Svetoslav Ganov345ffa52017-04-18 16:08:41 -07003838 * @see #getInstantAppCookieMaxBytes()
3839 * @see #clearInstantAppCookie()
David Christie31a16552017-03-01 15:08:45 -08003840 */
3841 public abstract boolean isInstantApp(String packageName);
3842
3843 /**
Svetoslav Ganov096d3042017-01-30 16:34:13 -08003844 * Gets the maximum size in bytes of the cookie data an instant app
Svet Ganov2acf0632015-11-24 19:10:59 -08003845 * can store on the device.
3846 *
3847 * @return The max cookie size in bytes.
3848 *
Svetoslav Ganov096d3042017-01-30 16:34:13 -08003849 * @see #isInstantApp()
David Christie31a16552017-03-01 15:08:45 -08003850 * @see #isInstantApp(String)
Svetoslav Ganov345ffa52017-04-18 16:08:41 -07003851 * @see #updateInstantAppCookie(byte[])
Svetoslav Ganov096d3042017-01-30 16:34:13 -08003852 * @see #getInstantAppCookie()
Svetoslav Ganov345ffa52017-04-18 16:08:41 -07003853 * @see #clearInstantAppCookie()
3854 */
3855 public abstract int getInstantAppCookieMaxBytes();
3856
3857 /**
Daniel Cashman5cdda342018-01-19 07:22:52 -08003858 * deprecated
Svetoslav Ganov345ffa52017-04-18 16:08:41 -07003859 * @hide
Svet Ganov2acf0632015-11-24 19:10:59 -08003860 */
Svetoslav Ganov096d3042017-01-30 16:34:13 -08003861 public abstract int getInstantAppCookieMaxSize();
Svet Ganov2acf0632015-11-24 19:10:59 -08003862
3863 /**
Svetoslav Ganov096d3042017-01-30 16:34:13 -08003864 * Gets the instant application cookie for this app. Non
3865 * instant apps and apps that were instant but were upgraded
3866 * to normal apps can still access this API. For instant apps
Svetoslav Ganov345ffa52017-04-18 16:08:41 -07003867 * this cookie is cached for some time after uninstall while for
Svet Ganov2acf0632015-11-24 19:10:59 -08003868 * normal apps the cookie is deleted after the app is uninstalled.
3869 * The cookie is always present while the app is installed.
3870 *
3871 * @return The cookie.
3872 *
Svetoslav Ganov096d3042017-01-30 16:34:13 -08003873 * @see #isInstantApp()
David Christie31a16552017-03-01 15:08:45 -08003874 * @see #isInstantApp(String)
Svetoslav Ganov345ffa52017-04-18 16:08:41 -07003875 * @see #updateInstantAppCookie(byte[])
3876 * @see #getInstantAppCookieMaxBytes()
3877 * @see #clearInstantAppCookie()
Svet Ganov2acf0632015-11-24 19:10:59 -08003878 */
Svetoslav Ganov096d3042017-01-30 16:34:13 -08003879 public abstract @NonNull byte[] getInstantAppCookie();
Svet Ganov2acf0632015-11-24 19:10:59 -08003880
3881 /**
Svetoslav Ganov345ffa52017-04-18 16:08:41 -07003882 * Clears the instant application cookie for the calling app.
Svet Ganov2acf0632015-11-24 19:10:59 -08003883 *
Svetoslav Ganov096d3042017-01-30 16:34:13 -08003884 * @see #isInstantApp()
David Christie31a16552017-03-01 15:08:45 -08003885 * @see #isInstantApp(String)
Svetoslav Ganov345ffa52017-04-18 16:08:41 -07003886 * @see #getInstantAppCookieMaxBytes()
Svetoslav Ganov096d3042017-01-30 16:34:13 -08003887 * @see #getInstantAppCookie()
Svetoslav Ganov345ffa52017-04-18 16:08:41 -07003888 * @see #clearInstantAppCookie()
3889 */
3890 public abstract void clearInstantAppCookie();
3891
3892 /**
3893 * Updates the instant application cookie for the calling app. Non
3894 * instant apps and apps that were instant but were upgraded
3895 * to normal apps can still access this API. For instant apps
3896 * this cookie is cached for some time after uninstall while for
3897 * normal apps the cookie is deleted after the app is uninstalled.
3898 * The cookie is always present while the app is installed. The
3899 * cookie size is limited by {@link #getInstantAppCookieMaxBytes()}.
3900 * Passing <code>null</code> or an empty array clears the cookie.
3901 * </p>
3902 *
3903 * @param cookie The cookie data.
3904 *
3905 * @see #isInstantApp()
3906 * @see #isInstantApp(String)
3907 * @see #getInstantAppCookieMaxBytes()
3908 * @see #getInstantAppCookie()
3909 * @see #clearInstantAppCookie()
3910 *
3911 * @throws IllegalArgumentException if the array exceeds max cookie size.
3912 */
3913 public abstract void updateInstantAppCookie(@Nullable byte[] cookie);
3914
3915 /**
3916 * @removed
Svet Ganov2acf0632015-11-24 19:10:59 -08003917 */
Svetoslav Ganov096d3042017-01-30 16:34:13 -08003918 public abstract boolean setInstantAppCookie(@Nullable byte[] cookie);
Svet Ganov2acf0632015-11-24 19:10:59 -08003919
3920 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003921 * Get a list of shared libraries that are available on the
3922 * system.
Amith Yamasani4b2e9342011-03-31 12:38:53 -07003923 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003924 * @return An array of shared library names that are
3925 * available on the system, or null if none are installed.
Amith Yamasani4b2e9342011-03-31 12:38:53 -07003926 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003927 */
3928 public abstract String[] getSystemSharedLibraryNames();
3929
3930 /**
Svet Ganov67882122016-12-11 16:36:34 -08003931 * Get a list of shared libraries on the device.
3932 *
3933 * @param flags To filter the libraries to return.
3934 * @return The shared library list.
3935 *
Svet Ganov67882122016-12-11 16:36:34 -08003936 * @see #MATCH_UNINSTALLED_PACKAGES
3937 */
3938 public abstract @NonNull List<SharedLibraryInfo> getSharedLibraries(
3939 @InstallFlags int flags);
3940
3941 /**
3942 * Get a list of shared libraries on the device.
3943 *
3944 * @param flags To filter the libraries to return.
3945 * @param userId The user to query for.
3946 * @return The shared library list.
3947 *
3948 * @see #MATCH_FACTORY_ONLY
3949 * @see #MATCH_KNOWN_PACKAGES
3950 * @see #MATCH_ANY_USER
3951 * @see #MATCH_UNINSTALLED_PACKAGES
3952 *
3953 * @hide
3954 */
3955 public abstract @NonNull List<SharedLibraryInfo> getSharedLibrariesAsUser(
3956 @InstallFlags int flags, @UserIdInt int userId);
3957
3958 /**
Svet Ganovd7b1f4112016-02-09 18:49:23 -08003959 * Get the name of the package hosting the services shared library.
3960 *
3961 * @return The library host package.
3962 *
3963 * @hide
3964 */
Philip P. Moltmannf80809f2018-04-04 11:20:44 -07003965 @TestApi
Svetoslav Ganova9c25002016-04-13 19:25:56 -07003966 public abstract @NonNull String getServicesSystemSharedLibraryPackageName();
3967
3968 /**
3969 * Get the name of the package hosting the shared components shared library.
3970 *
3971 * @return The library host package.
3972 *
3973 * @hide
3974 */
Philip P. Moltmannf80809f2018-04-04 11:20:44 -07003975 @TestApi
Svetoslav Ganova9c25002016-04-13 19:25:56 -07003976 public abstract @NonNull String getSharedSystemSharedLibraryPackageName();
Svet Ganovd7b1f4112016-02-09 18:49:23 -08003977
3978 /**
Todd Kennedy9106c642017-02-08 14:16:53 -08003979 * Returns the names of the packages that have been changed
3980 * [eg. added, removed or updated] since the given sequence
3981 * number.
3982 * <p>If no packages have been changed, returns <code>null</code>.
3983 * <p>The sequence number starts at <code>0</code> and is
3984 * reset every boot.
Todd Kennedy8fddf9d2017-04-17 15:16:12 -07003985 * @param sequenceNumber The first sequence number for which to retrieve package changes.
3986 * @see Settings.Global#BOOT_COUNT
Todd Kennedy9106c642017-02-08 14:16:53 -08003987 */
3988 public abstract @Nullable ChangedPackages getChangedPackages(
3989 @IntRange(from=0) int sequenceNumber);
3990
3991 /**
Dianne Hackborn49237342009-08-27 20:08:01 -07003992 * Get a list of features that are available on the
3993 * system.
Amith Yamasani4b2e9342011-03-31 12:38:53 -07003994 *
Dianne Hackborn49237342009-08-27 20:08:01 -07003995 * @return An array of FeatureInfo classes describing the features
3996 * that are available on the system, or null if there are none(!!).
Dianne Hackborn49237342009-08-27 20:08:01 -07003997 */
3998 public abstract FeatureInfo[] getSystemAvailableFeatures();
3999
4000 /**
Jeff Sharkey115d2c12016-02-15 17:25:57 -07004001 * Check whether the given feature name is one of the available features as
4002 * returned by {@link #getSystemAvailableFeatures()}. This tests for the
4003 * presence of <em>any</em> version of the given feature name; use
4004 * {@link #hasSystemFeature(String, int)} to check for a minimum version.
Amith Yamasani4b2e9342011-03-31 12:38:53 -07004005 *
Jeff Sharkey115d2c12016-02-15 17:25:57 -07004006 * @return Returns true if the devices supports the feature, else false.
Dianne Hackborn039c68e2009-09-26 16:39:23 -07004007 */
4008 public abstract boolean hasSystemFeature(String name);
4009
4010 /**
Jeff Sharkey115d2c12016-02-15 17:25:57 -07004011 * Check whether the given feature name and version is one of the available
4012 * features as returned by {@link #getSystemAvailableFeatures()}. Since
4013 * features are defined to always be backwards compatible, this returns true
4014 * if the available feature version is greater than or equal to the
4015 * requested version.
4016 *
4017 * @return Returns true if the devices supports the feature, else false.
4018 */
4019 public abstract boolean hasSystemFeature(String name, int version);
4020
4021 /**
Jeff Sharkey8a372a02016-03-16 16:25:45 -06004022 * Determine the best action to perform for a given Intent. This is how
4023 * {@link Intent#resolveActivity} finds an activity if a class has not been
4024 * explicitly specified.
4025 * <p>
4026 * <em>Note:</em> if using an implicit Intent (without an explicit
4027 * ComponentName specified), be sure to consider whether to set the
4028 * {@link #MATCH_DEFAULT_ONLY} only flag. You need to do so to resolve the
4029 * activity in the same way that
4030 * {@link android.content.Context#startActivity(Intent)} and
Dianne Hackborn4d023d212010-10-01 13:41:04 -07004031 * {@link android.content.Intent#resolveActivity(PackageManager)
Jeff Sharkey8a372a02016-03-16 16:25:45 -06004032 * Intent.resolveActivity(PackageManager)} do.
4033 * </p>
Amith Yamasani4b2e9342011-03-31 12:38:53 -07004034 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004035 * @param intent An intent containing all of the desired specification
Jeff Sharkey8a372a02016-03-16 16:25:45 -06004036 * (action, data, type, category, and/or component).
Jeff Sharkey4347f812017-04-21 12:08:39 -06004037 * @param flags Additional option flags to modify the data returned. The
4038 * most important is {@link #MATCH_DEFAULT_ONLY}, to limit the
4039 * resolution to only those activities that support the
4040 * {@link android.content.Intent#CATEGORY_DEFAULT}.
Todd Kennedy6b9bfa12016-01-08 13:44:51 -08004041 * @return Returns a ResolveInfo object containing the final activity intent
Jeff Sharkey8a372a02016-03-16 16:25:45 -06004042 * that was determined to be the best action. Returns null if no
Mike LeBeaubd3f5272010-02-18 19:27:17 -08004043 * matching activity was found. If multiple matching activities are
Todd Kennedy6b9bfa12016-01-08 13:44:51 -08004044 * found and there is no default set, returns a ResolveInfo object
Mike LeBeaubd3f5272010-02-18 19:27:17 -08004045 * containing something else, such as the activity resolver.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004046 */
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07004047 public abstract ResolveInfo resolveActivity(Intent intent, @ResolveInfoFlags int flags);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004048
4049 /**
Jeff Sharkey8a372a02016-03-16 16:25:45 -06004050 * Determine the best action to perform for a given Intent for a given user.
4051 * This is how {@link Intent#resolveActivity} finds an activity if a class
4052 * has not been explicitly specified.
4053 * <p>
4054 * <em>Note:</em> if using an implicit Intent (without an explicit
4055 * ComponentName specified), be sure to consider whether to set the
4056 * {@link #MATCH_DEFAULT_ONLY} only flag. You need to do so to resolve the
4057 * activity in the same way that
4058 * {@link android.content.Context#startActivity(Intent)} and
Svetoslav Ganov58d37b52012-09-18 12:04:19 -07004059 * {@link android.content.Intent#resolveActivity(PackageManager)
Jeff Sharkey8a372a02016-03-16 16:25:45 -06004060 * Intent.resolveActivity(PackageManager)} do.
4061 * </p>
Svetoslav Ganov58d37b52012-09-18 12:04:19 -07004062 *
4063 * @param intent An intent containing all of the desired specification
Jeff Sharkey8a372a02016-03-16 16:25:45 -06004064 * (action, data, type, category, and/or component).
Jeff Sharkey4347f812017-04-21 12:08:39 -06004065 * @param flags Additional option flags to modify the data returned. The
4066 * most important is {@link #MATCH_DEFAULT_ONLY}, to limit the
4067 * resolution to only those activities that support the
4068 * {@link android.content.Intent#CATEGORY_DEFAULT}.
Svetoslav Ganov58d37b52012-09-18 12:04:19 -07004069 * @param userId The user id.
Todd Kennedy6b9bfa12016-01-08 13:44:51 -08004070 * @return Returns a ResolveInfo object containing the final activity intent
Jeff Sharkey8a372a02016-03-16 16:25:45 -06004071 * that was determined to be the best action. Returns null if no
Svetoslav Ganov58d37b52012-09-18 12:04:19 -07004072 * matching activity was found. If multiple matching activities are
Todd Kennedy6b9bfa12016-01-08 13:44:51 -08004073 * found and there is no default set, returns a ResolveInfo object
Svetoslav Ganov58d37b52012-09-18 12:04:19 -07004074 * containing something else, such as the activity resolver.
Svetoslav Ganov58d37b52012-09-18 12:04:19 -07004075 * @hide
4076 */
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07004077 public abstract ResolveInfo resolveActivityAsUser(Intent intent, @ResolveInfoFlags int flags,
Jeff Sharkey8588bc12016-01-06 16:47:42 -07004078 @UserIdInt int userId);
Svetoslav Ganov58d37b52012-09-18 12:04:19 -07004079
4080 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004081 * Retrieve all activities that can be performed for the given intent.
4082 *
4083 * @param intent The desired intent as per resolveActivity().
Jeff Sharkey4347f812017-04-21 12:08:39 -06004084 * @param flags Additional option flags to modify the data returned. The
4085 * most important is {@link #MATCH_DEFAULT_ONLY}, to limit the
4086 * resolution to only those activities that support the
4087 * {@link android.content.Intent#CATEGORY_DEFAULT}. Or, set
Jeff Sharkey8a372a02016-03-16 16:25:45 -06004088 * {@link #MATCH_ALL} to prevent any filtering of the results.
4089 * @return Returns a List of ResolveInfo objects containing one entry for
4090 * each matching activity, ordered from best to worst. In other
4091 * words, the first item is what would be returned by
4092 * {@link #resolveActivity}. If there are no matching activities, an
4093 * empty list is returned.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004094 */
4095 public abstract List<ResolveInfo> queryIntentActivities(Intent intent,
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07004096 @ResolveInfoFlags int flags);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004097
4098 /**
Jeff Sharkey8a372a02016-03-16 16:25:45 -06004099 * Retrieve all activities that can be performed for the given intent, for a
4100 * specific user.
Amith Yamasani151ec4c2012-09-07 19:25:16 -07004101 *
4102 * @param intent The desired intent as per resolveActivity().
Jeff Sharkey4347f812017-04-21 12:08:39 -06004103 * @param flags Additional option flags to modify the data returned. The
4104 * most important is {@link #MATCH_DEFAULT_ONLY}, to limit the
4105 * resolution to only those activities that support the
4106 * {@link android.content.Intent#CATEGORY_DEFAULT}. Or, set
Jeff Sharkey8a372a02016-03-16 16:25:45 -06004107 * {@link #MATCH_ALL} to prevent any filtering of the results.
4108 * @return Returns a List of ResolveInfo objects containing one entry for
4109 * each matching activity, ordered from best to worst. In other
4110 * words, the first item is what would be returned by
4111 * {@link #resolveActivity}. If there are no matching activities, an
4112 * empty list is returned.
Amith Yamasani151ec4c2012-09-07 19:25:16 -07004113 * @hide
4114 */
Svetoslav Ganov58d37b52012-09-18 12:04:19 -07004115 public abstract List<ResolveInfo> queryIntentActivitiesAsUser(Intent intent,
Jeff Sharkey8588bc12016-01-06 16:47:42 -07004116 @ResolveInfoFlags int flags, @UserIdInt int userId);
Amith Yamasani151ec4c2012-09-07 19:25:16 -07004117
4118 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004119 * Retrieve a set of activities that should be presented to the user as
Jeff Sharkey8a372a02016-03-16 16:25:45 -06004120 * similar options. This is like {@link #queryIntentActivities}, except it
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004121 * also allows you to supply a list of more explicit Intents that you would
4122 * like to resolve to particular options, and takes care of returning the
4123 * final ResolveInfo list in a reasonable order, with no duplicates, based
4124 * on those inputs.
4125 *
Jeff Sharkey8a372a02016-03-16 16:25:45 -06004126 * @param caller The class name of the activity that is making the request.
4127 * This activity will never appear in the output list. Can be
4128 * null.
4129 * @param specifics An array of Intents that should be resolved to the first
4130 * specific results. Can be null.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004131 * @param intent The desired intent as per resolveActivity().
Jeff Sharkey4347f812017-04-21 12:08:39 -06004132 * @param flags Additional option flags to modify the data returned. The
4133 * most important is {@link #MATCH_DEFAULT_ONLY}, to limit the
4134 * resolution to only those activities that support the
4135 * {@link android.content.Intent#CATEGORY_DEFAULT}.
Jeff Sharkey8a372a02016-03-16 16:25:45 -06004136 * @return Returns a List of ResolveInfo objects containing one entry for
4137 * each matching activity. The list is ordered first by all of the
4138 * intents resolved in <var>specifics</var> and then any additional
4139 * activities that can handle <var>intent</var> but did not get
4140 * included by one of the <var>specifics</var> intents. If there are
4141 * no matching activities, an empty list is returned.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004142 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06004143 public abstract List<ResolveInfo> queryIntentActivityOptions(@Nullable ComponentName caller,
4144 @Nullable Intent[] specifics, Intent intent, @ResolveInfoFlags int flags);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004145
4146 /**
4147 * Retrieve all receivers that can handle a broadcast of the given intent.
4148 *
4149 * @param intent The desired intent as per resolveActivity().
Jeff Sharkey4347f812017-04-21 12:08:39 -06004150 * @param flags Additional option flags to modify the data returned.
Jeff Sharkey8a372a02016-03-16 16:25:45 -06004151 * @return Returns a List of ResolveInfo objects containing one entry for
4152 * each matching receiver, ordered from best to worst. If there are
4153 * no matching receivers, an empty list or null is returned.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004154 */
4155 public abstract List<ResolveInfo> queryBroadcastReceivers(Intent intent,
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07004156 @ResolveInfoFlags int flags);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004157
4158 /**
Jeff Sharkey8a372a02016-03-16 16:25:45 -06004159 * Retrieve all receivers that can handle a broadcast of the given intent,
4160 * for a specific user.
Amith Yamasanif203aee2012-08-29 18:41:53 -07004161 *
4162 * @param intent The desired intent as per resolveActivity().
Jeff Sharkey4347f812017-04-21 12:08:39 -06004163 * @param flags Additional option flags to modify the data returned.
Fyodor Kupolov940e8572016-01-26 12:03:51 -08004164 * @param userHandle UserHandle of the user being queried.
Jeff Sharkey8a372a02016-03-16 16:25:45 -06004165 * @return Returns a List of ResolveInfo objects containing one entry for
4166 * each matching receiver, ordered from best to worst. If there are
4167 * no matching receivers, an empty list or null is returned.
Amith Yamasanif203aee2012-08-29 18:41:53 -07004168 * @hide
4169 */
Fyodor Kupolov940e8572016-01-26 12:03:51 -08004170 @SystemApi
Todd Kennedydbaef6d2017-07-24 11:28:00 -07004171 @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS)
Fyodor Kupolov940e8572016-01-26 12:03:51 -08004172 public List<ResolveInfo> queryBroadcastReceiversAsUser(Intent intent,
4173 @ResolveInfoFlags int flags, UserHandle userHandle) {
4174 return queryBroadcastReceiversAsUser(intent, flags, userHandle.getIdentifier());
4175 }
4176
4177 /**
4178 * @hide
4179 */
Jeff Sharkeye06b4d12016-01-06 14:51:50 -07004180 public abstract List<ResolveInfo> queryBroadcastReceiversAsUser(Intent intent,
Jeff Sharkey8588bc12016-01-06 16:47:42 -07004181 @ResolveInfoFlags int flags, @UserIdInt int userId);
Amith Yamasanif203aee2012-08-29 18:41:53 -07004182
Fyodor Kupolov940e8572016-01-26 12:03:51 -08004183
Jeff Sharkeybd940222016-01-08 11:07:13 -07004184 /** {@hide} */
4185 @Deprecated
4186 public List<ResolveInfo> queryBroadcastReceivers(Intent intent,
4187 @ResolveInfoFlags int flags, @UserIdInt int userId) {
Jeff Sharkey6f4b2a32017-03-21 14:13:41 -06004188 final String msg = "Shame on you for calling the hidden API "
4189 + "queryBroadcastReceivers(). Shame!";
4190 if (VMRuntime.getRuntime().getTargetSdkVersion() >= Build.VERSION_CODES.O) {
4191 throw new UnsupportedOperationException(msg);
4192 } else {
4193 Log.d(TAG, msg);
4194 return queryBroadcastReceiversAsUser(intent, flags, userId);
4195 }
Jeff Sharkeybd940222016-01-08 11:07:13 -07004196 }
4197
Amith Yamasanif203aee2012-08-29 18:41:53 -07004198 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004199 * Determine the best service to handle for a given Intent.
4200 *
4201 * @param intent An intent containing all of the desired specification
Jeff Sharkey8a372a02016-03-16 16:25:45 -06004202 * (action, data, type, category, and/or component).
Jeff Sharkey4347f812017-04-21 12:08:39 -06004203 * @param flags Additional option flags to modify the data returned.
Todd Kennedy6b9bfa12016-01-08 13:44:51 -08004204 * @return Returns a ResolveInfo object containing the final service intent
Jeff Sharkey8a372a02016-03-16 16:25:45 -06004205 * that was determined to be the best action. Returns null if no
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004206 * matching service was found.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004207 */
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07004208 public abstract ResolveInfo resolveService(Intent intent, @ResolveInfoFlags int flags);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004209
4210 /**
Philip P. Moltmann18e3eb82018-03-09 16:55:55 -08004211 * @hide
4212 */
4213 public abstract ResolveInfo resolveServiceAsUser(Intent intent, @ResolveInfoFlags int flags,
4214 @UserIdInt int userId);
4215
4216 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004217 * Retrieve all services that can match the given intent.
4218 *
4219 * @param intent The desired intent as per resolveService().
Jeff Sharkey4347f812017-04-21 12:08:39 -06004220 * @param flags Additional option flags to modify the data returned.
Jeff Sharkey8a372a02016-03-16 16:25:45 -06004221 * @return Returns a List of ResolveInfo objects containing one entry for
4222 * each matching service, ordered from best to worst. In other
4223 * words, the first item is what would be returned by
4224 * {@link #resolveService}. If there are no matching services, an
4225 * empty list or null is returned.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004226 */
4227 public abstract List<ResolveInfo> queryIntentServices(Intent intent,
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07004228 @ResolveInfoFlags int flags);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004229
4230 /**
Svetoslav Ganov58d37b52012-09-18 12:04:19 -07004231 * Retrieve all services that can match the given intent for a given user.
4232 *
4233 * @param intent The desired intent as per resolveService().
Jeff Sharkey4347f812017-04-21 12:08:39 -06004234 * @param flags Additional option flags to modify the data returned.
Svetoslav Ganov58d37b52012-09-18 12:04:19 -07004235 * @param userId The user id.
Jeff Sharkey8a372a02016-03-16 16:25:45 -06004236 * @return Returns a List of ResolveInfo objects containing one entry for
4237 * each matching service, ordered from best to worst. In other
4238 * words, the first item is what would be returned by
4239 * {@link #resolveService}. If there are no matching services, an
4240 * empty list or null is returned.
Svetoslav Ganov58d37b52012-09-18 12:04:19 -07004241 * @hide
4242 */
4243 public abstract List<ResolveInfo> queryIntentServicesAsUser(Intent intent,
Jeff Sharkey8588bc12016-01-06 16:47:42 -07004244 @ResolveInfoFlags int flags, @UserIdInt int userId);
Svetoslav Ganov58d37b52012-09-18 12:04:19 -07004245
Todd Kennedy6b9bfa12016-01-08 13:44:51 -08004246 /**
4247 * Retrieve all providers that can match the given intent.
4248 *
4249 * @param intent An intent containing all of the desired specification
4250 * (action, data, type, category, and/or component).
Jeff Sharkey4347f812017-04-21 12:08:39 -06004251 * @param flags Additional option flags to modify the data returned.
Todd Kennedy6b9bfa12016-01-08 13:44:51 -08004252 * @param userId The user id.
Jeff Sharkey8a372a02016-03-16 16:25:45 -06004253 * @return Returns a List of ResolveInfo objects containing one entry for
4254 * each matching provider, ordered from best to worst. If there are
4255 * no matching services, an empty list or null is returned.
Todd Kennedy6b9bfa12016-01-08 13:44:51 -08004256 * @hide
4257 */
Jeff Sharkey85f5f812013-10-07 10:16:12 -07004258 public abstract List<ResolveInfo> queryIntentContentProvidersAsUser(
Jeff Sharkey8588bc12016-01-06 16:47:42 -07004259 Intent intent, @ResolveInfoFlags int flags, @UserIdInt int userId);
Jeff Sharkey85f5f812013-10-07 10:16:12 -07004260
4261 /**
4262 * Retrieve all providers that can match the given intent.
4263 *
4264 * @param intent An intent containing all of the desired specification
4265 * (action, data, type, category, and/or component).
Jeff Sharkey4347f812017-04-21 12:08:39 -06004266 * @param flags Additional option flags to modify the data returned.
Jeff Sharkey8a372a02016-03-16 16:25:45 -06004267 * @return Returns a List of ResolveInfo objects containing one entry for
4268 * each matching provider, ordered from best to worst. If there are
4269 * no matching services, an empty list or null is returned.
Jeff Sharkey85f5f812013-10-07 10:16:12 -07004270 */
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07004271 public abstract List<ResolveInfo> queryIntentContentProviders(Intent intent,
4272 @ResolveInfoFlags int flags);
Jeff Sharkey85f5f812013-10-07 10:16:12 -07004273
Svetoslav Ganov58d37b52012-09-18 12:04:19 -07004274 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004275 * Find a single content provider by its base path name.
4276 *
4277 * @param name The name of the provider to find.
Jeff Sharkey4347f812017-04-21 12:08:39 -06004278 * @param flags Additional option flags to modify the data returned.
Jeff Sharkey8a372a02016-03-16 16:25:45 -06004279 * @return A {@link ProviderInfo} object containing information about the
4280 * provider. If a provider was not found, returns null.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004281 */
4282 public abstract ProviderInfo resolveContentProvider(String name,
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07004283 @ComponentInfoFlags int flags);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004284
4285 /**
Alexandra Gherghina0363c3e2014-06-23 13:34:59 +01004286 * Find a single content provider by its base path name.
4287 *
4288 * @param name The name of the provider to find.
Jeff Sharkey4347f812017-04-21 12:08:39 -06004289 * @param flags Additional option flags to modify the data returned.
Alexandra Gherghina0363c3e2014-06-23 13:34:59 +01004290 * @param userId The user id.
Jeff Sharkey8a372a02016-03-16 16:25:45 -06004291 * @return A {@link ProviderInfo} object containing information about the
4292 * provider. If a provider was not found, returns null.
Alexandra Gherghina0363c3e2014-06-23 13:34:59 +01004293 * @hide
4294 */
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07004295 public abstract ProviderInfo resolveContentProviderAsUser(String name,
Jeff Sharkey8588bc12016-01-06 16:47:42 -07004296 @ComponentInfoFlags int flags, @UserIdInt int userId);
Alexandra Gherghina0363c3e2014-06-23 13:34:59 +01004297
4298 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004299 * Retrieve content provider information.
Jeff Sharkey8a372a02016-03-16 16:25:45 -06004300 * <p>
4301 * <em>Note: unlike most other methods, an empty result set is indicated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004302 * by a null return instead of an empty list.</em>
4303 *
4304 * @param processName If non-null, limits the returned providers to only
Jeff Sharkey8a372a02016-03-16 16:25:45 -06004305 * those that are hosted by the given process. If null, all
4306 * content providers are returned.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004307 * @param uid If <var>processName</var> is non-null, this is the required
Jeff Sharkey8a372a02016-03-16 16:25:45 -06004308 * uid owning the requested content providers.
Jeff Sharkey4347f812017-04-21 12:08:39 -06004309 * @param flags Additional option flags to modify the data returned.
Todd Kennedy6b9bfa12016-01-08 13:44:51 -08004310 * @return A list of {@link ProviderInfo} objects containing one entry for
4311 * each provider either matching <var>processName</var> or, if
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004312 * <var>processName</var> is null, all known content providers.
4313 * <em>If there are no matching providers, null is returned.</em>
4314 */
4315 public abstract List<ProviderInfo> queryContentProviders(
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07004316 String processName, int uid, @ComponentInfoFlags int flags);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004317
4318 /**
Makoto Onuki32757292017-02-22 14:36:59 -08004319 * Same as {@link #queryContentProviders}, except when {@code metaDataKey} is not null,
4320 * it only returns providers which have metadata with the {@code metaDataKey} key.
4321 *
4322 * <p>DO NOT USE the {@code metaDataKey} parameter, unless you're the contacts provider.
4323 * You really shouldn't need it. Other apps should use {@link #queryIntentContentProviders}
4324 * instead.
4325 *
4326 * <p>The {@code metaDataKey} parameter was added to allow the contacts provider to quickly
4327 * scan the GAL providers on the device. Unfortunately the discovery protocol used metadata
4328 * to mark GAL providers, rather than intent filters, so we can't use
4329 * {@link #queryIntentContentProviders} for that.
4330 *
4331 * @hide
4332 */
4333 public List<ProviderInfo> queryContentProviders(
4334 String processName, int uid, @ComponentInfoFlags int flags, String metaDataKey) {
4335 // Provide the default implementation for mocks.
4336 return queryContentProviders(processName, uid, flags);
4337 }
4338
4339 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004340 * Retrieve all of the information we know about a particular
4341 * instrumentation class.
4342 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004343 * @param className The full name (i.e.
Jeff Sharkey4347f812017-04-21 12:08:39 -06004344 * com.google.apps.contacts.InstrumentList) of an Instrumentation
4345 * class.
4346 * @param flags Additional option flags to modify the data returned.
4347 * @return An {@link InstrumentationInfo} object containing information
4348 * about the instrumentation.
Jeff Sharkey8588bc12016-01-06 16:47:42 -07004349 * @throws NameNotFoundException if a package with the given name cannot be
4350 * found on the system.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004351 */
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07004352 public abstract InstrumentationInfo getInstrumentationInfo(ComponentName className,
4353 @InstrumentationInfoFlags int flags) throws NameNotFoundException;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004354
4355 /**
Jeff Sharkey4347f812017-04-21 12:08:39 -06004356 * Retrieve information about available instrumentation code. May be used to
4357 * retrieve either all instrumentation code, or only the code targeting a
4358 * particular package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004359 *
4360 * @param targetPackage If null, all instrumentation is returned; only the
Jeff Sharkey4347f812017-04-21 12:08:39 -06004361 * instrumentation targeting this package name is returned.
4362 * @param flags Additional option flags to modify the data returned.
Todd Kennedy6b9bfa12016-01-08 13:44:51 -08004363 * @return A list of {@link InstrumentationInfo} objects containing one
4364 * entry for each matching instrumentation. If there are no
Jesse Hallf77a34f2016-02-04 18:41:33 -08004365 * instrumentation available, returns an empty list.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004366 */
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07004367 public abstract List<InstrumentationInfo> queryInstrumentation(String targetPackage,
4368 @InstrumentationInfoFlags int flags);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004369
4370 /**
4371 * Retrieve an image from a package. This is a low-level API used by
4372 * the various package manager info structures (such as
4373 * {@link ComponentInfo} to implement retrieval of their associated
4374 * icon.
4375 *
4376 * @param packageName The name of the package that this icon is coming from.
kmccormick30498b42013-03-27 17:39:17 -07004377 * Cannot be null.
4378 * @param resid The resource identifier of the desired image. Cannot be 0.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004379 * @param appInfo Overall information about <var>packageName</var>. This
4380 * may be null, in which case the application information will be retrieved
4381 * for you if needed; if you already have this information around, it can
4382 * be much more efficient to supply it here.
4383 *
4384 * @return Returns a Drawable holding the requested image. Returns null if
4385 * an image could not be found for any reason.
4386 */
Tor Norbye7b9c9122013-05-30 16:48:33 -07004387 public abstract Drawable getDrawable(String packageName, @DrawableRes int resid,
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004388 ApplicationInfo appInfo);
4389
4390 /**
4391 * Retrieve the icon associated with an activity. Given the full name of
4392 * an activity, retrieves the information about it and calls
4393 * {@link ComponentInfo#loadIcon ComponentInfo.loadIcon()} to return its icon.
kmccormick30498b42013-03-27 17:39:17 -07004394 * If the activity cannot be found, NameNotFoundException is thrown.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004395 *
4396 * @param activityName Name of the activity whose icon is to be retrieved.
4397 *
4398 * @return Returns the image of the icon, or the default activity icon if
4399 * it could not be found. Does not return null.
4400 * @throws NameNotFoundException Thrown if the resources for the given
4401 * activity could not be loaded.
4402 *
4403 * @see #getActivityIcon(Intent)
4404 */
4405 public abstract Drawable getActivityIcon(ComponentName activityName)
4406 throws NameNotFoundException;
4407
4408 /**
4409 * Retrieve the icon associated with an Intent. If intent.getClassName() is
4410 * set, this simply returns the result of
4411 * getActivityIcon(intent.getClassName()). Otherwise it resolves the intent's
4412 * component and returns the icon associated with the resolved component.
kmccormick30498b42013-03-27 17:39:17 -07004413 * If intent.getClassName() cannot be found or the Intent cannot be resolved
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004414 * to a component, NameNotFoundException is thrown.
4415 *
4416 * @param intent The intent for which you would like to retrieve an icon.
4417 *
4418 * @return Returns the image of the icon, or the default activity icon if
4419 * it could not be found. Does not return null.
4420 * @throws NameNotFoundException Thrown if the resources for application
4421 * matching the given intent could not be loaded.
4422 *
4423 * @see #getActivityIcon(ComponentName)
4424 */
4425 public abstract Drawable getActivityIcon(Intent intent)
4426 throws NameNotFoundException;
4427
4428 /**
Jose Limaf78e3122014-03-06 12:13:15 -08004429 * Retrieve the banner associated with an activity. Given the full name of
4430 * an activity, retrieves the information about it and calls
4431 * {@link ComponentInfo#loadIcon ComponentInfo.loadIcon()} to return its
4432 * banner. If the activity cannot be found, NameNotFoundException is thrown.
4433 *
4434 * @param activityName Name of the activity whose banner is to be retrieved.
4435 * @return Returns the image of the banner, or null if the activity has no
4436 * banner specified.
4437 * @throws NameNotFoundException Thrown if the resources for the given
4438 * activity could not be loaded.
4439 * @see #getActivityBanner(Intent)
4440 */
4441 public abstract Drawable getActivityBanner(ComponentName activityName)
4442 throws NameNotFoundException;
4443
4444 /**
4445 * Retrieve the banner associated with an Intent. If intent.getClassName()
4446 * is set, this simply returns the result of
4447 * getActivityBanner(intent.getClassName()). Otherwise it resolves the
4448 * intent's component and returns the banner associated with the resolved
4449 * component. If intent.getClassName() cannot be found or the Intent cannot
4450 * be resolved to a component, NameNotFoundException is thrown.
4451 *
4452 * @param intent The intent for which you would like to retrieve a banner.
4453 * @return Returns the image of the banner, or null if the activity has no
4454 * banner specified.
4455 * @throws NameNotFoundException Thrown if the resources for application
4456 * matching the given intent could not be loaded.
4457 * @see #getActivityBanner(ComponentName)
4458 */
4459 public abstract Drawable getActivityBanner(Intent intent)
4460 throws NameNotFoundException;
4461
4462 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004463 * Return the generic icon for an activity that is used when no specific
4464 * icon is defined.
Adam Connors23cc04e2014-04-01 12:12:20 +01004465 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004466 * @return Drawable Image of the icon.
4467 */
4468 public abstract Drawable getDefaultActivityIcon();
4469
4470 /**
4471 * Retrieve the icon associated with an application. If it has not defined
4472 * an icon, the default app icon is returned. Does not return null.
4473 *
4474 * @param info Information about application being queried.
4475 *
4476 * @return Returns the image of the icon, or the default application icon
4477 * if it could not be found.
4478 *
4479 * @see #getApplicationIcon(String)
4480 */
4481 public abstract Drawable getApplicationIcon(ApplicationInfo info);
4482
4483 /**
4484 * Retrieve the icon associated with an application. Given the name of the
4485 * application's package, retrieves the information about it and calls
kmccormick30498b42013-03-27 17:39:17 -07004486 * getApplicationIcon() to return its icon. If the application cannot be
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004487 * found, NameNotFoundException is thrown.
4488 *
4489 * @param packageName Name of the package whose application icon is to be
4490 * retrieved.
4491 *
4492 * @return Returns the image of the icon, or the default application icon
4493 * if it could not be found. Does not return null.
4494 * @throws NameNotFoundException Thrown if the resources for the given
4495 * application could not be loaded.
4496 *
4497 * @see #getApplicationIcon(ApplicationInfo)
4498 */
4499 public abstract Drawable getApplicationIcon(String packageName)
4500 throws NameNotFoundException;
4501
4502 /**
Jose Limaf78e3122014-03-06 12:13:15 -08004503 * Retrieve the banner associated with an application.
4504 *
4505 * @param info Information about application being queried.
4506 * @return Returns the image of the banner or null if the application has no
4507 * banner specified.
4508 * @see #getApplicationBanner(String)
4509 */
4510 public abstract Drawable getApplicationBanner(ApplicationInfo info);
4511
4512 /**
4513 * Retrieve the banner associated with an application. Given the name of the
4514 * application's package, retrieves the information about it and calls
4515 * getApplicationIcon() to return its banner. If the application cannot be
4516 * found, NameNotFoundException is thrown.
4517 *
4518 * @param packageName Name of the package whose application banner is to be
4519 * retrieved.
4520 * @return Returns the image of the banner or null if the application has no
4521 * banner specified.
4522 * @throws NameNotFoundException Thrown if the resources for the given
4523 * application could not be loaded.
4524 * @see #getApplicationBanner(ApplicationInfo)
4525 */
4526 public abstract Drawable getApplicationBanner(String packageName)
4527 throws NameNotFoundException;
4528
4529 /**
4530 * Retrieve the logo associated with an activity. Given the full name of an
4531 * activity, retrieves the information about it and calls
4532 * {@link ComponentInfo#loadLogo ComponentInfo.loadLogo()} to return its
4533 * logo. If the activity cannot be found, NameNotFoundException is thrown.
Adam Powell81cd2e92010-04-21 16:35:18 -07004534 *
4535 * @param activityName Name of the activity whose logo is to be retrieved.
Jose Limaf78e3122014-03-06 12:13:15 -08004536 * @return Returns the image of the logo or null if the activity has no logo
4537 * specified.
Adam Powell81cd2e92010-04-21 16:35:18 -07004538 * @throws NameNotFoundException Thrown if the resources for the given
Jose Limaf78e3122014-03-06 12:13:15 -08004539 * activity could not be loaded.
Adam Powell81cd2e92010-04-21 16:35:18 -07004540 * @see #getActivityLogo(Intent)
4541 */
4542 public abstract Drawable getActivityLogo(ComponentName activityName)
4543 throws NameNotFoundException;
4544
4545 /**
4546 * Retrieve the logo associated with an Intent. If intent.getClassName() is
4547 * set, this simply returns the result of
4548 * getActivityLogo(intent.getClassName()). Otherwise it resolves the intent's
4549 * component and returns the logo associated with the resolved component.
kmccormick30498b42013-03-27 17:39:17 -07004550 * If intent.getClassName() cannot be found or the Intent cannot be resolved
Adam Powell81cd2e92010-04-21 16:35:18 -07004551 * to a component, NameNotFoundException is thrown.
4552 *
4553 * @param intent The intent for which you would like to retrieve a logo.
4554 *
4555 * @return Returns the image of the logo, or null if the activity has no
4556 * logo specified.
Amith Yamasani4b2e9342011-03-31 12:38:53 -07004557 *
Adam Powell81cd2e92010-04-21 16:35:18 -07004558 * @throws NameNotFoundException Thrown if the resources for application
4559 * matching the given intent could not be loaded.
4560 *
4561 * @see #getActivityLogo(ComponentName)
4562 */
4563 public abstract Drawable getActivityLogo(Intent intent)
4564 throws NameNotFoundException;
4565
4566 /**
4567 * Retrieve the logo associated with an application. If it has not specified
4568 * a logo, this method returns null.
4569 *
4570 * @param info Information about application being queried.
4571 *
4572 * @return Returns the image of the logo, or null if no logo is specified
4573 * by the application.
4574 *
4575 * @see #getApplicationLogo(String)
4576 */
4577 public abstract Drawable getApplicationLogo(ApplicationInfo info);
4578
4579 /**
4580 * Retrieve the logo associated with an application. Given the name of the
4581 * application's package, retrieves the information about it and calls
kmccormick30498b42013-03-27 17:39:17 -07004582 * getApplicationLogo() to return its logo. If the application cannot be
Adam Powell81cd2e92010-04-21 16:35:18 -07004583 * found, NameNotFoundException is thrown.
4584 *
4585 * @param packageName Name of the package whose application logo is to be
4586 * retrieved.
4587 *
4588 * @return Returns the image of the logo, or null if no application logo
4589 * has been specified.
Amith Yamasani4b2e9342011-03-31 12:38:53 -07004590 *
Adam Powell81cd2e92010-04-21 16:35:18 -07004591 * @throws NameNotFoundException Thrown if the resources for the given
4592 * application could not be loaded.
4593 *
4594 * @see #getApplicationLogo(ApplicationInfo)
4595 */
4596 public abstract Drawable getApplicationLogo(String packageName)
4597 throws NameNotFoundException;
4598
4599 /**
Tony Mak4dc008c2016-03-16 10:46:49 +00004600 * If the target user is a managed profile, then this returns a badged copy of the given icon
4601 * to be able to distinguish it from the original icon. For badging an arbitrary drawable use
Kenny Guydf77d712015-05-29 17:02:22 +01004602 * {@link #getUserBadgedDrawableForDensity(
Svetoslavc7d62f02014-09-04 15:39:54 -07004603 * android.graphics.drawable.Drawable, UserHandle, android.graphics.Rect, int)}.
4604 * <p>
4605 * If the original drawable is a BitmapDrawable and the backing bitmap is
4606 * mutable as per {@link android.graphics.Bitmap#isMutable()}, the badging
4607 * is performed in place and the original drawable is returned.
4608 * </p>
4609 *
4610 * @param icon The icon to badge.
4611 * @param user The target user.
4612 * @return A drawable that combines the original icon and a badge as
4613 * determined by the system.
4614 */
4615 public abstract Drawable getUserBadgedIcon(Drawable icon, UserHandle user);
4616
4617 /**
4618 * If the target user is a managed profile of the calling user or the caller
4619 * is itself a managed profile, then this returns a badged copy of the given
4620 * drawable allowing the user to distinguish it from the original drawable.
4621 * The caller can specify the location in the bounds of the drawable to be
4622 * badged where the badge should be applied as well as the density of the
4623 * badge to be used.
4624 * <p>
4625 * If the original drawable is a BitmapDrawable and the backing bitmap is
Vadim Tryshev66ae66a2016-02-18 15:41:21 -08004626 * mutable as per {@link android.graphics.Bitmap#isMutable()}, the badging
Svetoslavc7d62f02014-09-04 15:39:54 -07004627 * is performed in place and the original drawable is returned.
4628 * </p>
4629 *
4630 * @param drawable The drawable to badge.
4631 * @param user The target user.
4632 * @param badgeLocation Where in the bounds of the badged drawable to place
Vadim Tryshev66ae66a2016-02-18 15:41:21 -08004633 * the badge. If it's {@code null}, the badge is applied on top of the entire
Svetoslavc7d62f02014-09-04 15:39:54 -07004634 * drawable being badged.
4635 * @param badgeDensity The optional desired density for the badge as per
Vadim Tryshev66ae66a2016-02-18 15:41:21 -08004636 * {@link android.util.DisplayMetrics#densityDpi}. If it's not positive,
Svetoslavc7d62f02014-09-04 15:39:54 -07004637 * the density of the display is used.
4638 * @return A drawable that combines the original drawable and a badge as
4639 * determined by the system.
4640 */
4641 public abstract Drawable getUserBadgedDrawableForDensity(Drawable drawable,
4642 UserHandle user, Rect badgeLocation, int badgeDensity);
4643
4644 /**
4645 * If the target user is a managed profile of the calling user or the caller
4646 * is itself a managed profile, then this returns a drawable to use as a small
4647 * icon to include in a view to distinguish it from the original icon.
4648 *
4649 * @param user The target user.
4650 * @param density The optional desired density for the badge as per
4651 * {@link android.util.DisplayMetrics#densityDpi}. If not provided
4652 * the density of the current display is used.
4653 * @return the drawable or null if no drawable is required.
4654 * @hide
4655 */
4656 public abstract Drawable getUserBadgeForDensity(UserHandle user, int density);
4657
4658 /**
4659 * If the target user is a managed profile of the calling user or the caller
Selim Cineke6ff9462016-01-15 15:07:06 -08004660 * is itself a managed profile, then this returns a drawable to use as a small
4661 * icon to include in a view to distinguish it from the original icon. This version
4662 * doesn't have background protection and should be used over a light background instead of
4663 * a badge.
4664 *
4665 * @param user The target user.
4666 * @param density The optional desired density for the badge as per
4667 * {@link android.util.DisplayMetrics#densityDpi}. If not provided
4668 * the density of the current display is used.
4669 * @return the drawable or null if no drawable is required.
4670 * @hide
4671 */
4672 public abstract Drawable getUserBadgeForDensityNoBackground(UserHandle user, int density);
4673
4674 /**
4675 * If the target user is a managed profile of the calling user or the caller
Svetoslavc7d62f02014-09-04 15:39:54 -07004676 * is itself a managed profile, then this returns a copy of the label with
4677 * badging for accessibility services like talkback. E.g. passing in "Email"
4678 * and it might return "Work Email" for Email in the work profile.
4679 *
4680 * @param label The label to change.
4681 * @param user The target user.
4682 * @return A label that combines the original label and a badge as
4683 * determined by the system.
4684 */
4685 public abstract CharSequence getUserBadgedLabel(CharSequence label, UserHandle user);
4686
4687 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004688 * Retrieve text from a package. This is a low-level API used by
4689 * the various package manager info structures (such as
4690 * {@link ComponentInfo} to implement retrieval of their associated
4691 * labels and other text.
4692 *
4693 * @param packageName The name of the package that this text is coming from.
kmccormick30498b42013-03-27 17:39:17 -07004694 * Cannot be null.
4695 * @param resid The resource identifier of the desired text. Cannot be 0.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004696 * @param appInfo Overall information about <var>packageName</var>. This
4697 * may be null, in which case the application information will be retrieved
4698 * for you if needed; if you already have this information around, it can
4699 * be much more efficient to supply it here.
4700 *
4701 * @return Returns a CharSequence holding the requested text. Returns null
4702 * if the text could not be found for any reason.
4703 */
Tor Norbye7b9c9122013-05-30 16:48:33 -07004704 public abstract CharSequence getText(String packageName, @StringRes int resid,
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004705 ApplicationInfo appInfo);
4706
4707 /**
4708 * Retrieve an XML file from a package. This is a low-level API used to
4709 * retrieve XML meta data.
4710 *
4711 * @param packageName The name of the package that this xml is coming from.
kmccormick30498b42013-03-27 17:39:17 -07004712 * Cannot be null.
4713 * @param resid The resource identifier of the desired xml. Cannot be 0.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004714 * @param appInfo Overall information about <var>packageName</var>. This
4715 * may be null, in which case the application information will be retrieved
4716 * for you if needed; if you already have this information around, it can
4717 * be much more efficient to supply it here.
4718 *
4719 * @return Returns an XmlPullParser allowing you to parse out the XML
4720 * data. Returns null if the xml resource could not be found for any
4721 * reason.
4722 */
Tor Norbye7b9c9122013-05-30 16:48:33 -07004723 public abstract XmlResourceParser getXml(String packageName, @XmlRes int resid,
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004724 ApplicationInfo appInfo);
4725
4726 /**
4727 * Return the label to use for this application.
4728 *
4729 * @return Returns the label associated with this application, or null if
4730 * it could not be found for any reason.
kmccormick30498b42013-03-27 17:39:17 -07004731 * @param info The application to get the label of.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004732 */
4733 public abstract CharSequence getApplicationLabel(ApplicationInfo info);
4734
4735 /**
4736 * Retrieve the resources associated with an activity. Given the full
4737 * name of an activity, retrieves the information about it and calls
4738 * getResources() to return its application's resources. If the activity
kmccormick30498b42013-03-27 17:39:17 -07004739 * cannot be found, NameNotFoundException is thrown.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004740 *
4741 * @param activityName Name of the activity whose resources are to be
4742 * retrieved.
4743 *
4744 * @return Returns the application's Resources.
4745 * @throws NameNotFoundException Thrown if the resources for the given
4746 * application could not be loaded.
4747 *
4748 * @see #getResourcesForApplication(ApplicationInfo)
4749 */
4750 public abstract Resources getResourcesForActivity(ComponentName activityName)
4751 throws NameNotFoundException;
4752
4753 /**
4754 * Retrieve the resources for an application. Throws NameNotFoundException
4755 * if the package is no longer installed.
4756 *
4757 * @param app Information about the desired application.
4758 *
4759 * @return Returns the application's Resources.
4760 * @throws NameNotFoundException Thrown if the resources for the given
4761 * application could not be loaded (most likely because it was uninstalled).
4762 */
4763 public abstract Resources getResourcesForApplication(ApplicationInfo app)
4764 throws NameNotFoundException;
4765
4766 /**
4767 * Retrieve the resources associated with an application. Given the full
4768 * package name of an application, retrieves the information about it and
4769 * calls getResources() to return its application's resources. If the
kmccormick30498b42013-03-27 17:39:17 -07004770 * appPackageName cannot be found, NameNotFoundException is thrown.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004771 *
4772 * @param appPackageName Package name of the application whose resources
4773 * are to be retrieved.
4774 *
4775 * @return Returns the application's Resources.
4776 * @throws NameNotFoundException Thrown if the resources for the given
4777 * application could not be loaded.
4778 *
4779 * @see #getResourcesForApplication(ApplicationInfo)
4780 */
4781 public abstract Resources getResourcesForApplication(String appPackageName)
4782 throws NameNotFoundException;
4783
Amith Yamasani98edc952012-09-25 14:09:27 -07004784 /** @hide */
Jeff Sharkey8588bc12016-01-06 16:47:42 -07004785 public abstract Resources getResourcesForApplicationAsUser(String appPackageName,
4786 @UserIdInt int userId) throws NameNotFoundException;
Amith Yamasani98edc952012-09-25 14:09:27 -07004787
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004788 /**
Jeff Sharkey4347f812017-04-21 12:08:39 -06004789 * Retrieve overall information about an application package defined in a
4790 * package archive file
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004791 *
4792 * @param archiveFilePath The path to the archive file
Jeff Sharkey4347f812017-04-21 12:08:39 -06004793 * @param flags Additional option flags to modify the data returned.
4794 * @return A PackageInfo object containing information about the package
4795 * archive. If the package could not be parsed, returns null.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004796 */
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07004797 public PackageInfo getPackageArchiveInfo(String archiveFilePath, @PackageInfoFlags int flags) {
Jeff Sharkey275e0852014-06-17 18:18:49 -07004798 final PackageParser parser = new PackageParser();
Dianne Hackborncd154e92017-02-28 17:37:35 -08004799 parser.setCallback(new PackageParser.CallbackImpl(this));
Jeff Sharkey275e0852014-06-17 18:18:49 -07004800 final File apkFile = new File(archiveFilePath);
Jeff Sharkeyc4858a22014-06-16 10:51:20 -07004801 try {
Jeff Sharkey8a372a02016-03-16 16:25:45 -06004802 if ((flags & (MATCH_DIRECT_BOOT_UNAWARE | MATCH_DIRECT_BOOT_AWARE)) != 0) {
Jeff Sharkeyc3132512016-01-12 14:06:58 -07004803 // Caller expressed an explicit opinion about what encryption
4804 // aware/unaware components they want to see, so fall through and
4805 // give them what they want
4806 } else {
4807 // Caller expressed no opinion, so match everything
Jeff Sharkey8a372a02016-03-16 16:25:45 -06004808 flags |= MATCH_DIRECT_BOOT_AWARE | MATCH_DIRECT_BOOT_UNAWARE;
Jeff Sharkeyc3132512016-01-12 14:06:58 -07004809 }
4810
Jeff Sharkey275e0852014-06-17 18:18:49 -07004811 PackageParser.Package pkg = parser.parseMonolithicPackage(apkFile, 0);
Jeff Sharkeyc4858a22014-06-16 10:51:20 -07004812 if ((flags & GET_SIGNATURES) != 0) {
Victor Hsieh5f761242018-01-20 10:30:12 -08004813 PackageParser.collectCertificates(pkg, false /* skipVerify */);
Jeff Sharkeyc4858a22014-06-16 10:51:20 -07004814 }
4815 PackageUserState state = new PackageUserState();
4816 return PackageParser.generatePackageInfo(pkg, null, flags, 0, 0, null, state);
4817 } catch (PackageParserException e) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004818 return null;
4819 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004820 }
4821
4822 /**
Dianne Hackborn7767eac2012-08-23 18:25:40 -07004823 * If there is already an application with the given package name installed
4824 * on the system for other users, also install it for the calling user.
4825 * @hide
4826 */
Sunny Goyal07f41fb2017-08-09 02:56:34 -07004827 @SystemApi
Nicolas Prevot9a80e532015-09-23 15:49:28 +01004828 public abstract int installExistingPackage(String packageName) throws NameNotFoundException;
4829
4830 /**
4831 * If there is already an application with the given package name installed
Sunny Goyala31a74b2017-05-11 15:59:19 -07004832 * on the system for other users, also install it for the calling user.
4833 * @hide
4834 */
Sunny Goyal07f41fb2017-08-09 02:56:34 -07004835 @SystemApi
Sunny Goyala31a74b2017-05-11 15:59:19 -07004836 public abstract int installExistingPackage(String packageName, @InstallReason int installReason)
4837 throws NameNotFoundException;
4838
4839 /**
4840 * If there is already an application with the given package name installed
Nicolas Prevot9a80e532015-09-23 15:49:28 +01004841 * on the system for other users, also install it for the specified user.
4842 * @hide
4843 */
Sanry Huangafef5da2018-06-06 17:34:34 +00004844 @RequiresPermission(anyOf = {
Nicolas Prevot9a80e532015-09-23 15:49:28 +01004845 Manifest.permission.INSTALL_PACKAGES,
4846 Manifest.permission.INTERACT_ACROSS_USERS_FULL})
Jeff Sharkey8588bc12016-01-06 16:47:42 -07004847 public abstract int installExistingPackageAsUser(String packageName, @UserIdInt int userId)
Dianne Hackborn7767eac2012-08-23 18:25:40 -07004848 throws NameNotFoundException;
4849
4850 /**
Kenny Root5ab21572011-07-27 11:11:19 -07004851 * Allows a package listening to the
4852 * {@link Intent#ACTION_PACKAGE_NEEDS_VERIFICATION package verification
Kenny Root3a9b5fb2011-09-20 14:15:38 -07004853 * broadcast} to respond to the package manager. The response must include
4854 * the {@code verificationCode} which is one of
4855 * {@link PackageManager#VERIFICATION_ALLOW} or
4856 * {@link PackageManager#VERIFICATION_REJECT}.
Kenny Root5ab21572011-07-27 11:11:19 -07004857 *
4858 * @param id pending package identifier as passed via the
kmccormick30498b42013-03-27 17:39:17 -07004859 * {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra.
Kenny Root3a9b5fb2011-09-20 14:15:38 -07004860 * @param verificationCode either {@link PackageManager#VERIFICATION_ALLOW}
4861 * or {@link PackageManager#VERIFICATION_REJECT}.
rich cannings7e671512012-08-27 14:44:16 -07004862 * @throws SecurityException if the caller does not have the
Dianne Hackborn8832c182012-09-17 17:20:24 -07004863 * PACKAGE_VERIFICATION_AGENT permission.
Kenny Root5ab21572011-07-27 11:11:19 -07004864 */
Kenny Root3a9b5fb2011-09-20 14:15:38 -07004865 public abstract void verifyPendingInstall(int id, int verificationCode);
Kenny Root5ab21572011-07-27 11:11:19 -07004866
4867 /**
rich canningsd9ef3e52012-08-22 14:28:05 -07004868 * Allows a package listening to the
4869 * {@link Intent#ACTION_PACKAGE_NEEDS_VERIFICATION package verification
4870 * broadcast} to extend the default timeout for a response and declare what
4871 * action to perform after the timeout occurs. The response must include
4872 * the {@code verificationCodeAtTimeout} which is one of
4873 * {@link PackageManager#VERIFICATION_ALLOW} or
4874 * {@link PackageManager#VERIFICATION_REJECT}.
4875 *
4876 * This method may only be called once per package id. Additional calls
4877 * will have no effect.
4878 *
4879 * @param id pending package identifier as passed via the
kmccormick30498b42013-03-27 17:39:17 -07004880 * {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra.
rich canningsd9ef3e52012-08-22 14:28:05 -07004881 * @param verificationCodeAtTimeout either
4882 * {@link PackageManager#VERIFICATION_ALLOW} or
rich canningsd1b5cfc2012-08-29 14:49:51 -07004883 * {@link PackageManager#VERIFICATION_REJECT}. If
4884 * {@code verificationCodeAtTimeout} is neither
4885 * {@link PackageManager#VERIFICATION_ALLOW} or
4886 * {@link PackageManager#VERIFICATION_REJECT}, then
4887 * {@code verificationCodeAtTimeout} will default to
rich canningsd9ef3e52012-08-22 14:28:05 -07004888 * {@link PackageManager#VERIFICATION_REJECT}.
4889 * @param millisecondsToDelay the amount of time requested for the timeout.
4890 * Must be positive and less than
rich canningsd1b5cfc2012-08-29 14:49:51 -07004891 * {@link PackageManager#MAXIMUM_VERIFICATION_TIMEOUT}. If
4892 * {@code millisecondsToDelay} is out of bounds,
4893 * {@code millisecondsToDelay} will be set to the closest in
4894 * bounds value; namely, 0 or
rich canningsd9ef3e52012-08-22 14:28:05 -07004895 * {@link PackageManager#MAXIMUM_VERIFICATION_TIMEOUT}.
rich cannings7e671512012-08-27 14:44:16 -07004896 * @throws SecurityException if the caller does not have the
Dianne Hackborn8832c182012-09-17 17:20:24 -07004897 * PACKAGE_VERIFICATION_AGENT permission.
rich canningsd9ef3e52012-08-22 14:28:05 -07004898 */
4899 public abstract void extendVerificationTimeout(int id,
4900 int verificationCodeAtTimeout, long millisecondsToDelay);
4901
4902 /**
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -08004903 * Allows a package listening to the
Todd Kennedydfa93ab2016-03-03 15:24:33 -08004904 * {@link Intent#ACTION_INTENT_FILTER_NEEDS_VERIFICATION} intent filter verification
4905 * broadcast to respond to the package manager. The response must include
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -08004906 * the {@code verificationCode} which is one of
4907 * {@link PackageManager#INTENT_FILTER_VERIFICATION_SUCCESS} or
4908 * {@link PackageManager#INTENT_FILTER_VERIFICATION_FAILURE}.
4909 *
4910 * @param verificationId pending package identifier as passed via the
4911 * {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra.
4912 * @param verificationCode either {@link PackageManager#INTENT_FILTER_VERIFICATION_SUCCESS}
4913 * or {@link PackageManager#INTENT_FILTER_VERIFICATION_FAILURE}.
Todd Kennedydfa93ab2016-03-03 15:24:33 -08004914 * @param failedDomains a list of failed domains if the verificationCode is
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -08004915 * {@link PackageManager#INTENT_FILTER_VERIFICATION_FAILURE}, otherwise null;
4916 * @throws SecurityException if the caller does not have the
4917 * INTENT_FILTER_VERIFICATION_AGENT permission.
4918 *
4919 * @hide
4920 */
Fabrice Di Meglioef741da2015-05-12 16:31:38 -07004921 @SystemApi
Jeff Sharkeyd86b8fe2017-06-02 17:36:26 -06004922 @RequiresPermission(android.Manifest.permission.INTENT_FILTER_VERIFICATION_AGENT)
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -08004923 public abstract void verifyIntentFilter(int verificationId, int verificationCode,
Todd Kennedydfa93ab2016-03-03 15:24:33 -08004924 List<String> failedDomains);
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -08004925
4926 /**
4927 * Get the status of a Domain Verification Result for an IntentFilter. This is
4928 * related to the {@link android.content.IntentFilter#setAutoVerify(boolean)} and
4929 * {@link android.content.IntentFilter#getAutoVerify()}
4930 *
4931 * This is used by the ResolverActivity to change the status depending on what the User select
4932 * in the Disambiguation Dialog and also used by the Settings App for changing the default App
4933 * for a domain.
4934 *
4935 * @param packageName The package name of the Activity associated with the IntentFilter.
4936 * @param userId The user id.
4937 *
4938 * @return The status to set to. This can be
4939 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK} or
4940 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS} or
4941 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER} or
4942 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_UNDEFINED}
4943 *
4944 * @hide
4945 */
Jeff Schumacher6fd90ed2017-01-20 13:58:34 -08004946 @SystemApi
Todd Kennedydbaef6d2017-07-24 11:28:00 -07004947 @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS_FULL)
Jeff Sharkey8588bc12016-01-06 16:47:42 -07004948 public abstract int getIntentVerificationStatusAsUser(String packageName, @UserIdInt int userId);
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -08004949
4950 /**
4951 * Allow to change the status of a Intent Verification status for all IntentFilter of an App.
4952 * This is related to the {@link android.content.IntentFilter#setAutoVerify(boolean)} and
4953 * {@link android.content.IntentFilter#getAutoVerify()}
4954 *
4955 * This is used by the ResolverActivity to change the status depending on what the User select
4956 * in the Disambiguation Dialog and also used by the Settings App for changing the default App
4957 * for a domain.
4958 *
4959 * @param packageName The package name of the Activity associated with the IntentFilter.
4960 * @param status The status to set to. This can be
4961 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK} or
4962 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS} or
4963 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER}
4964 * @param userId The user id.
4965 *
4966 * @return true if the status has been set. False otherwise.
4967 *
4968 * @hide
4969 */
Jeff Schumacher6fd90ed2017-01-20 13:58:34 -08004970 @SystemApi
Jeff Sharkeyd86b8fe2017-06-02 17:36:26 -06004971 @RequiresPermission(android.Manifest.permission.SET_PREFERRED_APPLICATIONS)
Jeff Sharkeye06b4d12016-01-06 14:51:50 -07004972 public abstract boolean updateIntentVerificationStatusAsUser(String packageName, int status,
Jeff Sharkey8588bc12016-01-06 16:47:42 -07004973 @UserIdInt int userId);
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -08004974
4975 /**
4976 * Get the list of IntentFilterVerificationInfo for a specific package and User.
4977 *
4978 * @param packageName the package name. When this parameter is set to a non null value,
4979 * the results will be filtered by the package name provided.
4980 * Otherwise, there will be no filtering and it will return a list
Fabrice Di Meglio07885952015-04-06 19:41:28 -07004981 * corresponding for all packages
4982 *
4983 * @return a list of IntentFilterVerificationInfo for a specific package.
4984 *
4985 * @hide
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -08004986 */
Jeff Schumacher6fd90ed2017-01-20 13:58:34 -08004987 @SystemApi
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -08004988 public abstract List<IntentFilterVerificationInfo> getIntentFilterVerifications(
4989 String packageName);
4990
4991 /**
Fabrice Di Meglio07885952015-04-06 19:41:28 -07004992 * Get the list of IntentFilter for a specific package.
4993 *
4994 * @param packageName the package name. This parameter is set to a non null value,
4995 * the list will contain all the IntentFilter for that package.
4996 * Otherwise, the list will be empty.
4997 *
4998 * @return a list of IntentFilter for a specific package.
4999 *
5000 * @hide
5001 */
Jeff Schumacher6fd90ed2017-01-20 13:58:34 -08005002 @SystemApi
Fabrice Di Meglio07885952015-04-06 19:41:28 -07005003 public abstract List<IntentFilter> getAllIntentFilters(String packageName);
5004
5005 /**
Fabrice Di Meglio62271722015-04-10 17:24:02 -07005006 * Get the default Browser package name for a specific user.
5007 *
5008 * @param userId The user id.
5009 *
5010 * @return the package name of the default Browser for the specified user. If the user id passed
5011 * is -1 (all users) it will return a null value.
5012 *
5013 * @hide
5014 */
Jeff Sharkeya73b8fd2016-01-06 17:02:08 -07005015 @TestApi
Jeff Schumacher6fd90ed2017-01-20 13:58:34 -08005016 @SystemApi
Todd Kennedydbaef6d2017-07-24 11:28:00 -07005017 @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS_FULL)
Jeff Sharkey8588bc12016-01-06 16:47:42 -07005018 public abstract String getDefaultBrowserPackageNameAsUser(@UserIdInt int userId);
Fabrice Di Meglio62271722015-04-10 17:24:02 -07005019
5020 /**
5021 * Set the default Browser package name for a specific user.
5022 *
5023 * @param packageName The package name of the default Browser.
5024 * @param userId The user id.
5025 *
5026 * @return true if the default Browser for the specified user has been set,
5027 * otherwise return false. If the user id passed is -1 (all users) this call will not
5028 * do anything and just return false.
5029 *
5030 * @hide
5031 */
Jeff Schumacher6fd90ed2017-01-20 13:58:34 -08005032 @SystemApi
Todd Kennedydbaef6d2017-07-24 11:28:00 -07005033 @RequiresPermission(allOf = {
5034 Manifest.permission.SET_PREFERRED_APPLICATIONS,
5035 Manifest.permission.INTERACT_ACROSS_USERS_FULL})
Jeff Sharkey8588bc12016-01-06 16:47:42 -07005036 public abstract boolean setDefaultBrowserPackageNameAsUser(String packageName,
5037 @UserIdInt int userId);
Fabrice Di Meglio62271722015-04-10 17:24:02 -07005038
5039 /**
Dianne Hackborn880119b2010-11-18 22:26:40 -08005040 * Change the installer associated with a given package. There are limitations
5041 * on how the installer package can be changed; in particular:
5042 * <ul>
5043 * <li> A SecurityException will be thrown if <var>installerPackageName</var>
5044 * is not signed with the same certificate as the calling application.
5045 * <li> A SecurityException will be thrown if <var>targetPackage</var> already
5046 * has an installer package, and that installer package is not signed with
5047 * the same certificate as the calling application.
5048 * </ul>
5049 *
5050 * @param targetPackage The installed package whose installer will be changed.
5051 * @param installerPackageName The package name of the new installer. May be
5052 * null to clear the association.
5053 */
5054 public abstract void setInstallerPackageName(String targetPackage,
5055 String installerPackageName);
5056
Todd Kennedyab532892017-03-08 14:19:49 -08005057 /** @hide */
5058 @SystemApi
5059 @RequiresPermission(Manifest.permission.INSTALL_PACKAGES)
5060 public abstract void setUpdateAvailable(String packageName, boolean updateAvaialble);
5061
Dianne Hackborn880119b2010-11-18 22:26:40 -08005062 /**
Jeff Sharkey5aa86932016-01-08 19:07:49 -07005063 * Attempts to delete a package. Since this may take a little while, the
5064 * result will be posted back to the given observer. A deletion will fail if
5065 * the calling context lacks the
5066 * {@link android.Manifest.permission#DELETE_PACKAGES} permission, if the
5067 * named package cannot be found, or if the named package is a system
5068 * package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005069 *
5070 * @param packageName The name of the package to delete
Jeff Sharkey5aa86932016-01-08 19:07:49 -07005071 * @param observer An observer callback to get notified when the package
5072 * deletion is complete.
5073 * {@link android.content.pm.IPackageDeleteObserver#packageDeleted}
5074 * will be called when that happens. observer may be null to
5075 * indicate that no callback is desired.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005076 * @hide
5077 */
Svet Ganov67882122016-12-11 16:36:34 -08005078 @RequiresPermission(Manifest.permission.DELETE_PACKAGES)
Jeff Sharkey5aa86932016-01-08 19:07:49 -07005079 public abstract void deletePackage(String packageName, IPackageDeleteObserver observer,
5080 @DeleteFlags int flags);
Jacek Surazski65e13172009-04-28 15:26:38 +02005081
5082 /**
Jeff Sharkey5aa86932016-01-08 19:07:49 -07005083 * Attempts to delete a package. Since this may take a little while, the
5084 * result will be posted back to the given observer. A deletion will fail if
5085 * the named package cannot be found, or if the named package is a system
5086 * package.
Nicolas Prevot9a80e532015-09-23 15:49:28 +01005087 *
5088 * @param packageName The name of the package to delete
Jeff Sharkey5aa86932016-01-08 19:07:49 -07005089 * @param observer An observer callback to get notified when the package
5090 * deletion is complete.
5091 * {@link android.content.pm.IPackageDeleteObserver#packageDeleted}
5092 * will be called when that happens. observer may be null to
5093 * indicate that no callback is desired.
Nicolas Prevot9a80e532015-09-23 15:49:28 +01005094 * @param userId The user Id
Nicolas Prevot9a80e532015-09-23 15:49:28 +01005095 * @hide
5096 */
Svet Ganov67882122016-12-11 16:36:34 -08005097 @RequiresPermission(anyOf = {
Nicolas Prevot9a80e532015-09-23 15:49:28 +01005098 Manifest.permission.DELETE_PACKAGES,
5099 Manifest.permission.INTERACT_ACROSS_USERS_FULL})
Svet Ganov67882122016-12-11 16:36:34 -08005100 public abstract void deletePackageAsUser(@NonNull String packageName,
5101 IPackageDeleteObserver observer, @DeleteFlags int flags, @UserIdInt int userId);
Nicolas Prevot9a80e532015-09-23 15:49:28 +01005102
5103 /**
Jacek Surazski65e13172009-04-28 15:26:38 +02005104 * Retrieve the package name of the application that installed a package. This identifies
5105 * which market the package came from.
Amith Yamasani4b2e9342011-03-31 12:38:53 -07005106 *
Jacek Surazski65e13172009-04-28 15:26:38 +02005107 * @param packageName The name of the package to query
Todd Kennedy9db65632018-02-13 11:12:35 -08005108 * @throws IllegalArgumentException if the given package name is not installed
Jacek Surazski65e13172009-04-28 15:26:38 +02005109 */
5110 public abstract String getInstallerPackageName(String packageName);
Amith Yamasani4b2e9342011-03-31 12:38:53 -07005111
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005112 /**
5113 * Attempts to clear the user data directory of an application.
5114 * Since this may take a little while, the result will
5115 * be posted back to the given observer. A deletion will fail if the
5116 * named package cannot be found, or if the named package is a "system package".
5117 *
5118 * @param packageName The name of the package
5119 * @param observer An observer callback to get notified when the operation is finished
5120 * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)}
5121 * will be called when that happens. observer may be null to indicate that
5122 * no callback is desired.
5123 *
5124 * @hide
5125 */
5126 public abstract void clearApplicationUserData(String packageName,
5127 IPackageDataObserver observer);
5128 /**
5129 * Attempts to delete the cache files associated with an application.
5130 * Since this may take a little while, the result will
5131 * be posted back to the given observer. A deletion will fail if the calling context
5132 * lacks the {@link android.Manifest.permission#DELETE_CACHE_FILES} permission, if the
5133 * named package cannot be found, or if the named package is a "system package".
5134 *
5135 * @param packageName The name of the package to delete
5136 * @param observer An observer callback to get notified when the cache file deletion
5137 * is complete.
5138 * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)}
5139 * will be called when that happens. observer may be null to indicate that
5140 * no callback is desired.
5141 *
5142 * @hide
5143 */
5144 public abstract void deleteApplicationCacheFiles(String packageName,
5145 IPackageDataObserver observer);
5146
5147 /**
Suprabh Shukla78c9eb82016-04-12 15:51:35 -07005148 * Attempts to delete the cache files associated with an application for a given user. Since
5149 * this may take a little while, the result will be posted back to the given observer. A
5150 * deletion will fail if the calling context lacks the
5151 * {@link android.Manifest.permission#DELETE_CACHE_FILES} permission, if the named package
5152 * cannot be found, or if the named package is a "system package". If {@code userId} does not
5153 * belong to the calling user, the caller must have
5154 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} permission.
5155 *
5156 * @param packageName The name of the package to delete
5157 * @param userId the user for which the cache files needs to be deleted
5158 * @param observer An observer callback to get notified when the cache file deletion is
5159 * complete.
5160 * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)}
5161 * will be called when that happens. observer may be null to indicate that no
5162 * callback is desired.
5163 * @hide
5164 */
5165 public abstract void deleteApplicationCacheFilesAsUser(String packageName, int userId,
5166 IPackageDataObserver observer);
5167
5168 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005169 * Free storage by deleting LRU sorted list of cache files across
5170 * all applications. If the currently available free storage
5171 * on the device is greater than or equal to the requested
5172 * free storage, no cache files are cleared. If the currently
5173 * available storage on the device is less than the requested
5174 * free storage, some or all of the cache files across
5175 * all applications are deleted (based on last accessed time)
5176 * to increase the free storage space on the device to
5177 * the requested value. There is no guarantee that clearing all
5178 * the cache files from all applications will clear up
5179 * enough storage to achieve the desired value.
5180 * @param freeStorageSize The number of bytes of storage to be
5181 * freed by the system. Say if freeStorageSize is XX,
5182 * and the current free storage is YY,
5183 * if XX is less than YY, just return. if not free XX-YY number
5184 * of bytes if possible.
5185 * @param observer call back used to notify when
5186 * the operation is completed
Amith Yamasani4b2e9342011-03-31 12:38:53 -07005187 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005188 * @hide
5189 */
Jeff Sharkey529f91f2015-04-18 20:23:13 -07005190 public void freeStorageAndNotify(long freeStorageSize, IPackageDataObserver observer) {
5191 freeStorageAndNotify(null, freeStorageSize, observer);
5192 }
5193
5194 /** {@hide} */
5195 public abstract void freeStorageAndNotify(String volumeUuid, long freeStorageSize,
5196 IPackageDataObserver observer);
Suchi Amalapurapu1ccac752009-06-12 10:09:58 -07005197
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005198 /**
5199 * Free storage by deleting LRU sorted list of cache files across
5200 * all applications. If the currently available free storage
5201 * on the device is greater than or equal to the requested
5202 * free storage, no cache files are cleared. If the currently
5203 * available storage on the device is less than the requested
5204 * free storage, some or all of the cache files across
5205 * all applications are deleted (based on last accessed time)
5206 * to increase the free storage space on the device to
5207 * the requested value. There is no guarantee that clearing all
5208 * the cache files from all applications will clear up
5209 * enough storage to achieve the desired value.
5210 * @param freeStorageSize The number of bytes of storage to be
5211 * freed by the system. Say if freeStorageSize is XX,
5212 * and the current free storage is YY,
5213 * if XX is less than YY, just return. if not free XX-YY number
5214 * of bytes if possible.
Suchi Amalapurapu1ccac752009-06-12 10:09:58 -07005215 * @param pi IntentSender call back used to
5216 * notify when the operation is completed.May be null
5217 * to indicate that no call back is desired.
Amith Yamasani4b2e9342011-03-31 12:38:53 -07005218 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005219 * @hide
5220 */
Jeff Sharkey529f91f2015-04-18 20:23:13 -07005221 public void freeStorage(long freeStorageSize, IntentSender pi) {
5222 freeStorage(null, freeStorageSize, pi);
5223 }
5224
5225 /** {@hide} */
5226 public abstract void freeStorage(String volumeUuid, long freeStorageSize, IntentSender pi);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005227
5228 /**
5229 * Retrieve the size information for a package.
5230 * Since this may take a little while, the result will
5231 * be posted back to the given observer. The calling context
5232 * should have the {@link android.Manifest.permission#GET_PACKAGE_SIZE} permission.
5233 *
5234 * @param packageName The name of the package whose size information is to be retrieved
Jeff Sharkeye06b4d12016-01-06 14:51:50 -07005235 * @param userId The user whose size information should be retrieved.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005236 * @param observer An observer callback to get notified when the operation
5237 * is complete.
5238 * {@link android.content.pm.IPackageStatsObserver#onGetStatsCompleted(PackageStats, boolean)}
5239 * The observer's callback is invoked with a PackageStats object(containing the
5240 * code, data and cache sizes of the package) and a boolean value representing
5241 * the status of the operation. observer may be null to indicate that
5242 * no callback is desired.
5243 *
Jeff Sharkey60f95aa2017-03-08 13:57:15 -07005244 * @deprecated use {@link StorageStatsManager} instead.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005245 * @hide
5246 */
Jeff Sharkey60f95aa2017-03-08 13:57:15 -07005247 @Deprecated
Jeff Sharkey8588bc12016-01-06 16:47:42 -07005248 public abstract void getPackageSizeInfoAsUser(String packageName, @UserIdInt int userId,
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005249 IPackageStatsObserver observer);
5250
5251 /**
Jeff Sharkeye06b4d12016-01-06 14:51:50 -07005252 * Like {@link #getPackageSizeInfoAsUser(String, int, IPackageStatsObserver)}, but
Dianne Hackborn0c380492012-08-20 17:23:30 -07005253 * returns the size for the calling user.
5254 *
Jeff Sharkey60f95aa2017-03-08 13:57:15 -07005255 * @deprecated use {@link StorageStatsManager} instead.
Dianne Hackborn0c380492012-08-20 17:23:30 -07005256 * @hide
5257 */
Jeff Sharkey60f95aa2017-03-08 13:57:15 -07005258 @Deprecated
Dianne Hackborn0c380492012-08-20 17:23:30 -07005259 public void getPackageSizeInfo(String packageName, IPackageStatsObserver observer) {
Jeff Sharkeyad357d12018-02-02 13:25:31 -07005260 getPackageSizeInfoAsUser(packageName, getUserId(), observer);
Dianne Hackborn0c380492012-08-20 17:23:30 -07005261 }
5262
5263 /**
Dianne Hackborna7ca0e52009-12-01 14:31:55 -08005264 * @deprecated This function no longer does anything; it was an old
kmccormickac66b852013-03-28 15:17:15 -07005265 * approach to managing preferred activities, which has been superseded
5266 * by (and conflicts with) the modern activity-based preferences.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005267 */
Dianne Hackborna7ca0e52009-12-01 14:31:55 -08005268 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005269 public abstract void addPackageToPreferred(String packageName);
5270
5271 /**
Dianne Hackborna7ca0e52009-12-01 14:31:55 -08005272 * @deprecated This function no longer does anything; it was an old
kmccormickac66b852013-03-28 15:17:15 -07005273 * approach to managing preferred activities, which has been superseded
5274 * by (and conflicts with) the modern activity-based preferences.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005275 */
Dianne Hackborna7ca0e52009-12-01 14:31:55 -08005276 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005277 public abstract void removePackageFromPreferred(String packageName);
5278
5279 /**
Jeff Sharkey4347f812017-04-21 12:08:39 -06005280 * Retrieve the list of all currently configured preferred packages. The
5281 * first package on the list is the most preferred, the last is the least
5282 * preferred.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005283 *
Jeff Sharkey4347f812017-04-21 12:08:39 -06005284 * @param flags Additional option flags to modify the data returned.
5285 * @return A List of PackageInfo objects, one for each preferred
5286 * application, in order of preference.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005287 */
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07005288 public abstract List<PackageInfo> getPreferredPackages(@PackageInfoFlags int flags);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005289
5290 /**
Dianne Hackborn2ee89ea2010-03-10 18:27:09 -08005291 * @deprecated This is a protected API that should not have been available
5292 * to third party applications. It is the platform's responsibility for
kmccormick30498b42013-03-27 17:39:17 -07005293 * assigning preferred activities and this cannot be directly modified.
Amith Yamasani4b2e9342011-03-31 12:38:53 -07005294 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005295 * Add a new preferred activity mapping to the system. This will be used
5296 * to automatically select the given activity component when
5297 * {@link Context#startActivity(Intent) Context.startActivity()} finds
5298 * multiple matching activities and also matches the given filter.
5299 *
5300 * @param filter The set of intents under which this activity will be
5301 * made preferred.
5302 * @param match The IntentFilter match category that this preference
5303 * applies to.
5304 * @param set The set of activities that the user was picking from when
5305 * this preference was made.
5306 * @param activity The component name of the activity that is to be
5307 * preferred.
5308 */
Dianne Hackborn2ee89ea2010-03-10 18:27:09 -08005309 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005310 public abstract void addPreferredActivity(IntentFilter filter, int match,
5311 ComponentName[] set, ComponentName activity);
5312
5313 /**
Amith Yamasania3f133a2012-08-09 17:11:28 -07005314 * Same as {@link #addPreferredActivity(IntentFilter, int,
5315 ComponentName[], ComponentName)}, but with a specific userId to apply the preference
5316 to.
5317 * @hide
5318 */
Jeff Sharkeye06b4d12016-01-06 14:51:50 -07005319 public void addPreferredActivityAsUser(IntentFilter filter, int match,
Jeff Sharkey8588bc12016-01-06 16:47:42 -07005320 ComponentName[] set, ComponentName activity, @UserIdInt int userId) {
Amith Yamasania3f133a2012-08-09 17:11:28 -07005321 throw new RuntimeException("Not implemented. Must override in a subclass.");
5322 }
5323
5324 /**
Dianne Hackborn2ee89ea2010-03-10 18:27:09 -08005325 * @deprecated This is a protected API that should not have been available
5326 * to third party applications. It is the platform's responsibility for
kmccormick30498b42013-03-27 17:39:17 -07005327 * assigning preferred activities and this cannot be directly modified.
Amith Yamasani4b2e9342011-03-31 12:38:53 -07005328 *
Satish Sampath8dbe6122009-06-02 23:35:54 +01005329 * Replaces an existing preferred activity mapping to the system, and if that were not present
5330 * adds a new preferred activity. This will be used
5331 * to automatically select the given activity component when
5332 * {@link Context#startActivity(Intent) Context.startActivity()} finds
5333 * multiple matching activities and also matches the given filter.
5334 *
5335 * @param filter The set of intents under which this activity will be
5336 * made preferred.
5337 * @param match The IntentFilter match category that this preference
5338 * applies to.
5339 * @param set The set of activities that the user was picking from when
5340 * this preference was made.
5341 * @param activity The component name of the activity that is to be
5342 * preferred.
5343 * @hide
5344 */
Dianne Hackborn2ee89ea2010-03-10 18:27:09 -08005345 @Deprecated
Satish Sampath8dbe6122009-06-02 23:35:54 +01005346 public abstract void replacePreferredActivity(IntentFilter filter, int match,
5347 ComponentName[] set, ComponentName activity);
5348
5349 /**
Amith Yamasani41c1ded2014-08-05 11:15:05 -07005350 * @hide
5351 */
5352 @Deprecated
5353 public void replacePreferredActivityAsUser(IntentFilter filter, int match,
Jeff Sharkey8588bc12016-01-06 16:47:42 -07005354 ComponentName[] set, ComponentName activity, @UserIdInt int userId) {
Amith Yamasani41c1ded2014-08-05 11:15:05 -07005355 throw new RuntimeException("Not implemented. Must override in a subclass.");
5356 }
5357
5358 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005359 * Remove all preferred activity mappings, previously added with
5360 * {@link #addPreferredActivity}, from the
5361 * system whose activities are implemented in the given package name.
Dianne Hackborn2ee89ea2010-03-10 18:27:09 -08005362 * An application can only clear its own package(s).
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005363 *
5364 * @param packageName The name of the package whose preferred activity
5365 * mappings are to be removed.
5366 */
5367 public abstract void clearPackagePreferredActivities(String packageName);
5368
5369 /**
5370 * Retrieve all preferred activities, previously added with
5371 * {@link #addPreferredActivity}, that are
5372 * currently registered with the system.
5373 *
John Spurlock38e64252015-03-18 12:09:32 -04005374 * @param outFilters A required list in which to place the filters of all of the
5375 * preferred activities.
5376 * @param outActivities A required list in which to place the component names of
5377 * all of the preferred activities.
5378 * @param packageName An optional package in which you would like to limit
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005379 * the list. If null, all activities will be returned; if non-null, only
5380 * those activities in the given package are returned.
5381 *
5382 * @return Returns the total number of registered preferred activities
5383 * (the number of distinct IntentFilter records, not the number of unique
5384 * activity components) that were found.
5385 */
John Spurlock38e64252015-03-18 12:09:32 -04005386 public abstract int getPreferredActivities(@NonNull List<IntentFilter> outFilters,
5387 @NonNull List<ComponentName> outActivities, String packageName);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005388
5389 /**
Christopher Tatea2a0850d2013-09-05 16:38:58 -07005390 * Ask for the set of available 'home' activities and the current explicit
5391 * default, if any.
5392 * @hide
5393 */
5394 public abstract ComponentName getHomeActivities(List<ResolveInfo> outActivities);
5395
5396 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005397 * Set the enabled setting for a package component (activity, receiver, service, provider).
5398 * This setting will override any enabled state which may have been set by the component in its
5399 * manifest.
5400 *
5401 * @param componentName The component to enable
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005402 * @param newState The new enabled state for the component.
5403 * @param flags Optional behavior flags.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005404 */
5405 public abstract void setComponentEnabledSetting(ComponentName componentName,
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005406 @EnabledState int newState, @EnabledFlags int flags);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005407
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005408 /**
Amaury Medeirosdde24262014-06-03 20:06:41 -03005409 * Return the enabled setting for a package component (activity,
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005410 * receiver, service, provider). This returns the last value set by
5411 * {@link #setComponentEnabledSetting(ComponentName, int, int)}; in most
5412 * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since
5413 * the value originally specified in the manifest has not been modified.
5414 *
5415 * @param componentName The component to retrieve.
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005416 * @return Returns the current enabled state for the component.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005417 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005418 public abstract @EnabledState int getComponentEnabledSetting(
5419 ComponentName componentName);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005420
5421 /**
5422 * Set the enabled setting for an application
5423 * This setting will override any enabled state which may have been set by the application in
5424 * its manifest. It also overrides the enabled state set in the manifest for any of the
5425 * application's components. It does not override any enabled state set by
5426 * {@link #setComponentEnabledSetting} for any of the application's components.
5427 *
5428 * @param packageName The package name of the application to enable
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005429 * @param newState The new enabled state for the application.
5430 * @param flags Optional behavior flags.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005431 */
5432 public abstract void setApplicationEnabledSetting(String packageName,
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005433 @EnabledState int newState, @EnabledFlags int flags);
Amith Yamasani4b2e9342011-03-31 12:38:53 -07005434
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005435 /**
Amaury Medeirosdde24262014-06-03 20:06:41 -03005436 * Return the enabled setting for an application. This returns
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005437 * the last value set by
5438 * {@link #setApplicationEnabledSetting(String, int, int)}; in most
5439 * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since
5440 * the value originally specified in the manifest has not been modified.
5441 *
Amaury Medeirosdde24262014-06-03 20:06:41 -03005442 * @param packageName The package name of the application to retrieve.
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005443 * @return Returns the current enabled state for the application.
Mathew Inwood1b9f8d92011-09-26 13:23:56 +01005444 * @throws IllegalArgumentException if the named package does not exist.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005445 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005446 public abstract @EnabledState int getApplicationEnabledSetting(String packageName);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005447
5448 /**
Sudheer Shankabbb3ff22015-07-09 15:39:23 +01005449 * Flush the package restrictions for a given user to disk. This forces the package restrictions
5450 * like component and package enabled settings to be written to disk and avoids the delay that
5451 * is otherwise present when changing those settings.
5452 *
5453 * @param userId Ther userId of the user whose restrictions are to be flushed.
5454 * @hide
5455 */
5456 public abstract void flushPackageRestrictionsAsUser(int userId);
5457
5458 /**
Amith Yamasanie5bcff62014-07-19 15:44:09 -07005459 * Puts the package in a hidden state, which is almost like an uninstalled state,
Amith Yamasani655d0e22013-06-12 14:19:10 -07005460 * making the package unavailable, but it doesn't remove the data or the actual
Amith Yamasanie5bcff62014-07-19 15:44:09 -07005461 * package file. Application can be unhidden by either resetting the hidden state
5462 * or by installing it, such as with {@link #installExistingPackage(String)}
Amith Yamasani655d0e22013-06-12 14:19:10 -07005463 * @hide
5464 */
Amith Yamasanie5bcff62014-07-19 15:44:09 -07005465 public abstract boolean setApplicationHiddenSettingAsUser(String packageName, boolean hidden,
Amith Yamasani655d0e22013-06-12 14:19:10 -07005466 UserHandle userHandle);
5467
5468 /**
Amith Yamasanie5bcff62014-07-19 15:44:09 -07005469 * Returns the hidden state of a package.
5470 * @see #setApplicationHiddenSettingAsUser(String, boolean, UserHandle)
Amith Yamasani655d0e22013-06-12 14:19:10 -07005471 * @hide
5472 */
Amith Yamasanie5bcff62014-07-19 15:44:09 -07005473 public abstract boolean getApplicationHiddenSettingAsUser(String packageName,
Amith Yamasani655d0e22013-06-12 14:19:10 -07005474 UserHandle userHandle);
5475
5476 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005477 * Return whether the device has been booted into safe mode.
5478 */
5479 public abstract boolean isSafeMode();
Suchi Amalapurapu8946dd32010-02-19 09:19:34 -08005480
5481 /**
Svetoslavf7c06eb2015-06-10 18:43:22 -07005482 * Adds a listener for permission changes for installed packages.
5483 *
5484 * @param listener The listener to add.
5485 *
5486 * @hide
5487 */
5488 @SystemApi
5489 @RequiresPermission(Manifest.permission.OBSERVE_GRANT_REVOKE_PERMISSIONS)
5490 public abstract void addOnPermissionsChangeListener(OnPermissionsChangedListener listener);
5491
5492 /**
5493 * Remvoes a listener for permission changes for installed packages.
5494 *
5495 * @param listener The listener to remove.
5496 *
5497 * @hide
5498 */
5499 @SystemApi
Jeff Sharkeyd86b8fe2017-06-02 17:36:26 -06005500 @RequiresPermission(Manifest.permission.OBSERVE_GRANT_REVOKE_PERMISSIONS)
Svetoslavf7c06eb2015-06-10 18:43:22 -07005501 public abstract void removeOnPermissionsChangeListener(OnPermissionsChangedListener listener);
5502
5503 /**
dcashman9d2f4412014-06-09 09:27:54 -07005504 * Return the {@link KeySet} associated with the String alias for this
5505 * application.
5506 *
5507 * @param alias The alias for a given {@link KeySet} as defined in the
5508 * application's AndroidManifest.xml.
dcashmanc6f22492014-08-14 09:54:51 -07005509 * @hide
dcashman9d2f4412014-06-09 09:27:54 -07005510 */
5511 public abstract KeySet getKeySetByAlias(String packageName, String alias);
5512
Ihab Awad1ec68882014-09-12 11:09:01 -07005513 /** Return the signing {@link KeySet} for this application.
dcashmanc6f22492014-08-14 09:54:51 -07005514 * @hide
5515 */
dcashman9d2f4412014-06-09 09:27:54 -07005516 public abstract KeySet getSigningKeySet(String packageName);
5517
5518 /**
5519 * Return whether the package denoted by packageName has been signed by all
5520 * of the keys specified by the {@link KeySet} ks. This will return true if
5521 * the package has been signed by additional keys (a superset) as well.
5522 * Compare to {@link #isSignedByExactly(String packageName, KeySet ks)}.
dcashmanc6f22492014-08-14 09:54:51 -07005523 * @hide
dcashman9d2f4412014-06-09 09:27:54 -07005524 */
5525 public abstract boolean isSignedBy(String packageName, KeySet ks);
5526
5527 /**
5528 * Return whether the package denoted by packageName has been signed by all
5529 * of, and only, the keys specified by the {@link KeySet} ks. Compare to
5530 * {@link #isSignedBy(String packageName, KeySet ks)}.
dcashmanc6f22492014-08-14 09:54:51 -07005531 * @hide
dcashman9d2f4412014-06-09 09:27:54 -07005532 */
5533 public abstract boolean isSignedByExactly(String packageName, KeySet ks);
5534
5535 /**
Andrei Stingaceanueb84b182016-01-26 18:39:55 +00005536 * Puts the package in a suspended state, where attempts at starting activities are denied.
Andrei Stingaceanu1e283912015-11-26 15:26:28 +00005537 *
Suprabh Shukla021b57a2018-03-08 18:21:50 -08005538 * <p>It doesn't remove the data or the actual package file. The application's notifications
Suprabh Shukla2fd43ba2018-03-22 16:57:49 -07005539 * will be hidden, any of its started activities will be stopped and it will not be able to
Suprabh Shukla3e03ab92018-04-11 16:03:49 -07005540 * show toasts or system alert windows or ring the device.
5541 *
5542 * <p>When the user tries to launch a suspended app, a system dialog with the given
5543 * {@code dialogMessage} will be shown instead. Since the message is supplied to the system as
5544 * a {@link String}, the caller needs to take care of localization as needed.
5545 * The dialog message can optionally contain a placeholder for the name of the suspended app.
5546 * The system uses {@link String#format(Locale, String, Object...) String.format} to insert the
5547 * app name into the message, so an example format string could be {@code "The app %1$s is
5548 * currently suspended"}. This makes it easier for callers to provide a single message which
5549 * works for all the packages being suspended in a single call.
Andrei Stingaceanueb84b182016-01-26 18:39:55 +00005550 *
Kenny Guy871f3eb2016-03-09 20:06:16 +00005551 * <p>The package must already be installed. If the package is uninstalled while suspended
Suprabh Shukla021b57a2018-03-08 18:21:50 -08005552 * the package will no longer be suspended. </p>
5553 *
5554 * <p>Optionally, the suspending app can provide extra information in the form of
5555 * {@link PersistableBundle} objects to be shared with the apps being suspended and the
Suprabh Shukla3e03ab92018-04-11 16:03:49 -07005556 * launcher to support customization that they might need to handle the suspended state.
Suprabh Shukla021b57a2018-03-08 18:21:50 -08005557 *
5558 * <p>The caller must hold {@link Manifest.permission#SUSPEND_APPS} or
5559 * {@link Manifest.permission#MANAGE_USERS} to use this api.</p>
Kenny Guy871f3eb2016-03-09 20:06:16 +00005560 *
Andrei Stingaceanueb84b182016-01-26 18:39:55 +00005561 * @param packageNames The names of the packages to set the suspended status.
5562 * @param suspended If set to {@code true} than the packages will be suspended, if set to
Suprabh Shukla021b57a2018-03-08 18:21:50 -08005563 * {@code false}, the packages will be unsuspended.
5564 * @param appExtras An optional {@link PersistableBundle} that the suspending app can provide
5565 * which will be shared with the apps being suspended. Ignored if
5566 * {@code suspended} is false.
5567 * @param launcherExtras An optional {@link PersistableBundle} that the suspending app can
5568 * provide which will be shared with the launcher. Ignored if
5569 * {@code suspended} is false.
5570 * @param dialogMessage The message to be displayed to the user, when they try to launch a
5571 * suspended app.
Andrei Stingaceanu1e283912015-11-26 15:26:28 +00005572 *
Suprabh Shukla3e03ab92018-04-11 16:03:49 -07005573 * @return an array of package names for which the suspended status could not be set as
5574 * requested in this method.
Andrei Stingaceanueb84b182016-01-26 18:39:55 +00005575 *
Andrei Stingaceanu1e283912015-11-26 15:26:28 +00005576 * @hide
5577 */
Suprabh Shukla021b57a2018-03-08 18:21:50 -08005578 @SystemApi
Suprabh Shukla14405c92018-05-16 20:41:00 -07005579 @RequiresPermission(Manifest.permission.SUSPEND_APPS)
Suprabh Shukla021b57a2018-03-08 18:21:50 -08005580 public String[] setPackagesSuspended(String[] packageNames, boolean suspended,
5581 @Nullable PersistableBundle appExtras, @Nullable PersistableBundle launcherExtras,
5582 String dialogMessage) {
5583 throw new UnsupportedOperationException("setPackagesSuspended not implemented");
5584 }
Andrei Stingaceanu1e283912015-11-26 15:26:28 +00005585
Andrei Stingaceanu355b2322016-02-12 16:43:51 +00005586 /**
Suprabh Shukla021b57a2018-03-08 18:21:50 -08005587 * @see #setPackagesSuspended(String[], boolean, PersistableBundle, PersistableBundle, String)
Andrei Stingaceanu355b2322016-02-12 16:43:51 +00005588 * @param packageName The name of the package to get the suspended status of.
5589 * @param userId The user id.
5590 * @return {@code true} if the package is suspended or {@code false} if the package is not
Suprabh Shukla96212bc2018-04-10 15:04:51 -07005591 * suspended.
5592 * @throws IllegalArgumentException if the package was not found.
Andrei Stingaceanu355b2322016-02-12 16:43:51 +00005593 * @hide
5594 */
5595 public abstract boolean isPackageSuspendedForUser(String packageName, int userId);
5596
Jeff Sharkey9bc89af2017-01-11 11:25:50 -07005597 /**
Suprabh Shukla021b57a2018-03-08 18:21:50 -08005598 * Query if an app is currently suspended.
5599 *
5600 * @return {@code true} if the given package is suspended, {@code false} otherwise
Suprabh Shukla96212bc2018-04-10 15:04:51 -07005601 * @throws NameNotFoundException if the package could not be found.
Suprabh Shukla021b57a2018-03-08 18:21:50 -08005602 *
5603 * @see #setPackagesSuspended(String[], boolean, PersistableBundle, PersistableBundle, String)
5604 * @hide
5605 */
5606 @SystemApi
Suprabh Shukla96212bc2018-04-10 15:04:51 -07005607 public boolean isPackageSuspended(String packageName) throws NameNotFoundException {
Suprabh Shukla021b57a2018-03-08 18:21:50 -08005608 throw new UnsupportedOperationException("isPackageSuspended not implemented");
5609 }
5610
5611 /**
Suprabh Shukla2fd43ba2018-03-22 16:57:49 -07005612 * Apps can query this to know if they have been suspended. A system app with the permission
5613 * {@code android.permission.SUSPEND_APPS} can put any app on the device into a suspended state.
5614 *
5615 * <p>While in this state, the application's notifications will be hidden, any of its started
5616 * activities will be stopped and it will not be able to show toasts or dialogs or ring the
5617 * device. When the user tries to launch a suspended app, the system will, instead, show a
5618 * dialog to the user informing them that they cannot use this app while it is suspended.
5619 *
5620 * <p>When an app is put into this state, the broadcast action
5621 * {@link Intent#ACTION_MY_PACKAGE_SUSPENDED} will be delivered to any of its broadcast
5622 * receivers that included this action in their intent-filters, <em>including manifest
5623 * receivers.</em> Similarly, a broadcast action {@link Intent#ACTION_MY_PACKAGE_UNSUSPENDED}
5624 * is delivered when a previously suspended app is taken out of this state.
5625 * </p>
Suprabh Shukla021b57a2018-03-08 18:21:50 -08005626 *
5627 * @return {@code true} if the calling package has been suspended, {@code false} otherwise.
5628 *
5629 * @see #getSuspendedPackageAppExtras()
Suprabh Shukla2fd43ba2018-03-22 16:57:49 -07005630 * @see Intent#ACTION_MY_PACKAGE_SUSPENDED
5631 * @see Intent#ACTION_MY_PACKAGE_UNSUSPENDED
Suprabh Shukla021b57a2018-03-08 18:21:50 -08005632 */
5633 public boolean isPackageSuspended() {
5634 throw new UnsupportedOperationException("isPackageSuspended not implemented");
5635 }
5636
5637 /**
Suprabh Shukla96212bc2018-04-10 15:04:51 -07005638 * Returns a {@link Bundle} of extras that was meant to be sent to the calling app when it was
5639 * suspended. An app with the permission {@code android.permission.SUSPEND_APPS} can supply this
5640 * to the system at the time of suspending an app.
Suprabh Shukla021b57a2018-03-08 18:21:50 -08005641 *
Suprabh Shukla96212bc2018-04-10 15:04:51 -07005642 * <p>This is the same {@link Bundle} that is sent along with the broadcast
5643 * {@link Intent#ACTION_MY_PACKAGE_SUSPENDED}, whenever the app is suspended. The contents of
5644 * this {@link Bundle} are a contract between the suspended app and the suspending app.
5645 *
5646 * <p>Note: These extras are optional, so if no extras were supplied to the system, this method
5647 * will return {@code null}, even when the calling app has been suspended.
Suprabh Shukla021b57a2018-03-08 18:21:50 -08005648 *
Suprabh Shukla2fd43ba2018-03-22 16:57:49 -07005649 * @return A {@link Bundle} containing the extras for the app, or {@code null} if the
Suprabh Shukla021b57a2018-03-08 18:21:50 -08005650 * package is not currently suspended.
Suprabh Shukla2fd43ba2018-03-22 16:57:49 -07005651 *
Suprabh Shukla021b57a2018-03-08 18:21:50 -08005652 * @see #isPackageSuspended()
Suprabh Shukla2fd43ba2018-03-22 16:57:49 -07005653 * @see Intent#ACTION_MY_PACKAGE_UNSUSPENDED
5654 * @see Intent#ACTION_MY_PACKAGE_SUSPENDED
Suprabh Shukla96212bc2018-04-10 15:04:51 -07005655 * @see Intent#EXTRA_SUSPENDED_PACKAGE_EXTRAS
Suprabh Shukla021b57a2018-03-08 18:21:50 -08005656 */
Suprabh Shukla2fd43ba2018-03-22 16:57:49 -07005657 public @Nullable Bundle getSuspendedPackageAppExtras() {
Suprabh Shukla021b57a2018-03-08 18:21:50 -08005658 throw new UnsupportedOperationException("getSuspendedPackageAppExtras not implemented");
5659 }
5660
5661 /**
Jeff Sharkey9bc89af2017-01-11 11:25:50 -07005662 * Provide a hint of what the {@link ApplicationInfo#category} value should
5663 * be for the given package.
5664 * <p>
5665 * This hint can only be set by the app which installed this package, as
5666 * determined by {@link #getInstallerPackageName(String)}.
Jeff Sharkey60a82cd2017-04-18 18:19:16 -06005667 *
5668 * @param packageName the package to change the category hint for.
Jeff Sharkey4347f812017-04-21 12:08:39 -06005669 * @param categoryHint the category hint to set.
Jeff Sharkey9bc89af2017-01-11 11:25:50 -07005670 */
Jeff Sharkey60a82cd2017-04-18 18:19:16 -06005671 public abstract void setApplicationCategoryHint(@NonNull String packageName,
Jeff Sharkey9bc89af2017-01-11 11:25:50 -07005672 @ApplicationInfo.Category int categoryHint);
5673
Jeff Sharkeyb2b9ab82015-04-05 21:10:42 -07005674 /** {@hide} */
Jeff Sharkey620b32b2015-04-23 19:36:02 -07005675 public static boolean isMoveStatusFinished(int status) {
5676 return (status < 0 || status > 100);
5677 }
Amith Yamasani4b2e9342011-03-31 12:38:53 -07005678
Jeff Sharkeye2d45be2015-04-15 17:14:12 -07005679 /** {@hide} */
Jeff Sharkey620b32b2015-04-23 19:36:02 -07005680 public static abstract class MoveCallback {
Jeff Sharkey50a05452015-04-29 11:24:52 -07005681 public void onCreated(int moveId, Bundle extras) {}
5682 public abstract void onStatusChanged(int moveId, int status, long estMillis);
Jeff Sharkey620b32b2015-04-23 19:36:02 -07005683 }
Jeff Sharkeye2d45be2015-04-15 17:14:12 -07005684
5685 /** {@hide} */
Jeff Sharkey620b32b2015-04-23 19:36:02 -07005686 public abstract int getMoveStatus(int moveId);
5687
5688 /** {@hide} */
5689 public abstract void registerMoveCallback(MoveCallback callback, Handler handler);
5690 /** {@hide} */
5691 public abstract void unregisterMoveCallback(MoveCallback callback);
5692
5693 /** {@hide} */
5694 public abstract int movePackage(String packageName, VolumeInfo vol);
5695 /** {@hide} */
5696 public abstract @Nullable VolumeInfo getPackageCurrentVolume(ApplicationInfo app);
5697 /** {@hide} */
5698 public abstract @NonNull List<VolumeInfo> getPackageCandidateVolumes(ApplicationInfo app);
5699
5700 /** {@hide} */
5701 public abstract int movePrimaryStorage(VolumeInfo vol);
5702 /** {@hide} */
5703 public abstract @Nullable VolumeInfo getPrimaryStorageCurrentVolume();
5704 /** {@hide} */
5705 public abstract @NonNull List<VolumeInfo> getPrimaryStorageCandidateVolumes();
Jeff Sharkeye2d45be2015-04-15 17:14:12 -07005706
Amith Yamasani4b2e9342011-03-31 12:38:53 -07005707 /**
Amith Yamasani13593602012-03-22 16:16:17 -07005708 * Returns the device identity that verifiers can use to associate their scheme to a particular
5709 * device. This should not be used by anything other than a package verifier.
Aravind Akella068b0c02013-10-12 17:39:15 -07005710 *
Kenny Root0aaa0d92011-09-12 16:42:55 -07005711 * @return identity that uniquely identifies current device
5712 * @hide
5713 */
5714 public abstract VerifierDeviceIdentity getVerifierDeviceIdentity();
Amith Yamasani742a6712011-05-04 14:49:28 -07005715
Jeff Sharkey6c833e02014-07-14 22:44:30 -07005716 /**
Jeff Hao9f60c082014-10-28 18:51:07 -07005717 * Returns true if the device is upgrading, such as first boot after OTA.
5718 *
5719 * @hide
5720 */
5721 public abstract boolean isUpgrade();
5722
5723 /**
Jeff Sharkey6c833e02014-07-14 22:44:30 -07005724 * Return interface that offers the ability to install, upgrade, and remove
5725 * applications on the device.
5726 */
Jeff Sharkey16c8e3f2014-07-24 17:08:17 -07005727 public abstract @NonNull PackageInstaller getPackageInstaller();
Jeff Sharkey3a44f3f2014-04-28 17:36:31 -07005728
Amith Yamasani742a6712011-05-04 14:49:28 -07005729 /**
Jeff Sharkey5aa86932016-01-08 19:07:49 -07005730 * Adds a {@code CrossProfileIntentFilter}. After calling this method all
5731 * intents sent from the user with id sourceUserId can also be be resolved
5732 * by activities in the user with id targetUserId if they match the
5733 * specified intent filter.
5734 *
Nicolas Prevot3f7777f2014-07-24 15:58:39 +01005735 * @param filter The {@link IntentFilter} the intent has to match
5736 * @param sourceUserId The source user id.
5737 * @param targetUserId The target user id.
Jeff Sharkey5aa86932016-01-08 19:07:49 -07005738 * @param flags The possible values are {@link #SKIP_CURRENT_PROFILE} and
5739 * {@link #ONLY_IF_NO_MATCH_FOUND}.
Nicolas Prevotc79586e2014-05-06 12:47:57 +01005740 * @hide
5741 */
Nicolas Prevot63798c52014-05-27 13:22:38 +01005742 public abstract void addCrossProfileIntentFilter(IntentFilter filter, int sourceUserId,
5743 int targetUserId, int flags);
Nicolas Prevotc79586e2014-05-06 12:47:57 +01005744
5745 /**
Jeff Sharkey5aa86932016-01-08 19:07:49 -07005746 * Clearing {@code CrossProfileIntentFilter}s which have the specified user
5747 * as their source, and have been set by the app calling this method.
5748 *
Nicolas Prevot3f7777f2014-07-24 15:58:39 +01005749 * @param sourceUserId The source user id.
Nicolas Prevotc79586e2014-05-06 12:47:57 +01005750 * @hide
5751 */
Nicolas Prevot81948992014-05-16 18:25:26 +01005752 public abstract void clearCrossProfileIntentFilters(int sourceUserId);
Alexandra Gherghina6e2ae252014-06-12 16:03:58 +01005753
5754 /**
Nicolas Prevot88cc3462014-05-14 14:51:48 +01005755 * @hide
5756 */
Nicolas Prevot7f7b0c72014-06-23 15:59:38 +01005757 public abstract Drawable loadItemIcon(PackageItemInfo itemInfo, ApplicationInfo appInfo);
Jeff Sharkey6c833e02014-07-14 22:44:30 -07005758
Benjamin Franzec2d48b2014-10-01 15:38:43 +01005759 /**
5760 * @hide
5761 */
5762 public abstract Drawable loadUnbadgedItemIcon(PackageItemInfo itemInfo, ApplicationInfo appInfo);
5763
Jeff Sharkey6c833e02014-07-14 22:44:30 -07005764 /** {@hide} */
5765 public abstract boolean isPackageAvailable(String packageName);
Jeff Sharkey16c8e3f2014-07-24 17:08:17 -07005766
5767 /** {@hide} */
Jeff Sharkeya0907432014-08-15 10:23:11 -07005768 public static String installStatusToString(int status, String msg) {
5769 final String str = installStatusToString(status);
5770 if (msg != null) {
5771 return str + ": " + msg;
5772 } else {
5773 return str;
5774 }
5775 }
5776
5777 /** {@hide} */
Jeff Sharkey16c8e3f2014-07-24 17:08:17 -07005778 public static String installStatusToString(int status) {
5779 switch (status) {
5780 case INSTALL_SUCCEEDED: return "INSTALL_SUCCEEDED";
5781 case INSTALL_FAILED_ALREADY_EXISTS: return "INSTALL_FAILED_ALREADY_EXISTS";
5782 case INSTALL_FAILED_INVALID_APK: return "INSTALL_FAILED_INVALID_APK";
5783 case INSTALL_FAILED_INVALID_URI: return "INSTALL_FAILED_INVALID_URI";
5784 case INSTALL_FAILED_INSUFFICIENT_STORAGE: return "INSTALL_FAILED_INSUFFICIENT_STORAGE";
5785 case INSTALL_FAILED_DUPLICATE_PACKAGE: return "INSTALL_FAILED_DUPLICATE_PACKAGE";
5786 case INSTALL_FAILED_NO_SHARED_USER: return "INSTALL_FAILED_NO_SHARED_USER";
5787 case INSTALL_FAILED_UPDATE_INCOMPATIBLE: return "INSTALL_FAILED_UPDATE_INCOMPATIBLE";
5788 case INSTALL_FAILED_SHARED_USER_INCOMPATIBLE: return "INSTALL_FAILED_SHARED_USER_INCOMPATIBLE";
5789 case INSTALL_FAILED_MISSING_SHARED_LIBRARY: return "INSTALL_FAILED_MISSING_SHARED_LIBRARY";
5790 case INSTALL_FAILED_REPLACE_COULDNT_DELETE: return "INSTALL_FAILED_REPLACE_COULDNT_DELETE";
5791 case INSTALL_FAILED_DEXOPT: return "INSTALL_FAILED_DEXOPT";
5792 case INSTALL_FAILED_OLDER_SDK: return "INSTALL_FAILED_OLDER_SDK";
5793 case INSTALL_FAILED_CONFLICTING_PROVIDER: return "INSTALL_FAILED_CONFLICTING_PROVIDER";
5794 case INSTALL_FAILED_NEWER_SDK: return "INSTALL_FAILED_NEWER_SDK";
5795 case INSTALL_FAILED_TEST_ONLY: return "INSTALL_FAILED_TEST_ONLY";
5796 case INSTALL_FAILED_CPU_ABI_INCOMPATIBLE: return "INSTALL_FAILED_CPU_ABI_INCOMPATIBLE";
5797 case INSTALL_FAILED_MISSING_FEATURE: return "INSTALL_FAILED_MISSING_FEATURE";
5798 case INSTALL_FAILED_CONTAINER_ERROR: return "INSTALL_FAILED_CONTAINER_ERROR";
5799 case INSTALL_FAILED_INVALID_INSTALL_LOCATION: return "INSTALL_FAILED_INVALID_INSTALL_LOCATION";
5800 case INSTALL_FAILED_MEDIA_UNAVAILABLE: return "INSTALL_FAILED_MEDIA_UNAVAILABLE";
5801 case INSTALL_FAILED_VERIFICATION_TIMEOUT: return "INSTALL_FAILED_VERIFICATION_TIMEOUT";
5802 case INSTALL_FAILED_VERIFICATION_FAILURE: return "INSTALL_FAILED_VERIFICATION_FAILURE";
5803 case INSTALL_FAILED_PACKAGE_CHANGED: return "INSTALL_FAILED_PACKAGE_CHANGED";
5804 case INSTALL_FAILED_UID_CHANGED: return "INSTALL_FAILED_UID_CHANGED";
5805 case INSTALL_FAILED_VERSION_DOWNGRADE: return "INSTALL_FAILED_VERSION_DOWNGRADE";
5806 case INSTALL_PARSE_FAILED_NOT_APK: return "INSTALL_PARSE_FAILED_NOT_APK";
5807 case INSTALL_PARSE_FAILED_BAD_MANIFEST: return "INSTALL_PARSE_FAILED_BAD_MANIFEST";
5808 case INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION: return "INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION";
5809 case INSTALL_PARSE_FAILED_NO_CERTIFICATES: return "INSTALL_PARSE_FAILED_NO_CERTIFICATES";
5810 case INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES: return "INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES";
5811 case INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING: return "INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING";
5812 case INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME: return "INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME";
5813 case INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID: return "INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID";
5814 case INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: return "INSTALL_PARSE_FAILED_MANIFEST_MALFORMED";
5815 case INSTALL_PARSE_FAILED_MANIFEST_EMPTY: return "INSTALL_PARSE_FAILED_MANIFEST_EMPTY";
5816 case INSTALL_FAILED_INTERNAL_ERROR: return "INSTALL_FAILED_INTERNAL_ERROR";
5817 case INSTALL_FAILED_USER_RESTRICTED: return "INSTALL_FAILED_USER_RESTRICTED";
5818 case INSTALL_FAILED_DUPLICATE_PERMISSION: return "INSTALL_FAILED_DUPLICATE_PERMISSION";
5819 case INSTALL_FAILED_NO_MATCHING_ABIS: return "INSTALL_FAILED_NO_MATCHING_ABIS";
Jeff Sharkeyf0600952014-08-07 17:31:53 -07005820 case INSTALL_FAILED_ABORTED: return "INSTALL_FAILED_ABORTED";
Calin Juravle3fc56c32017-12-11 18:26:13 -08005821 case INSTALL_FAILED_BAD_DEX_METADATA:
5822 return "INSTALL_FAILED_BAD_DEX_METADATA";
Jeff Sharkey16c8e3f2014-07-24 17:08:17 -07005823 default: return Integer.toString(status);
5824 }
5825 }
5826
5827 /** {@hide} */
Jeff Sharkeya0907432014-08-15 10:23:11 -07005828 public static int installStatusToPublicStatus(int status) {
Jeff Sharkey16c8e3f2014-07-24 17:08:17 -07005829 switch (status) {
Jeff Sharkeya0907432014-08-15 10:23:11 -07005830 case INSTALL_SUCCEEDED: return PackageInstaller.STATUS_SUCCESS;
5831 case INSTALL_FAILED_ALREADY_EXISTS: return PackageInstaller.STATUS_FAILURE_CONFLICT;
5832 case INSTALL_FAILED_INVALID_APK: return PackageInstaller.STATUS_FAILURE_INVALID;
5833 case INSTALL_FAILED_INVALID_URI: return PackageInstaller.STATUS_FAILURE_INVALID;
5834 case INSTALL_FAILED_INSUFFICIENT_STORAGE: return PackageInstaller.STATUS_FAILURE_STORAGE;
5835 case INSTALL_FAILED_DUPLICATE_PACKAGE: return PackageInstaller.STATUS_FAILURE_CONFLICT;
5836 case INSTALL_FAILED_NO_SHARED_USER: return PackageInstaller.STATUS_FAILURE_CONFLICT;
5837 case INSTALL_FAILED_UPDATE_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_CONFLICT;
5838 case INSTALL_FAILED_SHARED_USER_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_CONFLICT;
5839 case INSTALL_FAILED_MISSING_SHARED_LIBRARY: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
5840 case INSTALL_FAILED_REPLACE_COULDNT_DELETE: return PackageInstaller.STATUS_FAILURE_CONFLICT;
5841 case INSTALL_FAILED_DEXOPT: return PackageInstaller.STATUS_FAILURE_INVALID;
5842 case INSTALL_FAILED_OLDER_SDK: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
5843 case INSTALL_FAILED_CONFLICTING_PROVIDER: return PackageInstaller.STATUS_FAILURE_CONFLICT;
5844 case INSTALL_FAILED_NEWER_SDK: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
5845 case INSTALL_FAILED_TEST_ONLY: return PackageInstaller.STATUS_FAILURE_INVALID;
5846 case INSTALL_FAILED_CPU_ABI_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
5847 case INSTALL_FAILED_MISSING_FEATURE: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
5848 case INSTALL_FAILED_CONTAINER_ERROR: return PackageInstaller.STATUS_FAILURE_STORAGE;
5849 case INSTALL_FAILED_INVALID_INSTALL_LOCATION: return PackageInstaller.STATUS_FAILURE_STORAGE;
5850 case INSTALL_FAILED_MEDIA_UNAVAILABLE: return PackageInstaller.STATUS_FAILURE_STORAGE;
5851 case INSTALL_FAILED_VERIFICATION_TIMEOUT: return PackageInstaller.STATUS_FAILURE_ABORTED;
5852 case INSTALL_FAILED_VERIFICATION_FAILURE: return PackageInstaller.STATUS_FAILURE_ABORTED;
5853 case INSTALL_FAILED_PACKAGE_CHANGED: return PackageInstaller.STATUS_FAILURE_INVALID;
5854 case INSTALL_FAILED_UID_CHANGED: return PackageInstaller.STATUS_FAILURE_INVALID;
5855 case INSTALL_FAILED_VERSION_DOWNGRADE: return PackageInstaller.STATUS_FAILURE_INVALID;
Svetoslavd9653702015-05-13 18:02:46 -07005856 case INSTALL_FAILED_PERMISSION_MODEL_DOWNGRADE: return PackageInstaller.STATUS_FAILURE_INVALID;
Jeff Sharkeya0907432014-08-15 10:23:11 -07005857 case INSTALL_PARSE_FAILED_NOT_APK: return PackageInstaller.STATUS_FAILURE_INVALID;
5858 case INSTALL_PARSE_FAILED_BAD_MANIFEST: return PackageInstaller.STATUS_FAILURE_INVALID;
5859 case INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION: return PackageInstaller.STATUS_FAILURE_INVALID;
5860 case INSTALL_PARSE_FAILED_NO_CERTIFICATES: return PackageInstaller.STATUS_FAILURE_INVALID;
5861 case INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES: return PackageInstaller.STATUS_FAILURE_INVALID;
5862 case INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING: return PackageInstaller.STATUS_FAILURE_INVALID;
5863 case INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME: return PackageInstaller.STATUS_FAILURE_INVALID;
5864 case INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID: return PackageInstaller.STATUS_FAILURE_INVALID;
5865 case INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: return PackageInstaller.STATUS_FAILURE_INVALID;
5866 case INSTALL_PARSE_FAILED_MANIFEST_EMPTY: return PackageInstaller.STATUS_FAILURE_INVALID;
Calin Juravle3fc56c32017-12-11 18:26:13 -08005867 case INSTALL_FAILED_BAD_DEX_METADATA: return PackageInstaller.STATUS_FAILURE_INVALID;
Jeff Sharkeya0907432014-08-15 10:23:11 -07005868 case INSTALL_FAILED_INTERNAL_ERROR: return PackageInstaller.STATUS_FAILURE;
5869 case INSTALL_FAILED_USER_RESTRICTED: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
5870 case INSTALL_FAILED_DUPLICATE_PERMISSION: return PackageInstaller.STATUS_FAILURE_CONFLICT;
5871 case INSTALL_FAILED_NO_MATCHING_ABIS: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
5872 case INSTALL_FAILED_ABORTED: return PackageInstaller.STATUS_FAILURE_ABORTED;
5873 default: return PackageInstaller.STATUS_FAILURE;
5874 }
5875 }
5876
5877 /** {@hide} */
5878 public static String deleteStatusToString(int status, String msg) {
5879 final String str = deleteStatusToString(status);
5880 if (msg != null) {
5881 return str + ": " + msg;
5882 } else {
5883 return str;
Jeff Sharkey16c8e3f2014-07-24 17:08:17 -07005884 }
5885 }
5886
5887 /** {@hide} */
5888 public static String deleteStatusToString(int status) {
5889 switch (status) {
5890 case DELETE_SUCCEEDED: return "DELETE_SUCCEEDED";
5891 case DELETE_FAILED_INTERNAL_ERROR: return "DELETE_FAILED_INTERNAL_ERROR";
5892 case DELETE_FAILED_DEVICE_POLICY_MANAGER: return "DELETE_FAILED_DEVICE_POLICY_MANAGER";
5893 case DELETE_FAILED_USER_RESTRICTED: return "DELETE_FAILED_USER_RESTRICTED";
5894 case DELETE_FAILED_OWNER_BLOCKED: return "DELETE_FAILED_OWNER_BLOCKED";
Jeff Sharkeyf0600952014-08-07 17:31:53 -07005895 case DELETE_FAILED_ABORTED: return "DELETE_FAILED_ABORTED";
Svet Ganov67882122016-12-11 16:36:34 -08005896 case DELETE_FAILED_USED_SHARED_LIBRARY: return "DELETE_FAILED_USED_SHARED_LIBRARY";
Jeff Sharkey16c8e3f2014-07-24 17:08:17 -07005897 default: return Integer.toString(status);
5898 }
5899 }
Jeff Sharkeyf0600952014-08-07 17:31:53 -07005900
5901 /** {@hide} */
Jeff Sharkeya0907432014-08-15 10:23:11 -07005902 public static int deleteStatusToPublicStatus(int status) {
Jeff Sharkeyf0600952014-08-07 17:31:53 -07005903 switch (status) {
Jeff Sharkeya0907432014-08-15 10:23:11 -07005904 case DELETE_SUCCEEDED: return PackageInstaller.STATUS_SUCCESS;
5905 case DELETE_FAILED_INTERNAL_ERROR: return PackageInstaller.STATUS_FAILURE;
5906 case DELETE_FAILED_DEVICE_POLICY_MANAGER: return PackageInstaller.STATUS_FAILURE_BLOCKED;
5907 case DELETE_FAILED_USER_RESTRICTED: return PackageInstaller.STATUS_FAILURE_BLOCKED;
5908 case DELETE_FAILED_OWNER_BLOCKED: return PackageInstaller.STATUS_FAILURE_BLOCKED;
5909 case DELETE_FAILED_ABORTED: return PackageInstaller.STATUS_FAILURE_ABORTED;
Svet Ganov67882122016-12-11 16:36:34 -08005910 case DELETE_FAILED_USED_SHARED_LIBRARY: return PackageInstaller.STATUS_FAILURE_CONFLICT;
Jeff Sharkeya0907432014-08-15 10:23:11 -07005911 default: return PackageInstaller.STATUS_FAILURE;
Jeff Sharkeyf0600952014-08-07 17:31:53 -07005912 }
5913 }
Jeff Sharkey6c0b9da2014-08-07 22:07:11 -07005914
5915 /** {@hide} */
Svet Ganov77ab6a82015-07-03 12:03:02 -07005916 public static String permissionFlagToString(int flag) {
5917 switch (flag) {
Svetoslav4a5f4a22015-07-07 18:18:15 -07005918 case FLAG_PERMISSION_GRANTED_BY_DEFAULT: return "GRANTED_BY_DEFAULT";
5919 case FLAG_PERMISSION_POLICY_FIXED: return "POLICY_FIXED";
5920 case FLAG_PERMISSION_SYSTEM_FIXED: return "SYSTEM_FIXED";
5921 case FLAG_PERMISSION_USER_SET: return "USER_SET";
5922 case FLAG_PERMISSION_REVOKE_ON_UPGRADE: return "REVOKE_ON_UPGRADE";
5923 case FLAG_PERMISSION_USER_FIXED: return "USER_FIXED";
Svet Ganov9c165d72015-12-01 19:52:26 -08005924 case FLAG_PERMISSION_REVIEW_REQUIRED: return "REVIEW_REQUIRED";
Svet Ganov77ab6a82015-07-03 12:03:02 -07005925 default: return Integer.toString(flag);
5926 }
5927 }
5928
5929 /** {@hide} */
Jeff Sharkey6c0b9da2014-08-07 22:07:11 -07005930 public static class LegacyPackageDeleteObserver extends PackageDeleteObserver {
5931 private final IPackageDeleteObserver mLegacy;
5932
5933 public LegacyPackageDeleteObserver(IPackageDeleteObserver legacy) {
5934 mLegacy = legacy;
5935 }
5936
5937 @Override
5938 public void onPackageDeleted(String basePackageName, int returnCode, String msg) {
5939 if (mLegacy == null) return;
5940 try {
5941 mLegacy.packageDeleted(basePackageName, returnCode);
5942 } catch (RemoteException ignored) {
5943 }
5944 }
5945 }
Bartosz Fabianowskia34f53f2017-01-11 18:08:47 +01005946
5947 /**
Jeff Sharkey4347f812017-04-21 12:08:39 -06005948 * Return the install reason that was recorded when a package was first
5949 * installed for a specific user. Requesting the install reason for another
5950 * user will require the permission INTERACT_ACROSS_USERS_FULL.
Bartosz Fabianowskia34f53f2017-01-11 18:08:47 +01005951 *
5952 * @param packageName The package for which to retrieve the install reason
5953 * @param user The user for whom to retrieve the install reason
Jeff Sharkey4347f812017-04-21 12:08:39 -06005954 * @return The install reason. If the package is not installed for the given
5955 * user, {@code INSTALL_REASON_UNKNOWN} is returned.
Bartosz Fabianowskia34f53f2017-01-11 18:08:47 +01005956 * @hide
5957 */
5958 @TestApi
5959 public abstract @InstallReason int getInstallReason(String packageName,
5960 @NonNull UserHandle user);
Suprabh Shuklaaef25132017-01-23 18:09:03 -08005961
5962 /**
5963 * Checks whether the calling package is allowed to request package installs through package
Suprabh Shukla57528472017-04-14 19:22:45 -07005964 * installer. Apps are encouraged to call this API before launching the package installer via
Suprabh Shuklaaef25132017-01-23 18:09:03 -08005965 * intent {@link android.content.Intent#ACTION_INSTALL_PACKAGE}. Starting from Android O, the
5966 * user can explicitly choose what external sources they trust to install apps on the device.
Suprabh Shukla57528472017-04-14 19:22:45 -07005967 * If this API returns false, the install request will be blocked by the package installer and
Suprabh Shuklaaef25132017-01-23 18:09:03 -08005968 * a dialog will be shown to the user with an option to launch settings to change their
5969 * preference. An application must target Android O or higher and declare permission
Suprabh Shukla57528472017-04-14 19:22:45 -07005970 * {@link android.Manifest.permission#REQUEST_INSTALL_PACKAGES} in order to use this API.
Suprabh Shuklaaef25132017-01-23 18:09:03 -08005971 *
5972 * @return true if the calling package is trusted by the user to request install packages on
5973 * the device, false otherwise.
Suprabh Shukla57528472017-04-14 19:22:45 -07005974 * @see android.content.Intent#ACTION_INSTALL_PACKAGE
5975 * @see android.provider.Settings#ACTION_MANAGE_UNKNOWN_APP_SOURCES
Suprabh Shuklaaef25132017-01-23 18:09:03 -08005976 */
5977 public abstract boolean canRequestPackageInstalls();
Chad Brubakeraa49cb82017-03-24 15:53:09 -07005978
5979 /**
5980 * Return the {@link ComponentName} of the activity providing Settings for the Instant App
5981 * resolver.
5982 *
Todd Kennedy801e6592017-04-12 14:10:12 -07005983 * @see {@link android.content.Intent#ACTION_INSTANT_APP_RESOLVER_SETTINGS}
Chad Brubakeraa49cb82017-03-24 15:53:09 -07005984 * @hide
5985 */
5986 @SystemApi
5987 public abstract ComponentName getInstantAppResolverSettingsComponent();
Todd Kennedy801e6592017-04-12 14:10:12 -07005988
5989 /**
5990 * Return the {@link ComponentName} of the activity responsible for installing instant
5991 * applications.
5992 *
5993 * @see {@link android.content.Intent#ACTION_INSTALL_INSTANT_APP_PACKAGE}
5994 * @hide
5995 */
5996 @SystemApi
5997 public abstract ComponentName getInstantAppInstallerComponent();
Chad Brubaker0d277a72017-04-12 16:56:53 -07005998
5999 /**
6000 * Return the Android Id for a given Instant App.
6001 *
6002 * @see {@link android.provider.Settings.Secure#ANDROID_ID}
6003 * @hide
6004 */
6005 public abstract String getInstantAppAndroidId(String packageName, @NonNull UserHandle user);
Calin Juravle3d2af7f2017-04-19 19:56:21 -07006006
6007 /**
6008 * Callback use to notify the callers of module registration that the operation
6009 * has finished.
6010 *
6011 * @hide
6012 */
Jeff Sharkey90396362017-06-12 16:26:53 -06006013 @SystemApi
Calin Juravle3d2af7f2017-04-19 19:56:21 -07006014 public static abstract class DexModuleRegisterCallback {
6015 public abstract void onDexModuleRegistered(String dexModulePath, boolean success,
6016 String message);
6017 }
6018
6019 /**
6020 * Register an application dex module with the package manager.
6021 * The package manager will keep track of the given module for future optimizations.
6022 *
6023 * Dex module optimizations will disable the classpath checking at runtime. The client bares
6024 * the responsibility to ensure that the static assumptions on classes in the optimized code
6025 * hold at runtime (e.g. there's no duplicate classes in the classpath).
6026 *
6027 * Note that the package manager already keeps track of dex modules loaded with
6028 * {@link dalvik.system.DexClassLoader} and {@link dalvik.system.PathClassLoader}.
6029 * This can be called for an eager registration.
6030 *
6031 * The call might take a while and the results will be posted on the main thread, using
6032 * the given callback.
6033 *
6034 * If the module is intended to be shared with other apps, make sure that the file
6035 * permissions allow for it.
6036 * If at registration time the permissions allow for others to read it, the module would
6037 * be marked as a shared module which might undergo a different optimization strategy.
6038 * (usually shared modules will generated larger optimizations artifacts,
6039 * taking more disk space).
6040 *
6041 * @param dexModulePath the absolute path of the dex module.
6042 * @param callback if not null, {@link DexModuleRegisterCallback#onDexModuleRegistered} will
6043 * be called once the registration finishes.
6044 *
6045 * @hide
6046 */
Jeff Sharkey90396362017-06-12 16:26:53 -06006047 @SystemApi
Calin Juravle3d2af7f2017-04-19 19:56:21 -07006048 public abstract void registerDexModule(String dexModulePath,
6049 @Nullable DexModuleRegisterCallback callback);
Calin Juravle45f8b292017-11-07 18:49:43 -08006050
6051 /**
6052 * Returns the {@link ArtManager} associated with this package manager.
6053 *
6054 * @hide
6055 */
6056 @SystemApi
6057 public @NonNull ArtManager getArtManager() {
6058 throw new UnsupportedOperationException("getArtManager not implemented in subclass");
6059 }
Ben Gruver1ab3d6e2017-12-07 13:45:08 -08006060
6061 /**
6062 * Sets or clears the harmful app warning details for the given app.
6063 *
6064 * When set, any attempt to launch an activity in this package will be intercepted and a
6065 * warning dialog will be shown to the user instead, with the given warning. The user
6066 * will have the option to proceed with the activity launch, or to uninstall the application.
6067 *
6068 * @param packageName The full name of the package to warn on.
6069 * @param warning A warning string to display to the user describing the threat posed by the
6070 * application, or null to clear the warning.
6071 *
6072 * @hide
6073 */
6074 @RequiresPermission(Manifest.permission.SET_HARMFUL_APP_WARNINGS)
6075 @SystemApi
6076 public void setHarmfulAppWarning(@NonNull String packageName, @Nullable CharSequence warning) {
6077 throw new UnsupportedOperationException("setHarmfulAppWarning not implemented in subclass");
6078 }
6079
6080 /**
6081 * Returns the harmful app warning string for the given app, or null if there is none set.
6082 *
6083 * @param packageName The full name of the desired package.
6084 *
6085 * @hide
6086 */
6087 @RequiresPermission(Manifest.permission.SET_HARMFUL_APP_WARNINGS)
6088 @Nullable
6089 @SystemApi
6090 public CharSequence getHarmfulAppWarning(@NonNull String packageName) {
6091 throw new UnsupportedOperationException("getHarmfulAppWarning not implemented in subclass");
6092 }
Daniel Cashman5cdda342018-01-19 07:22:52 -08006093
6094 /** @hide */
6095 @IntDef(prefix = { "CERT_INPUT_" }, value = {
6096 CERT_INPUT_RAW_X509,
6097 CERT_INPUT_SHA256
6098 })
6099 @Retention(RetentionPolicy.SOURCE)
6100 public @interface CertificateInputType {}
6101
6102 /**
6103 * Certificate input bytes: the input bytes represent an encoded X.509 Certificate which could
6104 * be generated using an {@code CertificateFactory}
6105 */
6106 public static final int CERT_INPUT_RAW_X509 = 0;
6107
6108 /**
6109 * Certificate input bytes: the input bytes represent the SHA256 output of an encoded X.509
6110 * Certificate.
6111 */
6112 public static final int CERT_INPUT_SHA256 = 1;
6113
6114 /**
6115 * Searches the set of signing certificates by which the given package has proven to have been
6116 * signed. This should be used instead of {@code getPackageInfo} with {@code GET_SIGNATURES}
6117 * since it takes into account the possibility of signing certificate rotation, except in the
6118 * case of packages that are signed by multiple certificates, for which signing certificate
Daniel Cashmanbd8ce382018-04-02 16:59:19 -07006119 * rotation is not supported. This method is analogous to using {@code getPackageInfo} with
6120 * {@code GET_SIGNING_CERTIFICATES} and then searching through the resulting {@code
Dan Cashmane942b912018-04-16 14:41:24 -07006121 * signingInfo} field to see if the desired certificate is present.
Daniel Cashman5cdda342018-01-19 07:22:52 -08006122 *
6123 * @param packageName package whose signing certificates to check
6124 * @param certificate signing certificate for which to search
6125 * @param type representation of the {@code certificate}
6126 * @return true if this package was or is signed by exactly the certificate {@code certificate}
6127 */
6128 public boolean hasSigningCertificate(
6129 String packageName, byte[] certificate, @CertificateInputType int type) {
6130 throw new UnsupportedOperationException(
6131 "hasSigningCertificate not implemented in subclass");
6132 }
6133
6134 /**
Daniel Cashmanbd8ce382018-04-02 16:59:19 -07006135 * Searches the set of signing certificates by which the package(s) for the given uid has proven
6136 * to have been signed. For multiple packages sharing the same uid, this will return the
6137 * signing certificates found in the signing history of the "newest" package, where "newest"
6138 * indicates the package with the newest signing certificate in the shared uid group. This
6139 * method should be used instead of {@code getPackageInfo} with {@code GET_SIGNATURES}
Daniel Cashman5cdda342018-01-19 07:22:52 -08006140 * since it takes into account the possibility of signing certificate rotation, except in the
6141 * case of packages that are signed by multiple certificates, for which signing certificate
Daniel Cashmanbd8ce382018-04-02 16:59:19 -07006142 * rotation is not supported. This method is analogous to using {@code getPackagesForUid}
6143 * followed by {@code getPackageInfo} with {@code GET_SIGNING_CERTIFICATES}, selecting the
6144 * {@code PackageInfo} of the newest-signed bpackage , and finally searching through the
Dan Cashmane942b912018-04-16 14:41:24 -07006145 * resulting {@code signingInfo} field to see if the desired certificate is there.
Daniel Cashman5cdda342018-01-19 07:22:52 -08006146 *
Daniel Cashmanbd8ce382018-04-02 16:59:19 -07006147 * @param uid uid whose signing certificates to check
Daniel Cashman5cdda342018-01-19 07:22:52 -08006148 * @param certificate signing certificate for which to search
6149 * @param type representation of the {@code certificate}
6150 * @return true if this package was or is signed by exactly the certificate {@code certificate}
6151 */
6152 public boolean hasSigningCertificate(
6153 int uid, byte[] certificate, @CertificateInputType int type) {
6154 throw new UnsupportedOperationException(
6155 "hasSigningCertificate not implemented in subclass");
6156 }
Makoto Onuki700feef2018-02-15 10:59:41 -08006157
6158 /**
6159 * @return the system defined text classifier package name, or null if there's none.
6160 *
6161 * @hide
6162 */
6163 public String getSystemTextClassifierPackageName() {
6164 throw new UnsupportedOperationException(
6165 "getSystemTextClassifierPackageName not implemented in subclass");
6166 }
Benjamin Franz7cc9a812018-03-22 10:11:29 +00006167
6168 /**
6169 * @return whether a given package's state is protected, e.g. package cannot be disabled,
6170 * suspended, hidden or force stopped.
6171 *
6172 * @hide
6173 */
6174 public boolean isPackageStateProtected(String packageName, int userId) {
6175 throw new UnsupportedOperationException(
6176 "isPackageStateProtected not implemented in subclass");
6177 }
6178
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08006179}