blob: 08fccab6a5b246c72600a192a3b1a451f554d298 [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;
Jeff Sharkey6c0b9da2014-08-07 22:07:11 -070054import android.os.RemoteException;
Dianne Hackborn0c380492012-08-20 17:23:30 -070055import android.os.UserHandle;
Jeff Sharkey8a372a02016-03-16 16:25:45 -060056import android.os.UserManager;
Jeff Sharkey683bcd32017-03-18 17:54:51 -060057import android.os.storage.StorageManager;
Jeff Sharkeyb2b9ab82015-04-05 21:10:42 -070058import android.os.storage.VolumeInfo;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080059import android.util.AndroidException;
Jeff Sharkeybd940222016-01-08 11:07:13 -070060import android.util.Log;
Jeff Sharkeyb2b9ab82015-04-05 21:10:42 -070061
Svetoslavc6d1c342015-02-26 14:44:43 -080062import com.android.internal.util.ArrayUtils;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080063
Jeff Sharkey6f4b2a32017-03-21 14:13:41 -060064import dalvik.system.VMRuntime;
65
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080066import java.io.File;
Tor Norbyed9273d62013-05-30 15:59:53 -070067import java.lang.annotation.Retention;
68import java.lang.annotation.RetentionPolicy;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080069import java.util.List;
70
71/**
72 * Class for retrieving various kinds of information related to the application
73 * packages that are currently installed on the device.
74 *
75 * You can find this class through {@link Context#getPackageManager}.
76 */
77public abstract class PackageManager {
Jeff Sharkeybd940222016-01-08 11:07:13 -070078 private static final String TAG = "PackageManager";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080079
Jeff Sharkeye4697132016-02-06 19:46:15 -070080 /** {@hide} */
Jeff Sharkey8a372a02016-03-16 16:25:45 -060081 public static final boolean APPLY_DEFAULT_TO_DEVICE_PROTECTED_STORAGE = true;
Jeff Sharkeye4697132016-02-06 19:46:15 -070082
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080083 /**
84 * This exception is thrown when a given package, application, or component
kmccormick30498b42013-03-27 17:39:17 -070085 * name cannot be found.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080086 */
87 public static class NameNotFoundException extends AndroidException {
88 public NameNotFoundException() {
89 }
90
91 public NameNotFoundException(String name) {
92 super(name);
93 }
94 }
95
96 /**
Svetoslavf7c06eb2015-06-10 18:43:22 -070097 * Listener for changes in permissions granted to a UID.
98 *
99 * @hide
100 */
101 @SystemApi
102 public interface OnPermissionsChangedListener {
103
104 /**
105 * Called when the permissions for a UID change.
106 * @param uid The UID with a change.
107 */
108 public void onPermissionsChanged(int uid);
109 }
110
111 /**
Jeff Sharkey2f3e3532015-12-21 14:16:43 -0700112 * As a guiding principle:
113 * <p>
114 * {@code GET_} flags are used to request additional data that may have been
115 * elided to save wire space.
116 * <p>
117 * {@code MATCH_} flags are used to include components or packages that
118 * would have otherwise been omitted from a result set by current system
119 * state.
120 */
121
122 /** @hide */
Jeff Sharkey4347f812017-04-21 12:08:39 -0600123 @IntDef(flag = true, prefix = { "GET_", "MATCH_" }, value = {
Jeff Sharkey2f3e3532015-12-21 14:16:43 -0700124 GET_ACTIVITIES,
Todd Kennedy6b9bfa12016-01-08 13:44:51 -0800125 GET_CONFIGURATIONS,
126 GET_GIDS,
Jeff Sharkey2f3e3532015-12-21 14:16:43 -0700127 GET_INSTRUMENTATION,
128 GET_INTENT_FILTERS,
Jeff Sharkey2f3e3532015-12-21 14:16:43 -0700129 GET_META_DATA,
Jeff Sharkey2f3e3532015-12-21 14:16:43 -0700130 GET_PERMISSIONS,
Todd Kennedy6b9bfa12016-01-08 13:44:51 -0800131 GET_PROVIDERS,
132 GET_RECEIVERS,
133 GET_SERVICES,
134 GET_SHARED_LIBRARY_FILES,
135 GET_SIGNATURES,
Daniel Cashman5cdda342018-01-19 07:22:52 -0800136 GET_SIGNING_CERTIFICATES,
Todd Kennedy6b9bfa12016-01-08 13:44:51 -0800137 GET_URI_PERMISSION_PATTERNS,
Jeff Sharkey2f3e3532015-12-21 14:16:43 -0700138 MATCH_UNINSTALLED_PACKAGES,
139 MATCH_DISABLED_COMPONENTS,
140 MATCH_DISABLED_UNTIL_USED_COMPONENTS,
Jeff Sharkeyc5967e92016-01-07 18:50:29 -0700141 MATCH_SYSTEM_ONLY,
Todd Kennedyd6ee0ba2016-03-31 15:11:11 -0700142 MATCH_FACTORY_ONLY,
Jeff Sharkey2f3e3532015-12-21 14:16:43 -0700143 MATCH_DEBUG_TRIAGED_MISSING,
Todd Kennedy9c9fdf22017-03-06 10:58:27 -0800144 MATCH_INSTANT,
Todd Kennedy1f397f42016-06-28 12:14:11 -0700145 GET_DISABLED_COMPONENTS,
146 GET_DISABLED_UNTIL_USED_COMPONENTS,
147 GET_UNINSTALLED_PACKAGES,
Jeff Sharkey2f3e3532015-12-21 14:16:43 -0700148 })
149 @Retention(RetentionPolicy.SOURCE)
150 public @interface PackageInfoFlags {}
151
152 /** @hide */
Jeff Sharkey4347f812017-04-21 12:08:39 -0600153 @IntDef(flag = true, prefix = { "GET_", "MATCH_" }, value = {
Jeff Sharkey2f3e3532015-12-21 14:16:43 -0700154 GET_META_DATA,
155 GET_SHARED_LIBRARY_FILES,
156 MATCH_UNINSTALLED_PACKAGES,
157 MATCH_SYSTEM_ONLY,
158 MATCH_DEBUG_TRIAGED_MISSING,
Todd Kennedy24522022017-03-27 16:32:20 -0700159 MATCH_DISABLED_COMPONENTS,
Todd Kennedy5a32c6c2016-07-07 14:29:06 -0700160 MATCH_DISABLED_UNTIL_USED_COMPONENTS,
Todd Kennedy9c9fdf22017-03-06 10:58:27 -0800161 MATCH_INSTANT,
Svet Ganov9e779772017-05-11 14:36:50 -0700162 MATCH_STATIC_SHARED_LIBRARIES,
Todd Kennedy5a32c6c2016-07-07 14:29:06 -0700163 GET_DISABLED_UNTIL_USED_COMPONENTS,
Todd Kennedy1f397f42016-06-28 12:14:11 -0700164 GET_UNINSTALLED_PACKAGES,
Jeff Sharkey2f3e3532015-12-21 14:16:43 -0700165 })
166 @Retention(RetentionPolicy.SOURCE)
167 public @interface ApplicationInfoFlags {}
168
169 /** @hide */
Jeff Sharkey4347f812017-04-21 12:08:39 -0600170 @IntDef(flag = true, prefix = { "GET_", "MATCH_" }, value = {
Jeff Sharkey2f3e3532015-12-21 14:16:43 -0700171 GET_META_DATA,
172 GET_SHARED_LIBRARY_FILES,
Todd Kennedy6b9bfa12016-01-08 13:44:51 -0800173 MATCH_ALL,
174 MATCH_DEBUG_TRIAGED_MISSING,
175 MATCH_DEFAULT_ONLY,
Jeff Sharkey2f3e3532015-12-21 14:16:43 -0700176 MATCH_DISABLED_COMPONENTS,
177 MATCH_DISABLED_UNTIL_USED_COMPONENTS,
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600178 MATCH_DIRECT_BOOT_AWARE,
179 MATCH_DIRECT_BOOT_UNAWARE,
Jeff Sharkey2f3e3532015-12-21 14:16:43 -0700180 MATCH_SYSTEM_ONLY,
Todd Kennedy6b9bfa12016-01-08 13:44:51 -0800181 MATCH_UNINSTALLED_PACKAGES,
Todd Kennedy9c9fdf22017-03-06 10:58:27 -0800182 MATCH_INSTANT,
Svet Ganov9e779772017-05-11 14:36:50 -0700183 MATCH_STATIC_SHARED_LIBRARIES,
Todd Kennedy1f397f42016-06-28 12:14:11 -0700184 GET_DISABLED_COMPONENTS,
185 GET_DISABLED_UNTIL_USED_COMPONENTS,
186 GET_UNINSTALLED_PACKAGES,
Jeff Sharkey2f3e3532015-12-21 14:16:43 -0700187 })
188 @Retention(RetentionPolicy.SOURCE)
189 public @interface ComponentInfoFlags {}
190
191 /** @hide */
Jeff Sharkey4347f812017-04-21 12:08:39 -0600192 @IntDef(flag = true, prefix = { "GET_", "MATCH_" }, value = {
Jeff Sharkey2f3e3532015-12-21 14:16:43 -0700193 GET_META_DATA,
Jeff Sharkey2f3e3532015-12-21 14:16:43 -0700194 GET_RESOLVED_FILTER,
Todd Kennedy6b9bfa12016-01-08 13:44:51 -0800195 GET_SHARED_LIBRARY_FILES,
196 MATCH_ALL,
197 MATCH_DEBUG_TRIAGED_MISSING,
Jeff Sharkey2f3e3532015-12-21 14:16:43 -0700198 MATCH_DISABLED_COMPONENTS,
199 MATCH_DISABLED_UNTIL_USED_COMPONENTS,
Jeff Sharkey2f3e3532015-12-21 14:16:43 -0700200 MATCH_DEFAULT_ONLY,
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600201 MATCH_DIRECT_BOOT_AWARE,
202 MATCH_DIRECT_BOOT_UNAWARE,
Jeff Sharkey2f3e3532015-12-21 14:16:43 -0700203 MATCH_SYSTEM_ONLY,
Todd Kennedy6b9bfa12016-01-08 13:44:51 -0800204 MATCH_UNINSTALLED_PACKAGES,
Todd Kennedy9c9fdf22017-03-06 10:58:27 -0800205 MATCH_INSTANT,
Todd Kennedy1f397f42016-06-28 12:14:11 -0700206 GET_DISABLED_COMPONENTS,
207 GET_DISABLED_UNTIL_USED_COMPONENTS,
208 GET_UNINSTALLED_PACKAGES,
Jeff Sharkey2f3e3532015-12-21 14:16:43 -0700209 })
210 @Retention(RetentionPolicy.SOURCE)
211 public @interface ResolveInfoFlags {}
212
213 /** @hide */
Jeff Sharkey4347f812017-04-21 12:08:39 -0600214 @IntDef(flag = true, prefix = { "GET_", "MATCH_" }, value = {
Jeff Sharkey2f3e3532015-12-21 14:16:43 -0700215 GET_META_DATA,
216 })
217 @Retention(RetentionPolicy.SOURCE)
218 public @interface PermissionInfoFlags {}
219
220 /** @hide */
Jeff Sharkey4347f812017-04-21 12:08:39 -0600221 @IntDef(flag = true, prefix = { "GET_", "MATCH_" }, value = {
Jeff Sharkey2f3e3532015-12-21 14:16:43 -0700222 GET_META_DATA,
223 })
224 @Retention(RetentionPolicy.SOURCE)
225 public @interface PermissionGroupInfoFlags {}
226
227 /** @hide */
Jeff Sharkey4347f812017-04-21 12:08:39 -0600228 @IntDef(flag = true, prefix = { "GET_", "MATCH_" }, value = {
Jeff Sharkey2f3e3532015-12-21 14:16:43 -0700229 GET_META_DATA,
230 })
231 @Retention(RetentionPolicy.SOURCE)
232 public @interface InstrumentationInfoFlags {}
233
234 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800235 * {@link PackageInfo} flag: return information about
236 * activities in the package in {@link PackageInfo#activities}.
237 */
238 public static final int GET_ACTIVITIES = 0x00000001;
239
240 /**
241 * {@link PackageInfo} flag: return information about
242 * intent receivers in the package in
243 * {@link PackageInfo#receivers}.
244 */
245 public static final int GET_RECEIVERS = 0x00000002;
246
247 /**
248 * {@link PackageInfo} flag: return information about
249 * services in the package in {@link PackageInfo#services}.
250 */
251 public static final int GET_SERVICES = 0x00000004;
252
253 /**
254 * {@link PackageInfo} flag: return information about
255 * content providers in the package in
256 * {@link PackageInfo#providers}.
257 */
258 public static final int GET_PROVIDERS = 0x00000008;
259
260 /**
261 * {@link PackageInfo} flag: return information about
262 * instrumentation in the package in
263 * {@link PackageInfo#instrumentation}.
264 */
265 public static final int GET_INSTRUMENTATION = 0x00000010;
266
267 /**
268 * {@link PackageInfo} flag: return information about the
269 * intent filters supported by the activity.
270 */
271 public static final int GET_INTENT_FILTERS = 0x00000020;
272
273 /**
274 * {@link PackageInfo} flag: return information about the
275 * signatures included in the package.
Daniel Cashman5cdda342018-01-19 07:22:52 -0800276 *
277 * @deprecated use {@code GET_SIGNING_CERTIFICATES} instead
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800278 */
Daniel Cashman5cdda342018-01-19 07:22:52 -0800279 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800280 public static final int GET_SIGNATURES = 0x00000040;
281
282 /**
283 * {@link ResolveInfo} flag: return the IntentFilter that
284 * was matched for a particular ResolveInfo in
285 * {@link ResolveInfo#filter}.
286 */
287 public static final int GET_RESOLVED_FILTER = 0x00000040;
288
289 /**
290 * {@link ComponentInfo} flag: return the {@link ComponentInfo#metaData}
291 * data {@link android.os.Bundle}s that are associated with a component.
292 * This applies for any API returning a ComponentInfo subclass.
293 */
294 public static final int GET_META_DATA = 0x00000080;
295
296 /**
297 * {@link PackageInfo} flag: return the
298 * {@link PackageInfo#gids group ids} that are associated with an
299 * application.
Ken Wakasaf76a50c2012-03-09 19:56:35 +0900300 * This applies for any API returning a PackageInfo class, either
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800301 * directly or nested inside of another.
302 */
303 public static final int GET_GIDS = 0x00000100;
304
305 /**
Jeff Sharkey2f3e3532015-12-21 14:16:43 -0700306 * @deprecated replaced with {@link #MATCH_DISABLED_COMPONENTS}
307 */
308 @Deprecated
309 public static final int GET_DISABLED_COMPONENTS = 0x00000200;
310
311 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800312 * {@link PackageInfo} flag: include disabled components in the returned info.
313 */
Jeff Sharkey2f3e3532015-12-21 14:16:43 -0700314 public static final int MATCH_DISABLED_COMPONENTS = 0x00000200;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800315
316 /**
317 * {@link ApplicationInfo} flag: return the
318 * {@link ApplicationInfo#sharedLibraryFiles paths to the shared libraries}
319 * that are associated with an application.
320 * This applies for any API returning an ApplicationInfo class, either
321 * directly or nested inside of another.
322 */
323 public static final int GET_SHARED_LIBRARY_FILES = 0x00000400;
324
325 /**
326 * {@link ProviderInfo} flag: return the
327 * {@link ProviderInfo#uriPermissionPatterns URI permission patterns}
328 * that are associated with a content provider.
Ken Wakasaf76a50c2012-03-09 19:56:35 +0900329 * This applies for any API returning a ProviderInfo class, either
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800330 * directly or nested inside of another.
331 */
332 public static final int GET_URI_PERMISSION_PATTERNS = 0x00000800;
333 /**
334 * {@link PackageInfo} flag: return information about
335 * permissions in the package in
336 * {@link PackageInfo#permissions}.
337 */
338 public static final int GET_PERMISSIONS = 0x00001000;
Amith Yamasani4b2e9342011-03-31 12:38:53 -0700339
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800340 /**
Jeff Sharkey2f3e3532015-12-21 14:16:43 -0700341 * @deprecated replaced with {@link #MATCH_UNINSTALLED_PACKAGES}
342 */
343 @Deprecated
344 public static final int GET_UNINSTALLED_PACKAGES = 0x00002000;
345
346 /**
Kenny Root685f4902011-11-03 10:13:29 -0700347 * Flag parameter to retrieve some information about all applications (even
348 * uninstalled ones) which have data directories. This state could have
349 * resulted if applications have been deleted with flag
350 * {@code DONT_DELETE_DATA} with a possibility of being replaced or
351 * reinstalled in future.
352 * <p>
353 * Note: this flag may cause less information about currently installed
354 * applications to be returned.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800355 */
Jeff Sharkey2f3e3532015-12-21 14:16:43 -0700356 public static final int MATCH_UNINSTALLED_PACKAGES = 0x00002000;
Amith Yamasani4b2e9342011-03-31 12:38:53 -0700357
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800358 /**
359 * {@link PackageInfo} flag: return information about
Dianne Hackborn49237342009-08-27 20:08:01 -0700360 * hardware preferences in
Adam Lesinskid3edfde2014-08-08 17:32:44 -0700361 * {@link PackageInfo#configPreferences PackageInfo.configPreferences},
362 * and requested features in {@link PackageInfo#reqFeatures} and
363 * {@link PackageInfo#featureGroups}.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800364 */
365 public static final int GET_CONFIGURATIONS = 0x00004000;
366
367 /**
Jeff Sharkey2f3e3532015-12-21 14:16:43 -0700368 * @deprecated replaced with {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}.
369 */
370 @Deprecated
371 public static final int GET_DISABLED_UNTIL_USED_COMPONENTS = 0x00008000;
372
373 /**
Dianne Hackbornfd7aded2013-01-22 17:10:23 -0800374 * {@link PackageInfo} flag: include disabled components which are in
375 * that state only because of {@link #COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED}
376 * in the returned info. Note that if you set this flag, applications
377 * that are in this disabled state will be reported as enabled.
378 */
Jeff Sharkey2f3e3532015-12-21 14:16:43 -0700379 public static final int MATCH_DISABLED_UNTIL_USED_COMPONENTS = 0x00008000;
Dianne Hackbornfd7aded2013-01-22 17:10:23 -0800380
381 /**
Dianne Hackborn1655be42009-05-08 14:29:01 -0700382 * Resolution and querying flag: if set, only filters that support the
383 * {@link android.content.Intent#CATEGORY_DEFAULT} will be considered for
384 * matching. This is a synonym for including the CATEGORY_DEFAULT in your
385 * supplied Intent.
386 */
Fabrice Di Meglio9f7e39f2015-04-10 20:40:16 -0700387 public static final int MATCH_DEFAULT_ONLY = 0x00010000;
388
389 /**
Jeff Sharkey2f3e3532015-12-21 14:16:43 -0700390 * Querying flag: if set and if the platform is doing any filtering of the
391 * results, then the filtering will not happen. This is a synonym for saying
392 * that all results should be returned.
393 * <p>
394 * <em>This flag should be used with extreme care.</em>
Fabrice Di Meglio9f7e39f2015-04-10 20:40:16 -0700395 */
396 public static final int MATCH_ALL = 0x00020000;
Dianne Hackborn1655be42009-05-08 14:29:01 -0700397
Nicolas Prevot63798c52014-05-27 13:22:38 +0100398 /**
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600399 * Querying flag: match components which are direct boot <em>unaware</em> in
Jeff Sharkey2f3e3532015-12-21 14:16:43 -0700400 * the returned info, regardless of the current user state.
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600401 * <p>
402 * When neither {@link #MATCH_DIRECT_BOOT_AWARE} nor
403 * {@link #MATCH_DIRECT_BOOT_UNAWARE} are specified, the default behavior is
404 * to match only runnable components based on the user state. For example,
405 * when a user is started but credentials have not been presented yet, the
406 * user is running "locked" and only {@link #MATCH_DIRECT_BOOT_AWARE}
407 * components are returned. Once the user credentials have been presented,
408 * the user is running "unlocked" and both {@link #MATCH_DIRECT_BOOT_AWARE}
409 * and {@link #MATCH_DIRECT_BOOT_UNAWARE} components are returned.
410 *
411 * @see UserManager#isUserUnlocked()
Jeff Sharkeye17ac152015-11-06 22:40:29 -0800412 */
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600413 public static final int MATCH_DIRECT_BOOT_UNAWARE = 0x00040000;
414
415 /**
416 * Querying flag: match components which are direct boot <em>aware</em> in
417 * the returned info, regardless of the current user state.
418 * <p>
419 * When neither {@link #MATCH_DIRECT_BOOT_AWARE} nor
420 * {@link #MATCH_DIRECT_BOOT_UNAWARE} are specified, the default behavior is
421 * to match only runnable components based on the user state. For example,
422 * when a user is started but credentials have not been presented yet, the
423 * user is running "locked" and only {@link #MATCH_DIRECT_BOOT_AWARE}
424 * components are returned. Once the user credentials have been presented,
425 * the user is running "unlocked" and both {@link #MATCH_DIRECT_BOOT_AWARE}
426 * and {@link #MATCH_DIRECT_BOOT_UNAWARE} components are returned.
427 *
428 * @see UserManager#isUserUnlocked()
429 */
430 public static final int MATCH_DIRECT_BOOT_AWARE = 0x00080000;
431
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -0700432 /**
Jeff Sharkey2f3e3532015-12-21 14:16:43 -0700433 * Querying flag: include only components from applications that are marked
434 * with {@link ApplicationInfo#FLAG_SYSTEM}.
Jeff Sharkey5217cac2015-12-20 15:34:01 -0700435 */
436 public static final int MATCH_SYSTEM_ONLY = 0x00100000;
437
438 /**
Todd Kennedyd6ee0ba2016-03-31 15:11:11 -0700439 * Internal {@link PackageInfo} flag: include only components on the system image.
440 * This will not return information on any unbundled update to system components.
441 * @hide
442 */
Todd Kennedy49084962017-03-27 16:20:37 -0700443 @SystemApi
Fyodor Kupolove5698042018-01-26 14:24:37 -0800444 @TestApi
Todd Kennedyd6ee0ba2016-03-31 15:11:11 -0700445 public static final int MATCH_FACTORY_ONLY = 0x00200000;
446
447 /**
Amith Yamasani0d1fd8d2016-10-12 14:21:51 -0700448 * Allows querying of packages installed for any user, not just the specific one. This flag
Amith Yamasani475f9a32016-12-08 09:46:15 -0800449 * is only meant for use by apps that have INTERACT_ACROSS_USERS permission.
Amith Yamasani0d1fd8d2016-10-12 14:21:51 -0700450 * @hide
451 */
Amith Yamasani475f9a32016-12-08 09:46:15 -0800452 @SystemApi
Amith Yamasani0d1fd8d2016-10-12 14:21:51 -0700453 public static final int MATCH_ANY_USER = 0x00400000;
454
455 /**
456 * Combination of MATCH_ANY_USER and MATCH_UNINSTALLED_PACKAGES to mean any known
457 * package.
458 * @hide
459 */
460 public static final int MATCH_KNOWN_PACKAGES = MATCH_UNINSTALLED_PACKAGES | MATCH_ANY_USER;
461
462 /**
Todd Kennedy7bc3a702016-12-08 14:54:48 -0800463 * Internal {@link PackageInfo} flag: include components that are part of an
Todd Kennedybe0b8892017-02-15 14:13:52 -0800464 * instant app. By default, instant app components are not matched.
Todd Kennedy7bc3a702016-12-08 14:54:48 -0800465 * @hide
466 */
Todd Kennedy9c9fdf22017-03-06 10:58:27 -0800467 @SystemApi
Todd Kennedybe0b8892017-02-15 14:13:52 -0800468 public static final int MATCH_INSTANT = 0x00800000;
Todd Kennedy7bc3a702016-12-08 14:54:48 -0800469
470 /**
471 * Internal {@link PackageInfo} flag: include only components that are exposed to
Todd Kennedyc05f5d12017-04-25 11:11:40 -0700472 * instant apps. Matched components may have been either explicitly or implicitly
473 * exposed.
Todd Kennedy7bc3a702016-12-08 14:54:48 -0800474 * @hide
475 */
Todd Kennedybe0b8892017-02-15 14:13:52 -0800476 public static final int MATCH_VISIBLE_TO_INSTANT_APP_ONLY = 0x01000000;
Todd Kennedy7bc3a702016-12-08 14:54:48 -0800477
478 /**
Todd Kennedyc05f5d12017-04-25 11:11:40 -0700479 * Internal {@link PackageInfo} flag: include only components that have been
480 * explicitly exposed to instant apps.
481 * @hide
482 */
483 public static final int MATCH_EXPLICITLY_VISIBLE_ONLY = 0x02000000;
484
485 /**
Svet Ganov9e779772017-05-11 14:36:50 -0700486 * Internal {@link PackageInfo} flag: include static shared libraries.
487 * Apps that depend on static shared libs can always access the version
488 * of the lib they depend on. System/shell/root can access all shared
489 * libs regardless of dependency but need to explicitly ask for them
490 * via this flag.
491 * @hide
492 */
493 public static final int MATCH_STATIC_SHARED_LIBRARIES = 0x04000000;
494
495 /**
Daniel Cashman5cdda342018-01-19 07:22:52 -0800496 * {@link PackageInfo} flag: return the signing certificates associated with
497 * this package. Each entry is a signing certificate that the package
498 * has proven it is authorized to use, usually a past signing certificate from
499 * which it has rotated.
500 */
501 public static final int GET_SIGNING_CERTIFICATES = 0x08000000;
502
503 /**
Jeff Sharkey2f3e3532015-12-21 14:16:43 -0700504 * Internal flag used to indicate that a system component has done their
505 * homework and verified that they correctly handle packages and components
506 * that come and go over time. In particular:
507 * <ul>
508 * <li>Apps installed on external storage, which will appear to be
509 * uninstalled while the the device is ejected.
510 * <li>Apps with encryption unaware components, which will appear to not
511 * exist while the device is locked.
512 * </ul>
Jeff Sharkeye17ac152015-11-06 22:40:29 -0800513 *
Jeff Sharkey2f3e3532015-12-21 14:16:43 -0700514 * @see #MATCH_UNINSTALLED_PACKAGES
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600515 * @see #MATCH_DIRECT_BOOT_AWARE
516 * @see #MATCH_DIRECT_BOOT_UNAWARE
Jeff Sharkeye17ac152015-11-06 22:40:29 -0800517 * @hide
518 */
Jeff Sharkey2f3e3532015-12-21 14:16:43 -0700519 public static final int MATCH_DEBUG_TRIAGED_MISSING = 0x10000000;
Jeff Sharkeye17ac152015-11-06 22:40:29 -0800520
521 /**
Jeff Sharkey5aa86932016-01-08 19:07:49 -0700522 * Flag for {@link #addCrossProfileIntentFilter}: if this flag is set: when
523 * resolving an intent that matches the {@code CrossProfileIntentFilter},
524 * the current profile will be skipped. Only activities in the target user
525 * can respond to the intent.
526 *
Nicolas Prevot63798c52014-05-27 13:22:38 +0100527 * @hide
528 */
529 public static final int SKIP_CURRENT_PROFILE = 0x00000002;
530
Tony Mak807e01c2015-12-01 20:19:03 +0000531 /**
Jeff Sharkey5aa86932016-01-08 19:07:49 -0700532 * Flag for {@link #addCrossProfileIntentFilter}: if this flag is set:
Tony Mak807e01c2015-12-01 20:19:03 +0000533 * activities in the other profiles can respond to the intent only if no activity with
534 * non-negative priority in current profile can respond to the intent.
535 * @hide
536 */
537 public static final int ONLY_IF_NO_MATCH_FOUND = 0x00000004;
538
Tor Norbyed9273d62013-05-30 15:59:53 -0700539 /** @hide */
Jeff Sharkey4347f812017-04-21 12:08:39 -0600540 @IntDef(prefix = { "PERMISSION_" }, value = {
541 PERMISSION_GRANTED,
542 PERMISSION_DENIED
543 })
Tor Norbyed9273d62013-05-30 15:59:53 -0700544 @Retention(RetentionPolicy.SOURCE)
545 public @interface PermissionResult {}
546
Dianne Hackborn1655be42009-05-08 14:29:01 -0700547 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800548 * Permission check result: this is returned by {@link #checkPermission}
549 * if the permission has been granted to the given package.
550 */
551 public static final int PERMISSION_GRANTED = 0;
552
553 /**
554 * Permission check result: this is returned by {@link #checkPermission}
555 * if the permission has not been granted to the given package.
556 */
557 public static final int PERMISSION_DENIED = -1;
558
Jeff Sharkey30e06bb2017-04-24 11:18:03 -0600559 /** @hide */
560 @IntDef(prefix = { "SIGNATURE_" }, value = {
561 SIGNATURE_MATCH,
562 SIGNATURE_NEITHER_SIGNED,
563 SIGNATURE_FIRST_NOT_SIGNED,
564 SIGNATURE_SECOND_NOT_SIGNED,
565 SIGNATURE_NO_MATCH,
566 SIGNATURE_UNKNOWN_PACKAGE,
567 })
568 @Retention(RetentionPolicy.SOURCE)
569 public @interface SignatureResult {}
570
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800571 /**
572 * Signature check result: this is returned by {@link #checkSignatures}
Chris Palmer09f33602010-09-13 14:27:18 -0700573 * if all signatures on the two packages match.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800574 */
575 public static final int SIGNATURE_MATCH = 0;
576
577 /**
578 * Signature check result: this is returned by {@link #checkSignatures}
579 * if neither of the two packages is signed.
580 */
581 public static final int SIGNATURE_NEITHER_SIGNED = 1;
582
583 /**
584 * Signature check result: this is returned by {@link #checkSignatures}
Chris Palmer09f33602010-09-13 14:27:18 -0700585 * if the first package is not signed but the second is.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800586 */
587 public static final int SIGNATURE_FIRST_NOT_SIGNED = -1;
588
589 /**
590 * Signature check result: this is returned by {@link #checkSignatures}
Chris Palmer09f33602010-09-13 14:27:18 -0700591 * if the second package is not signed but the first is.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800592 */
593 public static final int SIGNATURE_SECOND_NOT_SIGNED = -2;
594
595 /**
596 * Signature check result: this is returned by {@link #checkSignatures}
Chris Palmer09f33602010-09-13 14:27:18 -0700597 * if not all signatures on both packages match.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800598 */
599 public static final int SIGNATURE_NO_MATCH = -3;
600
601 /**
602 * Signature check result: this is returned by {@link #checkSignatures}
Chris Palmer09f33602010-09-13 14:27:18 -0700603 * if either of the packages are not valid.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800604 */
605 public static final int SIGNATURE_UNKNOWN_PACKAGE = -4;
606
Jeff Sharkey30e06bb2017-04-24 11:18:03 -0600607 /** @hide */
608 @IntDef(prefix = { "COMPONENT_ENABLED_STATE_" }, value = {
609 COMPONENT_ENABLED_STATE_DEFAULT,
610 COMPONENT_ENABLED_STATE_ENABLED,
611 COMPONENT_ENABLED_STATE_DISABLED,
612 COMPONENT_ENABLED_STATE_DISABLED_USER,
613 COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED,
614 })
615 @Retention(RetentionPolicy.SOURCE)
616 public @interface EnabledState {}
617
Dianne Hackborn0ac30312011-06-17 14:49:23 -0700618 /**
Jeff Sharkey30e06bb2017-04-24 11:18:03 -0600619 * Flag for {@link #setApplicationEnabledSetting(String, int, int)} and
620 * {@link #setComponentEnabledSetting(ComponentName, int, int)}: This
621 * component or application is in its default enabled state (as specified in
622 * its manifest).
623 * <p>
624 * Explicitly setting the component state to this value restores it's
625 * enabled state to whatever is set in the manifest.
Dianne Hackborn0ac30312011-06-17 14:49:23 -0700626 */
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800627 public static final int COMPONENT_ENABLED_STATE_DEFAULT = 0;
Dianne Hackborn0ac30312011-06-17 14:49:23 -0700628
629 /**
630 * Flag for {@link #setApplicationEnabledSetting(String, int, int)}
631 * and {@link #setComponentEnabledSetting(ComponentName, int, int)}: This
632 * component or application has been explictily enabled, regardless of
633 * what it has specified in its manifest.
634 */
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800635 public static final int COMPONENT_ENABLED_STATE_ENABLED = 1;
Dianne Hackborn0ac30312011-06-17 14:49:23 -0700636
637 /**
638 * Flag for {@link #setApplicationEnabledSetting(String, int, int)}
639 * and {@link #setComponentEnabledSetting(ComponentName, int, int)}: This
640 * component or application has been explicitly disabled, regardless of
641 * what it has specified in its manifest.
642 */
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800643 public static final int COMPONENT_ENABLED_STATE_DISABLED = 2;
644
645 /**
Dianne Hackborn0ac30312011-06-17 14:49:23 -0700646 * Flag for {@link #setApplicationEnabledSetting(String, int, int)} only: The
647 * user has explicitly disabled the application, regardless of what it has
648 * specified in its manifest. Because this is due to the user's request,
649 * they may re-enable it if desired through the appropriate system UI. This
kmccormick30498b42013-03-27 17:39:17 -0700650 * option currently <strong>cannot</strong> be used with
Dianne Hackborn0ac30312011-06-17 14:49:23 -0700651 * {@link #setComponentEnabledSetting(ComponentName, int, int)}.
652 */
653 public static final int COMPONENT_ENABLED_STATE_DISABLED_USER = 3;
654
655 /**
Dianne Hackbornfd7aded2013-01-22 17:10:23 -0800656 * Flag for {@link #setApplicationEnabledSetting(String, int, int)} only: This
657 * application should be considered, until the point where the user actually
658 * wants to use it. This means that it will not normally show up to the user
659 * (such as in the launcher), but various parts of the user interface can
660 * use {@link #GET_DISABLED_UNTIL_USED_COMPONENTS} to still see it and allow
661 * the user to select it (as for example an IME, device admin, etc). Such code,
662 * once the user has selected the app, should at that point also make it enabled.
663 * This option currently <strong>can not</strong> be used with
664 * {@link #setComponentEnabledSetting(ComponentName, int, int)}.
665 */
666 public static final int COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED = 4;
667
Jeff Sharkey5aa86932016-01-08 19:07:49 -0700668 /** @hide */
Jeff Sharkey4347f812017-04-21 12:08:39 -0600669 @IntDef(flag = true, prefix = { "INSTALL_" }, value = {
Jeff Sharkey5aa86932016-01-08 19:07:49 -0700670 INSTALL_FORWARD_LOCK,
671 INSTALL_REPLACE_EXISTING,
672 INSTALL_ALLOW_TEST,
673 INSTALL_EXTERNAL,
674 INSTALL_INTERNAL,
675 INSTALL_FROM_ADB,
676 INSTALL_ALL_USERS,
677 INSTALL_ALLOW_DOWNGRADE,
678 INSTALL_GRANT_RUNTIME_PERMISSIONS,
679 INSTALL_FORCE_VOLUME_UUID,
680 INSTALL_FORCE_PERMISSION_PROMPT,
Todd Kennedybe0b8892017-02-15 14:13:52 -0800681 INSTALL_INSTANT_APP,
Todd Kennedy39bfee52016-02-24 10:28:21 -0800682 INSTALL_DONT_KILL_APP,
Jeff Sharkey683bcd32017-03-18 17:54:51 -0600683 INSTALL_FORCE_SDK,
684 INSTALL_FULL_APP,
685 INSTALL_ALLOCATE_AGGRESSIVE,
Jeff Sharkey5aa86932016-01-08 19:07:49 -0700686 })
687 @Retention(RetentionPolicy.SOURCE)
688 public @interface InstallFlags {}
689
Dianne Hackbornfd7aded2013-01-22 17:10:23 -0800690 /**
Jeff Sharkey5aa86932016-01-08 19:07:49 -0700691 * Flag parameter for {@link #installPackage} to indicate that this package
692 * should be installed as forward locked, i.e. only the app itself should
693 * have access to its code and non-resource assets.
694 *
Jeff Sharkey8c61e392017-02-24 09:22:48 -0700695 * @deprecated new installs into ASEC containers are no longer supported.
Dianne Hackbornade3eca2009-05-11 18:54:45 -0700696 * @hide
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800697 */
Jeff Sharkey8c61e392017-02-24 09:22:48 -0700698 @Deprecated
Dianne Hackbornade3eca2009-05-11 18:54:45 -0700699 public static final int INSTALL_FORWARD_LOCK = 0x00000001;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800700
701 /**
Jeff Sharkey5aa86932016-01-08 19:07:49 -0700702 * Flag parameter for {@link #installPackage} to indicate that you want to
703 * replace an already installed package, if one exists.
704 *
Dianne Hackbornade3eca2009-05-11 18:54:45 -0700705 * @hide
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800706 */
Dianne Hackbornade3eca2009-05-11 18:54:45 -0700707 public static final int INSTALL_REPLACE_EXISTING = 0x00000002;
708
709 /**
Amith Yamasani4b2e9342011-03-31 12:38:53 -0700710 * Flag parameter for {@link #installPackage} to indicate that you want to
Dianne Hackbornade3eca2009-05-11 18:54:45 -0700711 * allow test packages (those that have set android:testOnly in their
712 * manifest) to be installed.
713 * @hide
714 */
715 public static final int INSTALL_ALLOW_TEST = 0x00000004;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800716
717 /**
Jeff Sharkeyb2b9ab82015-04-05 21:10:42 -0700718 * Flag parameter for {@link #installPackage} to indicate that this package
719 * must be installed to an ASEC on a {@link VolumeInfo#TYPE_PUBLIC}.
720 *
Jeff Sharkey8c61e392017-02-24 09:22:48 -0700721 * @deprecated new installs into ASEC containers are no longer supported;
722 * use adoptable storage instead.
Suchi Amalapurapuaf8e9f42010-01-12 10:17:28 -0800723 * @hide
724 */
Jeff Sharkey8c61e392017-02-24 09:22:48 -0700725 @Deprecated
Suchi Amalapurapu5b993ce2010-02-12 09:43:29 -0800726 public static final int INSTALL_EXTERNAL = 0x00000008;
Oscar Montemayor539d3c42010-01-29 15:27:00 -0800727
728 /**
Kenny Root5ab21572011-07-27 11:11:19 -0700729 * Flag parameter for {@link #installPackage} to indicate that this package
Jeff Sharkeyb2b9ab82015-04-05 21:10:42 -0700730 * must be installed to internal storage.
731 *
Kenny Root5ab21572011-07-27 11:11:19 -0700732 * @hide
733 */
734 public static final int INSTALL_INTERNAL = 0x00000010;
735
736 /**
737 * Flag parameter for {@link #installPackage} to indicate that this install
738 * was initiated via ADB.
739 *
740 * @hide
741 */
742 public static final int INSTALL_FROM_ADB = 0x00000020;
Suchi Amalapurapu14b6abd2010-03-17 08:37:04 -0700743
744 /**
Dianne Hackborn7767eac2012-08-23 18:25:40 -0700745 * Flag parameter for {@link #installPackage} to indicate that this install
746 * should immediately be visible to all users.
747 *
748 * @hide
749 */
750 public static final int INSTALL_ALL_USERS = 0x00000040;
751
752 /**
753 * Flag parameter for {@link #installPackage} to indicate that it is okay
754 * to install an update to an app where the newly installed app has a lower
Alex Klyubin921dd752016-02-24 13:21:41 -0800755 * version code than the currently installed app. This is permitted only if
756 * the currently installed app is marked debuggable.
Dianne Hackborn7767eac2012-08-23 18:25:40 -0700757 *
758 * @hide
759 */
760 public static final int INSTALL_ALLOW_DOWNGRADE = 0x00000080;
761
762 /**
Svet Ganov95c1ade2015-03-19 09:38:52 -0700763 * Flag parameter for {@link #installPackage} to indicate that all runtime
764 * permissions should be granted to the package. If {@link #INSTALL_ALL_USERS}
765 * is set the runtime permissions will be granted to all users, otherwise
766 * only to the owner.
767 *
768 * @hide
769 */
770 public static final int INSTALL_GRANT_RUNTIME_PERMISSIONS = 0x00000100;
771
Jeff Sharkeyab234092015-06-09 21:42:22 -0700772 /** {@hide} */
773 public static final int INSTALL_FORCE_VOLUME_UUID = 0x00000200;
774
Svet Ganov95c1ade2015-03-19 09:38:52 -0700775 /**
Todd Kennedya1d12cf2015-09-29 15:43:00 -0700776 * Flag parameter for {@link #installPackage} to indicate that we always want to force
777 * the prompt for permission approval. This overrides any special behaviour for internal
778 * components.
779 *
780 * @hide
781 */
782 public static final int INSTALL_FORCE_PERMISSION_PROMPT = 0x00000400;
783
784 /**
Todd Kennedy27c24fb2015-09-17 16:49:25 -0700785 * Flag parameter for {@link #installPackage} to indicate that this package is
Todd Kennedy2699f062015-11-20 13:07:17 -0800786 * to be installed as a lightweight "ephemeral" app.
787 *
788 * @hide
789 */
Todd Kennedybe0b8892017-02-15 14:13:52 -0800790 public static final int INSTALL_INSTANT_APP = 0x00000800;
791
792 /**
Todd Kennedy39bfee52016-02-24 10:28:21 -0800793 * Flag parameter for {@link #installPackage} to indicate that this package contains
794 * a feature split to an existing application and the existing application should not
795 * be killed during the installation process.
796 *
797 * @hide
798 */
799 public static final int INSTALL_DONT_KILL_APP = 0x00001000;
800
801 /**
Todd Kennedyb1072712016-04-26 15:41:20 -0700802 * Flag parameter for {@link #installPackage} to indicate that this package is an
Patrick Baumannccb20b82018-01-08 13:22:46 -0800803 * upgrade to a package that refers to the SDK via release letter or is targeting an SDK via
804 * release letter that the current build does not support.
Todd Kennedyb1072712016-04-26 15:41:20 -0700805 *
806 * @hide
807 */
808 public static final int INSTALL_FORCE_SDK = 0x00002000;
809
810 /**
Jeff Sharkey683bcd32017-03-18 17:54:51 -0600811 * Flag parameter for {@link #installPackage} to indicate that this package is
812 * to be installed as a heavy weight app. This is fundamentally the opposite of
813 * {@link #INSTALL_INSTANT_APP}.
814 *
815 * @hide
816 */
817 public static final int INSTALL_FULL_APP = 0x00004000;
818
819 /**
820 * Flag parameter for {@link #installPackage} to indicate that this package
821 * is critical to system health or security, meaning the system should use
822 * {@link StorageManager#FLAG_ALLOCATE_AGGRESSIVE} internally.
823 *
824 * @hide
825 */
826 public static final int INSTALL_ALLOCATE_AGGRESSIVE = 0x00008000;
827
Todd Kennedy78a72502017-07-19 12:49:30 -0700828 /**
829 * Flag parameter for {@link #installPackage} to indicate that this package
830 * is a virtual preload.
831 *
832 * @hide
833 */
834 public static final int INSTALL_VIRTUAL_PRELOAD = 0x00010000;
835
Jeff Sharkey30e06bb2017-04-24 11:18:03 -0600836 /** @hide */
837 @IntDef(flag = true, prefix = { "DONT_KILL_APP" }, value = {
838 DONT_KILL_APP
839 })
840 @Retention(RetentionPolicy.SOURCE)
841 public @interface EnabledFlags {}
842
Jeff Sharkey683bcd32017-03-18 17:54:51 -0600843 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800844 * Flag parameter for
845 * {@link #setComponentEnabledSetting(android.content.ComponentName, int, int)} to indicate
846 * that you don't want to kill the app containing the component. Be careful when you set this
847 * since changing component states can make the containing application's behavior unpredictable.
848 */
849 public static final int DONT_KILL_APP = 0x00000001;
850
Bartosz Fabianowskia34f53f2017-01-11 18:08:47 +0100851 /** @hide */
Jeff Sharkey4347f812017-04-21 12:08:39 -0600852 @IntDef(prefix = { "INSTALL_REASON_" }, value = {
853 INSTALL_REASON_UNKNOWN,
854 INSTALL_REASON_POLICY,
855 INSTALL_REASON_DEVICE_RESTORE,
856 INSTALL_REASON_DEVICE_SETUP,
857 INSTALL_REASON_USER
858 })
Bartosz Fabianowskia34f53f2017-01-11 18:08:47 +0100859 @Retention(RetentionPolicy.SOURCE)
860 public @interface InstallReason {}
861
862 /**
863 * Code indicating that the reason for installing this package is unknown.
864 */
865 public static final int INSTALL_REASON_UNKNOWN = 0;
866
867 /**
868 * Code indicating that this package was installed due to enterprise policy.
869 */
870 public static final int INSTALL_REASON_POLICY = 1;
871
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800872 /**
Sunny Goyal80af6a22017-03-02 08:32:33 -0800873 * Code indicating that this package was installed as part of restoring from another device.
874 */
875 public static final int INSTALL_REASON_DEVICE_RESTORE = 2;
876
877 /**
878 * Code indicating that this package was installed as part of device setup.
879 */
880 public static final int INSTALL_REASON_DEVICE_SETUP = 3;
881
882 /**
883 * Code indicating that the package installation was initiated by the user.
884 */
885 public static final int INSTALL_REASON_USER = 4;
886
887 /**
Philip P. Moltmannb13f1532017-11-14 08:34:06 -0800888 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
889 * on success.
Jeff Sharkey5aa86932016-01-08 19:07:49 -0700890 *
Dianne Hackbornade3eca2009-05-11 18:54:45 -0700891 * @hide
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800892 */
Jeff Brownd5a5b5a2014-06-05 17:14:39 -0700893 @SystemApi
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800894 public static final int INSTALL_SUCCEEDED = 1;
895
896 /**
Philip P. Moltmannb13f1532017-11-14 08:34:06 -0800897 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
898 * if the package is already installed.
Jeff Sharkey5aa86932016-01-08 19:07:49 -0700899 *
Dianne Hackbornade3eca2009-05-11 18:54:45 -0700900 * @hide
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800901 */
Jeff Brownd5a5b5a2014-06-05 17:14:39 -0700902 @SystemApi
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800903 public static final int INSTALL_FAILED_ALREADY_EXISTS = -1;
904
905 /**
Philip P. Moltmannb13f1532017-11-14 08:34:06 -0800906 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
907 * if the package archive file is invalid.
Jeff Sharkey5aa86932016-01-08 19:07:49 -0700908 *
Dianne Hackbornade3eca2009-05-11 18:54:45 -0700909 * @hide
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800910 */
Jeff Brownd5a5b5a2014-06-05 17:14:39 -0700911 @SystemApi
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800912 public static final int INSTALL_FAILED_INVALID_APK = -2;
913
914 /**
Philip P. Moltmannb13f1532017-11-14 08:34:06 -0800915 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
916 * if the URI passed in is invalid.
Jeff Sharkey5aa86932016-01-08 19:07:49 -0700917 *
Dianne Hackbornade3eca2009-05-11 18:54:45 -0700918 * @hide
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800919 */
Jeff Brownd5a5b5a2014-06-05 17:14:39 -0700920 @SystemApi
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800921 public static final int INSTALL_FAILED_INVALID_URI = -3;
922
923 /**
Philip P. Moltmannb13f1532017-11-14 08:34:06 -0800924 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
925 * if the package manager service found that the device didn't have enough storage space to
926 * install the app.
Jeff Sharkey5aa86932016-01-08 19:07:49 -0700927 *
Dianne Hackbornade3eca2009-05-11 18:54:45 -0700928 * @hide
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800929 */
Jeff Brownd5a5b5a2014-06-05 17:14:39 -0700930 @SystemApi
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800931 public static final int INSTALL_FAILED_INSUFFICIENT_STORAGE = -4;
932
933 /**
Philip P. Moltmannb13f1532017-11-14 08:34:06 -0800934 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
935 * if a package is already installed with the same name.
Jeff Sharkey5aa86932016-01-08 19:07:49 -0700936 *
Dianne Hackbornade3eca2009-05-11 18:54:45 -0700937 * @hide
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800938 */
Jeff Brownd5a5b5a2014-06-05 17:14:39 -0700939 @SystemApi
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800940 public static final int INSTALL_FAILED_DUPLICATE_PACKAGE = -5;
941
942 /**
Philip P. Moltmannb13f1532017-11-14 08:34:06 -0800943 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
944 * if the requested shared user does not exist.
Jeff Sharkey5aa86932016-01-08 19:07:49 -0700945 *
Dianne Hackbornade3eca2009-05-11 18:54:45 -0700946 * @hide
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800947 */
Jeff Brownd5a5b5a2014-06-05 17:14:39 -0700948 @SystemApi
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800949 public static final int INSTALL_FAILED_NO_SHARED_USER = -6;
950
951 /**
Philip P. Moltmannb13f1532017-11-14 08:34:06 -0800952 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
953 * if a previously installed package of the same name has a different signature than the new
954 * package (and the old package's data was not removed).
Jeff Sharkey5aa86932016-01-08 19:07:49 -0700955 *
Dianne Hackbornade3eca2009-05-11 18:54:45 -0700956 * @hide
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800957 */
Jeff Brownd5a5b5a2014-06-05 17:14:39 -0700958 @SystemApi
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800959 public static final int INSTALL_FAILED_UPDATE_INCOMPATIBLE = -7;
960
961 /**
Philip P. Moltmannb13f1532017-11-14 08:34:06 -0800962 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
963 * if the new package is requested a shared user which is already installed on the device and
964 * does not have matching signature.
Jeff Sharkey5aa86932016-01-08 19:07:49 -0700965 *
Dianne Hackbornade3eca2009-05-11 18:54:45 -0700966 * @hide
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800967 */
Jeff Brownd5a5b5a2014-06-05 17:14:39 -0700968 @SystemApi
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800969 public static final int INSTALL_FAILED_SHARED_USER_INCOMPATIBLE = -8;
970
971 /**
Philip P. Moltmannb13f1532017-11-14 08:34:06 -0800972 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
973 * if the new package uses a shared library that is not available.
Jeff Sharkey5aa86932016-01-08 19:07:49 -0700974 *
Dianne Hackbornade3eca2009-05-11 18:54:45 -0700975 * @hide
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800976 */
Jeff Brownd5a5b5a2014-06-05 17:14:39 -0700977 @SystemApi
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800978 public static final int INSTALL_FAILED_MISSING_SHARED_LIBRARY = -9;
979
980 /**
Philip P. Moltmannb13f1532017-11-14 08:34:06 -0800981 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
982 * if the new package uses a shared library that is not available.
Jeff Sharkey5aa86932016-01-08 19:07:49 -0700983 *
Dianne Hackbornade3eca2009-05-11 18:54:45 -0700984 * @hide
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800985 */
Jeff Brownd5a5b5a2014-06-05 17:14:39 -0700986 @SystemApi
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800987 public static final int INSTALL_FAILED_REPLACE_COULDNT_DELETE = -10;
988
989 /**
Philip P. Moltmannb13f1532017-11-14 08:34:06 -0800990 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
991 * if the new package failed while optimizing and validating its dex files, either because there
992 * was not enough storage or the validation failed.
Jeff Sharkey5aa86932016-01-08 19:07:49 -0700993 *
Dianne Hackbornade3eca2009-05-11 18:54:45 -0700994 * @hide
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800995 */
Jeff Brownd5a5b5a2014-06-05 17:14:39 -0700996 @SystemApi
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800997 public static final int INSTALL_FAILED_DEXOPT = -11;
998
999 /**
Philip P. Moltmannb13f1532017-11-14 08:34:06 -08001000 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
1001 * if the new package failed because the current SDK version is older than that required by the
1002 * package.
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001003 *
Dianne Hackbornade3eca2009-05-11 18:54:45 -07001004 * @hide
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001005 */
Jeff Brownd5a5b5a2014-06-05 17:14:39 -07001006 @SystemApi
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001007 public static final int INSTALL_FAILED_OLDER_SDK = -12;
1008
1009 /**
Philip P. Moltmannb13f1532017-11-14 08:34:06 -08001010 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
1011 * if the new package failed because it contains a content provider with the same authority as a
1012 * provider already installed in the system.
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001013 *
Dianne Hackbornade3eca2009-05-11 18:54:45 -07001014 * @hide
The Android Open Source Project10592532009-03-18 17:39:46 -07001015 */
Jeff Brownd5a5b5a2014-06-05 17:14:39 -07001016 @SystemApi
The Android Open Source Project10592532009-03-18 17:39:46 -07001017 public static final int INSTALL_FAILED_CONFLICTING_PROVIDER = -13;
1018
1019 /**
Philip P. Moltmannb13f1532017-11-14 08:34:06 -08001020 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
1021 * if the new package failed because the current SDK version is newer than that required by the
1022 * package.
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001023 *
Dianne Hackbornade3eca2009-05-11 18:54:45 -07001024 * @hide
Dianne Hackborn851a5412009-05-08 12:06:44 -07001025 */
Jeff Brownd5a5b5a2014-06-05 17:14:39 -07001026 @SystemApi
Dianne Hackborn851a5412009-05-08 12:06:44 -07001027 public static final int INSTALL_FAILED_NEWER_SDK = -14;
1028
1029 /**
Philip P. Moltmannb13f1532017-11-14 08:34:06 -08001030 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
1031 * if the new package failed because it has specified that it is a test-only package and the
1032 * caller has not supplied the {@link #INSTALL_ALLOW_TEST} flag.
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001033 *
Dianne Hackbornade3eca2009-05-11 18:54:45 -07001034 * @hide
1035 */
Jeff Brownd5a5b5a2014-06-05 17:14:39 -07001036 @SystemApi
Dianne Hackbornade3eca2009-05-11 18:54:45 -07001037 public static final int INSTALL_FAILED_TEST_ONLY = -15;
1038
1039 /**
Philip P. Moltmannb13f1532017-11-14 08:34:06 -08001040 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
1041 * if the package being installed contains native code, but none that is compatible with the
1042 * device's CPU_ABI.
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001043 *
Dianne Hackbornb1811182009-05-21 15:45:42 -07001044 * @hide
1045 */
Jeff Brownd5a5b5a2014-06-05 17:14:39 -07001046 @SystemApi
Dianne Hackbornb1811182009-05-21 15:45:42 -07001047 public static final int INSTALL_FAILED_CPU_ABI_INCOMPATIBLE = -16;
1048
1049 /**
Philip P. Moltmannb13f1532017-11-14 08:34:06 -08001050 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
1051 * if the new package uses a feature that is not available.
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001052 *
Dianne Hackborn49237342009-08-27 20:08:01 -07001053 * @hide
1054 */
Jeff Brownd5a5b5a2014-06-05 17:14:39 -07001055 @SystemApi
Dianne Hackborn49237342009-08-27 20:08:01 -07001056 public static final int INSTALL_FAILED_MISSING_FEATURE = -17;
1057
Suchi Amalapurapuaf8e9f42010-01-12 10:17:28 -08001058 // ------ Errors related to sdcard
1059 /**
Philip P. Moltmannb13f1532017-11-14 08:34:06 -08001060 * Installation return code: this is passed in the
1061 * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if a secure container mount point couldn't be
1062 * accessed on external media.
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001063 *
Suchi Amalapurapuaf8e9f42010-01-12 10:17:28 -08001064 * @hide
1065 */
Jeff Brownd5a5b5a2014-06-05 17:14:39 -07001066 @SystemApi
Suchi Amalapurapuaf8e9f42010-01-12 10:17:28 -08001067 public static final int INSTALL_FAILED_CONTAINER_ERROR = -18;
1068
Dianne Hackborn49237342009-08-27 20:08:01 -07001069 /**
Philip P. Moltmannb13f1532017-11-14 08:34:06 -08001070 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
1071 * if the new package couldn't be installed in the specified install location.
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001072 *
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08001073 * @hide
1074 */
Jeff Brownd5a5b5a2014-06-05 17:14:39 -07001075 @SystemApi
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08001076 public static final int INSTALL_FAILED_INVALID_INSTALL_LOCATION = -19;
1077
1078 /**
Philip P. Moltmannb13f1532017-11-14 08:34:06 -08001079 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
1080 * if the new package couldn't be installed in the specified install location because the media
1081 * is not available.
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001082 *
Suchi Amalapurapu8a9ab242010-03-11 16:49:16 -08001083 * @hide
1084 */
Jeff Brownd5a5b5a2014-06-05 17:14:39 -07001085 @SystemApi
Suchi Amalapurapu8a9ab242010-03-11 16:49:16 -08001086 public static final int INSTALL_FAILED_MEDIA_UNAVAILABLE = -20;
1087
1088 /**
Philip P. Moltmannb13f1532017-11-14 08:34:06 -08001089 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
1090 * if the new package couldn't be installed because the verification timed out.
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001091 *
Kenny Root5ab21572011-07-27 11:11:19 -07001092 * @hide
1093 */
Jeff Brownd5a5b5a2014-06-05 17:14:39 -07001094 @SystemApi
Kenny Root5ab21572011-07-27 11:11:19 -07001095 public static final int INSTALL_FAILED_VERIFICATION_TIMEOUT = -21;
1096
1097 /**
Philip P. Moltmannb13f1532017-11-14 08:34:06 -08001098 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
1099 * if the new package couldn't be installed because the verification did not succeed.
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001100 *
Kenny Root5ab21572011-07-27 11:11:19 -07001101 * @hide
1102 */
Jeff Brownd5a5b5a2014-06-05 17:14:39 -07001103 @SystemApi
Kenny Root5ab21572011-07-27 11:11:19 -07001104 public static final int INSTALL_FAILED_VERIFICATION_FAILURE = -22;
1105
1106 /**
Philip P. Moltmannb13f1532017-11-14 08:34:06 -08001107 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
1108 * if the package changed from what the calling program expected.
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001109 *
Kenny Root5ab21572011-07-27 11:11:19 -07001110 * @hide
1111 */
Jeff Brownd5a5b5a2014-06-05 17:14:39 -07001112 @SystemApi
Kenny Root5ab21572011-07-27 11:11:19 -07001113 public static final int INSTALL_FAILED_PACKAGE_CHANGED = -23;
1114
1115 /**
Philip P. Moltmannb13f1532017-11-14 08:34:06 -08001116 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
1117 * if the new package is assigned a different UID than it previously held.
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001118 *
Dianne Hackbornd0c5f512012-06-07 16:53:59 -07001119 * @hide
1120 */
1121 public static final int INSTALL_FAILED_UID_CHANGED = -24;
1122
1123 /**
Philip P. Moltmannb13f1532017-11-14 08:34:06 -08001124 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
1125 * if the new package has an older version code than the currently installed package.
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001126 *
Dianne Hackborn7767eac2012-08-23 18:25:40 -07001127 * @hide
1128 */
1129 public static final int INSTALL_FAILED_VERSION_DOWNGRADE = -25;
1130
1131 /**
Philip P. Moltmannb13f1532017-11-14 08:34:06 -08001132 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
1133 * if the old package has target SDK high enough to support runtime permission and the new
1134 * package has target SDK low enough to not support runtime permissions.
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001135 *
Svetoslavd9653702015-05-13 18:02:46 -07001136 * @hide
1137 */
1138 @SystemApi
1139 public static final int INSTALL_FAILED_PERMISSION_MODEL_DOWNGRADE = -26;
1140
1141 /**
Philip P. Moltmannb13f1532017-11-14 08:34:06 -08001142 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
1143 * if the new package attempts to downgrade the target sandbox version of the app.
Chad Brubaker34573b22017-03-07 15:27:35 -08001144 *
1145 * @hide
1146 */
1147 @SystemApi
1148 public static final int INSTALL_FAILED_SANDBOX_VERSION_DOWNGRADE = -27;
1149
1150 /**
Philip P. Moltmannb13f1532017-11-14 08:34:06 -08001151 * Installation parse return code: this is passed in the
1152 * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the parser was given a path that is not a
1153 * file, or does not end with the expected '.apk' extension.
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001154 *
Dianne Hackbornade3eca2009-05-11 18:54:45 -07001155 * @hide
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001156 */
Jeff Brownd5a5b5a2014-06-05 17:14:39 -07001157 @SystemApi
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001158 public static final int INSTALL_PARSE_FAILED_NOT_APK = -100;
1159
1160 /**
Philip P. Moltmannb13f1532017-11-14 08:34:06 -08001161 * Installation parse return code: this is passed in the
1162 * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the parser was unable to retrieve the
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001163 * AndroidManifest.xml file.
1164 *
Dianne Hackbornade3eca2009-05-11 18:54:45 -07001165 * @hide
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001166 */
Jeff Brownd5a5b5a2014-06-05 17:14:39 -07001167 @SystemApi
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001168 public static final int INSTALL_PARSE_FAILED_BAD_MANIFEST = -101;
1169
1170 /**
Philip P. Moltmannb13f1532017-11-14 08:34:06 -08001171 * Installation parse return code: this is passed in the
1172 * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the parser encountered an unexpected
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001173 * exception.
1174 *
Dianne Hackbornade3eca2009-05-11 18:54:45 -07001175 * @hide
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001176 */
Jeff Brownd5a5b5a2014-06-05 17:14:39 -07001177 @SystemApi
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001178 public static final int INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION = -102;
1179
1180 /**
Philip P. Moltmannb13f1532017-11-14 08:34:06 -08001181 * Installation parse return code: this is passed in the
1182 * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the parser did not find any certificates in
1183 * the .apk.
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001184 *
Dianne Hackbornade3eca2009-05-11 18:54:45 -07001185 * @hide
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001186 */
Jeff Brownd5a5b5a2014-06-05 17:14:39 -07001187 @SystemApi
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001188 public static final int INSTALL_PARSE_FAILED_NO_CERTIFICATES = -103;
1189
1190 /**
Philip P. Moltmannb13f1532017-11-14 08:34:06 -08001191 * Installation parse return code: this is passed in the
1192 * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the parser found inconsistent certificates on
1193 * the files in the .apk.
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001194 *
Dianne Hackbornade3eca2009-05-11 18:54:45 -07001195 * @hide
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001196 */
Jeff Brownd5a5b5a2014-06-05 17:14:39 -07001197 @SystemApi
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001198 public static final int INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES = -104;
1199
1200 /**
Philip P. Moltmannb13f1532017-11-14 08:34:06 -08001201 * Installation parse return code: this is passed in the
1202 * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the parser encountered a
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001203 * CertificateEncodingException in one of the files in the .apk.
1204 *
Dianne Hackbornade3eca2009-05-11 18:54:45 -07001205 * @hide
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001206 */
Jeff Brownd5a5b5a2014-06-05 17:14:39 -07001207 @SystemApi
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001208 public static final int INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING = -105;
1209
1210 /**
Philip P. Moltmannb13f1532017-11-14 08:34:06 -08001211 * Installation parse return code: this is passed in the
1212 * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the parser encountered a bad or missing
1213 * package name in the manifest.
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001214 *
Dianne Hackbornade3eca2009-05-11 18:54:45 -07001215 * @hide
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001216 */
Jeff Brownd5a5b5a2014-06-05 17:14:39 -07001217 @SystemApi
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001218 public static final int INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME = -106;
1219
1220 /**
Philip P. Moltmannb13f1532017-11-14 08:34:06 -08001221 * Installation parse return code: tthis is passed in the
1222 * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the parser encountered a bad shared user id
1223 * name in the manifest.
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001224 *
Dianne Hackbornade3eca2009-05-11 18:54:45 -07001225 * @hide
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001226 */
Jeff Brownd5a5b5a2014-06-05 17:14:39 -07001227 @SystemApi
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001228 public static final int INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID = -107;
1229
1230 /**
Philip P. Moltmannb13f1532017-11-14 08:34:06 -08001231 * Installation parse return code: this is passed in the
1232 * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the parser encountered some structural
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001233 * problem in the manifest.
1234 *
Dianne Hackbornade3eca2009-05-11 18:54:45 -07001235 * @hide
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001236 */
Jeff Brownd5a5b5a2014-06-05 17:14:39 -07001237 @SystemApi
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001238 public static final int INSTALL_PARSE_FAILED_MANIFEST_MALFORMED = -108;
1239
1240 /**
Philip P. Moltmannb13f1532017-11-14 08:34:06 -08001241 * Installation parse return code: this is passed in the
1242 * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the parser did not find any actionable tags
1243 * (instrumentation or application) in the manifest.
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001244 *
Dianne Hackbornade3eca2009-05-11 18:54:45 -07001245 * @hide
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001246 */
Jeff Brownd5a5b5a2014-06-05 17:14:39 -07001247 @SystemApi
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001248 public static final int INSTALL_PARSE_FAILED_MANIFEST_EMPTY = -109;
1249
1250 /**
Philip P. Moltmannb13f1532017-11-14 08:34:06 -08001251 * Installation failed return code: this is passed in the
1252 * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the system failed to install the package
1253 * because of system issues.
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001254 *
Suchi Amalapurapu5b993ce2010-02-12 09:43:29 -08001255 * @hide
1256 */
Jeff Brownd5a5b5a2014-06-05 17:14:39 -07001257 @SystemApi
Suchi Amalapurapu5b993ce2010-02-12 09:43:29 -08001258 public static final int INSTALL_FAILED_INTERNAL_ERROR = -110;
1259
1260 /**
Philip P. Moltmannb13f1532017-11-14 08:34:06 -08001261 * Installation failed return code: this is passed in the
1262 * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the system failed to install the package
1263 * because the user is restricted from installing apps.
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001264 *
Amith Yamasanie4cf7342012-12-17 11:12:09 -08001265 * @hide
1266 */
1267 public static final int INSTALL_FAILED_USER_RESTRICTED = -111;
1268
1269 /**
Philip P. Moltmannb13f1532017-11-14 08:34:06 -08001270 * Installation failed return code: this is passed in the
1271 * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the system failed to install the package
1272 * because it is attempting to define a permission that is already defined by some existing
1273 * package.
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001274 * <p>
Philip P. Moltmannb13f1532017-11-14 08:34:06 -08001275 * The package name of the app which has already defined the permission is passed to a
1276 * {@link PackageInstallObserver}, if any, as the {@link #EXTRA_FAILURE_EXISTING_PACKAGE} string
1277 * extra; and the name of the permission being redefined is passed in the
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001278 * {@link #EXTRA_FAILURE_EXISTING_PERMISSION} string extra.
Christopher Tatef1977b42014-03-24 16:25:51 -07001279 *
Christopher Tatef1977b42014-03-24 16:25:51 -07001280 * @hide
1281 */
1282 public static final int INSTALL_FAILED_DUPLICATE_PERMISSION = -112;
1283
1284 /**
Philip P. Moltmannb13f1532017-11-14 08:34:06 -08001285 * Installation failed return code: this is passed in the
1286 * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the system failed to install the package
1287 * because its packaged native code did not match any of the ABIs supported by the system.
Ramin Zaghi1378aba2014-02-28 15:03:19 +00001288 *
1289 * @hide
1290 */
Narayan Kamathd11f2232014-04-10 10:37:17 +01001291 public static final int INSTALL_FAILED_NO_MATCHING_ABIS = -113;
Ramin Zaghi1378aba2014-02-28 15:03:19 +00001292
1293 /**
1294 * Internal return code for NativeLibraryHelper methods to indicate that the package
1295 * being processed did not contain any native code. This is placed here only so that
1296 * it can belong to the same value space as the other install failure codes.
1297 *
1298 * @hide
1299 */
Narayan Kamathd11f2232014-04-10 10:37:17 +01001300 public static final int NO_NATIVE_LIBRARIES = -114;
Ramin Zaghi1378aba2014-02-28 15:03:19 +00001301
Jeff Sharkey7328a1b2014-08-07 14:01:43 -07001302 /** {@hide} */
Jeff Sharkeyf0600952014-08-07 17:31:53 -07001303 public static final int INSTALL_FAILED_ABORTED = -115;
Jeff Sharkey7328a1b2014-08-07 14:01:43 -07001304
Ramin Zaghi1378aba2014-02-28 15:03:19 +00001305 /**
Todd Kennedybe0b8892017-02-15 14:13:52 -08001306 * Installation failed return code: instant app installs are incompatible with some
Todd Kennedy2699f062015-11-20 13:07:17 -08001307 * other installation flags supplied for the operation; or other circumstances such
Todd Kennedybe0b8892017-02-15 14:13:52 -08001308 * as trying to upgrade a system app via an instant app install.
Todd Kennedy2699f062015-11-20 13:07:17 -08001309 * @hide
1310 */
Todd Kennedybe0b8892017-02-15 14:13:52 -08001311 public static final int INSTALL_FAILED_INSTANT_APP_INVALID = -116;
Todd Kennedy2699f062015-11-20 13:07:17 -08001312
Calin Juravle3fc56c32017-12-11 18:26:13 -08001313 /**
1314 * Installation parse return code: this is passed in the
1315 * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the dex metadata file is invalid or
1316 * if there was no matching apk file for a dex metadata file.
1317 *
1318 * @hide
1319 */
1320 public static final int INSTALL_FAILED_BAD_DEX_METADATA = -117;
1321
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001322 /** @hide */
Jeff Sharkey4347f812017-04-21 12:08:39 -06001323 @IntDef(flag = true, prefix = { "DELETE_" }, value = {
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001324 DELETE_KEEP_DATA,
1325 DELETE_ALL_USERS,
1326 DELETE_SYSTEM_APP,
Todd Kennedy39bfee52016-02-24 10:28:21 -08001327 DELETE_DONT_KILL_APP,
Todd Kennedy232d29e2017-11-06 14:45:53 -08001328 DELETE_CHATTY,
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001329 })
1330 @Retention(RetentionPolicy.SOURCE)
1331 public @interface DeleteFlags {}
1332
Todd Kennedy2699f062015-11-20 13:07:17 -08001333 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001334 * Flag parameter for {@link #deletePackage} to indicate that you don't want to delete the
1335 * package's data directory.
1336 *
1337 * @hide
1338 */
Dianne Hackborn7767eac2012-08-23 18:25:40 -07001339 public static final int DELETE_KEEP_DATA = 0x00000001;
1340
1341 /**
1342 * Flag parameter for {@link #deletePackage} to indicate that you want the
1343 * package deleted for all users.
1344 *
1345 * @hide
1346 */
1347 public static final int DELETE_ALL_USERS = 0x00000002;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001348
1349 /**
Dianne Hackbornc895be72013-03-11 17:48:43 -07001350 * Flag parameter for {@link #deletePackage} to indicate that, if you are calling
1351 * uninstall on a system that has been updated, then don't do the normal process
1352 * of uninstalling the update and rolling back to the older system version (which
1353 * needs to happen for all users); instead, just mark the app as uninstalled for
1354 * the current user.
1355 *
1356 * @hide
1357 */
1358 public static final int DELETE_SYSTEM_APP = 0x00000004;
1359
1360 /**
Todd Kennedy39bfee52016-02-24 10:28:21 -08001361 * Flag parameter for {@link #deletePackage} to indicate that, if you are calling
1362 * uninstall on a package that is replaced to provide new feature splits, the
1363 * existing application should not be killed during the removal process.
1364 *
1365 * @hide
1366 */
1367 public static final int DELETE_DONT_KILL_APP = 0x00000008;
1368
1369 /**
Todd Kennedy232d29e2017-11-06 14:45:53 -08001370 * Flag parameter for {@link #deletePackage} to indicate that package deletion
1371 * should be chatty.
1372 *
1373 * @hide
1374 */
1375 public static final int DELETE_CHATTY = 0x80000000;
1376
1377 /**
Kenny Rootc39bb4a2011-02-28 13:27:19 -08001378 * Return code for when package deletion succeeds. This is passed to the
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001379 * {@link IPackageDeleteObserver} if the system succeeded in deleting the
1380 * package.
Amith Yamasani4b2e9342011-03-31 12:38:53 -07001381 *
Kenny Rootc39bb4a2011-02-28 13:27:19 -08001382 * @hide
1383 */
1384 public static final int DELETE_SUCCEEDED = 1;
1385
1386 /**
1387 * Deletion failed return code: this is passed to the
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001388 * {@link IPackageDeleteObserver} if the system failed to delete the package
1389 * for an unspecified reason.
Amith Yamasani4b2e9342011-03-31 12:38:53 -07001390 *
Kenny Rootc39bb4a2011-02-28 13:27:19 -08001391 * @hide
1392 */
1393 public static final int DELETE_FAILED_INTERNAL_ERROR = -1;
1394
1395 /**
1396 * Deletion failed return code: this is passed to the
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001397 * {@link IPackageDeleteObserver} if the system failed to delete the package
1398 * because it is the active DevicePolicy manager.
Amith Yamasani4b2e9342011-03-31 12:38:53 -07001399 *
Kenny Rootc39bb4a2011-02-28 13:27:19 -08001400 * @hide
1401 */
1402 public static final int DELETE_FAILED_DEVICE_POLICY_MANAGER = -2;
1403
1404 /**
Amith Yamasanie4cf7342012-12-17 11:12:09 -08001405 * Deletion failed return code: this is passed to the
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001406 * {@link IPackageDeleteObserver} if the system failed to delete the package
1407 * since the user is restricted.
Amith Yamasanie4cf7342012-12-17 11:12:09 -08001408 *
1409 * @hide
1410 */
1411 public static final int DELETE_FAILED_USER_RESTRICTED = -3;
1412
1413 /**
Kenny Guy1b88da52014-07-10 16:33:49 +01001414 * Deletion failed return code: this is passed to the
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001415 * {@link IPackageDeleteObserver} if the system failed to delete the package
1416 * because a profile or device owner has marked the package as
1417 * uninstallable.
Kenny Guyc13053b2014-05-29 14:17:17 +01001418 *
1419 * @hide
1420 */
Jeff Sharkeyf0600952014-08-07 17:31:53 -07001421 public static final int DELETE_FAILED_OWNER_BLOCKED = -4;
1422
1423 /** {@hide} */
1424 public static final int DELETE_FAILED_ABORTED = -5;
Kenny Guyc13053b2014-05-29 14:17:17 +01001425
1426 /**
Svet Ganov67882122016-12-11 16:36:34 -08001427 * Deletion failed return code: this is passed to the
1428 * {@link IPackageDeleteObserver} if the system failed to delete the package
1429 * because the packge is a shared library used by other installed packages.
1430 * {@hide} */
1431 public static final int DELETE_FAILED_USED_SHARED_LIBRARY = -6;
1432
1433 /**
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001434 * Return code that is passed to the {@link IPackageMoveObserver} when the
Kenny Rootc39bb4a2011-02-28 13:27:19 -08001435 * package has been successfully moved by the system.
Amith Yamasani4b2e9342011-03-31 12:38:53 -07001436 *
Suchi Amalapurapu8946dd32010-02-19 09:19:34 -08001437 * @hide
1438 */
Jeff Sharkey620b32b2015-04-23 19:36:02 -07001439 public static final int MOVE_SUCCEEDED = -100;
1440
Suchi Amalapurapu8946dd32010-02-19 09:19:34 -08001441 /**
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001442 * Error code that is passed to the {@link IPackageMoveObserver} when the
1443 * package hasn't been successfully moved by the system because of
1444 * insufficient memory on specified media.
1445 *
Suchi Amalapurapu8946dd32010-02-19 09:19:34 -08001446 * @hide
1447 */
1448 public static final int MOVE_FAILED_INSUFFICIENT_STORAGE = -1;
1449
1450 /**
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001451 * Error code that is passed to the {@link IPackageMoveObserver} if the
1452 * specified package doesn't exist.
1453 *
Suchi Amalapurapu8946dd32010-02-19 09:19:34 -08001454 * @hide
1455 */
1456 public static final int MOVE_FAILED_DOESNT_EXIST = -2;
1457
1458 /**
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001459 * Error code that is passed to the {@link IPackageMoveObserver} if the
1460 * specified package cannot be moved since its a system package.
1461 *
Suchi Amalapurapu8946dd32010-02-19 09:19:34 -08001462 * @hide
1463 */
1464 public static final int MOVE_FAILED_SYSTEM_PACKAGE = -3;
1465
1466 /**
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001467 * Error code that is passed to the {@link IPackageMoveObserver} if the
1468 * specified package cannot be moved since its forward locked.
1469 *
Suchi Amalapurapu8946dd32010-02-19 09:19:34 -08001470 * @hide
1471 */
1472 public static final int MOVE_FAILED_FORWARD_LOCKED = -4;
1473
1474 /**
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001475 * Error code that is passed to the {@link IPackageMoveObserver} if the
1476 * specified package cannot be moved to the specified location.
1477 *
Suchi Amalapurapu8946dd32010-02-19 09:19:34 -08001478 * @hide
1479 */
1480 public static final int MOVE_FAILED_INVALID_LOCATION = -5;
1481
1482 /**
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001483 * Error code that is passed to the {@link IPackageMoveObserver} if the
1484 * specified package cannot be moved to the specified location.
1485 *
Suchi Amalapurapu8a9ab242010-03-11 16:49:16 -08001486 * @hide
1487 */
1488 public static final int MOVE_FAILED_INTERNAL_ERROR = -6;
1489
1490 /**
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001491 * Error code that is passed to the {@link IPackageMoveObserver} if the
1492 * specified package already has an operation pending in the queue.
Amith Yamasani4b2e9342011-03-31 12:38:53 -07001493 *
Kenny Rootdeb11262010-08-02 11:36:21 -07001494 * @hide
1495 */
1496 public static final int MOVE_FAILED_OPERATION_PENDING = -7;
1497
1498 /**
Makoto Onukif34db0a2016-02-17 11:17:15 -08001499 * Error code that is passed to the {@link IPackageMoveObserver} if the
1500 * specified package cannot be moved since it contains a device admin.
1501 *
1502 * @hide
1503 */
1504 public static final int MOVE_FAILED_DEVICE_ADMIN = -8;
1505
1506 /**
Yao Chen022b8ea2016-12-16 11:03:28 -08001507 * Error code that is passed to the {@link IPackageMoveObserver} if system does not allow
1508 * non-system apps to be moved to internal storage.
1509 *
1510 * @hide
1511 */
1512 public static final int MOVE_FAILED_3RD_PARTY_NOT_ALLOWED_ON_INTERNAL = -9;
1513
Jeff Sharkeya65e6492017-06-21 13:45:11 -06001514 /** @hide */
1515 public static final int MOVE_FAILED_LOCKED_USER = -10;
1516
Yao Chen022b8ea2016-12-16 11:03:28 -08001517 /**
Suchi Amalapurapu8946dd32010-02-19 09:19:34 -08001518 * Flag parameter for {@link #movePackage} to indicate that
1519 * the package should be moved to internal storage if its
1520 * been installed on external media.
1521 * @hide
1522 */
Jeff Sharkey620b32b2015-04-23 19:36:02 -07001523 @Deprecated
Suchi Amalapurapu8946dd32010-02-19 09:19:34 -08001524 public static final int MOVE_INTERNAL = 0x00000001;
1525
1526 /**
1527 * Flag parameter for {@link #movePackage} to indicate that
1528 * the package should be moved to external media.
1529 * @hide
1530 */
Jeff Sharkey620b32b2015-04-23 19:36:02 -07001531 @Deprecated
Suchi Amalapurapu8946dd32010-02-19 09:19:34 -08001532 public static final int MOVE_EXTERNAL_MEDIA = 0x00000002;
1533
Jeff Sharkey620b32b2015-04-23 19:36:02 -07001534 /** {@hide} */
1535 public static final String EXTRA_MOVE_ID = "android.content.pm.extra.MOVE_ID";
1536
Suchi Amalapurapu8946dd32010-02-19 09:19:34 -08001537 /**
Kenny Root05ca4c92011-09-15 10:36:25 -07001538 * Usable by the required verifier as the {@code verificationCode} argument
1539 * for {@link PackageManager#verifyPendingInstall} to indicate that it will
1540 * allow the installation to proceed without any of the optional verifiers
1541 * needing to vote.
1542 *
1543 * @hide
1544 */
1545 public static final int VERIFICATION_ALLOW_WITHOUT_SUFFICIENT = 2;
1546
1547 /**
Kenny Root3a9b5fb2011-09-20 14:15:38 -07001548 * Used as the {@code verificationCode} argument for
1549 * {@link PackageManager#verifyPendingInstall} to indicate that the calling
1550 * package verifier allows the installation to proceed.
1551 */
1552 public static final int VERIFICATION_ALLOW = 1;
1553
1554 /**
1555 * Used as the {@code verificationCode} argument for
1556 * {@link PackageManager#verifyPendingInstall} to indicate the calling
1557 * package verifier does not vote to allow the installation to proceed.
1558 */
1559 public static final int VERIFICATION_REJECT = -1;
1560
1561 /**
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -08001562 * Used as the {@code verificationCode} argument for
1563 * {@link PackageManager#verifyIntentFilter} to indicate that the calling
1564 * IntentFilter Verifier confirms that the IntentFilter is verified.
1565 *
1566 * @hide
1567 */
Todd Kennedydfa93ab2016-03-03 15:24:33 -08001568 @SystemApi
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -08001569 public static final int INTENT_FILTER_VERIFICATION_SUCCESS = 1;
1570
1571 /**
1572 * Used as the {@code verificationCode} argument for
1573 * {@link PackageManager#verifyIntentFilter} to indicate that the calling
1574 * IntentFilter Verifier confirms that the IntentFilter is NOT verified.
1575 *
1576 * @hide
1577 */
Todd Kennedydfa93ab2016-03-03 15:24:33 -08001578 @SystemApi
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -08001579 public static final int INTENT_FILTER_VERIFICATION_FAILURE = -1;
1580
1581 /**
1582 * Internal status code to indicate that an IntentFilter verification result is not specified.
1583 *
1584 * @hide
1585 */
Jeff Schumacher6fd90ed2017-01-20 13:58:34 -08001586 @SystemApi
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -08001587 public static final int INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_UNDEFINED = 0;
1588
1589 /**
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001590 * Used as the {@code status} argument for
1591 * {@link #updateIntentVerificationStatusAsUser} to indicate that the User
1592 * will always be prompted the Intent Disambiguation Dialog if there are two
1593 * or more Intent resolved for the IntentFilter's domain(s).
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -08001594 *
1595 * @hide
1596 */
Jeff Schumacher6fd90ed2017-01-20 13:58:34 -08001597 @SystemApi
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -08001598 public static final int INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK = 1;
1599
1600 /**
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001601 * Used as the {@code status} argument for
1602 * {@link #updateIntentVerificationStatusAsUser} to indicate that the User
1603 * will never be prompted the Intent Disambiguation Dialog if there are two
1604 * or more resolution of the Intent. The default App for the domain(s)
1605 * specified in the IntentFilter will also ALWAYS be used.
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -08001606 *
1607 * @hide
1608 */
Jeff Schumacher6fd90ed2017-01-20 13:58:34 -08001609 @SystemApi
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -08001610 public static final int INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS = 2;
1611
1612 /**
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001613 * Used as the {@code status} argument for
1614 * {@link #updateIntentVerificationStatusAsUser} to indicate that the User
1615 * may be prompted the Intent Disambiguation Dialog if there are two or more
1616 * Intent resolved. The default App for the domain(s) specified in the
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -08001617 * IntentFilter will also NEVER be presented to the User.
1618 *
1619 * @hide
1620 */
Jeff Schumacher6fd90ed2017-01-20 13:58:34 -08001621 @SystemApi
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -08001622 public static final int INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER = 3;
1623
1624 /**
Jeff Sharkey5aa86932016-01-08 19:07:49 -07001625 * Used as the {@code status} argument for
1626 * {@link #updateIntentVerificationStatusAsUser} to indicate that this app
1627 * should always be considered as an ambiguous candidate for handling the
1628 * matching Intent even if there are other candidate apps in the "always"
1629 * state. Put another way: if there are any 'always ask' apps in a set of
1630 * more than one candidate app, then a disambiguation is *always* presented
1631 * even if there is another candidate app with the 'always' state.
Christopher Tate56f0ff32015-08-13 16:29:33 -07001632 *
1633 * @hide
1634 */
Jeff Schumacher6fd90ed2017-01-20 13:58:34 -08001635 @SystemApi
Christopher Tate56f0ff32015-08-13 16:29:33 -07001636 public static final int INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS_ASK = 4;
1637
1638 /**
rich canningsd9ef3e52012-08-22 14:28:05 -07001639 * Can be used as the {@code millisecondsToDelay} argument for
1640 * {@link PackageManager#extendVerificationTimeout}. This is the
1641 * maximum time {@code PackageManager} waits for the verification
1642 * agent to return (in milliseconds).
1643 */
1644 public static final long MAXIMUM_VERIFICATION_TIMEOUT = 60*60*1000;
1645
1646 /**
Amith Yamasani0b285492011-04-14 17:35:23 -07001647 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device's
1648 * audio pipeline is low-latency, more suitable for audio applications sensitive to delays or
1649 * lag in sound input or output.
Dan Morrill898e1e82010-09-26 17:28:30 -07001650 */
1651 @SdkConstant(SdkConstantType.FEATURE)
1652 public static final String FEATURE_AUDIO_LOW_LATENCY = "android.hardware.audio.low_latency";
1653
1654 /**
1655 * Feature for {@link #getSystemAvailableFeatures} and
Unsuk Jung50909f62014-09-02 18:25:49 -07001656 * {@link #hasSystemFeature}: The device includes at least one form of audio
1657 * output, such as speakers, audio jack or streaming over bluetooth
1658 */
1659 @SdkConstant(SdkConstantType.FEATURE)
1660 public static final String FEATURE_AUDIO_OUTPUT = "android.hardware.audio.output";
1661
1662 /**
Glenn Kastencdcb5772015-05-06 15:54:49 -07001663 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
Glenn Kasten7587edc2015-10-30 17:45:52 -07001664 * The device has professional audio level of functionality and performance.
Glenn Kastencdcb5772015-05-06 15:54:49 -07001665 */
1666 @SdkConstant(SdkConstantType.FEATURE)
1667 public static final String FEATURE_AUDIO_PRO = "android.hardware.audio.pro";
1668
1669 /**
Unsuk Jung50909f62014-09-02 18:25:49 -07001670 * Feature for {@link #getSystemAvailableFeatures} and
Dan Morrill50ab63f2010-03-05 16:16:19 -08001671 * {@link #hasSystemFeature}: The device is capable of communicating with
1672 * other devices via Bluetooth.
1673 */
1674 @SdkConstant(SdkConstantType.FEATURE)
1675 public static final String FEATURE_BLUETOOTH = "android.hardware.bluetooth";
1676
1677 /**
1678 * Feature for {@link #getSystemAvailableFeatures} and
Matthew Xiea7227722013-04-18 15:25:59 -07001679 * {@link #hasSystemFeature}: The device is capable of communicating with
1680 * other devices via Bluetooth Low Energy radio.
1681 */
1682 @SdkConstant(SdkConstantType.FEATURE)
1683 public static final String FEATURE_BLUETOOTH_LE = "android.hardware.bluetooth_le";
1684
1685 /**
1686 * Feature for {@link #getSystemAvailableFeatures} and
Dianne Hackborn08ee42c2009-11-19 17:08:01 -08001687 * {@link #hasSystemFeature}: The device has a camera facing away
1688 * from the screen.
1689 */
Xavier Ducrohet3274b9b2009-12-14 17:52:20 -08001690 @SdkConstant(SdkConstantType.FEATURE)
Dianne Hackborn08ee42c2009-11-19 17:08:01 -08001691 public static final String FEATURE_CAMERA = "android.hardware.camera";
Dan Morrill50ab63f2010-03-05 16:16:19 -08001692
Dianne Hackborn08ee42c2009-11-19 17:08:01 -08001693 /**
1694 * Feature for {@link #getSystemAvailableFeatures} and
1695 * {@link #hasSystemFeature}: The device's camera supports auto-focus.
1696 */
Xavier Ducrohet3274b9b2009-12-14 17:52:20 -08001697 @SdkConstant(SdkConstantType.FEATURE)
Dianne Hackborn08ee42c2009-11-19 17:08:01 -08001698 public static final String FEATURE_CAMERA_AUTOFOCUS = "android.hardware.camera.autofocus";
Dan Morrill50ab63f2010-03-05 16:16:19 -08001699
Dianne Hackborn08ee42c2009-11-19 17:08:01 -08001700 /**
1701 * Feature for {@link #getSystemAvailableFeatures} and
Eino-Ville Talvala752af832012-09-18 14:45:37 -07001702 * {@link #hasSystemFeature}: The device has at least one camera pointing in
Eino-Ville Talvala9131da22014-05-08 11:39:53 -07001703 * some direction, or can support an external camera being connected to it.
Eino-Ville Talvala752af832012-09-18 14:45:37 -07001704 */
1705 @SdkConstant(SdkConstantType.FEATURE)
1706 public static final String FEATURE_CAMERA_ANY = "android.hardware.camera.any";
1707
1708 /**
1709 * Feature for {@link #getSystemAvailableFeatures} and
Eino-Ville Talvala9131da22014-05-08 11:39:53 -07001710 * {@link #hasSystemFeature}: The device can support having an external camera connected to it.
1711 * The external camera may not always be connected or available to applications to use.
1712 */
1713 @SdkConstant(SdkConstantType.FEATURE)
1714 public static final String FEATURE_CAMERA_EXTERNAL = "android.hardware.camera.external";
1715
1716 /**
1717 * Feature for {@link #getSystemAvailableFeatures} and
Dianne Hackborn08ee42c2009-11-19 17:08:01 -08001718 * {@link #hasSystemFeature}: The device's camera supports flash.
1719 */
Xavier Ducrohet3274b9b2009-12-14 17:52:20 -08001720 @SdkConstant(SdkConstantType.FEATURE)
Dianne Hackborn08ee42c2009-11-19 17:08:01 -08001721 public static final String FEATURE_CAMERA_FLASH = "android.hardware.camera.flash";
Dan Morrill50ab63f2010-03-05 16:16:19 -08001722
1723 /**
1724 * Feature for {@link #getSystemAvailableFeatures} and
Chih-Chung Changde1057c2010-06-14 19:15:00 +08001725 * {@link #hasSystemFeature}: The device has a front facing camera.
1726 */
1727 @SdkConstant(SdkConstantType.FEATURE)
1728 public static final String FEATURE_CAMERA_FRONT = "android.hardware.camera.front";
1729
1730 /**
Eino-Ville Talvala611fece2014-07-10 17:29:38 -07001731 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: At least one
1732 * of the cameras on the device supports the
1733 * {@link android.hardware.camera2.CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL full hardware}
1734 * capability level.
1735 */
1736 @SdkConstant(SdkConstantType.FEATURE)
1737 public static final String FEATURE_CAMERA_LEVEL_FULL = "android.hardware.camera.level.full";
1738
1739 /**
1740 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: At least one
1741 * of the cameras on the device supports the
1742 * {@link android.hardware.camera2.CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_MANUAL_SENSOR manual sensor}
1743 * capability level.
1744 */
1745 @SdkConstant(SdkConstantType.FEATURE)
1746 public static final String FEATURE_CAMERA_CAPABILITY_MANUAL_SENSOR =
1747 "android.hardware.camera.capability.manual_sensor";
1748
1749 /**
1750 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: At least one
1751 * of the cameras on the device supports the
1752 * {@link android.hardware.camera2.CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_MANUAL_POST_PROCESSING manual post-processing}
1753 * capability level.
1754 */
1755 @SdkConstant(SdkConstantType.FEATURE)
1756 public static final String FEATURE_CAMERA_CAPABILITY_MANUAL_POST_PROCESSING =
1757 "android.hardware.camera.capability.manual_post_processing";
1758
1759 /**
1760 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: At least one
1761 * of the cameras on the device supports the
1762 * {@link android.hardware.camera2.CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_RAW RAW}
1763 * capability level.
1764 */
1765 @SdkConstant(SdkConstantType.FEATURE)
1766 public static final String FEATURE_CAMERA_CAPABILITY_RAW =
1767 "android.hardware.camera.capability.raw";
1768
1769 /**
Eino-Ville Talvaladfa0c2a2018-01-10 12:01:08 -08001770 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: At least one
1771 * of the cameras on the device supports the
1772 * {@link android.hardware.camera2.CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_MOTION_TRACKING
1773 * MOTION_TRACKING} capability level.
1774 */
1775 @SdkConstant(SdkConstantType.FEATURE)
1776 public static final String FEATURE_CAMERA_AR =
1777 "android.hardware.camera.ar";
1778
1779 /**
Chih-Chung Changde1057c2010-06-14 19:15:00 +08001780 * Feature for {@link #getSystemAvailableFeatures} and
Alex Ray0c9d61f2013-10-03 12:17:54 -07001781 * {@link #hasSystemFeature}: The device is capable of communicating with
1782 * consumer IR devices.
1783 */
1784 @SdkConstant(SdkConstantType.FEATURE)
1785 public static final String FEATURE_CONSUMER_IR = "android.hardware.consumerir";
1786
Sam Lin90e258b2017-04-03 20:57:45 -07001787 /** {@hide} */
1788 @SdkConstant(SdkConstantType.FEATURE)
1789 public static final String FEATURE_CTS = "android.software.cts";
1790
Alex Ray0c9d61f2013-10-03 12:17:54 -07001791 /**
1792 * Feature for {@link #getSystemAvailableFeatures} and
Dan Morrill50ab63f2010-03-05 16:16:19 -08001793 * {@link #hasSystemFeature}: The device supports one or more methods of
1794 * reporting current location.
1795 */
1796 @SdkConstant(SdkConstantType.FEATURE)
1797 public static final String FEATURE_LOCATION = "android.hardware.location";
1798
1799 /**
1800 * Feature for {@link #getSystemAvailableFeatures} and
1801 * {@link #hasSystemFeature}: The device has a Global Positioning System
1802 * receiver and can report precise location.
1803 */
1804 @SdkConstant(SdkConstantType.FEATURE)
1805 public static final String FEATURE_LOCATION_GPS = "android.hardware.location.gps";
1806
1807 /**
1808 * Feature for {@link #getSystemAvailableFeatures} and
1809 * {@link #hasSystemFeature}: The device can report location with coarse
1810 * accuracy using a network-based geolocation system.
1811 */
1812 @SdkConstant(SdkConstantType.FEATURE)
1813 public static final String FEATURE_LOCATION_NETWORK = "android.hardware.location.network";
1814
1815 /**
1816 * Feature for {@link #getSystemAvailableFeatures} and
Dianne Hackborn2a103f12017-08-08 15:50:31 -07001817 * {@link #hasSystemFeature}: The device's
1818 * {@link ActivityManager#isLowRamDevice() ActivityManager.isLowRamDevice()} method returns
1819 * true.
1820 */
1821 @SdkConstant(SdkConstantType.FEATURE)
1822 public static final String FEATURE_RAM_LOW = "android.hardware.ram.low";
1823
1824 /**
1825 * Feature for {@link #getSystemAvailableFeatures} and
1826 * {@link #hasSystemFeature}: The device's
1827 * {@link ActivityManager#isLowRamDevice() ActivityManager.isLowRamDevice()} method returns
1828 * false.
1829 */
1830 @SdkConstant(SdkConstantType.FEATURE)
1831 public static final String FEATURE_RAM_NORMAL = "android.hardware.ram.normal";
1832
1833 /**
1834 * Feature for {@link #getSystemAvailableFeatures} and
Dan Morrill50ab63f2010-03-05 16:16:19 -08001835 * {@link #hasSystemFeature}: The device can record audio via a
1836 * microphone.
1837 */
1838 @SdkConstant(SdkConstantType.FEATURE)
1839 public static final String FEATURE_MICROPHONE = "android.hardware.microphone";
1840
1841 /**
1842 * Feature for {@link #getSystemAvailableFeatures} and
Dan Morrill76437d32010-09-01 11:17:20 -07001843 * {@link #hasSystemFeature}: The device can communicate using Near-Field
1844 * Communications (NFC).
1845 */
1846 @SdkConstant(SdkConstantType.FEATURE)
1847 public static final String FEATURE_NFC = "android.hardware.nfc";
1848
1849 /**
1850 * Feature for {@link #getSystemAvailableFeatures} and
Martijn Coenenf4bf1582013-07-22 12:01:19 -07001851 * {@link #hasSystemFeature}: The device supports host-
1852 * based NFC card emulation.
Martijn Coenendf4d1d62013-08-28 11:18:58 -07001853 *
1854 * TODO remove when depending apps have moved to new constant.
1855 * @hide
1856 * @deprecated
Martijn Coenenf4bf1582013-07-22 12:01:19 -07001857 */
Jose Lima970417c2014-04-10 10:42:19 -07001858 @Deprecated
Martijn Coenenf4bf1582013-07-22 12:01:19 -07001859 @SdkConstant(SdkConstantType.FEATURE)
1860 public static final String FEATURE_NFC_HCE = "android.hardware.nfc.hce";
1861
1862 /**
1863 * Feature for {@link #getSystemAvailableFeatures} and
Martijn Coenendf4d1d62013-08-28 11:18:58 -07001864 * {@link #hasSystemFeature}: The device supports host-
1865 * based NFC card emulation.
1866 */
1867 @SdkConstant(SdkConstantType.FEATURE)
1868 public static final String FEATURE_NFC_HOST_CARD_EMULATION = "android.hardware.nfc.hce";
1869
1870 /**
1871 * Feature for {@link #getSystemAvailableFeatures} and
Yoshinobu Itoc52adfe2016-01-22 18:14:18 +09001872 * {@link #hasSystemFeature}: The device supports host-
1873 * based NFC-F card emulation.
1874 */
1875 @SdkConstant(SdkConstantType.FEATURE)
1876 public static final String FEATURE_NFC_HOST_CARD_EMULATION_NFCF = "android.hardware.nfc.hcef";
1877
1878 /**
1879 * Feature for {@link #getSystemAvailableFeatures} and
Martijn Coenen441d61b2017-04-12 13:52:40 -07001880 * {@link #hasSystemFeature}: The device supports any
1881 * one of the {@link #FEATURE_NFC}, {@link #FEATURE_NFC_HOST_CARD_EMULATION},
1882 * or {@link #FEATURE_NFC_HOST_CARD_EMULATION_NFCF} features.
1883 *
1884 * @hide
1885 */
1886 @SdkConstant(SdkConstantType.FEATURE)
1887 public static final String FEATURE_NFC_ANY = "android.hardware.nfc.any";
1888
1889 /**
1890 * Feature for {@link #getSystemAvailableFeatures} and
Jesse Hall7f517062014-07-18 11:54:41 -07001891 * {@link #hasSystemFeature}: The device supports the OpenGL ES
1892 * <a href="http://www.khronos.org/registry/gles/extensions/ANDROID/ANDROID_extension_pack_es31a.txt">
1893 * Android Extension Pack</a>.
1894 */
1895 @SdkConstant(SdkConstantType.FEATURE)
1896 public static final String FEATURE_OPENGLES_EXTENSION_PACK = "android.hardware.opengles.aep";
1897
1898 /**
1899 * Feature for {@link #getSystemAvailableFeatures} and
Jesse Hall39ceeb52016-03-10 09:04:26 -08001900 * {@link #hasSystemFeature(String, int)}: If this feature is supported, the Vulkan native API
1901 * will enumerate at least one {@code VkPhysicalDevice}, and the feature version will indicate
1902 * what level of optional hardware features limits it supports.
Jesse Hallf77a34f2016-02-04 18:41:33 -08001903 * <p>
1904 * Level 0 includes the base Vulkan requirements as well as:
1905 * <ul><li>{@code VkPhysicalDeviceFeatures::textureCompressionETC2}</li></ul>
1906 * <p>
1907 * Level 1 additionally includes:
1908 * <ul>
1909 * <li>{@code VkPhysicalDeviceFeatures::fullDrawIndexUint32}</li>
1910 * <li>{@code VkPhysicalDeviceFeatures::imageCubeArray}</li>
1911 * <li>{@code VkPhysicalDeviceFeatures::independentBlend}</li>
1912 * <li>{@code VkPhysicalDeviceFeatures::geometryShader}</li>
1913 * <li>{@code VkPhysicalDeviceFeatures::tessellationShader}</li>
1914 * <li>{@code VkPhysicalDeviceFeatures::sampleRateShading}</li>
1915 * <li>{@code VkPhysicalDeviceFeatures::textureCompressionASTC_LDR}</li>
1916 * <li>{@code VkPhysicalDeviceFeatures::fragmentStoresAndAtomics}</li>
1917 * <li>{@code VkPhysicalDeviceFeatures::shaderImageGatherExtended}</li>
1918 * <li>{@code VkPhysicalDeviceFeatures::shaderUniformBufferArrayDynamicIndexing}</li>
1919 * <li>{@code VkPhysicalDeviceFeatures::shaderSampledImageArrayDynamicIndexing}</li>
1920 * </ul>
1921 */
1922 @SdkConstant(SdkConstantType.FEATURE)
1923 public static final String FEATURE_VULKAN_HARDWARE_LEVEL = "android.hardware.vulkan.level";
1924
1925 /**
1926 * Feature for {@link #getSystemAvailableFeatures} and
Jesse Hall1cd7e932017-02-05 19:58:15 -08001927 * {@link #hasSystemFeature(String, int)}: If this feature is supported, the Vulkan native API
1928 * will enumerate at least one {@code VkPhysicalDevice}, and the feature version will indicate
Jesse Hall54fc6092017-08-22 07:19:56 -07001929 * what level of optional compute features that device supports beyond the Vulkan 1.0
1930 * requirements.
Jesse Hall1cd7e932017-02-05 19:58:15 -08001931 * <p>
Jesse Hall54fc6092017-08-22 07:19:56 -07001932 * Compute level 0 indicates:
1933 * <ul>
1934 * <li>The {@code VK_KHR_variable_pointers} extension and
1935 * {@code VkPhysicalDeviceVariablePointerFeaturesKHR::variablePointers} feature are
1936 supported.</li>
1937 * <li>{@code VkPhysicalDeviceLimits::maxPerStageDescriptorStorageBuffers} is at least 16.</li>
1938 * </ul>
Jesse Hall1cd7e932017-02-05 19:58:15 -08001939 */
1940 @SdkConstant(SdkConstantType.FEATURE)
1941 public static final String FEATURE_VULKAN_HARDWARE_COMPUTE = "android.hardware.vulkan.compute";
1942
1943 /**
1944 * Feature for {@link #getSystemAvailableFeatures} and
Jesse Hall39ceeb52016-03-10 09:04:26 -08001945 * {@link #hasSystemFeature(String, int)}: The version of this feature indicates the highest
Jesse Hallf77a34f2016-02-04 18:41:33 -08001946 * {@code VkPhysicalDeviceProperties::apiVersion} supported by the physical devices that support
1947 * the hardware level indicated by {@link #FEATURE_VULKAN_HARDWARE_LEVEL}. The feature version
1948 * uses the same encoding as Vulkan version numbers:
1949 * <ul>
1950 * <li>Major version number in bits 31-22</li>
1951 * <li>Minor version number in bits 21-12</li>
1952 * <li>Patch version number in bits 11-0</li>
1953 * </ul>
Jesse Hall239373f2018-01-26 11:35:10 +08001954 * A version of 1.1.0 or higher also indicates:
1955 * <ul>
1956 * <li>The {@code VK_ANDROID_external_memory_android_hardware_buffer} extension is
1957 * supported.</li>
1958 * <li>{@code SYNC_FD} external semaphore and fence handles are supported.</li>
1959 * <li>{@code VkPhysicalDeviceSamplerYcbcrConversionFeatures::samplerYcbcrConversion} is
1960 * supported.</li>
1961 * </ul>
Jesse Hallf77a34f2016-02-04 18:41:33 -08001962 */
1963 @SdkConstant(SdkConstantType.FEATURE)
1964 public static final String FEATURE_VULKAN_HARDWARE_VERSION = "android.hardware.vulkan.version";
1965
1966 /**
Tomasz Wasilczyk05392d62017-07-10 19:33:22 -07001967 * Feature for {@link #getSystemAvailableFeatures} and
1968 * {@link #hasSystemFeature}: The device includes broadcast radio tuner.
1969 * @hide
Tomasz Wasilczyk347192e2017-04-04 11:13:44 -07001970 */
Tomasz Wasilczyk05392d62017-07-10 19:33:22 -07001971 @SystemApi
Tomasz Wasilczyk347192e2017-04-04 11:13:44 -07001972 @SdkConstant(SdkConstantType.FEATURE)
Tomasz Wasilczyk05392d62017-07-10 19:33:22 -07001973 public static final String FEATURE_BROADCAST_RADIO = "android.hardware.broadcastradio";
Tomasz Wasilczyk347192e2017-04-04 11:13:44 -07001974
1975 /**
Jesse Hallf77a34f2016-02-04 18:41:33 -08001976 * Feature for {@link #getSystemAvailableFeatures} and
Dan Morrill5744bb42010-09-01 19:18:57 -07001977 * {@link #hasSystemFeature}: The device includes an accelerometer.
1978 */
1979 @SdkConstant(SdkConstantType.FEATURE)
1980 public static final String FEATURE_SENSOR_ACCELEROMETER = "android.hardware.sensor.accelerometer";
1981
1982 /**
1983 * Feature for {@link #getSystemAvailableFeatures} and
1984 * {@link #hasSystemFeature}: The device includes a barometer (air
1985 * pressure sensor.)
1986 */
1987 @SdkConstant(SdkConstantType.FEATURE)
1988 public static final String FEATURE_SENSOR_BAROMETER = "android.hardware.sensor.barometer";
1989
1990 /**
1991 * Feature for {@link #getSystemAvailableFeatures} and
Dan Morrill50ab63f2010-03-05 16:16:19 -08001992 * {@link #hasSystemFeature}: The device includes a magnetometer (compass).
1993 */
1994 @SdkConstant(SdkConstantType.FEATURE)
1995 public static final String FEATURE_SENSOR_COMPASS = "android.hardware.sensor.compass";
1996
1997 /**
1998 * Feature for {@link #getSystemAvailableFeatures} and
Dan Morrill5744bb42010-09-01 19:18:57 -07001999 * {@link #hasSystemFeature}: The device includes a gyroscope.
Dan Morrill50ab63f2010-03-05 16:16:19 -08002000 */
2001 @SdkConstant(SdkConstantType.FEATURE)
Dan Morrill5744bb42010-09-01 19:18:57 -07002002 public static final String FEATURE_SENSOR_GYROSCOPE = "android.hardware.sensor.gyroscope";
Dan Morrill50ab63f2010-03-05 16:16:19 -08002003
Dianne Hackborn08ee42c2009-11-19 17:08:01 -08002004 /**
2005 * Feature for {@link #getSystemAvailableFeatures} and
2006 * {@link #hasSystemFeature}: The device includes a light sensor.
2007 */
Xavier Ducrohet3274b9b2009-12-14 17:52:20 -08002008 @SdkConstant(SdkConstantType.FEATURE)
Dianne Hackborn08ee42c2009-11-19 17:08:01 -08002009 public static final String FEATURE_SENSOR_LIGHT = "android.hardware.sensor.light";
Dan Morrill50ab63f2010-03-05 16:16:19 -08002010
Dianne Hackborn08ee42c2009-11-19 17:08:01 -08002011 /**
2012 * Feature for {@link #getSystemAvailableFeatures} and
2013 * {@link #hasSystemFeature}: The device includes a proximity sensor.
2014 */
Xavier Ducrohet3274b9b2009-12-14 17:52:20 -08002015 @SdkConstant(SdkConstantType.FEATURE)
Dianne Hackborn08ee42c2009-11-19 17:08:01 -08002016 public static final String FEATURE_SENSOR_PROXIMITY = "android.hardware.sensor.proximity";
Amith Yamasani4b2e9342011-03-31 12:38:53 -07002017
Dianne Hackborn08ee42c2009-11-19 17:08:01 -08002018 /**
2019 * Feature for {@link #getSystemAvailableFeatures} and
Aravind Akella068b0c02013-10-12 17:39:15 -07002020 * {@link #hasSystemFeature}: The device includes a hardware step counter.
2021 */
2022 @SdkConstant(SdkConstantType.FEATURE)
2023 public static final String FEATURE_SENSOR_STEP_COUNTER = "android.hardware.sensor.stepcounter";
2024
2025 /**
2026 * Feature for {@link #getSystemAvailableFeatures} and
2027 * {@link #hasSystemFeature}: The device includes a hardware step detector.
2028 */
2029 @SdkConstant(SdkConstantType.FEATURE)
2030 public static final String FEATURE_SENSOR_STEP_DETECTOR = "android.hardware.sensor.stepdetector";
2031
2032 /**
2033 * Feature for {@link #getSystemAvailableFeatures} and
Vinod Krishnan8afb23c2014-04-30 11:11:39 -07002034 * {@link #hasSystemFeature}: The device includes a heart rate monitor.
2035 */
2036 @SdkConstant(SdkConstantType.FEATURE)
2037 public static final String FEATURE_SENSOR_HEART_RATE = "android.hardware.sensor.heartrate";
2038
2039 /**
2040 * Feature for {@link #getSystemAvailableFeatures} and
Trevor Johns682c24e2016-04-12 10:13:47 -07002041 * {@link #hasSystemFeature}: The heart rate sensor on this device is an Electrocardiogram.
Vinod Krishnan1ab76892014-08-20 11:11:55 -07002042 */
2043 @SdkConstant(SdkConstantType.FEATURE)
2044 public static final String FEATURE_SENSOR_HEART_RATE_ECG =
2045 "android.hardware.sensor.heartrate.ecg";
2046
2047 /**
2048 * Feature for {@link #getSystemAvailableFeatures} and
Aravind Akella8b8e74b2014-07-09 11:52:39 -07002049 * {@link #hasSystemFeature}: The device includes a relative humidity sensor.
2050 */
2051 @SdkConstant(SdkConstantType.FEATURE)
2052 public static final String FEATURE_SENSOR_RELATIVE_HUMIDITY =
2053 "android.hardware.sensor.relative_humidity";
2054
2055 /**
2056 * Feature for {@link #getSystemAvailableFeatures} and
2057 * {@link #hasSystemFeature}: The device includes an ambient temperature sensor.
2058 */
2059 @SdkConstant(SdkConstantType.FEATURE)
2060 public static final String FEATURE_SENSOR_AMBIENT_TEMPERATURE =
2061 "android.hardware.sensor.ambient_temperature";
2062
2063 /**
2064 * Feature for {@link #getSystemAvailableFeatures} and
Ashutosh Joshieae371b2015-04-09 10:30:07 -07002065 * {@link #hasSystemFeature}: The device supports high fidelity sensor processing
2066 * capabilities.
2067 */
2068 @SdkConstant(SdkConstantType.FEATURE)
2069 public static final String FEATURE_HIFI_SENSORS =
2070 "android.hardware.sensor.hifi_sensors";
2071
2072 /**
2073 * Feature for {@link #getSystemAvailableFeatures} and
Dianne Hackborn08ee42c2009-11-19 17:08:01 -08002074 * {@link #hasSystemFeature}: The device has a telephony radio with data
2075 * communication support.
2076 */
Xavier Ducrohet3274b9b2009-12-14 17:52:20 -08002077 @SdkConstant(SdkConstantType.FEATURE)
Dianne Hackborn08ee42c2009-11-19 17:08:01 -08002078 public static final String FEATURE_TELEPHONY = "android.hardware.telephony";
Amith Yamasani4b2e9342011-03-31 12:38:53 -07002079
Dianne Hackborn08ee42c2009-11-19 17:08:01 -08002080 /**
2081 * Feature for {@link #getSystemAvailableFeatures} and
2082 * {@link #hasSystemFeature}: The device has a CDMA telephony stack.
2083 */
Xavier Ducrohet3274b9b2009-12-14 17:52:20 -08002084 @SdkConstant(SdkConstantType.FEATURE)
Dianne Hackborn08ee42c2009-11-19 17:08:01 -08002085 public static final String FEATURE_TELEPHONY_CDMA = "android.hardware.telephony.cdma";
Amith Yamasani4b2e9342011-03-31 12:38:53 -07002086
Dianne Hackborn08ee42c2009-11-19 17:08:01 -08002087 /**
2088 * Feature for {@link #getSystemAvailableFeatures} and
2089 * {@link #hasSystemFeature}: The device has a GSM telephony stack.
2090 */
Xavier Ducrohet3274b9b2009-12-14 17:52:20 -08002091 @SdkConstant(SdkConstantType.FEATURE)
Dianne Hackborn08ee42c2009-11-19 17:08:01 -08002092 public static final String FEATURE_TELEPHONY_GSM = "android.hardware.telephony.gsm";
Hung-ying Tyan3424c022010-08-27 18:08:19 +08002093
2094 /**
Polina Bondarenko80909ce2017-01-12 21:10:38 +01002095 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
2096 * The device supports telephony carrier restriction mechanism.
2097 *
2098 * <p>Devices declaring this feature must have an implementation of the
2099 * {@link android.telephony.TelephonyManager#getAllowedCarriers} and
2100 * {@link android.telephony.TelephonyManager#setAllowedCarriers}.
2101 * @hide
2102 */
2103 @SystemApi
2104 @SdkConstant(SdkConstantType.FEATURE)
2105 public static final String FEATURE_TELEPHONY_CARRIERLOCK =
2106 "android.hardware.telephony.carrierlock";
2107
2108 /**
Jeff Davidson35cda392017-02-27 09:46:00 -08002109 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device
2110 * supports embedded subscriptions on eUICCs.
Jeff Davidson35cda392017-02-27 09:46:00 -08002111 */
2112 @SdkConstant(SdkConstantType.FEATURE)
2113 public static final String FEATURE_TELEPHONY_EUICC = "android.hardware.telephony.euicc";
2114
2115 /**
Hall Liuc6703d92017-11-17 11:31:57 -08002116 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device
2117 * supports cell-broadcast reception using the MBMS APIs.
2118 */
2119 @SdkConstant(SdkConstantType.FEATURE)
2120 public static final String FEATURE_TELEPHONY_MBMS = "android.hardware.telephony.mbms";
2121
2122 /**
Hung-ying Tyan3424c022010-08-27 18:08:19 +08002123 * Feature for {@link #getSystemAvailableFeatures} and
Mike Lockwoodf4ca2472011-02-27 11:23:25 -08002124 * {@link #hasSystemFeature}: The device supports connecting to USB devices
2125 * as the USB host.
2126 */
2127 @SdkConstant(SdkConstantType.FEATURE)
2128 public static final String FEATURE_USB_HOST = "android.hardware.usb.host";
2129
2130 /**
2131 * Feature for {@link #getSystemAvailableFeatures} and
2132 * {@link #hasSystemFeature}: The device supports connecting to USB accessories.
2133 */
2134 @SdkConstant(SdkConstantType.FEATURE)
2135 public static final String FEATURE_USB_ACCESSORY = "android.hardware.usb.accessory";
2136
2137 /**
2138 * Feature for {@link #getSystemAvailableFeatures} and
Hung-ying Tyan3424c022010-08-27 18:08:19 +08002139 * {@link #hasSystemFeature}: The SIP API is enabled on the device.
2140 */
2141 @SdkConstant(SdkConstantType.FEATURE)
2142 public static final String FEATURE_SIP = "android.software.sip";
2143
2144 /**
2145 * Feature for {@link #getSystemAvailableFeatures} and
2146 * {@link #hasSystemFeature}: The device supports SIP-based VOIP.
2147 */
2148 @SdkConstant(SdkConstantType.FEATURE)
2149 public static final String FEATURE_SIP_VOIP = "android.software.sip.voip";
2150
Dianne Hackborn08ee42c2009-11-19 17:08:01 -08002151 /**
2152 * Feature for {@link #getSystemAvailableFeatures} and
Ihab Awad1ec68882014-09-12 11:09:01 -07002153 * {@link #hasSystemFeature}: The Connection Service API is enabled on the device.
2154 */
2155 @SdkConstant(SdkConstantType.FEATURE)
2156 public static final String FEATURE_CONNECTION_SERVICE = "android.software.connectionservice";
2157
2158 /**
2159 * Feature for {@link #getSystemAvailableFeatures} and
Dan Morrillb0fe0332010-04-05 14:43:58 -07002160 * {@link #hasSystemFeature}: The device's display has a touch screen.
2161 */
2162 @SdkConstant(SdkConstantType.FEATURE)
2163 public static final String FEATURE_TOUCHSCREEN = "android.hardware.touchscreen";
Amith Yamasani4b2e9342011-03-31 12:38:53 -07002164
Dan Morrillb0fe0332010-04-05 14:43:58 -07002165 /**
2166 * Feature for {@link #getSystemAvailableFeatures} and
Dan Morrill50ab63f2010-03-05 16:16:19 -08002167 * {@link #hasSystemFeature}: The device's touch screen supports
2168 * multitouch sufficient for basic two-finger gesture detection.
Dianne Hackborn08ee42c2009-11-19 17:08:01 -08002169 */
Xavier Ducrohet3274b9b2009-12-14 17:52:20 -08002170 @SdkConstant(SdkConstantType.FEATURE)
Dianne Hackborn08ee42c2009-11-19 17:08:01 -08002171 public static final String FEATURE_TOUCHSCREEN_MULTITOUCH = "android.hardware.touchscreen.multitouch";
Amith Yamasani4b2e9342011-03-31 12:38:53 -07002172
Dianne Hackborn08ee42c2009-11-19 17:08:01 -08002173 /**
2174 * Feature for {@link #getSystemAvailableFeatures} and
Dan Morrill50ab63f2010-03-05 16:16:19 -08002175 * {@link #hasSystemFeature}: The device's touch screen is capable of
2176 * tracking two or more fingers fully independently.
2177 */
2178 @SdkConstant(SdkConstantType.FEATURE)
2179 public static final String FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT = "android.hardware.touchscreen.multitouch.distinct";
2180
2181 /**
2182 * Feature for {@link #getSystemAvailableFeatures} and
Dan Morrill6993d3d2010-09-03 14:30:14 -07002183 * {@link #hasSystemFeature}: The device's touch screen is capable of
2184 * tracking a full hand of fingers fully independently -- that is, 5 or
2185 * more simultaneous independent pointers.
2186 */
2187 @SdkConstant(SdkConstantType.FEATURE)
2188 public static final String FEATURE_TOUCHSCREEN_MULTITOUCH_JAZZHAND = "android.hardware.touchscreen.multitouch.jazzhand";
2189
2190 /**
2191 * Feature for {@link #getSystemAvailableFeatures} and
Dan Morrilla5376872011-01-23 13:15:53 -08002192 * {@link #hasSystemFeature}: The device does not have a touch screen, but
2193 * does support touch emulation for basic events. For instance, the
2194 * device might use a mouse or remote control to drive a cursor, and
2195 * emulate basic touch pointer events like down, up, drag, etc. All
2196 * devices that support android.hardware.touchscreen or a sub-feature are
2197 * presumed to also support faketouch.
2198 */
2199 @SdkConstant(SdkConstantType.FEATURE)
2200 public static final String FEATURE_FAKETOUCH = "android.hardware.faketouch";
2201
2202 /**
2203 * Feature for {@link #getSystemAvailableFeatures} and
Dianne Hackborne22fe932011-06-08 20:24:29 -07002204 * {@link #hasSystemFeature}: The device does not have a touch screen, but
2205 * does support touch emulation for basic events that supports distinct
2206 * tracking of two or more fingers. This is an extension of
2207 * {@link #FEATURE_FAKETOUCH} for input devices with this capability. Note
2208 * that unlike a distinct multitouch screen as defined by
2209 * {@link #FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT}, these kinds of input
2210 * devices will not actually provide full two-finger gestures since the
2211 * input is being transformed to cursor movement on the screen. That is,
2212 * single finger gestures will move a cursor; two-finger swipes will
2213 * result in single-finger touch events; other two-finger gestures will
2214 * result in the corresponding two-finger touch event.
2215 */
2216 @SdkConstant(SdkConstantType.FEATURE)
2217 public static final String FEATURE_FAKETOUCH_MULTITOUCH_DISTINCT = "android.hardware.faketouch.multitouch.distinct";
2218
2219 /**
2220 * Feature for {@link #getSystemAvailableFeatures} and
2221 * {@link #hasSystemFeature}: The device does not have a touch screen, but
2222 * does support touch emulation for basic events that supports tracking
2223 * a hand of fingers (5 or more fingers) fully independently.
2224 * This is an extension of
2225 * {@link #FEATURE_FAKETOUCH} for input devices with this capability. Note
2226 * that unlike a multitouch screen as defined by
2227 * {@link #FEATURE_TOUCHSCREEN_MULTITOUCH_JAZZHAND}, not all two finger
2228 * gestures can be detected due to the limitations described for
2229 * {@link #FEATURE_FAKETOUCH_MULTITOUCH_DISTINCT}.
2230 */
2231 @SdkConstant(SdkConstantType.FEATURE)
2232 public static final String FEATURE_FAKETOUCH_MULTITOUCH_JAZZHAND = "android.hardware.faketouch.multitouch.jazzhand";
2233
2234 /**
2235 * Feature for {@link #getSystemAvailableFeatures} and
Jim Millerd9b9d412015-07-22 19:51:40 -07002236 * {@link #hasSystemFeature}: The device has biometric hardware to detect a fingerprint.
2237 */
2238 @SdkConstant(SdkConstantType.FEATURE)
2239 public static final String FEATURE_FINGERPRINT = "android.hardware.fingerprint";
2240
2241 /**
2242 * Feature for {@link #getSystemAvailableFeatures} and
Dianne Hackborne289bff2011-06-13 19:33:22 -07002243 * {@link #hasSystemFeature}: The device supports portrait orientation
2244 * screens. For backwards compatibility, you can assume that if neither
2245 * this nor {@link #FEATURE_SCREEN_LANDSCAPE} is set then the device supports
2246 * both portrait and landscape.
2247 */
2248 @SdkConstant(SdkConstantType.FEATURE)
2249 public static final String FEATURE_SCREEN_PORTRAIT = "android.hardware.screen.portrait";
2250
2251 /**
2252 * Feature for {@link #getSystemAvailableFeatures} and
2253 * {@link #hasSystemFeature}: The device supports landscape orientation
2254 * screens. For backwards compatibility, you can assume that if neither
2255 * this nor {@link #FEATURE_SCREEN_PORTRAIT} is set then the device supports
2256 * both portrait and landscape.
2257 */
2258 @SdkConstant(SdkConstantType.FEATURE)
2259 public static final String FEATURE_SCREEN_LANDSCAPE = "android.hardware.screen.landscape";
2260
2261 /**
2262 * Feature for {@link #getSystemAvailableFeatures} and
Dianne Hackborn08ee42c2009-11-19 17:08:01 -08002263 * {@link #hasSystemFeature}: The device supports live wallpapers.
2264 */
Xavier Ducrohet3274b9b2009-12-14 17:52:20 -08002265 @SdkConstant(SdkConstantType.FEATURE)
Dianne Hackborn08ee42c2009-11-19 17:08:01 -08002266 public static final String FEATURE_LIVE_WALLPAPER = "android.software.live_wallpaper";
Oscar Montemayor1228d0a2010-01-28 12:01:44 -08002267 /**
Dan Morrill50ab63f2010-03-05 16:16:19 -08002268 * Feature for {@link #getSystemAvailableFeatures} and
Dianne Hackborn119bbc32013-03-22 17:27:25 -07002269 * {@link #hasSystemFeature}: The device supports app widgets.
2270 */
2271 @SdkConstant(SdkConstantType.FEATURE)
2272 public static final String FEATURE_APP_WIDGETS = "android.software.app_widgets";
2273
2274 /**
Dianne Hackborn91097de2014-04-04 18:02:06 -07002275 * @hide
2276 * Feature for {@link #getSystemAvailableFeatures} and
2277 * {@link #hasSystemFeature}: The device supports
2278 * {@link android.service.voice.VoiceInteractionService} and
2279 * {@link android.app.VoiceInteractor}.
2280 */
2281 @SdkConstant(SdkConstantType.FEATURE)
2282 public static final String FEATURE_VOICE_RECOGNIZERS = "android.software.voice_recognizers";
2283
2284
2285 /**
Dianne Hackborn119bbc32013-03-22 17:27:25 -07002286 * Feature for {@link #getSystemAvailableFeatures} and
2287 * {@link #hasSystemFeature}: The device supports a home screen that is replaceable
2288 * by third party applications.
2289 */
2290 @SdkConstant(SdkConstantType.FEATURE)
2291 public static final String FEATURE_HOME_SCREEN = "android.software.home_screen";
2292
2293 /**
2294 * Feature for {@link #getSystemAvailableFeatures} and
2295 * {@link #hasSystemFeature}: The device supports adding new input methods implemented
2296 * with the {@link android.inputmethodservice.InputMethodService} API.
2297 */
2298 @SdkConstant(SdkConstantType.FEATURE)
2299 public static final String FEATURE_INPUT_METHODS = "android.software.input_methods";
2300
2301 /**
2302 * Feature for {@link #getSystemAvailableFeatures} and
Amith Yamasani44a01b72013-09-16 10:44:57 -07002303 * {@link #hasSystemFeature}: The device supports device policy enforcement via device admins.
2304 */
2305 @SdkConstant(SdkConstantType.FEATURE)
2306 public static final String FEATURE_DEVICE_ADMIN = "android.software.device_admin";
2307
2308 /**
2309 * Feature for {@link #getSystemAvailableFeatures} and
Tim Kilbournf94b6a92014-03-07 15:13:48 -08002310 * {@link #hasSystemFeature}: The device supports leanback UI. This is
2311 * typically used in a living room television experience, but is a software
2312 * feature unlike {@link #FEATURE_TELEVISION}. Devices running with this
2313 * feature will use resources associated with the "television" UI mode.
2314 */
2315 @SdkConstant(SdkConstantType.FEATURE)
2316 public static final String FEATURE_LEANBACK = "android.software.leanback";
2317
2318 /**
2319 * Feature for {@link #getSystemAvailableFeatures} and
2320 * {@link #hasSystemFeature}: The device supports only leanback UI. Only
2321 * applications designed for this experience should be run, though this is
2322 * not enforced by the system.
Tim Kilbournf94b6a92014-03-07 15:13:48 -08002323 */
2324 @SdkConstant(SdkConstantType.FEATURE)
2325 public static final String FEATURE_LEANBACK_ONLY = "android.software.leanback_only";
2326
2327 /**
2328 * Feature for {@link #getSystemAvailableFeatures} and
Jae Seocfd861e2014-08-27 14:02:15 -07002329 * {@link #hasSystemFeature}: The device supports live TV and can display
2330 * contents from TV inputs implemented with the
2331 * {@link android.media.tv.TvInputService} API.
2332 */
2333 @SdkConstant(SdkConstantType.FEATURE)
2334 public static final String FEATURE_LIVE_TV = "android.software.live_tv";
2335
2336 /**
2337 * Feature for {@link #getSystemAvailableFeatures} and
Dan Morrill50ab63f2010-03-05 16:16:19 -08002338 * {@link #hasSystemFeature}: The device supports WiFi (802.11) networking.
2339 */
2340 @SdkConstant(SdkConstantType.FEATURE)
2341 public static final String FEATURE_WIFI = "android.hardware.wifi";
2342
2343 /**
Irfan Sheriff45b8b462011-09-07 11:24:16 -07002344 * Feature for {@link #getSystemAvailableFeatures} and
2345 * {@link #hasSystemFeature}: The device supports Wi-Fi Direct networking.
2346 */
2347 @SdkConstant(SdkConstantType.FEATURE)
2348 public static final String FEATURE_WIFI_DIRECT = "android.hardware.wifi.direct";
2349
2350 /**
Dianne Hackborn0cf2c8a2012-05-17 17:29:49 -07002351 * Feature for {@link #getSystemAvailableFeatures} and
Etan Cohen04133272016-10-26 11:22:06 -07002352 * {@link #hasSystemFeature}: The device supports Wi-Fi Aware.
Etan Cohen20d329b2015-09-29 13:49:02 -07002353 */
2354 @SdkConstant(SdkConstantType.FEATURE)
Etan Cohen04133272016-10-26 11:22:06 -07002355 public static final String FEATURE_WIFI_AWARE = "android.hardware.wifi.aware";
Etan Cohen20d329b2015-09-29 13:49:02 -07002356
2357 /**
2358 * Feature for {@link #getSystemAvailableFeatures} and
Peter Qiu3d615e42017-08-07 20:13:32 +00002359 * {@link #hasSystemFeature}: The device supports Wi-Fi Passpoint and all
2360 * Passpoint related APIs in {@link WifiManager} are supported. Refer to
2361 * {@link WifiManager#addOrUpdatePasspointConfiguration} for more info.
Peter Qiub99fe312017-05-05 13:48:47 -07002362 */
2363 @SdkConstant(SdkConstantType.FEATURE)
2364 public static final String FEATURE_WIFI_PASSPOINT = "android.hardware.wifi.passpoint";
2365
2366 /**
2367 * Feature for {@link #getSystemAvailableFeatures} and
Etan Cohen692e68e2017-09-14 15:42:01 -07002368 * {@link #hasSystemFeature}: The device supports Wi-Fi RTT (IEEE 802.11mc).
Etan Cohen692e68e2017-09-14 15:42:01 -07002369 */
2370 @SdkConstant(SdkConstantType.FEATURE)
2371 public static final String FEATURE_WIFI_RTT = "android.hardware.wifi.rtt";
2372
2373
2374 /**
2375 * Feature for {@link #getSystemAvailableFeatures} and
Robert Quattlebaum87a71042017-05-15 15:45:20 -07002376 * {@link #hasSystemFeature}: The device supports LoWPAN networking.
2377 * @hide
2378 */
2379 @SdkConstant(SdkConstantType.FEATURE)
2380 public static final String FEATURE_LOWPAN = "android.hardware.lowpan";
2381
2382 /**
2383 * Feature for {@link #getSystemAvailableFeatures} and
Dianne Hackborn0cf2c8a2012-05-17 17:29:49 -07002384 * {@link #hasSystemFeature}: This is a device dedicated to showing UI
Todd Kennedy7f95a002015-04-22 14:28:25 -07002385 * on a vehicle headunit. A headunit here is defined to be inside a
2386 * vehicle that may or may not be moving. A headunit uses either a
2387 * primary display in the center console and/or additional displays in
2388 * the instrument cluster or elsewhere in the vehicle. Headunit display(s)
2389 * have limited size and resolution. The user will likely be focused on
2390 * driving so limiting driver distraction is a primary concern. User input
2391 * can be a variety of hard buttons, touch, rotary controllers and even mouse-
2392 * like interfaces.
2393 */
2394 @SdkConstant(SdkConstantType.FEATURE)
2395 public static final String FEATURE_AUTOMOTIVE = "android.hardware.type.automotive";
2396
2397 /**
2398 * Feature for {@link #getSystemAvailableFeatures} and
2399 * {@link #hasSystemFeature}: This is a device dedicated to showing UI
Dianne Hackborn0cf2c8a2012-05-17 17:29:49 -07002400 * on a television. Television here is defined to be a typical living
2401 * room television experience: displayed on a big screen, where the user
2402 * is sitting far away from it, and the dominant form of input will be
2403 * something like a DPAD, not through touch or mouse.
Tim Kilbournf94b6a92014-03-07 15:13:48 -08002404 * @deprecated use {@link #FEATURE_LEANBACK} instead.
Dianne Hackborn0cf2c8a2012-05-17 17:29:49 -07002405 */
Jose Lima970417c2014-04-10 10:42:19 -07002406 @Deprecated
Dianne Hackborn0cf2c8a2012-05-17 17:29:49 -07002407 @SdkConstant(SdkConstantType.FEATURE)
2408 public static final String FEATURE_TELEVISION = "android.hardware.type.television";
2409
2410 /**
Justin Kohb5731f091c2014-02-13 16:06:59 -08002411 * Feature for {@link #getSystemAvailableFeatures} and
2412 * {@link #hasSystemFeature}: This is a device dedicated to showing UI
2413 * on a watch. A watch here is defined to be a device worn on the body, perhaps on
2414 * the wrist. The user is very close when interacting with the device.
2415 */
2416 @SdkConstant(SdkConstantType.FEATURE)
2417 public static final String FEATURE_WATCH = "android.hardware.type.watch";
2418
2419 /**
Ralph Nathanb8e0dee2017-01-24 15:24:59 -08002420 * Feature for {@link #getSystemAvailableFeatures} and
2421 * {@link #hasSystemFeature}: This is a device for IoT and may not have an UI. An embedded
2422 * device is defined as a full stack Android device with or without a display and no
2423 * user-installable apps.
2424 */
2425 @SdkConstant(SdkConstantType.FEATURE)
2426 public static final String FEATURE_EMBEDDED = "android.hardware.type.embedded";
2427
2428 /**
Dennis Kempin7345ed52017-04-14 16:40:56 -07002429 * Feature for {@link #getSystemAvailableFeatures} and
2430 * {@link #hasSystemFeature}: This is a device dedicated to be primarily used
2431 * with keyboard, mouse or touchpad. This includes traditional desktop
2432 * computers, laptops and variants such as convertibles or detachables.
2433 * Due to the larger screen, the device will most likely use the
2434 * {@link #FEATURE_FREEFORM_WINDOW_MANAGEMENT} feature as well.
2435 */
2436 @SdkConstant(SdkConstantType.FEATURE)
2437 public static final String FEATURE_PC = "android.hardware.type.pc";
2438
2439 /**
Adam Lesinski3d9bcb92014-02-18 14:05:14 -08002440 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
2441 * The device supports printing.
2442 */
2443 @SdkConstant(SdkConstantType.FEATURE)
2444 public static final String FEATURE_PRINTING = "android.software.print";
2445
2446 /**
2447 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
Eugene Susla7c3eef22017-03-10 14:25:58 -08002448 * The device supports {@link android.companion.CompanionDeviceManager#associate associating}
2449 * with devices via {@link android.companion.CompanionDeviceManager}.
2450 */
2451 @SdkConstant(SdkConstantType.FEATURE)
2452 public static final String FEATURE_COMPANION_DEVICE_SETUP
2453 = "android.software.companion_device_setup";
2454
2455 /**
2456 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
Adam Lesinski3d9bcb92014-02-18 14:05:14 -08002457 * The device can perform backup and restore operations on installed applications.
2458 */
2459 @SdkConstant(SdkConstantType.FEATURE)
2460 public static final String FEATURE_BACKUP = "android.software.backup";
2461
2462 /**
Vladislav Kaznacheevd303b252015-10-27 17:30:58 -07002463 * Feature for {@link #getSystemAvailableFeatures} and
2464 * {@link #hasSystemFeature}: The device supports freeform window management.
2465 * Windows have title bars and can be moved and resized.
2466 */
Filip Gruszczynski811dc3b2015-11-23 12:34:22 -08002467 // If this feature is present, you also need to set
2468 // com.android.internal.R.config_freeformWindowManagement to true in your configuration overlay.
Vladislav Kaznacheevd303b252015-10-27 17:30:58 -07002469 @SdkConstant(SdkConstantType.FEATURE)
2470 public static final String FEATURE_FREEFORM_WINDOW_MANAGEMENT
2471 = "android.software.freeform_window_management";
2472
2473 /**
Adam Connors23cc04e2014-04-01 12:12:20 +01002474 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
Wale Ogunwalefbe12c42015-12-06 16:23:50 -08002475 * The device supports picture-in-picture multi-window mode.
2476 */
2477 @SdkConstant(SdkConstantType.FEATURE)
2478 public static final String FEATURE_PICTURE_IN_PICTURE = "android.software.picture_in_picture";
2479
2480 /**
2481 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
Andrii Kulian1981f5f2017-04-07 16:23:12 -07002482 * The device supports running activities on secondary displays.
2483 */
2484 @SdkConstant(SdkConstantType.FEATURE)
2485 public static final String FEATURE_ACTIVITIES_ON_SECONDARY_DISPLAYS
2486 = "android.software.activities_on_secondary_displays";
2487
2488 /**
2489 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
Amith Yamasani1d653272014-09-11 17:56:05 -07002490 * The device supports creating secondary users and managed profiles via
2491 * {@link DevicePolicyManager}.
Adam Connors23cc04e2014-04-01 12:12:20 +01002492 */
2493 @SdkConstant(SdkConstantType.FEATURE)
Amith Yamasani1d653272014-09-11 17:56:05 -07002494 public static final String FEATURE_MANAGED_USERS = "android.software.managed_users";
2495
2496 /**
2497 * @hide
2498 * TODO: Remove after dependencies updated b/17392243
2499 */
2500 public static final String FEATURE_MANAGED_PROFILES = "android.software.managed_users";
Adam Connors23cc04e2014-04-01 12:12:20 +01002501
2502 /**
Ben Murdochf564c7f2014-05-20 18:58:06 +01002503 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
Adam Connors19ccb5f2014-09-08 17:31:50 +01002504 * The device supports verified boot.
2505 */
2506 @SdkConstant(SdkConstantType.FEATURE)
2507 public static final String FEATURE_VERIFIED_BOOT = "android.software.verified_boot";
2508
2509 /**
2510 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
2511 * The device supports secure removal of users. When a user is deleted the data associated
2512 * with that user is securely deleted and no longer available.
2513 */
2514 @SdkConstant(SdkConstantType.FEATURE)
2515 public static final String FEATURE_SECURELY_REMOVES_USERS
2516 = "android.software.securely_removes_users";
2517
Jeff Sharkeyb92b05b2016-01-28 09:50:00 -07002518 /** {@hide} */
Jeff Sharkey8eb783b2018-01-04 16:46:48 -07002519 @TestApi
Jeff Sharkeyb92b05b2016-01-28 09:50:00 -07002520 @SdkConstant(SdkConstantType.FEATURE)
2521 public static final String FEATURE_FILE_BASED_ENCRYPTION
2522 = "android.software.file_based_encryption";
2523
Jeff Sharkey8eb783b2018-01-04 16:46:48 -07002524 /** {@hide} */
2525 @TestApi
2526 @SdkConstant(SdkConstantType.FEATURE)
2527 public static final String FEATURE_ADOPTABLE_STORAGE
2528 = "android.software.adoptable_storage";
2529
Adam Connors19ccb5f2014-09-08 17:31:50 +01002530 /**
2531 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
Ben Murdoch422c7a52014-05-16 13:45:47 +01002532 * The device has a full implementation of the android.webkit.* APIs. Devices
2533 * lacking this feature will not have a functioning WebView implementation.
2534 */
2535 @SdkConstant(SdkConstantType.FEATURE)
2536 public static final String FEATURE_WEBVIEW = "android.software.webview";
2537
2538 /**
Joe LaPenna4bb015d2014-07-04 17:15:54 -07002539 * Feature for {@link #getSystemAvailableFeatures} and
2540 * {@link #hasSystemFeature}: This device supports ethernet.
Joe LaPenna4bb015d2014-07-04 17:15:54 -07002541 */
2542 @SdkConstant(SdkConstantType.FEATURE)
2543 public static final String FEATURE_ETHERNET = "android.hardware.ethernet";
2544
2545 /**
Yuncheol Heoa0c4a062014-07-10 20:49:27 +09002546 * Feature for {@link #getSystemAvailableFeatures} and
2547 * {@link #hasSystemFeature}: This device supports HDMI-CEC.
2548 * @hide
2549 */
2550 @SdkConstant(SdkConstantType.FEATURE)
2551 public static final String FEATURE_HDMI_CEC = "android.hardware.hdmi.cec";
2552
2553 /**
Michael Wright6faa6752014-09-05 17:57:44 -07002554 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
2555 * The device has all of the inputs necessary to be considered a compatible game controller, or
2556 * includes a compatible game controller in the box.
2557 */
2558 @SdkConstant(SdkConstantType.FEATURE)
2559 public static final String FEATURE_GAMEPAD = "android.hardware.gamepad";
2560
Mike Lockwood5781cd52015-03-27 13:23:41 -07002561 /**
2562 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
2563 * The device has a full implementation of the android.media.midi.* APIs.
2564 */
2565 @SdkConstant(SdkConstantType.FEATURE)
2566 public static final String FEATURE_MIDI = "android.software.midi";
Michael Wright6faa6752014-09-05 17:57:44 -07002567
2568 /**
Ruben Brunkdd18a0b2015-12-04 16:16:31 -08002569 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
Ruben Brunk927d3452016-05-02 19:30:51 -07002570 * The device implements an optimized mode for virtual reality (VR) applications that handles
2571 * stereoscopic rendering of notifications, and disables most monocular system UI components
2572 * while a VR application has user focus.
2573 * Devices declaring this feature must include an application implementing a
2574 * {@link android.service.vr.VrListenerService} that can be targeted by VR applications via
2575 * {@link android.app.Activity#setVrModeEnabled}.
Craig Donnerc6f9c852017-12-27 17:15:19 -08002576 * @deprecated use {@link #FEATURE_VR_MODE_HIGH_PERFORMANCE} instead.
Ruben Brunkdd18a0b2015-12-04 16:16:31 -08002577 */
Craig Donnerc6f9c852017-12-27 17:15:19 -08002578 @Deprecated
Ruben Brunkdd18a0b2015-12-04 16:16:31 -08002579 @SdkConstant(SdkConstantType.FEATURE)
2580 public static final String FEATURE_VR_MODE = "android.software.vr.mode";
2581
2582 /**
Ruben Brunk31d80ea2016-01-25 20:14:08 -08002583 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
Craig Donnerc6f9c852017-12-27 17:15:19 -08002584 * The device implements an optimized mode for virtual reality (VR) applications that handles
2585 * stereoscopic rendering of notifications, disables most monocular system UI components
2586 * while a VR application has user focus and meets extra CDD requirements to provide a
2587 * high-quality VR experience.
2588 * Devices declaring this feature must include an application implementing a
2589 * {@link android.service.vr.VrListenerService} that can be targeted by VR applications via
2590 * {@link android.app.Activity#setVrModeEnabled}.
2591 * and must meet CDD requirements to provide a high-quality VR experience.
Ruben Brunk31d80ea2016-01-25 20:14:08 -08002592 */
2593 @SdkConstant(SdkConstantType.FEATURE)
2594 public static final String FEATURE_VR_MODE_HIGH_PERFORMANCE
2595 = "android.hardware.vr.high_performance";
2596
2597 /**
Craig Donner279dd662017-03-15 17:10:50 -07002598 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
Svet Ganov43574b02017-04-12 09:25:20 -07002599 * The device supports autofill of user credentials, addresses, credit cards, etc
2600 * via integration with {@link android.service.autofill.AutofillService autofill
2601 * providers}.
2602 */
2603 @SdkConstant(SdkConstantType.FEATURE)
2604 public static final String FEATURE_AUTOFILL = "android.software.autofill";
2605
2606 /**
2607 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
Craig Donner279dd662017-03-15 17:10:50 -07002608 * The device implements headtracking suitable for a VR device.
2609 */
2610 @SdkConstant(SdkConstantType.FEATURE)
2611 public static final String FEATURE_VR_HEADTRACKING = "android.hardware.vr.headtracking";
2612
2613 /**
Frank Salimea5e0382018-01-23 22:42:29 -08002614 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
2615 * The device has a StrongBox hardware-backed Keystore.
2616 */
2617 @SdkConstant(SdkConstantType.FEATURE)
2618 public static final String FEATURE_STRONGBOX_KEYSTORE =
2619 "android.hardware.strongbox_keystore";
2620
2621 /**
Dianne Hackborne83cefce2010-02-04 17:38:14 -08002622 * Action to external storage service to clean out removed apps.
2623 * @hide
2624 */
2625 public static final String ACTION_CLEAN_EXTERNAL_STORAGE
2626 = "android.content.pm.CLEAN_EXTERNAL_STORAGE";
Oscar Montemayor1228d0a2010-01-28 12:01:44 -08002627
Dianne Hackborn08ee42c2009-11-19 17:08:01 -08002628 /**
Kenny Root5ab21572011-07-27 11:11:19 -07002629 * Extra field name for the URI to a verification file. Passed to a package
2630 * verifier.
2631 *
2632 * @hide
2633 */
2634 public static final String EXTRA_VERIFICATION_URI = "android.content.pm.extra.VERIFICATION_URI";
2635
2636 /**
2637 * Extra field name for the ID of a package pending verification. Passed to
2638 * a package verifier and is used to call back to
Kenny Root3a9b5fb2011-09-20 14:15:38 -07002639 * {@link PackageManager#verifyPendingInstall(int, int)}
Kenny Root5ab21572011-07-27 11:11:19 -07002640 */
2641 public static final String EXTRA_VERIFICATION_ID = "android.content.pm.extra.VERIFICATION_ID";
2642
2643 /**
2644 * Extra field name for the package identifier which is trying to install
2645 * the package.
2646 *
2647 * @hide
2648 */
2649 public static final String EXTRA_VERIFICATION_INSTALLER_PACKAGE
2650 = "android.content.pm.extra.VERIFICATION_INSTALLER_PACKAGE";
2651
2652 /**
2653 * Extra field name for the requested install flags for a package pending
2654 * verification. Passed to a package verifier.
2655 *
2656 * @hide
2657 */
2658 public static final String EXTRA_VERIFICATION_INSTALL_FLAGS
2659 = "android.content.pm.extra.VERIFICATION_INSTALL_FLAGS";
2660
2661 /**
rich cannings13d428e2012-09-13 13:43:07 -07002662 * Extra field name for the uid of who is requesting to install
2663 * the package.
2664 *
2665 * @hide
2666 */
2667 public static final String EXTRA_VERIFICATION_INSTALLER_UID
2668 = "android.content.pm.extra.VERIFICATION_INSTALLER_UID";
2669
2670 /**
2671 * Extra field name for the package name of a package pending verification.
2672 *
2673 * @hide
2674 */
2675 public static final String EXTRA_VERIFICATION_PACKAGE_NAME
2676 = "android.content.pm.extra.VERIFICATION_PACKAGE_NAME";
2677 /**
rich canningsd1b5cfc2012-08-29 14:49:51 -07002678 * Extra field name for the result of a verification, either
2679 * {@link #VERIFICATION_ALLOW}, or {@link #VERIFICATION_REJECT}.
2680 * Passed to package verifiers after a package is verified.
2681 */
2682 public static final String EXTRA_VERIFICATION_RESULT
2683 = "android.content.pm.extra.VERIFICATION_RESULT";
2684
2685 /**
rich cannings13d428e2012-09-13 13:43:07 -07002686 * Extra field name for the version code of a package pending verification.
Dianne Hackborn3accca02013-09-20 09:32:11 -07002687 * @deprecated Use {@link #EXTRA_VERIFICATION_LONG_VERSION_CODE} instead.
2688 * @hide
2689 */
2690 @Deprecated
2691 public static final String EXTRA_VERIFICATION_VERSION_CODE
2692 = "android.content.pm.extra.VERIFICATION_VERSION_CODE";
2693
2694 /**
2695 * Extra field name for the long version code of a package pending verification.
rich cannings13d428e2012-09-13 13:43:07 -07002696 *
2697 * @hide
2698 */
Dianne Hackborn3accca02013-09-20 09:32:11 -07002699 public static final String EXTRA_VERIFICATION_LONG_VERSION_CODE =
2700 "android.content.pm.extra.VERIFICATION_LONG_VERSION_CODE";
rich cannings13d428e2012-09-13 13:43:07 -07002701
2702 /**
Jeff Sharkey5aa86932016-01-08 19:07:49 -07002703 * Extra field name for the ID of a intent filter pending verification.
2704 * Passed to an intent filter verifier and is used to call back to
2705 * {@link #verifyIntentFilter}
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -08002706 *
2707 * @hide
2708 */
2709 public static final String EXTRA_INTENT_FILTER_VERIFICATION_ID
2710 = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_ID";
2711
2712 /**
2713 * Extra field name for the scheme used for an intent filter pending verification. Passed to
2714 * an intent filter verifier and is used to construct the URI to verify against.
2715 *
2716 * Usually this is "https"
2717 *
2718 * @hide
2719 */
2720 public static final String EXTRA_INTENT_FILTER_VERIFICATION_URI_SCHEME
2721 = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_URI_SCHEME";
2722
2723 /**
2724 * Extra field name for the host names to be used for an intent filter pending verification.
2725 * Passed to an intent filter verifier and is used to construct the URI to verify the
2726 * intent filter.
2727 *
2728 * This is a space delimited list of hosts.
2729 *
2730 * @hide
2731 */
2732 public static final String EXTRA_INTENT_FILTER_VERIFICATION_HOSTS
2733 = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_HOSTS";
2734
2735 /**
2736 * Extra field name for the package name to be used for an intent filter pending verification.
2737 * Passed to an intent filter verifier and is used to check the verification responses coming
2738 * from the hosts. Each host response will need to include the package name of APK containing
2739 * the intent filter.
2740 *
2741 * @hide
2742 */
2743 public static final String EXTRA_INTENT_FILTER_VERIFICATION_PACKAGE_NAME
2744 = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_PACKAGE_NAME";
2745
2746 /**
2747 * The action used to request that the user approve a permission request
2748 * from the application.
Nick Kralevich035f80d2013-03-27 15:20:08 -07002749 *
2750 * @hide
2751 */
Svetoslavc6d1c342015-02-26 14:44:43 -08002752 @SystemApi
2753 public static final String ACTION_REQUEST_PERMISSIONS =
2754 "android.content.pm.action.REQUEST_PERMISSIONS";
Nick Kralevich035f80d2013-03-27 15:20:08 -07002755
2756 /**
Svetoslavc6d1c342015-02-26 14:44:43 -08002757 * The names of the requested permissions.
2758 * <p>
2759 * <strong>Type:</strong> String[]
2760 * </p>
2761 *
2762 * @hide
2763 */
2764 @SystemApi
2765 public static final String EXTRA_REQUEST_PERMISSIONS_NAMES =
2766 "android.content.pm.extra.REQUEST_PERMISSIONS_NAMES";
2767
2768 /**
2769 * The results from the permissions request.
2770 * <p>
2771 * <strong>Type:</strong> int[] of #PermissionResult
2772 * </p>
2773 *
2774 * @hide
2775 */
2776 @SystemApi
2777 public static final String EXTRA_REQUEST_PERMISSIONS_RESULTS
2778 = "android.content.pm.extra.REQUEST_PERMISSIONS_RESULTS";
Nick Kralevich035f80d2013-03-27 15:20:08 -07002779
2780 /**
Jeff Sharkeybb580672014-07-10 12:10:25 -07002781 * String extra for {@link PackageInstallObserver} in the 'extras' Bundle in case of
Christopher Tatef1977b42014-03-24 16:25:51 -07002782 * {@link #INSTALL_FAILED_DUPLICATE_PERMISSION}. This extra names the package which provides
2783 * the existing definition for the permission.
2784 * @hide
2785 */
2786 public static final String EXTRA_FAILURE_EXISTING_PACKAGE
2787 = "android.content.pm.extra.FAILURE_EXISTING_PACKAGE";
2788
2789 /**
Jeff Sharkeybb580672014-07-10 12:10:25 -07002790 * String extra for {@link PackageInstallObserver} in the 'extras' Bundle in case of
Christopher Tatef1977b42014-03-24 16:25:51 -07002791 * {@link #INSTALL_FAILED_DUPLICATE_PERMISSION}. This extra names the permission that is
2792 * being redundantly defined by the package being installed.
2793 * @hide
2794 */
2795 public static final String EXTRA_FAILURE_EXISTING_PERMISSION
2796 = "android.content.pm.extra.FAILURE_EXISTING_PERMISSION";
2797
Svet Ganov8c7f7002015-05-07 10:48:44 -07002798 /**
2799 * Permission flag: The permission is set in its current state
2800 * by the user and apps can still request it at runtime.
2801 *
2802 * @hide
2803 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08002804 @SystemApi
Svet Ganov8c7f7002015-05-07 10:48:44 -07002805 public static final int FLAG_PERMISSION_USER_SET = 1 << 0;
2806
2807 /**
2808 * Permission flag: The permission is set in its current state
2809 * by the user and it is fixed, i.e. apps can no longer request
2810 * this permission.
2811 *
2812 * @hide
2813 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08002814 @SystemApi
Svet Ganov8c7f7002015-05-07 10:48:44 -07002815 public static final int FLAG_PERMISSION_USER_FIXED = 1 << 1;
2816
2817 /**
2818 * Permission flag: The permission is set in its current state
2819 * by device policy and neither apps nor the user can change
2820 * its state.
2821 *
2822 * @hide
2823 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08002824 @SystemApi
Svet Ganov8c7f7002015-05-07 10:48:44 -07002825 public static final int FLAG_PERMISSION_POLICY_FIXED = 1 << 2;
2826
2827 /**
2828 * Permission flag: The permission is set in a granted state but
2829 * access to resources it guards is restricted by other means to
2830 * enable revoking a permission on legacy apps that do not support
2831 * runtime permissions. If this permission is upgraded to runtime
2832 * because the app was updated to support runtime permissions, the
2833 * the permission will be revoked in the upgrade process.
2834 *
2835 * @hide
2836 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08002837 @SystemApi
Svet Ganov8c7f7002015-05-07 10:48:44 -07002838 public static final int FLAG_PERMISSION_REVOKE_ON_UPGRADE = 1 << 3;
2839
Svet Ganovb3f22b42015-05-12 11:01:24 -07002840 /**
2841 * Permission flag: The permission is set in its current state
2842 * because the app is a component that is a part of the system.
2843 *
2844 * @hide
2845 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08002846 @SystemApi
Svet Ganovb3f22b42015-05-12 11:01:24 -07002847 public static final int FLAG_PERMISSION_SYSTEM_FIXED = 1 << 4;
Svet Ganov8c7f7002015-05-07 10:48:44 -07002848
Svet Ganov77ab6a82015-07-03 12:03:02 -07002849 /**
2850 * Permission flag: The permission is granted by default because it
2851 * enables app functionality that is expected to work out-of-the-box
2852 * for providing a smooth user experience. For example, the phone app
2853 * is expected to have the phone permission.
2854 *
2855 * @hide
2856 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08002857 @SystemApi
Svet Ganov77ab6a82015-07-03 12:03:02 -07002858 public static final int FLAG_PERMISSION_GRANTED_BY_DEFAULT = 1 << 5;
2859
Svet Ganov8c7f7002015-05-07 10:48:44 -07002860 /**
Svet Ganov9c165d72015-12-01 19:52:26 -08002861 * Permission flag: The permission has to be reviewed before any of
2862 * the app components can run.
2863 *
2864 * @hide
2865 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08002866 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08002867 public static final int FLAG_PERMISSION_REVIEW_REQUIRED = 1 << 6;
2868
2869 /**
Svet Ganov8c7f7002015-05-07 10:48:44 -07002870 * Mask for all permission flags.
2871 *
2872 * @hide
2873 */
2874 @SystemApi
Svet Ganovb3f22b42015-05-12 11:01:24 -07002875 public static final int MASK_PERMISSION_FLAGS = 0xFF;
Svet Ganov8c7f7002015-05-07 10:48:44 -07002876
Christopher Tatef1977b42014-03-24 16:25:51 -07002877 /**
Svet Ganovd7b1f4112016-02-09 18:49:23 -08002878 * This is a library that contains components apps can invoke. For
2879 * example, a services for apps to bind to, or standard chooser UI,
2880 * etc. This library is versioned and backwards compatible. Clients
2881 * should check its version via {@link android.ext.services.Version
2882 * #getVersionCode()} and avoid calling APIs added in later versions.
2883 *
2884 * @hide
2885 */
2886 public static final String SYSTEM_SHARED_LIBRARY_SERVICES = "android.ext.services";
2887
2888 /**
2889 * This is a library that contains components apps can dynamically
2890 * load. For example, new widgets, helper classes, etc. This library
2891 * is versioned and backwards compatible. Clients should check its
2892 * version via {@link android.ext.shared.Version#getVersionCode()}
2893 * and avoid calling APIs added in later versions.
2894 *
2895 * @hide
2896 */
2897 public static final String SYSTEM_SHARED_LIBRARY_SHARED = "android.ext.shared";
2898
2899 /**
Brian Carlstromca82e612016-04-19 23:16:08 -07002900 * Used when starting a process for an Activity.
2901 *
2902 * @hide
2903 */
2904 public static final int NOTIFY_PACKAGE_USE_ACTIVITY = 0;
2905
2906 /**
2907 * Used when starting a process for a Service.
2908 *
2909 * @hide
2910 */
2911 public static final int NOTIFY_PACKAGE_USE_SERVICE = 1;
2912
2913 /**
2914 * Used when moving a Service to the foreground.
2915 *
2916 * @hide
2917 */
2918 public static final int NOTIFY_PACKAGE_USE_FOREGROUND_SERVICE = 2;
2919
2920 /**
2921 * Used when starting a process for a BroadcastReceiver.
2922 *
2923 * @hide
2924 */
2925 public static final int NOTIFY_PACKAGE_USE_BROADCAST_RECEIVER = 3;
2926
2927 /**
2928 * Used when starting a process for a ContentProvider.
2929 *
2930 * @hide
2931 */
2932 public static final int NOTIFY_PACKAGE_USE_CONTENT_PROVIDER = 4;
2933
2934 /**
2935 * Used when starting a process for a BroadcastReceiver.
2936 *
2937 * @hide
2938 */
2939 public static final int NOTIFY_PACKAGE_USE_BACKUP = 5;
2940
2941 /**
2942 * Used with Context.getClassLoader() across Android packages.
2943 *
2944 * @hide
2945 */
2946 public static final int NOTIFY_PACKAGE_USE_CROSS_PACKAGE = 6;
2947
2948 /**
2949 * Used when starting a package within a process for Instrumentation.
2950 *
2951 * @hide
2952 */
2953 public static final int NOTIFY_PACKAGE_USE_INSTRUMENTATION = 7;
2954
2955 /**
2956 * Total number of usage reasons.
2957 *
2958 * @hide
2959 */
2960 public static final int NOTIFY_PACKAGE_USE_REASONS_COUNT = 8;
2961
2962 /**
Svet Ganov67882122016-12-11 16:36:34 -08002963 * Constant for specifying the highest installed package version code.
2964 */
2965 public static final int VERSION_CODE_HIGHEST = -1;
2966
Jeff Sharkeyad357d12018-02-02 13:25:31 -07002967 /** {@hide} */
2968 public int getUserId() {
2969 return UserHandle.myUserId();
2970 }
2971
Svet Ganov67882122016-12-11 16:36:34 -08002972 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002973 * Retrieve overall information about an application package that is
2974 * installed on the system.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002975 *
2976 * @param packageName The full name (i.e. com.google.apps.contacts) of the
Jeff Sharkey4347f812017-04-21 12:08:39 -06002977 * desired package.
2978 * @param flags Additional option flags to modify the data returned.
2979 * @return A PackageInfo object containing information about the package. If
2980 * flag {@code MATCH_UNINSTALLED_PACKAGES} is set and if the package
2981 * is not found in the list of installed applications, the package
2982 * information is retrieved from the list of uninstalled
kmccormick30498b42013-03-27 17:39:17 -07002983 * applications (which includes installed applications as well as
2984 * applications with data directory i.e. applications which had been
2985 * deleted with {@code DONT_DELETE_DATA} flag set).
Jeff Sharkey8588bc12016-01-06 16:47:42 -07002986 * @throws NameNotFoundException if a package with the given name cannot be
2987 * found on the system.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002988 */
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07002989 public abstract PackageInfo getPackageInfo(String packageName, @PackageInfoFlags int flags)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002990 throws NameNotFoundException;
2991
2992 /**
Svet Ganov67882122016-12-11 16:36:34 -08002993 * Retrieve overall information about an application package that is
2994 * installed on the system. This method can be used for retrieving
Jeff Sharkey4347f812017-04-21 12:08:39 -06002995 * information about packages for which multiple versions can be installed
2996 * at the time. Currently only packages hosting static shared libraries can
2997 * have multiple installed versions. The method can also be used to get info
2998 * for a package that has a single version installed by passing
2999 * {@link #VERSION_CODE_HIGHEST} in the {@link VersionedPackage}
Svet Ganov67882122016-12-11 16:36:34 -08003000 * constructor.
3001 *
Svetoslav Ganov345ffa52017-04-18 16:08:41 -07003002 * @param versionedPackage The versioned package for which to query.
Jeff Sharkey4347f812017-04-21 12:08:39 -06003003 * @param flags Additional option flags to modify the data returned.
3004 * @return A PackageInfo object containing information about the package. If
3005 * flag {@code MATCH_UNINSTALLED_PACKAGES} is set and if the package
3006 * is not found in the list of installed applications, the package
3007 * information is retrieved from the list of uninstalled
Svet Ganov67882122016-12-11 16:36:34 -08003008 * applications (which includes installed applications as well as
3009 * applications with data directory i.e. applications which had been
3010 * deleted with {@code DONT_DELETE_DATA} flag set).
3011 * @throws NameNotFoundException if a package with the given name cannot be
3012 * found on the system.
Svet Ganov67882122016-12-11 16:36:34 -08003013 */
3014 public abstract PackageInfo getPackageInfo(VersionedPackage versionedPackage,
3015 @PackageInfoFlags int flags) throws NameNotFoundException;
3016
3017 /**
Nicolas Prevot9a80e532015-09-23 15:49:28 +01003018 * Retrieve overall information about an application package that is
3019 * installed on the system.
Nicolas Prevot9a80e532015-09-23 15:49:28 +01003020 *
3021 * @param packageName The full name (i.e. com.google.apps.contacts) of the
Jeff Sharkey4347f812017-04-21 12:08:39 -06003022 * desired package.
3023 * @param flags Additional option flags to modify the data returned.
Nicolas Prevot9a80e532015-09-23 15:49:28 +01003024 * @param userId The user id.
Jeff Sharkey4347f812017-04-21 12:08:39 -06003025 * @return A PackageInfo object containing information about the package. If
3026 * flag {@code MATCH_UNINSTALLED_PACKAGES} is set and if the package
3027 * is not found in the list of installed applications, the package
3028 * information is retrieved from the list of uninstalled
Nicolas Prevot9a80e532015-09-23 15:49:28 +01003029 * applications (which includes installed applications as well as
3030 * applications with data directory i.e. applications which had been
3031 * deleted with {@code DONT_DELETE_DATA} flag set).
Jeff Sharkey8588bc12016-01-06 16:47:42 -07003032 * @throws NameNotFoundException if a package with the given name cannot be
3033 * found on the system.
Svet Ganov67882122016-12-11 16:36:34 -08003034 * @hide
Nicolas Prevot9a80e532015-09-23 15:49:28 +01003035 */
3036 @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS)
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07003037 public abstract PackageInfo getPackageInfoAsUser(String packageName,
Jeff Sharkey8588bc12016-01-06 16:47:42 -07003038 @PackageInfoFlags int flags, @UserIdInt int userId) throws NameNotFoundException;
Nicolas Prevot9a80e532015-09-23 15:49:28 +01003039
3040 /**
Dianne Hackborn47096932010-02-11 15:57:09 -08003041 * Map from the current package names in use on the device to whatever
3042 * the current canonical name of that package is.
3043 * @param names Array of current names to be mapped.
3044 * @return Returns an array of the same size as the original, containing
3045 * the canonical name for each package.
3046 */
3047 public abstract String[] currentToCanonicalPackageNames(String[] names);
Amith Yamasani4b2e9342011-03-31 12:38:53 -07003048
Dianne Hackborn47096932010-02-11 15:57:09 -08003049 /**
3050 * Map from a packages canonical name to the current name in use on the device.
3051 * @param names Array of new names to be mapped.
3052 * @return Returns an array of the same size as the original, containing
3053 * the current name for each package.
3054 */
3055 public abstract String[] canonicalToCurrentPackageNames(String[] names);
Amith Yamasani4b2e9342011-03-31 12:38:53 -07003056
Dianne Hackborn47096932010-02-11 15:57:09 -08003057 /**
Andrew Solovay5ae13352014-06-06 12:23:09 -07003058 * Returns a "good" intent to launch a front-door activity in a package.
3059 * This is used, for example, to implement an "open" button when browsing
3060 * through packages. The current implementation looks first for a main
3061 * activity in the category {@link Intent#CATEGORY_INFO}, and next for a
3062 * main activity in the category {@link Intent#CATEGORY_LAUNCHER}. Returns
3063 * <code>null</code> if neither are found.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003064 *
3065 * @param packageName The name of the package to inspect.
Amith Yamasani4b2e9342011-03-31 12:38:53 -07003066 *
Andrew Solovay5ae13352014-06-06 12:23:09 -07003067 * @return A fully-qualified {@link Intent} that can be used to launch the
3068 * main activity in the package. Returns <code>null</code> if the package
3069 * does not contain such an activity, or if <em>packageName</em> is not
Ihab Awad1ec68882014-09-12 11:09:01 -07003070 * recognized.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003071 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06003072 public abstract @Nullable Intent getLaunchIntentForPackage(@NonNull String packageName);
Mihai Predaeae850c2009-05-13 10:13:48 +02003073
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003074 /**
Jose Lima970417c2014-04-10 10:42:19 -07003075 * Return a "good" intent to launch a front-door Leanback activity in a
3076 * package, for use for example to implement an "open" button when browsing
3077 * through packages. The current implementation will look for a main
3078 * activity in the category {@link Intent#CATEGORY_LEANBACK_LAUNCHER}, or
3079 * return null if no main leanback activities are found.
Adam Connors551c0782014-06-05 12:13:03 +01003080 *
Jose Lima970417c2014-04-10 10:42:19 -07003081 * @param packageName The name of the package to inspect.
3082 * @return Returns either a fully-qualified Intent that can be used to launch
3083 * the main Leanback activity in the package, or null if the package
3084 * does not contain such an activity.
3085 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06003086 public abstract @Nullable Intent getLeanbackLaunchIntentForPackage(@NonNull String packageName);
Jose Lima970417c2014-04-10 10:42:19 -07003087
3088 /**
Roberto Perez7ee1a7a2017-12-04 17:14:33 -08003089 * Return a "good" intent to launch a front-door Car activity in a
3090 * package, for use for example to implement an "open" button when browsing
3091 * through packages. The current implementation will look for a main
3092 * activity in the category {@link Intent#CATEGORY_CAR_LAUNCHER}, or
3093 * return null if no main car activities are found.
3094 *
3095 * @param packageName The name of the package to inspect.
3096 * @return Returns either a fully-qualified Intent that can be used to launch
3097 * the main Car activity in the package, or null if the package
3098 * does not contain such an activity.
3099 * @hide
3100 */
3101 public abstract @Nullable Intent getCarLaunchIntentForPackage(@NonNull String packageName);
3102
3103 /**
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06003104 * Return an array of all of the POSIX secondary group IDs that have been
3105 * assigned to the given package.
3106 * <p>
3107 * Note that the same package may have different GIDs under different
3108 * {@link UserHandle} on the same device.
Adam Connors551c0782014-06-05 12:13:03 +01003109 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003110 * @param packageName The full name (i.e. com.google.apps.contacts) of the
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06003111 * desired package.
3112 * @return Returns an int array of the assigned GIDs, or null if there are
Jose Lima970417c2014-04-10 10:42:19 -07003113 * none.
Jeff Sharkey8588bc12016-01-06 16:47:42 -07003114 * @throws NameNotFoundException if a package with the given name cannot be
3115 * found on the system.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003116 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06003117 public abstract int[] getPackageGids(@NonNull String packageName)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003118 throws NameNotFoundException;
3119
3120 /**
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06003121 * Return an array of all of the POSIX secondary group IDs that have been
3122 * assigned to the given package.
3123 * <p>
3124 * Note that the same package may have different GIDs under different
3125 * {@link UserHandle} on the same device.
Dianne Hackborna06de0f2012-12-11 16:34:47 -08003126 *
3127 * @param packageName The full name (i.e. com.google.apps.contacts) of the
Jeff Sharkey8588bc12016-01-06 16:47:42 -07003128 * desired package.
3129 * @return Returns an int array of the assigned gids, or null if there are
3130 * none.
3131 * @throws NameNotFoundException if a package with the given name cannot be
3132 * found on the system.
Dianne Hackborna06de0f2012-12-11 16:34:47 -08003133 */
Jeff Sharkey8588bc12016-01-06 16:47:42 -07003134 public abstract int[] getPackageGids(String packageName, @PackageInfoFlags int flags)
Dianne Hackborna06de0f2012-12-11 16:34:47 -08003135 throws NameNotFoundException;
3136
3137 /**
Jeff Sharkey8588bc12016-01-06 16:47:42 -07003138 * Return the UID associated with the given package name.
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06003139 * <p>
3140 * Note that the same package will have different UIDs under different
3141 * {@link UserHandle} on the same device.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003142 *
Jeff Sharkey8588bc12016-01-06 16:47:42 -07003143 * @param packageName The full name (i.e. com.google.apps.contacts) of the
3144 * desired package.
3145 * @return Returns an integer UID who owns the given package name.
3146 * @throws NameNotFoundException if a package with the given name can not be
3147 * found on the system.
3148 */
3149 public abstract int getPackageUid(String packageName, @PackageInfoFlags int flags)
3150 throws NameNotFoundException;
3151
3152 /**
3153 * Return the UID associated with the given package name.
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06003154 * <p>
3155 * Note that the same package will have different UIDs under different
3156 * {@link UserHandle} on the same device.
Jeff Sharkey8588bc12016-01-06 16:47:42 -07003157 *
3158 * @param packageName The full name (i.e. com.google.apps.contacts) of the
3159 * desired package.
3160 * @param userId The user handle identifier to look up the package under.
3161 * @return Returns an integer UID who owns the given package name.
3162 * @throws NameNotFoundException if a package with the given name can not be
3163 * found on the system.
3164 * @hide
3165 */
3166 public abstract int getPackageUidAsUser(String packageName, @UserIdInt int userId)
3167 throws NameNotFoundException;
3168
3169 /**
3170 * Return the UID associated with the given package name.
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06003171 * <p>
3172 * Note that the same package will have different UIDs under different
3173 * {@link UserHandle} on the same device.
Jeff Sharkey8588bc12016-01-06 16:47:42 -07003174 *
3175 * @param packageName The full name (i.e. com.google.apps.contacts) of the
3176 * desired package.
3177 * @param userId The user handle identifier to look up the package under.
3178 * @return Returns an integer UID who owns the given package name.
3179 * @throws NameNotFoundException if a package with the given name can not be
3180 * found on the system.
3181 * @hide
3182 */
3183 public abstract int getPackageUidAsUser(String packageName, @PackageInfoFlags int flags,
3184 @UserIdInt int userId) throws NameNotFoundException;
3185
3186 /**
3187 * Retrieve all of the information we know about a particular permission.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003188 *
3189 * @param name The fully qualified name (i.e. com.google.permission.LOGIN)
Jeff Sharkey4347f812017-04-21 12:08:39 -06003190 * of the permission you are interested in.
3191 * @param flags Additional option flags to modify the data returned.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003192 * @return Returns a {@link PermissionInfo} containing information about the
3193 * permission.
Jeff Sharkey8588bc12016-01-06 16:47:42 -07003194 * @throws NameNotFoundException if a package with the given name cannot be
3195 * found on the system.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003196 */
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07003197 public abstract PermissionInfo getPermissionInfo(String name, @PermissionInfoFlags int flags)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003198 throws NameNotFoundException;
3199
3200 /**
3201 * Query for all of the permissions associated with a particular group.
3202 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003203 * @param group The fully qualified name (i.e. com.google.permission.LOGIN)
Jeff Sharkey4347f812017-04-21 12:08:39 -06003204 * of the permission group you are interested in. Use null to
3205 * find all of the permissions not associated with a group.
3206 * @param flags Additional option flags to modify the data returned.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003207 * @return Returns a list of {@link PermissionInfo} containing information
Jeff Sharkey4347f812017-04-21 12:08:39 -06003208 * about all of the permissions in the given group.
Jeff Sharkey8588bc12016-01-06 16:47:42 -07003209 * @throws NameNotFoundException if a package with the given name cannot be
3210 * found on the system.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003211 */
3212 public abstract List<PermissionInfo> queryPermissionsByGroup(String group,
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07003213 @PermissionInfoFlags int flags) throws NameNotFoundException;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003214
3215 /**
Paul Navin7b89a7b2017-01-26 23:56:08 +00003216 * Returns true if Permission Review Mode is enabled, false otherwise.
3217 *
3218 * @hide
3219 */
3220 @TestApi
3221 public abstract boolean isPermissionReviewModeEnabled();
3222
3223 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003224 * Retrieve all of the information we know about a particular group of
3225 * permissions.
3226 *
Jeff Sharkey4347f812017-04-21 12:08:39 -06003227 * @param name The fully qualified name (i.e.
3228 * com.google.permission_group.APPS) of the permission you are
3229 * interested in.
3230 * @param flags Additional option flags to modify the data returned.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003231 * @return Returns a {@link PermissionGroupInfo} containing information
Todd Kennedy6b9bfa12016-01-08 13:44:51 -08003232 * about the permission.
Jeff Sharkey8588bc12016-01-06 16:47:42 -07003233 * @throws NameNotFoundException if a package with the given name cannot be
3234 * found on the system.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003235 */
3236 public abstract PermissionGroupInfo getPermissionGroupInfo(String name,
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07003237 @PermissionGroupInfoFlags int flags) throws NameNotFoundException;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003238
3239 /**
3240 * Retrieve all of the known permission groups in the system.
3241 *
Jeff Sharkey4347f812017-04-21 12:08:39 -06003242 * @param flags Additional option flags to modify the data returned.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003243 * @return Returns a list of {@link PermissionGroupInfo} containing
Todd Kennedy6b9bfa12016-01-08 13:44:51 -08003244 * information about all of the known permission groups.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003245 */
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07003246 public abstract List<PermissionGroupInfo> getAllPermissionGroups(
3247 @PermissionGroupInfoFlags int flags);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003248
3249 /**
3250 * Retrieve all of the information we know about a particular
3251 * package/application.
3252 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003253 * @param packageName The full name (i.e. com.google.apps.contacts) of an
Jeff Sharkey4347f812017-04-21 12:08:39 -06003254 * application.
3255 * @param flags Additional option flags to modify the data returned.
Todd Kennedy6b9bfa12016-01-08 13:44:51 -08003256 * @return An {@link ApplicationInfo} containing information about the
Jeff Sharkey4347f812017-04-21 12:08:39 -06003257 * package. If flag {@code MATCH_UNINSTALLED_PACKAGES} is set and if
3258 * the package is not found in the list of installed applications,
3259 * the application information is retrieved from the list of
3260 * uninstalled applications (which includes installed applications
3261 * as well as applications with data directory i.e. applications
3262 * which had been deleted with {@code DONT_DELETE_DATA} flag set).
Jeff Sharkey8588bc12016-01-06 16:47:42 -07003263 * @throws NameNotFoundException if a package with the given name cannot be
3264 * found on the system.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003265 */
3266 public abstract ApplicationInfo getApplicationInfo(String packageName,
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07003267 @ApplicationInfoFlags int flags) throws NameNotFoundException;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003268
Jeff Sharkeycd654482016-01-08 17:42:11 -07003269 /** {@hide} */
3270 public abstract ApplicationInfo getApplicationInfoAsUser(String packageName,
3271 @ApplicationInfoFlags int flags, @UserIdInt int userId) throws NameNotFoundException;
3272
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003273 /**
3274 * Retrieve all of the information we know about a particular activity
3275 * class.
3276 *
Dianne Hackborn361199b2010-08-30 17:42:07 -07003277 * @param component The full component name (i.e.
Jeff Sharkey8a372a02016-03-16 16:25:45 -06003278 * com.google.apps.contacts/com.google.apps.contacts.
3279 * ContactsList) of an Activity class.
Jeff Sharkey4347f812017-04-21 12:08:39 -06003280 * @param flags Additional option flags to modify the data returned.
Jeff Sharkey8a372a02016-03-16 16:25:45 -06003281 * @return An {@link ActivityInfo} containing information about the
3282 * activity.
Jeff Sharkey8588bc12016-01-06 16:47:42 -07003283 * @throws NameNotFoundException if a package with the given name cannot be
3284 * found on the system.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003285 */
Dianne Hackborn361199b2010-08-30 17:42:07 -07003286 public abstract ActivityInfo getActivityInfo(ComponentName component,
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07003287 @ComponentInfoFlags int flags) throws NameNotFoundException;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003288
3289 /**
3290 * Retrieve all of the information we know about a particular receiver
3291 * class.
3292 *
Dianne Hackborn361199b2010-08-30 17:42:07 -07003293 * @param component The full component name (i.e.
Jeff Sharkey8a372a02016-03-16 16:25:45 -06003294 * com.google.apps.calendar/com.google.apps.calendar.
3295 * CalendarAlarm) of a Receiver class.
Jeff Sharkey4347f812017-04-21 12:08:39 -06003296 * @param flags Additional option flags to modify the data returned.
Jeff Sharkey8a372a02016-03-16 16:25:45 -06003297 * @return An {@link ActivityInfo} containing information about the
3298 * receiver.
Jeff Sharkey8588bc12016-01-06 16:47:42 -07003299 * @throws NameNotFoundException if a package with the given name cannot be
3300 * found on the system.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003301 */
Dianne Hackborn361199b2010-08-30 17:42:07 -07003302 public abstract ActivityInfo getReceiverInfo(ComponentName component,
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07003303 @ComponentInfoFlags int flags) throws NameNotFoundException;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003304
3305 /**
Jeff Sharkey8a372a02016-03-16 16:25:45 -06003306 * Retrieve all of the information we know about a particular service class.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003307 *
Dianne Hackborn361199b2010-08-30 17:42:07 -07003308 * @param component The full component name (i.e.
Jeff Sharkey8a372a02016-03-16 16:25:45 -06003309 * com.google.apps.media/com.google.apps.media.
3310 * BackgroundPlayback) of a Service class.
Jeff Sharkey4347f812017-04-21 12:08:39 -06003311 * @param flags Additional option flags to modify the data returned.
Jeff Sharkey8a372a02016-03-16 16:25:45 -06003312 * @return A {@link ServiceInfo} object containing information about the
3313 * service.
Jeff Sharkey8588bc12016-01-06 16:47:42 -07003314 * @throws NameNotFoundException if a package with the given name cannot be
3315 * found on the system.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003316 */
Dianne Hackborn361199b2010-08-30 17:42:07 -07003317 public abstract ServiceInfo getServiceInfo(ComponentName component,
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07003318 @ComponentInfoFlags int flags) throws NameNotFoundException;
Dianne Hackborn361199b2010-08-30 17:42:07 -07003319
3320 /**
3321 * Retrieve all of the information we know about a particular content
3322 * provider class.
3323 *
Dianne Hackborn361199b2010-08-30 17:42:07 -07003324 * @param component The full component name (i.e.
Jeff Sharkey8a372a02016-03-16 16:25:45 -06003325 * com.google.providers.media/com.google.providers.media.
3326 * MediaProvider) of a ContentProvider class.
Jeff Sharkey4347f812017-04-21 12:08:39 -06003327 * @param flags Additional option flags to modify the data returned.
Jeff Sharkey8a372a02016-03-16 16:25:45 -06003328 * @return A {@link ProviderInfo} object containing information about the
3329 * provider.
Jeff Sharkey8588bc12016-01-06 16:47:42 -07003330 * @throws NameNotFoundException if a package with the given name cannot be
3331 * found on the system.
Dianne Hackborn361199b2010-08-30 17:42:07 -07003332 */
3333 public abstract ProviderInfo getProviderInfo(ComponentName component,
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07003334 @ComponentInfoFlags int flags) throws NameNotFoundException;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003335
3336 /**
Jeff Sharkey4347f812017-04-21 12:08:39 -06003337 * Return a List of all packages that are installed on the device.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003338 *
Jeff Sharkey4347f812017-04-21 12:08:39 -06003339 * @param flags Additional option flags to modify the data returned.
Todd Kennedy6b9bfa12016-01-08 13:44:51 -08003340 * @return A List of PackageInfo objects, one for each installed package,
Jeff Sharkey4347f812017-04-21 12:08:39 -06003341 * containing information about the package. In the unlikely case
Todd Kennedy6b9bfa12016-01-08 13:44:51 -08003342 * there are no installed packages, an empty list is returned. If
3343 * flag {@code MATCH_UNINSTALLED_PACKAGES} is set, the package
3344 * information is retrieved from the list of uninstalled
3345 * applications (which includes installed applications as well as
3346 * applications with data directory i.e. applications which had been
3347 * deleted with {@code DONT_DELETE_DATA} flag set).
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003348 */
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07003349 public abstract List<PackageInfo> getInstalledPackages(@PackageInfoFlags int flags);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003350
3351 /**
Jeff Sharkey4347f812017-04-21 12:08:39 -06003352 * Return a List of all installed packages that are currently holding any of
3353 * the given permissions.
Dianne Hackborne7991752013-01-16 17:56:46 -08003354 *
Jeff Sharkey4347f812017-04-21 12:08:39 -06003355 * @param flags Additional option flags to modify the data returned.
Todd Kennedy6b9bfa12016-01-08 13:44:51 -08003356 * @return A List of PackageInfo objects, one for each installed package
3357 * that holds any of the permissions that were provided, containing
3358 * information about the package. If no installed packages hold any
3359 * of the permissions, an empty list is returned. If flag
Jeff Sharkey4347f812017-04-21 12:08:39 -06003360 * {@code MATCH_UNINSTALLED_PACKAGES} is set, the package
3361 * information is retrieved from the list of uninstalled
3362 * applications (which includes installed applications as well as
3363 * applications with data directory i.e. applications which had been
3364 * deleted with {@code DONT_DELETE_DATA} flag set).
Dianne Hackborne7991752013-01-16 17:56:46 -08003365 */
3366 public abstract List<PackageInfo> getPackagesHoldingPermissions(
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07003367 String[] permissions, @PackageInfoFlags int flags);
Dianne Hackborne7991752013-01-16 17:56:46 -08003368
3369 /**
Jeff Sharkey4347f812017-04-21 12:08:39 -06003370 * Return a List of all packages that are installed on the device, for a
Jeff Sharkeyd86b8fe2017-06-02 17:36:26 -06003371 * specific user.
Todd Kennedy6b9bfa12016-01-08 13:44:51 -08003372 *
Jeff Sharkey4347f812017-04-21 12:08:39 -06003373 * @param flags Additional option flags to modify the data returned.
Amith Yamasani151ec4c2012-09-07 19:25:16 -07003374 * @param userId The user for whom the installed packages are to be listed
Todd Kennedy6b9bfa12016-01-08 13:44:51 -08003375 * @return A List of PackageInfo objects, one for each installed package,
Jeff Sharkey4347f812017-04-21 12:08:39 -06003376 * containing information about the package. In the unlikely case
Todd Kennedy6b9bfa12016-01-08 13:44:51 -08003377 * there are no installed packages, an empty list is returned. If
3378 * flag {@code MATCH_UNINSTALLED_PACKAGES} is set, the package
3379 * information is retrieved from the list of uninstalled
3380 * applications (which includes installed applications as well as
3381 * applications with data directory i.e. applications which had been
3382 * deleted with {@code DONT_DELETE_DATA} flag set).
Amith Yamasani151ec4c2012-09-07 19:25:16 -07003383 * @hide
3384 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08003385 @SystemApi
Jeff Sharkeyd86b8fe2017-06-02 17:36:26 -06003386 @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS_FULL)
Jeff Sharkeye06b4d12016-01-06 14:51:50 -07003387 public abstract List<PackageInfo> getInstalledPackagesAsUser(@PackageInfoFlags int flags,
Jeff Sharkey8588bc12016-01-06 16:47:42 -07003388 @UserIdInt int userId);
Amith Yamasani151ec4c2012-09-07 19:25:16 -07003389
3390 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003391 * Check whether a particular package has been granted a particular
3392 * permission.
3393 *
Svet Ganovad3b2972015-07-07 22:49:17 -07003394 * @param permName The name of the permission you are checking for.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003395 * @param pkgName The name of the package you are checking against.
3396 *
3397 * @return If the package has the permission, PERMISSION_GRANTED is
3398 * returned. If it does not have the permission, PERMISSION_DENIED
3399 * is returned.
3400 *
3401 * @see #PERMISSION_GRANTED
3402 * @see #PERMISSION_DENIED
3403 */
Tor Norbye1c2bf032015-03-02 10:57:08 -08003404 @CheckResult
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06003405 public abstract @PermissionResult int checkPermission(String permName, String pkgName);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003406
3407 /**
Svet Ganovad3b2972015-07-07 22:49:17 -07003408 * Checks whether a particular permissions has been revoked for a
3409 * package by policy. Typically the device owner or the profile owner
3410 * may apply such a policy. The user cannot grant policy revoked
3411 * permissions, hence the only way for an app to get such a permission
3412 * is by a policy change.
3413 *
3414 * @param permName The name of the permission you are checking for.
3415 * @param pkgName The name of the package you are checking against.
3416 *
3417 * @return Whether the permission is restricted by policy.
3418 */
3419 @CheckResult
Svet Ganovf1b7f202015-07-29 08:33:42 -07003420 public abstract boolean isPermissionRevokedByPolicy(@NonNull String permName,
3421 @NonNull String pkgName);
3422
3423 /**
3424 * Gets the package name of the component controlling runtime permissions.
3425 *
3426 * @return The package name.
3427 *
3428 * @hide
3429 */
Philip P. Moltmanneb0a0ae2017-06-30 10:55:51 -07003430 @TestApi
Svet Ganovf1b7f202015-07-29 08:33:42 -07003431 public abstract String getPermissionControllerPackageName();
Svet Ganovad3b2972015-07-07 22:49:17 -07003432
3433 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003434 * Add a new dynamic permission to the system. For this to work, your
3435 * package must have defined a permission tree through the
3436 * {@link android.R.styleable#AndroidManifestPermissionTree
3437 * &lt;permission-tree&gt;} tag in its manifest. A package can only add
3438 * permissions to trees that were defined by either its own package or
3439 * another with the same user id; a permission is in a tree if it
3440 * matches the name of the permission tree + ".": for example,
3441 * "com.foo.bar" is a member of the permission tree "com.foo".
3442 *
3443 * <p>It is good to make your permission tree name descriptive, because you
3444 * are taking possession of that entire set of permission names. Thus, it
3445 * must be under a domain you control, with a suffix that will not match
3446 * any normal permissions that may be declared in any applications that
3447 * are part of that domain.
3448 *
3449 * <p>New permissions must be added before
3450 * any .apks are installed that use those permissions. Permissions you
3451 * add through this method are remembered across reboots of the device.
3452 * If the given permission already exists, the info you supply here
3453 * will be used to update it.
3454 *
3455 * @param info Description of the permission to be added.
3456 *
3457 * @return Returns true if a new permission was created, false if an
3458 * existing one was updated.
3459 *
3460 * @throws SecurityException if you are not allowed to add the
3461 * given permission name.
3462 *
3463 * @see #removePermission(String)
3464 */
3465 public abstract boolean addPermission(PermissionInfo info);
3466
3467 /**
Dianne Hackbornd7c09682010-03-30 10:42:20 -07003468 * Like {@link #addPermission(PermissionInfo)} but asynchronously
3469 * persists the package manager state after returning from the call,
3470 * allowing it to return quicker and batch a series of adds at the
3471 * expense of no guarantee the added permission will be retained if
3472 * the device is rebooted before it is written.
3473 */
3474 public abstract boolean addPermissionAsync(PermissionInfo info);
Amith Yamasani4b2e9342011-03-31 12:38:53 -07003475
Dianne Hackbornd7c09682010-03-30 10:42:20 -07003476 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003477 * Removes a permission that was previously added with
3478 * {@link #addPermission(PermissionInfo)}. The same ownership rules apply
3479 * -- you are only allowed to remove permissions that you are allowed
3480 * to add.
3481 *
3482 * @param name The name of the permission to remove.
3483 *
3484 * @throws SecurityException if you are not allowed to remove the
3485 * given permission name.
3486 *
3487 * @see #addPermission(PermissionInfo)
3488 */
3489 public abstract void removePermission(String name);
3490
Svet Ganov8c7f7002015-05-07 10:48:44 -07003491 /**
3492 * Permission flags set when granting or revoking a permission.
3493 *
3494 * @hide
3495 */
3496 @SystemApi
Jeff Sharkey4347f812017-04-21 12:08:39 -06003497 @IntDef(prefix = { "FLAG_PERMISSION_" }, value = {
3498 FLAG_PERMISSION_USER_SET,
Svet Ganov8c7f7002015-05-07 10:48:44 -07003499 FLAG_PERMISSION_USER_FIXED,
3500 FLAG_PERMISSION_POLICY_FIXED,
Svet Ganovb3f22b42015-05-12 11:01:24 -07003501 FLAG_PERMISSION_REVOKE_ON_UPGRADE,
Svet Ganov77ab6a82015-07-03 12:03:02 -07003502 FLAG_PERMISSION_SYSTEM_FIXED,
Jeff Sharkey4347f812017-04-21 12:08:39 -06003503 FLAG_PERMISSION_GRANTED_BY_DEFAULT
3504 })
Svet Ganov8c7f7002015-05-07 10:48:44 -07003505 @Retention(RetentionPolicy.SOURCE)
3506 public @interface PermissionFlags {}
3507
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003508 /**
Svetoslavc6d1c342015-02-26 14:44:43 -08003509 * Grant a runtime permission to an application which the application does not
3510 * already have. The permission must have been requested by the application.
3511 * If the application is not allowed to hold the permission, a {@link
Ruben Brunk12ab5e12016-11-10 15:27:30 -08003512 * java.lang.SecurityException} is thrown. If the package or permission is
3513 * invalid, a {@link java.lang.IllegalArgumentException} is thrown.
Svetoslavc6d1c342015-02-26 14:44:43 -08003514 * <p>
3515 * <strong>Note: </strong>Using this API requires holding
Todd Kennedya8eb6a82016-07-28 16:35:42 -07003516 * android.permission.GRANT_RUNTIME_PERMISSIONS and if the user id is
Svetoslavc6d1c342015-02-26 14:44:43 -08003517 * not the current user android.permission.INTERACT_ACROSS_USERS_FULL.
3518 * </p>
Nick Kralevich035f80d2013-03-27 15:20:08 -07003519 *
Svetoslavc6d1c342015-02-26 14:44:43 -08003520 * @param packageName The package to which to grant the permission.
3521 * @param permissionName The permission name to grant.
3522 * @param user The user for which to grant the permission.
3523 *
Svet Ganov8c7f7002015-05-07 10:48:44 -07003524 * @see #revokeRuntimePermission(String, String, android.os.UserHandle)
Svetoslavc6d1c342015-02-26 14:44:43 -08003525 *
3526 * @hide
Nick Kralevich035f80d2013-03-27 15:20:08 -07003527 */
Svetoslavc6d1c342015-02-26 14:44:43 -08003528 @SystemApi
Jeff Sharkeyd86b8fe2017-06-02 17:36:26 -06003529 @RequiresPermission(android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS)
Svet Ganov8c7f7002015-05-07 10:48:44 -07003530 public abstract void grantRuntimePermission(@NonNull String packageName,
Svetoslavc6d1c342015-02-26 14:44:43 -08003531 @NonNull String permissionName, @NonNull UserHandle user);
Nick Kralevich035f80d2013-03-27 15:20:08 -07003532
Svetoslavc6d1c342015-02-26 14:44:43 -08003533 /**
3534 * Revoke a runtime permission that was previously granted by {@link
Svet Ganov8c7f7002015-05-07 10:48:44 -07003535 * #grantRuntimePermission(String, String, android.os.UserHandle)}. The
3536 * permission must have been requested by and granted to the application.
3537 * If the application is not allowed to hold the permission, a {@link
Ruben Brunk12ab5e12016-11-10 15:27:30 -08003538 * java.lang.SecurityException} is thrown. If the package or permission is
3539 * invalid, a {@link java.lang.IllegalArgumentException} is thrown.
Svetoslavc6d1c342015-02-26 14:44:43 -08003540 * <p>
3541 * <strong>Note: </strong>Using this API requires holding
Todd Kennedya8eb6a82016-07-28 16:35:42 -07003542 * android.permission.REVOKE_RUNTIME_PERMISSIONS and if the user id is
Svetoslavc6d1c342015-02-26 14:44:43 -08003543 * not the current user android.permission.INTERACT_ACROSS_USERS_FULL.
3544 * </p>
3545 *
3546 * @param packageName The package from which to revoke the permission.
3547 * @param permissionName The permission name to revoke.
3548 * @param user The user for which to revoke the permission.
3549 *
Svet Ganov8c7f7002015-05-07 10:48:44 -07003550 * @see #grantRuntimePermission(String, String, android.os.UserHandle)
Svetoslavc6d1c342015-02-26 14:44:43 -08003551 *
3552 * @hide
3553 */
3554 @SystemApi
Jeff Sharkeyd86b8fe2017-06-02 17:36:26 -06003555 @RequiresPermission(android.Manifest.permission.REVOKE_RUNTIME_PERMISSIONS)
Svet Ganov8c7f7002015-05-07 10:48:44 -07003556 public abstract void revokeRuntimePermission(@NonNull String packageName,
Svetoslavc6d1c342015-02-26 14:44:43 -08003557 @NonNull String permissionName, @NonNull UserHandle user);
3558
3559 /**
Svet Ganov8c7f7002015-05-07 10:48:44 -07003560 * Gets the state flags associated with a permission.
3561 *
3562 * @param permissionName The permission for which to get the flags.
3563 * @param packageName The package name for which to get the flags.
3564 * @param user The user for which to get permission flags.
3565 * @return The permission flags.
3566 *
3567 * @hide
3568 */
3569 @SystemApi
Jeff Sharkeyd86b8fe2017-06-02 17:36:26 -06003570 @RequiresPermission(anyOf = {
3571 android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS,
3572 android.Manifest.permission.REVOKE_RUNTIME_PERMISSIONS
3573 })
Svet Ganov8c7f7002015-05-07 10:48:44 -07003574 public abstract @PermissionFlags int getPermissionFlags(String permissionName,
3575 String packageName, @NonNull UserHandle user);
3576
3577 /**
3578 * Updates the flags associated with a permission by replacing the flags in
3579 * the specified mask with the provided flag values.
3580 *
3581 * @param permissionName The permission for which to update the flags.
3582 * @param packageName The package name for which to update the flags.
3583 * @param flagMask The flags which to replace.
3584 * @param flagValues The flags with which to replace.
3585 * @param user The user for which to update the permission flags.
3586 *
3587 * @hide
3588 */
3589 @SystemApi
Jeff Sharkeyd86b8fe2017-06-02 17:36:26 -06003590 @RequiresPermission(anyOf = {
3591 android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS,
3592 android.Manifest.permission.REVOKE_RUNTIME_PERMISSIONS
3593 })
Svet Ganov8c7f7002015-05-07 10:48:44 -07003594 public abstract void updatePermissionFlags(String permissionName,
Jeff Sharkey4347f812017-04-21 12:08:39 -06003595 String packageName, @PermissionFlags int flagMask, @PermissionFlags int flagValues,
Svet Ganov8c7f7002015-05-07 10:48:44 -07003596 @NonNull UserHandle user);
3597
3598 /**
Svetoslav20770dd2015-05-29 15:43:04 -07003599 * Gets whether you should show UI with rationale for requesting a permission.
3600 * You should do this only if you do not have the permission and the context in
3601 * which the permission is requested does not clearly communicate to the user
3602 * what would be the benefit from grating this permission.
3603 *
3604 * @param permission A permission your app wants to request.
3605 * @return Whether you can show permission rationale UI.
3606 *
3607 * @hide
3608 */
3609 public abstract boolean shouldShowRequestPermissionRationale(String permission);
3610
3611 /**
Svetoslavc6d1c342015-02-26 14:44:43 -08003612 * Returns an {@link android.content.Intent} suitable for passing to
3613 * {@link android.app.Activity#startActivityForResult(android.content.Intent, int)}
3614 * which prompts the user to grant permissions to this application.
3615 *
3616 * @throws NullPointerException if {@code permissions} is {@code null} or empty.
3617 *
3618 * @hide
3619 */
3620 public Intent buildRequestPermissionsIntent(@NonNull String[] permissions) {
3621 if (ArrayUtils.isEmpty(permissions)) {
Svet Ganovf66381c2016-02-18 20:02:36 -08003622 throw new IllegalArgumentException("permission cannot be null or empty");
Svetoslavc6d1c342015-02-26 14:44:43 -08003623 }
3624 Intent intent = new Intent(ACTION_REQUEST_PERMISSIONS);
3625 intent.putExtra(EXTRA_REQUEST_PERMISSIONS_NAMES, permissions);
Svet Ganovf1b7f202015-07-29 08:33:42 -07003626 intent.setPackage(getPermissionControllerPackageName());
Svetoslavc6d1c342015-02-26 14:44:43 -08003627 return intent;
Nick Kralevich035f80d2013-03-27 15:20:08 -07003628 }
3629
3630 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003631 * Compare the signatures of two packages to determine if the same
3632 * signature appears in both of them. If they do contain the same
3633 * signature, then they are allowed special privileges when working
3634 * with each other: they can share the same user-id, run instrumentation
3635 * against each other, etc.
3636 *
3637 * @param pkg1 First package name whose signature will be compared.
3638 * @param pkg2 Second package name whose signature will be compared.
Chris Palmer09f33602010-09-13 14:27:18 -07003639 *
3640 * @return Returns an integer indicating whether all signatures on the
3641 * two packages match. The value is >= 0 ({@link #SIGNATURE_MATCH}) if
3642 * all signatures match or < 0 if there is not a match ({@link
3643 * #SIGNATURE_NO_MATCH} or {@link #SIGNATURE_UNKNOWN_PACKAGE}).
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003644 *
Dianne Hackborn766cbfe2009-08-12 18:33:39 -07003645 * @see #checkSignatures(int, int)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003646 */
Tor Norbye1c2bf032015-03-02 10:57:08 -08003647 @CheckResult
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06003648 public abstract @SignatureResult int checkSignatures(String pkg1, String pkg2);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003649
3650 /**
Dianne Hackborn766cbfe2009-08-12 18:33:39 -07003651 * Like {@link #checkSignatures(String, String)}, but takes UIDs of
3652 * the two packages to be checked. This can be useful, for example,
3653 * when doing the check in an IPC, where the UID is the only identity
3654 * available. It is functionally identical to determining the package
3655 * associated with the UIDs and checking their signatures.
3656 *
Joe Onorato25660ec2009-08-12 22:40:37 -07003657 * @param uid1 First UID whose signature will be compared.
3658 * @param uid2 Second UID whose signature will be compared.
Dianne Hackborn766cbfe2009-08-12 18:33:39 -07003659 *
Chris Palmer09f33602010-09-13 14:27:18 -07003660 * @return Returns an integer indicating whether all signatures on the
3661 * two packages match. The value is >= 0 ({@link #SIGNATURE_MATCH}) if
3662 * all signatures match or < 0 if there is not a match ({@link
3663 * #SIGNATURE_NO_MATCH} or {@link #SIGNATURE_UNKNOWN_PACKAGE}).
3664 *
3665 * @see #checkSignatures(String, String)
Dianne Hackborn766cbfe2009-08-12 18:33:39 -07003666 */
Tor Norbye1c2bf032015-03-02 10:57:08 -08003667 @CheckResult
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06003668 public abstract @SignatureResult int checkSignatures(int uid1, int uid2);
Dianne Hackborn766cbfe2009-08-12 18:33:39 -07003669
3670 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003671 * Retrieve the names of all packages that are associated with a particular
3672 * user id. In most cases, this will be a single package name, the package
3673 * that has been assigned that user id. Where there are multiple packages
3674 * sharing the same user id through the "sharedUserId" mechanism, all
3675 * packages with that id will be returned.
3676 *
3677 * @param uid The user id for which you would like to retrieve the
3678 * associated packages.
3679 *
3680 * @return Returns an array of one or more packages assigned to the user
3681 * id, or null if there are no known packages with the given id.
3682 */
Jeff Sharkey377ded0f2016-01-10 13:15:41 -07003683 public abstract @Nullable String[] getPackagesForUid(int uid);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003684
3685 /**
Michal Karpinskicb67dc92016-12-13 18:20:23 +00003686 * Retrieve the official name associated with a uid. This name is
Jonathan Basseri7ea3a332015-05-12 19:39:22 -07003687 * guaranteed to never change, though it is possible for the underlying
Michal Karpinskicb67dc92016-12-13 18:20:23 +00003688 * uid to be changed. That is, if you are storing information about
3689 * uids in persistent storage, you should use the string returned
3690 * by this function instead of the raw uid.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003691 *
Michal Karpinskicb67dc92016-12-13 18:20:23 +00003692 * @param uid The uid for which you would like to retrieve a name.
3693 * @return Returns a unique name for the given uid, or null if the
3694 * uid is not currently assigned.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003695 */
Jeff Sharkey377ded0f2016-01-10 13:15:41 -07003696 public abstract @Nullable String getNameForUid(int uid);
Amith Yamasani4b2e9342011-03-31 12:38:53 -07003697
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003698 /**
Todd Kennedy9da8b8a72017-07-25 15:38:39 -07003699 * Retrieves the official names associated with each given uid.
3700 * @see #getNameForUid(int)
3701 *
3702 * @hide
3703 */
3704 public abstract @Nullable String[] getNamesForUids(int[] uids);
3705
3706 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003707 * Return the user id associated with a shared user name. Multiple
3708 * applications can specify a shared user name in their manifest and thus
3709 * end up using a common uid. This might be used for new applications
3710 * that use an existing shared user name and need to know the uid of the
3711 * shared user.
3712 *
3713 * @param sharedUserName The shared user name whose uid is to be retrieved.
Jeff Sharkey8588bc12016-01-06 16:47:42 -07003714 * @return Returns the UID associated with the shared user.
3715 * @throws NameNotFoundException if a package with the given name cannot be
3716 * found on the system.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003717 * @hide
3718 */
3719 public abstract int getUidForSharedUser(String sharedUserName)
3720 throws NameNotFoundException;
3721
3722 /**
3723 * Return a List of all application packages that are installed on the
3724 * device. If flag GET_UNINSTALLED_PACKAGES has been set, a list of all
Jeff Sharkey4347f812017-04-21 12:08:39 -06003725 * applications including those deleted with {@code DONT_DELETE_DATA}
3726 * (partially installed apps with data directory) will be returned.
Amith Yamasani4b2e9342011-03-31 12:38:53 -07003727 *
Jeff Sharkey4347f812017-04-21 12:08:39 -06003728 * @param flags Additional option flags to modify the data returned.
3729 * @return A List of ApplicationInfo objects, one for each installed
3730 * application. In the unlikely case there are no installed
3731 * packages, an empty list is returned. If flag
3732 * {@code MATCH_UNINSTALLED_PACKAGES} is set, the application
3733 * information is retrieved from the list of uninstalled
Todd Kennedy6b9bfa12016-01-08 13:44:51 -08003734 * applications (which includes installed applications as well as
3735 * applications with data directory i.e. applications which had been
3736 * deleted with {@code DONT_DELETE_DATA} flag set).
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003737 */
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07003738 public abstract List<ApplicationInfo> getInstalledApplications(@ApplicationInfoFlags int flags);
Amith Yamasani4b2e9342011-03-31 12:38:53 -07003739
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003740 /**
Jeff Sharkey4347f812017-04-21 12:08:39 -06003741 * Return a List of all application packages that are installed on the
3742 * device, for a specific user. If flag GET_UNINSTALLED_PACKAGES has been
3743 * set, a list of all applications including those deleted with
3744 * {@code DONT_DELETE_DATA} (partially installed apps with data directory)
Bartosz Fabianowski11334242016-11-17 20:49:16 +01003745 * will be returned.
3746 *
Jeff Sharkey4347f812017-04-21 12:08:39 -06003747 * @param flags Additional option flags to modify the data returned.
3748 * @param userId The user for whom the installed applications are to be
3749 * listed
3750 * @return A List of ApplicationInfo objects, one for each installed
3751 * application. In the unlikely case there are no installed
3752 * packages, an empty list is returned. If flag
3753 * {@code MATCH_UNINSTALLED_PACKAGES} is set, the application
3754 * information is retrieved from the list of uninstalled
Bartosz Fabianowski11334242016-11-17 20:49:16 +01003755 * applications (which includes installed applications as well as
3756 * applications with data directory i.e. applications which had been
3757 * deleted with {@code DONT_DELETE_DATA} flag set).
3758 * @hide
Bartosz Fabianowski11334242016-11-17 20:49:16 +01003759 */
3760 public abstract List<ApplicationInfo> getInstalledApplicationsAsUser(
3761 @ApplicationInfoFlags int flags, @UserIdInt int userId);
3762
3763 /**
Jeff Sharkey910e0812017-04-21 16:29:27 -06003764 * Gets the instant applications the user recently used.
Svet Ganov2acf0632015-11-24 19:10:59 -08003765 *
Svetoslav Ganov096d3042017-01-30 16:34:13 -08003766 * @return The instant app list.
Svet Ganov2acf0632015-11-24 19:10:59 -08003767 *
3768 * @hide
3769 */
Todd Kennedy9c9fdf22017-03-06 10:58:27 -08003770 @SystemApi
Svetoslav Ganov096d3042017-01-30 16:34:13 -08003771 @RequiresPermission(Manifest.permission.ACCESS_INSTANT_APPS)
3772 public abstract @NonNull List<InstantAppInfo> getInstantApps();
Svet Ganov2acf0632015-11-24 19:10:59 -08003773
3774 /**
Svetoslav Ganov096d3042017-01-30 16:34:13 -08003775 * Gets the icon for an instant application.
Svet Ganov2acf0632015-11-24 19:10:59 -08003776 *
3777 * @param packageName The app package name.
3778 *
3779 * @hide
3780 */
Todd Kennedy9c9fdf22017-03-06 10:58:27 -08003781 @SystemApi
Svetoslav Ganov096d3042017-01-30 16:34:13 -08003782 @RequiresPermission(Manifest.permission.ACCESS_INSTANT_APPS)
3783 public abstract @Nullable Drawable getInstantAppIcon(String packageName);
Svet Ganov2acf0632015-11-24 19:10:59 -08003784
3785 /**
David Christie31a16552017-03-01 15:08:45 -08003786 * Gets whether this application is an instant app.
Svet Ganov2acf0632015-11-24 19:10:59 -08003787 *
Svetoslav Ganov096d3042017-01-30 16:34:13 -08003788 * @return Whether caller is an instant app.
Svet Ganov2acf0632015-11-24 19:10:59 -08003789 *
David Christie31a16552017-03-01 15:08:45 -08003790 * @see #isInstantApp(String)
Svetoslav Ganov345ffa52017-04-18 16:08:41 -07003791 * @see #updateInstantAppCookie(byte[])
Svetoslav Ganov096d3042017-01-30 16:34:13 -08003792 * @see #getInstantAppCookie()
Svetoslav Ganov345ffa52017-04-18 16:08:41 -07003793 * @see #getInstantAppCookieMaxBytes()
Svet Ganov2acf0632015-11-24 19:10:59 -08003794 */
Svetoslav Ganov096d3042017-01-30 16:34:13 -08003795 public abstract boolean isInstantApp();
Svet Ganov2acf0632015-11-24 19:10:59 -08003796
3797 /**
David Christie31a16552017-03-01 15:08:45 -08003798 * Gets whether the given package is an instant app.
3799 *
3800 * @param packageName The package to check
3801 * @return Whether the given package is an instant app.
3802 *
3803 * @see #isInstantApp()
Svetoslav Ganov345ffa52017-04-18 16:08:41 -07003804 * @see #updateInstantAppCookie(byte[])
David Christie31a16552017-03-01 15:08:45 -08003805 * @see #getInstantAppCookie()
Svetoslav Ganov345ffa52017-04-18 16:08:41 -07003806 * @see #getInstantAppCookieMaxBytes()
3807 * @see #clearInstantAppCookie()
David Christie31a16552017-03-01 15:08:45 -08003808 */
3809 public abstract boolean isInstantApp(String packageName);
3810
3811 /**
Svetoslav Ganov096d3042017-01-30 16:34:13 -08003812 * Gets the maximum size in bytes of the cookie data an instant app
Svet Ganov2acf0632015-11-24 19:10:59 -08003813 * can store on the device.
3814 *
3815 * @return The max cookie size in bytes.
3816 *
Svetoslav Ganov096d3042017-01-30 16:34:13 -08003817 * @see #isInstantApp()
David Christie31a16552017-03-01 15:08:45 -08003818 * @see #isInstantApp(String)
Svetoslav Ganov345ffa52017-04-18 16:08:41 -07003819 * @see #updateInstantAppCookie(byte[])
Svetoslav Ganov096d3042017-01-30 16:34:13 -08003820 * @see #getInstantAppCookie()
Svetoslav Ganov345ffa52017-04-18 16:08:41 -07003821 * @see #clearInstantAppCookie()
3822 */
3823 public abstract int getInstantAppCookieMaxBytes();
3824
3825 /**
Daniel Cashman5cdda342018-01-19 07:22:52 -08003826 * deprecated
Svetoslav Ganov345ffa52017-04-18 16:08:41 -07003827 * @hide
Svet Ganov2acf0632015-11-24 19:10:59 -08003828 */
Svetoslav Ganov096d3042017-01-30 16:34:13 -08003829 public abstract int getInstantAppCookieMaxSize();
Svet Ganov2acf0632015-11-24 19:10:59 -08003830
3831 /**
Svetoslav Ganov096d3042017-01-30 16:34:13 -08003832 * Gets the instant application cookie for this app. Non
3833 * instant apps and apps that were instant but were upgraded
3834 * to normal apps can still access this API. For instant apps
Svetoslav Ganov345ffa52017-04-18 16:08:41 -07003835 * this cookie is cached for some time after uninstall while for
Svet Ganov2acf0632015-11-24 19:10:59 -08003836 * normal apps the cookie is deleted after the app is uninstalled.
3837 * The cookie is always present while the app is installed.
3838 *
3839 * @return The cookie.
3840 *
Svetoslav Ganov096d3042017-01-30 16:34:13 -08003841 * @see #isInstantApp()
David Christie31a16552017-03-01 15:08:45 -08003842 * @see #isInstantApp(String)
Svetoslav Ganov345ffa52017-04-18 16:08:41 -07003843 * @see #updateInstantAppCookie(byte[])
3844 * @see #getInstantAppCookieMaxBytes()
3845 * @see #clearInstantAppCookie()
Svet Ganov2acf0632015-11-24 19:10:59 -08003846 */
Svetoslav Ganov096d3042017-01-30 16:34:13 -08003847 public abstract @NonNull byte[] getInstantAppCookie();
Svet Ganov2acf0632015-11-24 19:10:59 -08003848
3849 /**
Svetoslav Ganov345ffa52017-04-18 16:08:41 -07003850 * Clears the instant application cookie for the calling app.
Svet Ganov2acf0632015-11-24 19:10:59 -08003851 *
Svetoslav Ganov096d3042017-01-30 16:34:13 -08003852 * @see #isInstantApp()
David Christie31a16552017-03-01 15:08:45 -08003853 * @see #isInstantApp(String)
Svetoslav Ganov345ffa52017-04-18 16:08:41 -07003854 * @see #getInstantAppCookieMaxBytes()
Svetoslav Ganov096d3042017-01-30 16:34:13 -08003855 * @see #getInstantAppCookie()
Svetoslav Ganov345ffa52017-04-18 16:08:41 -07003856 * @see #clearInstantAppCookie()
3857 */
3858 public abstract void clearInstantAppCookie();
3859
3860 /**
3861 * Updates the instant application cookie for the calling app. Non
3862 * instant apps and apps that were instant but were upgraded
3863 * to normal apps can still access this API. For instant apps
3864 * this cookie is cached for some time after uninstall while for
3865 * normal apps the cookie is deleted after the app is uninstalled.
3866 * The cookie is always present while the app is installed. The
3867 * cookie size is limited by {@link #getInstantAppCookieMaxBytes()}.
3868 * Passing <code>null</code> or an empty array clears the cookie.
3869 * </p>
3870 *
3871 * @param cookie The cookie data.
3872 *
3873 * @see #isInstantApp()
3874 * @see #isInstantApp(String)
3875 * @see #getInstantAppCookieMaxBytes()
3876 * @see #getInstantAppCookie()
3877 * @see #clearInstantAppCookie()
3878 *
3879 * @throws IllegalArgumentException if the array exceeds max cookie size.
3880 */
3881 public abstract void updateInstantAppCookie(@Nullable byte[] cookie);
3882
3883 /**
3884 * @removed
Svet Ganov2acf0632015-11-24 19:10:59 -08003885 */
Svetoslav Ganov096d3042017-01-30 16:34:13 -08003886 public abstract boolean setInstantAppCookie(@Nullable byte[] cookie);
Svet Ganov2acf0632015-11-24 19:10:59 -08003887
3888 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003889 * Get a list of shared libraries that are available on the
3890 * system.
Amith Yamasani4b2e9342011-03-31 12:38:53 -07003891 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003892 * @return An array of shared library names that are
3893 * available on the system, or null if none are installed.
Amith Yamasani4b2e9342011-03-31 12:38:53 -07003894 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003895 */
3896 public abstract String[] getSystemSharedLibraryNames();
3897
3898 /**
Svet Ganov67882122016-12-11 16:36:34 -08003899 * Get a list of shared libraries on the device.
3900 *
3901 * @param flags To filter the libraries to return.
3902 * @return The shared library list.
3903 *
Svet Ganov67882122016-12-11 16:36:34 -08003904 * @see #MATCH_UNINSTALLED_PACKAGES
3905 */
3906 public abstract @NonNull List<SharedLibraryInfo> getSharedLibraries(
3907 @InstallFlags int flags);
3908
3909 /**
3910 * Get a list of shared libraries on the device.
3911 *
3912 * @param flags To filter the libraries to return.
3913 * @param userId The user to query for.
3914 * @return The shared library list.
3915 *
3916 * @see #MATCH_FACTORY_ONLY
3917 * @see #MATCH_KNOWN_PACKAGES
3918 * @see #MATCH_ANY_USER
3919 * @see #MATCH_UNINSTALLED_PACKAGES
3920 *
3921 * @hide
3922 */
3923 public abstract @NonNull List<SharedLibraryInfo> getSharedLibrariesAsUser(
3924 @InstallFlags int flags, @UserIdInt int userId);
3925
3926 /**
Svet Ganovd7b1f4112016-02-09 18:49:23 -08003927 * Get the name of the package hosting the services shared library.
3928 *
3929 * @return The library host package.
3930 *
3931 * @hide
3932 */
Svetoslav Ganova9c25002016-04-13 19:25:56 -07003933 public abstract @NonNull String getServicesSystemSharedLibraryPackageName();
3934
3935 /**
3936 * Get the name of the package hosting the shared components shared library.
3937 *
3938 * @return The library host package.
3939 *
3940 * @hide
3941 */
3942 public abstract @NonNull String getSharedSystemSharedLibraryPackageName();
Svet Ganovd7b1f4112016-02-09 18:49:23 -08003943
3944 /**
Todd Kennedy9106c642017-02-08 14:16:53 -08003945 * Returns the names of the packages that have been changed
3946 * [eg. added, removed or updated] since the given sequence
3947 * number.
3948 * <p>If no packages have been changed, returns <code>null</code>.
3949 * <p>The sequence number starts at <code>0</code> and is
3950 * reset every boot.
Todd Kennedy8fddf9d2017-04-17 15:16:12 -07003951 * @param sequenceNumber The first sequence number for which to retrieve package changes.
3952 * @see Settings.Global#BOOT_COUNT
Todd Kennedy9106c642017-02-08 14:16:53 -08003953 */
3954 public abstract @Nullable ChangedPackages getChangedPackages(
3955 @IntRange(from=0) int sequenceNumber);
3956
3957 /**
Dianne Hackborn49237342009-08-27 20:08:01 -07003958 * Get a list of features that are available on the
3959 * system.
Amith Yamasani4b2e9342011-03-31 12:38:53 -07003960 *
Dianne Hackborn49237342009-08-27 20:08:01 -07003961 * @return An array of FeatureInfo classes describing the features
3962 * that are available on the system, or null if there are none(!!).
Dianne Hackborn49237342009-08-27 20:08:01 -07003963 */
3964 public abstract FeatureInfo[] getSystemAvailableFeatures();
3965
3966 /**
Jeff Sharkey115d2c12016-02-15 17:25:57 -07003967 * Check whether the given feature name is one of the available features as
3968 * returned by {@link #getSystemAvailableFeatures()}. This tests for the
3969 * presence of <em>any</em> version of the given feature name; use
3970 * {@link #hasSystemFeature(String, int)} to check for a minimum version.
Amith Yamasani4b2e9342011-03-31 12:38:53 -07003971 *
Jeff Sharkey115d2c12016-02-15 17:25:57 -07003972 * @return Returns true if the devices supports the feature, else false.
Dianne Hackborn039c68e2009-09-26 16:39:23 -07003973 */
3974 public abstract boolean hasSystemFeature(String name);
3975
3976 /**
Jeff Sharkey115d2c12016-02-15 17:25:57 -07003977 * Check whether the given feature name and version is one of the available
3978 * features as returned by {@link #getSystemAvailableFeatures()}. Since
3979 * features are defined to always be backwards compatible, this returns true
3980 * if the available feature version is greater than or equal to the
3981 * requested version.
3982 *
3983 * @return Returns true if the devices supports the feature, else false.
3984 */
3985 public abstract boolean hasSystemFeature(String name, int version);
3986
3987 /**
Jeff Sharkey8a372a02016-03-16 16:25:45 -06003988 * Determine the best action to perform for a given Intent. This is how
3989 * {@link Intent#resolveActivity} finds an activity if a class has not been
3990 * explicitly specified.
3991 * <p>
3992 * <em>Note:</em> if using an implicit Intent (without an explicit
3993 * ComponentName specified), be sure to consider whether to set the
3994 * {@link #MATCH_DEFAULT_ONLY} only flag. You need to do so to resolve the
3995 * activity in the same way that
3996 * {@link android.content.Context#startActivity(Intent)} and
Dianne Hackborn4d023d212010-10-01 13:41:04 -07003997 * {@link android.content.Intent#resolveActivity(PackageManager)
Jeff Sharkey8a372a02016-03-16 16:25:45 -06003998 * Intent.resolveActivity(PackageManager)} do.
3999 * </p>
Amith Yamasani4b2e9342011-03-31 12:38:53 -07004000 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004001 * @param intent An intent containing all of the desired specification
Jeff Sharkey8a372a02016-03-16 16:25:45 -06004002 * (action, data, type, category, and/or component).
Jeff Sharkey4347f812017-04-21 12:08:39 -06004003 * @param flags Additional option flags to modify the data returned. The
4004 * most important is {@link #MATCH_DEFAULT_ONLY}, to limit the
4005 * resolution to only those activities that support the
4006 * {@link android.content.Intent#CATEGORY_DEFAULT}.
Todd Kennedy6b9bfa12016-01-08 13:44:51 -08004007 * @return Returns a ResolveInfo object containing the final activity intent
Jeff Sharkey8a372a02016-03-16 16:25:45 -06004008 * that was determined to be the best action. Returns null if no
Mike LeBeaubd3f5272010-02-18 19:27:17 -08004009 * matching activity was found. If multiple matching activities are
Todd Kennedy6b9bfa12016-01-08 13:44:51 -08004010 * found and there is no default set, returns a ResolveInfo object
Mike LeBeaubd3f5272010-02-18 19:27:17 -08004011 * containing something else, such as the activity resolver.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004012 */
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07004013 public abstract ResolveInfo resolveActivity(Intent intent, @ResolveInfoFlags int flags);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004014
4015 /**
Jeff Sharkey8a372a02016-03-16 16:25:45 -06004016 * Determine the best action to perform for a given Intent for a given user.
4017 * This is how {@link Intent#resolveActivity} finds an activity if a class
4018 * has not been explicitly specified.
4019 * <p>
4020 * <em>Note:</em> if using an implicit Intent (without an explicit
4021 * ComponentName specified), be sure to consider whether to set the
4022 * {@link #MATCH_DEFAULT_ONLY} only flag. You need to do so to resolve the
4023 * activity in the same way that
4024 * {@link android.content.Context#startActivity(Intent)} and
Svetoslav Ganov58d37b52012-09-18 12:04:19 -07004025 * {@link android.content.Intent#resolveActivity(PackageManager)
Jeff Sharkey8a372a02016-03-16 16:25:45 -06004026 * Intent.resolveActivity(PackageManager)} do.
4027 * </p>
Svetoslav Ganov58d37b52012-09-18 12:04:19 -07004028 *
4029 * @param intent An intent containing all of the desired specification
Jeff Sharkey8a372a02016-03-16 16:25:45 -06004030 * (action, data, type, category, and/or component).
Jeff Sharkey4347f812017-04-21 12:08:39 -06004031 * @param flags Additional option flags to modify the data returned. The
4032 * most important is {@link #MATCH_DEFAULT_ONLY}, to limit the
4033 * resolution to only those activities that support the
4034 * {@link android.content.Intent#CATEGORY_DEFAULT}.
Svetoslav Ganov58d37b52012-09-18 12:04:19 -07004035 * @param userId The user id.
Todd Kennedy6b9bfa12016-01-08 13:44:51 -08004036 * @return Returns a ResolveInfo object containing the final activity intent
Jeff Sharkey8a372a02016-03-16 16:25:45 -06004037 * that was determined to be the best action. Returns null if no
Svetoslav Ganov58d37b52012-09-18 12:04:19 -07004038 * matching activity was found. If multiple matching activities are
Todd Kennedy6b9bfa12016-01-08 13:44:51 -08004039 * found and there is no default set, returns a ResolveInfo object
Svetoslav Ganov58d37b52012-09-18 12:04:19 -07004040 * containing something else, such as the activity resolver.
Svetoslav Ganov58d37b52012-09-18 12:04:19 -07004041 * @hide
4042 */
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07004043 public abstract ResolveInfo resolveActivityAsUser(Intent intent, @ResolveInfoFlags int flags,
Jeff Sharkey8588bc12016-01-06 16:47:42 -07004044 @UserIdInt int userId);
Svetoslav Ganov58d37b52012-09-18 12:04:19 -07004045
4046 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004047 * Retrieve all activities that can be performed for the given intent.
4048 *
4049 * @param intent The desired intent as per resolveActivity().
Jeff Sharkey4347f812017-04-21 12:08:39 -06004050 * @param flags Additional option flags to modify the data returned. The
4051 * most important is {@link #MATCH_DEFAULT_ONLY}, to limit the
4052 * resolution to only those activities that support the
4053 * {@link android.content.Intent#CATEGORY_DEFAULT}. Or, set
Jeff Sharkey8a372a02016-03-16 16:25:45 -06004054 * {@link #MATCH_ALL} to prevent any filtering of the results.
4055 * @return Returns a List of ResolveInfo objects containing one entry for
4056 * each matching activity, ordered from best to worst. In other
4057 * words, the first item is what would be returned by
4058 * {@link #resolveActivity}. If there are no matching activities, an
4059 * empty list is returned.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004060 */
4061 public abstract List<ResolveInfo> queryIntentActivities(Intent intent,
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07004062 @ResolveInfoFlags int flags);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004063
4064 /**
Jeff Sharkey8a372a02016-03-16 16:25:45 -06004065 * Retrieve all activities that can be performed for the given intent, for a
4066 * specific user.
Amith Yamasani151ec4c2012-09-07 19:25:16 -07004067 *
4068 * @param intent The desired intent as per resolveActivity().
Jeff Sharkey4347f812017-04-21 12:08:39 -06004069 * @param flags Additional option flags to modify the data returned. The
4070 * most important is {@link #MATCH_DEFAULT_ONLY}, to limit the
4071 * resolution to only those activities that support the
4072 * {@link android.content.Intent#CATEGORY_DEFAULT}. Or, set
Jeff Sharkey8a372a02016-03-16 16:25:45 -06004073 * {@link #MATCH_ALL} to prevent any filtering of the results.
4074 * @return Returns a List of ResolveInfo objects containing one entry for
4075 * each matching activity, ordered from best to worst. In other
4076 * words, the first item is what would be returned by
4077 * {@link #resolveActivity}. If there are no matching activities, an
4078 * empty list is returned.
Amith Yamasani151ec4c2012-09-07 19:25:16 -07004079 * @hide
4080 */
Svetoslav Ganov58d37b52012-09-18 12:04:19 -07004081 public abstract List<ResolveInfo> queryIntentActivitiesAsUser(Intent intent,
Jeff Sharkey8588bc12016-01-06 16:47:42 -07004082 @ResolveInfoFlags int flags, @UserIdInt int userId);
Amith Yamasani151ec4c2012-09-07 19:25:16 -07004083
4084 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004085 * Retrieve a set of activities that should be presented to the user as
Jeff Sharkey8a372a02016-03-16 16:25:45 -06004086 * similar options. This is like {@link #queryIntentActivities}, except it
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004087 * also allows you to supply a list of more explicit Intents that you would
4088 * like to resolve to particular options, and takes care of returning the
4089 * final ResolveInfo list in a reasonable order, with no duplicates, based
4090 * on those inputs.
4091 *
Jeff Sharkey8a372a02016-03-16 16:25:45 -06004092 * @param caller The class name of the activity that is making the request.
4093 * This activity will never appear in the output list. Can be
4094 * null.
4095 * @param specifics An array of Intents that should be resolved to the first
4096 * specific results. Can be null.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004097 * @param intent The desired intent as per resolveActivity().
Jeff Sharkey4347f812017-04-21 12:08:39 -06004098 * @param flags Additional option flags to modify the data returned. The
4099 * most important is {@link #MATCH_DEFAULT_ONLY}, to limit the
4100 * resolution to only those activities that support the
4101 * {@link android.content.Intent#CATEGORY_DEFAULT}.
Jeff Sharkey8a372a02016-03-16 16:25:45 -06004102 * @return Returns a List of ResolveInfo objects containing one entry for
4103 * each matching activity. The list is ordered first by all of the
4104 * intents resolved in <var>specifics</var> and then any additional
4105 * activities that can handle <var>intent</var> but did not get
4106 * included by one of the <var>specifics</var> intents. If there are
4107 * no matching activities, an empty list is returned.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004108 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06004109 public abstract List<ResolveInfo> queryIntentActivityOptions(@Nullable ComponentName caller,
4110 @Nullable Intent[] specifics, Intent intent, @ResolveInfoFlags int flags);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004111
4112 /**
4113 * Retrieve all receivers that can handle a broadcast of the given intent.
4114 *
4115 * @param intent The desired intent as per resolveActivity().
Jeff Sharkey4347f812017-04-21 12:08:39 -06004116 * @param flags Additional option flags to modify the data returned.
Jeff Sharkey8a372a02016-03-16 16:25:45 -06004117 * @return Returns a List of ResolveInfo objects containing one entry for
4118 * each matching receiver, ordered from best to worst. If there are
4119 * no matching receivers, an empty list or null is returned.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004120 */
4121 public abstract List<ResolveInfo> queryBroadcastReceivers(Intent intent,
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07004122 @ResolveInfoFlags int flags);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004123
4124 /**
Jeff Sharkey8a372a02016-03-16 16:25:45 -06004125 * Retrieve all receivers that can handle a broadcast of the given intent,
4126 * for a specific user.
Amith Yamasanif203aee2012-08-29 18:41:53 -07004127 *
4128 * @param intent The desired intent as per resolveActivity().
Jeff Sharkey4347f812017-04-21 12:08:39 -06004129 * @param flags Additional option flags to modify the data returned.
Fyodor Kupolov940e8572016-01-26 12:03:51 -08004130 * @param userHandle UserHandle of the user being queried.
Jeff Sharkey8a372a02016-03-16 16:25:45 -06004131 * @return Returns a List of ResolveInfo objects containing one entry for
4132 * each matching receiver, ordered from best to worst. If there are
4133 * no matching receivers, an empty list or null is returned.
Amith Yamasanif203aee2012-08-29 18:41:53 -07004134 * @hide
4135 */
Fyodor Kupolov940e8572016-01-26 12:03:51 -08004136 @SystemApi
Todd Kennedydbaef6d2017-07-24 11:28:00 -07004137 @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS)
Fyodor Kupolov940e8572016-01-26 12:03:51 -08004138 public List<ResolveInfo> queryBroadcastReceiversAsUser(Intent intent,
4139 @ResolveInfoFlags int flags, UserHandle userHandle) {
4140 return queryBroadcastReceiversAsUser(intent, flags, userHandle.getIdentifier());
4141 }
4142
4143 /**
4144 * @hide
4145 */
Jeff Sharkeye06b4d12016-01-06 14:51:50 -07004146 public abstract List<ResolveInfo> queryBroadcastReceiversAsUser(Intent intent,
Jeff Sharkey8588bc12016-01-06 16:47:42 -07004147 @ResolveInfoFlags int flags, @UserIdInt int userId);
Amith Yamasanif203aee2012-08-29 18:41:53 -07004148
Fyodor Kupolov940e8572016-01-26 12:03:51 -08004149
Jeff Sharkeybd940222016-01-08 11:07:13 -07004150 /** {@hide} */
4151 @Deprecated
4152 public List<ResolveInfo> queryBroadcastReceivers(Intent intent,
4153 @ResolveInfoFlags int flags, @UserIdInt int userId) {
Jeff Sharkey6f4b2a32017-03-21 14:13:41 -06004154 final String msg = "Shame on you for calling the hidden API "
4155 + "queryBroadcastReceivers(). Shame!";
4156 if (VMRuntime.getRuntime().getTargetSdkVersion() >= Build.VERSION_CODES.O) {
4157 throw new UnsupportedOperationException(msg);
4158 } else {
4159 Log.d(TAG, msg);
4160 return queryBroadcastReceiversAsUser(intent, flags, userId);
4161 }
Jeff Sharkeybd940222016-01-08 11:07:13 -07004162 }
4163
Amith Yamasanif203aee2012-08-29 18:41:53 -07004164 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004165 * Determine the best service to handle for a given Intent.
4166 *
4167 * @param intent An intent containing all of the desired specification
Jeff Sharkey8a372a02016-03-16 16:25:45 -06004168 * (action, data, type, category, and/or component).
Jeff Sharkey4347f812017-04-21 12:08:39 -06004169 * @param flags Additional option flags to modify the data returned.
Todd Kennedy6b9bfa12016-01-08 13:44:51 -08004170 * @return Returns a ResolveInfo object containing the final service intent
Jeff Sharkey8a372a02016-03-16 16:25:45 -06004171 * that was determined to be the best action. Returns null if no
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004172 * matching service was found.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004173 */
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07004174 public abstract ResolveInfo resolveService(Intent intent, @ResolveInfoFlags int flags);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004175
4176 /**
4177 * Retrieve all services that can match the given intent.
4178 *
4179 * @param intent The desired intent as per resolveService().
Jeff Sharkey4347f812017-04-21 12:08:39 -06004180 * @param flags Additional option flags to modify the data returned.
Jeff Sharkey8a372a02016-03-16 16:25:45 -06004181 * @return Returns a List of ResolveInfo objects containing one entry for
4182 * each matching service, ordered from best to worst. In other
4183 * words, the first item is what would be returned by
4184 * {@link #resolveService}. If there are no matching services, an
4185 * empty list or null is returned.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004186 */
4187 public abstract List<ResolveInfo> queryIntentServices(Intent intent,
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07004188 @ResolveInfoFlags int flags);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004189
4190 /**
Svetoslav Ganov58d37b52012-09-18 12:04:19 -07004191 * Retrieve all services that can match the given intent for a given user.
4192 *
4193 * @param intent The desired intent as per resolveService().
Jeff Sharkey4347f812017-04-21 12:08:39 -06004194 * @param flags Additional option flags to modify the data returned.
Svetoslav Ganov58d37b52012-09-18 12:04:19 -07004195 * @param userId The user id.
Jeff Sharkey8a372a02016-03-16 16:25:45 -06004196 * @return Returns a List of ResolveInfo objects containing one entry for
4197 * each matching service, ordered from best to worst. In other
4198 * words, the first item is what would be returned by
4199 * {@link #resolveService}. If there are no matching services, an
4200 * empty list or null is returned.
Svetoslav Ganov58d37b52012-09-18 12:04:19 -07004201 * @hide
4202 */
4203 public abstract List<ResolveInfo> queryIntentServicesAsUser(Intent intent,
Jeff Sharkey8588bc12016-01-06 16:47:42 -07004204 @ResolveInfoFlags int flags, @UserIdInt int userId);
Svetoslav Ganov58d37b52012-09-18 12:04:19 -07004205
Todd Kennedy6b9bfa12016-01-08 13:44:51 -08004206 /**
4207 * Retrieve all providers that can match the given intent.
4208 *
4209 * @param intent An intent containing all of the desired specification
4210 * (action, data, type, category, and/or component).
Jeff Sharkey4347f812017-04-21 12:08:39 -06004211 * @param flags Additional option flags to modify the data returned.
Todd Kennedy6b9bfa12016-01-08 13:44:51 -08004212 * @param userId The user id.
Jeff Sharkey8a372a02016-03-16 16:25:45 -06004213 * @return Returns a List of ResolveInfo objects containing one entry for
4214 * each matching provider, ordered from best to worst. If there are
4215 * no matching services, an empty list or null is returned.
Todd Kennedy6b9bfa12016-01-08 13:44:51 -08004216 * @hide
4217 */
Jeff Sharkey85f5f812013-10-07 10:16:12 -07004218 public abstract List<ResolveInfo> queryIntentContentProvidersAsUser(
Jeff Sharkey8588bc12016-01-06 16:47:42 -07004219 Intent intent, @ResolveInfoFlags int flags, @UserIdInt int userId);
Jeff Sharkey85f5f812013-10-07 10:16:12 -07004220
4221 /**
4222 * Retrieve all providers that can match the given intent.
4223 *
4224 * @param intent An intent containing all of the desired specification
4225 * (action, data, type, category, and/or component).
Jeff Sharkey4347f812017-04-21 12:08:39 -06004226 * @param flags Additional option flags to modify the data returned.
Jeff Sharkey8a372a02016-03-16 16:25:45 -06004227 * @return Returns a List of ResolveInfo objects containing one entry for
4228 * each matching provider, ordered from best to worst. If there are
4229 * no matching services, an empty list or null is returned.
Jeff Sharkey85f5f812013-10-07 10:16:12 -07004230 */
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07004231 public abstract List<ResolveInfo> queryIntentContentProviders(Intent intent,
4232 @ResolveInfoFlags int flags);
Jeff Sharkey85f5f812013-10-07 10:16:12 -07004233
Svetoslav Ganov58d37b52012-09-18 12:04:19 -07004234 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004235 * Find a single content provider by its base path name.
4236 *
4237 * @param name The name of the provider to find.
Jeff Sharkey4347f812017-04-21 12:08:39 -06004238 * @param flags Additional option flags to modify the data returned.
Jeff Sharkey8a372a02016-03-16 16:25:45 -06004239 * @return A {@link ProviderInfo} object containing information about the
4240 * provider. If a provider was not found, returns null.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004241 */
4242 public abstract ProviderInfo resolveContentProvider(String name,
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07004243 @ComponentInfoFlags int flags);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004244
4245 /**
Alexandra Gherghina0363c3e2014-06-23 13:34:59 +01004246 * Find a single content provider by its base path name.
4247 *
4248 * @param name The name of the provider to find.
Jeff Sharkey4347f812017-04-21 12:08:39 -06004249 * @param flags Additional option flags to modify the data returned.
Alexandra Gherghina0363c3e2014-06-23 13:34:59 +01004250 * @param userId The user id.
Jeff Sharkey8a372a02016-03-16 16:25:45 -06004251 * @return A {@link ProviderInfo} object containing information about the
4252 * provider. If a provider was not found, returns null.
Alexandra Gherghina0363c3e2014-06-23 13:34:59 +01004253 * @hide
4254 */
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07004255 public abstract ProviderInfo resolveContentProviderAsUser(String name,
Jeff Sharkey8588bc12016-01-06 16:47:42 -07004256 @ComponentInfoFlags int flags, @UserIdInt int userId);
Alexandra Gherghina0363c3e2014-06-23 13:34:59 +01004257
4258 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004259 * Retrieve content provider information.
Jeff Sharkey8a372a02016-03-16 16:25:45 -06004260 * <p>
4261 * <em>Note: unlike most other methods, an empty result set is indicated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004262 * by a null return instead of an empty list.</em>
4263 *
4264 * @param processName If non-null, limits the returned providers to only
Jeff Sharkey8a372a02016-03-16 16:25:45 -06004265 * those that are hosted by the given process. If null, all
4266 * content providers are returned.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004267 * @param uid If <var>processName</var> is non-null, this is the required
Jeff Sharkey8a372a02016-03-16 16:25:45 -06004268 * uid owning the requested content providers.
Jeff Sharkey4347f812017-04-21 12:08:39 -06004269 * @param flags Additional option flags to modify the data returned.
Todd Kennedy6b9bfa12016-01-08 13:44:51 -08004270 * @return A list of {@link ProviderInfo} objects containing one entry for
4271 * each provider either matching <var>processName</var> or, if
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004272 * <var>processName</var> is null, all known content providers.
4273 * <em>If there are no matching providers, null is returned.</em>
4274 */
4275 public abstract List<ProviderInfo> queryContentProviders(
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07004276 String processName, int uid, @ComponentInfoFlags int flags);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004277
4278 /**
Makoto Onuki32757292017-02-22 14:36:59 -08004279 * Same as {@link #queryContentProviders}, except when {@code metaDataKey} is not null,
4280 * it only returns providers which have metadata with the {@code metaDataKey} key.
4281 *
4282 * <p>DO NOT USE the {@code metaDataKey} parameter, unless you're the contacts provider.
4283 * You really shouldn't need it. Other apps should use {@link #queryIntentContentProviders}
4284 * instead.
4285 *
4286 * <p>The {@code metaDataKey} parameter was added to allow the contacts provider to quickly
4287 * scan the GAL providers on the device. Unfortunately the discovery protocol used metadata
4288 * to mark GAL providers, rather than intent filters, so we can't use
4289 * {@link #queryIntentContentProviders} for that.
4290 *
4291 * @hide
4292 */
4293 public List<ProviderInfo> queryContentProviders(
4294 String processName, int uid, @ComponentInfoFlags int flags, String metaDataKey) {
4295 // Provide the default implementation for mocks.
4296 return queryContentProviders(processName, uid, flags);
4297 }
4298
4299 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004300 * Retrieve all of the information we know about a particular
4301 * instrumentation class.
4302 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004303 * @param className The full name (i.e.
Jeff Sharkey4347f812017-04-21 12:08:39 -06004304 * com.google.apps.contacts.InstrumentList) of an Instrumentation
4305 * class.
4306 * @param flags Additional option flags to modify the data returned.
4307 * @return An {@link InstrumentationInfo} object containing information
4308 * about the instrumentation.
Jeff Sharkey8588bc12016-01-06 16:47:42 -07004309 * @throws NameNotFoundException if a package with the given name cannot be
4310 * found on the system.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004311 */
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07004312 public abstract InstrumentationInfo getInstrumentationInfo(ComponentName className,
4313 @InstrumentationInfoFlags int flags) throws NameNotFoundException;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004314
4315 /**
Jeff Sharkey4347f812017-04-21 12:08:39 -06004316 * Retrieve information about available instrumentation code. May be used to
4317 * retrieve either all instrumentation code, or only the code targeting a
4318 * particular package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004319 *
4320 * @param targetPackage If null, all instrumentation is returned; only the
Jeff Sharkey4347f812017-04-21 12:08:39 -06004321 * instrumentation targeting this package name is returned.
4322 * @param flags Additional option flags to modify the data returned.
Todd Kennedy6b9bfa12016-01-08 13:44:51 -08004323 * @return A list of {@link InstrumentationInfo} objects containing one
4324 * entry for each matching instrumentation. If there are no
Jesse Hallf77a34f2016-02-04 18:41:33 -08004325 * instrumentation available, returns an empty list.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004326 */
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07004327 public abstract List<InstrumentationInfo> queryInstrumentation(String targetPackage,
4328 @InstrumentationInfoFlags int flags);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004329
4330 /**
4331 * Retrieve an image from a package. This is a low-level API used by
4332 * the various package manager info structures (such as
4333 * {@link ComponentInfo} to implement retrieval of their associated
4334 * icon.
4335 *
4336 * @param packageName The name of the package that this icon is coming from.
kmccormick30498b42013-03-27 17:39:17 -07004337 * Cannot be null.
4338 * @param resid The resource identifier of the desired image. Cannot be 0.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004339 * @param appInfo Overall information about <var>packageName</var>. This
4340 * may be null, in which case the application information will be retrieved
4341 * for you if needed; if you already have this information around, it can
4342 * be much more efficient to supply it here.
4343 *
4344 * @return Returns a Drawable holding the requested image. Returns null if
4345 * an image could not be found for any reason.
4346 */
Tor Norbye7b9c9122013-05-30 16:48:33 -07004347 public abstract Drawable getDrawable(String packageName, @DrawableRes int resid,
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004348 ApplicationInfo appInfo);
4349
4350 /**
4351 * Retrieve the icon associated with an activity. Given the full name of
4352 * an activity, retrieves the information about it and calls
4353 * {@link ComponentInfo#loadIcon ComponentInfo.loadIcon()} to return its icon.
kmccormick30498b42013-03-27 17:39:17 -07004354 * If the activity cannot be found, NameNotFoundException is thrown.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004355 *
4356 * @param activityName Name of the activity whose icon is to be retrieved.
4357 *
4358 * @return Returns the image of the icon, or the default activity icon if
4359 * it could not be found. Does not return null.
4360 * @throws NameNotFoundException Thrown if the resources for the given
4361 * activity could not be loaded.
4362 *
4363 * @see #getActivityIcon(Intent)
4364 */
4365 public abstract Drawable getActivityIcon(ComponentName activityName)
4366 throws NameNotFoundException;
4367
4368 /**
4369 * Retrieve the icon associated with an Intent. If intent.getClassName() is
4370 * set, this simply returns the result of
4371 * getActivityIcon(intent.getClassName()). Otherwise it resolves the intent's
4372 * component and returns the icon associated with the resolved component.
kmccormick30498b42013-03-27 17:39:17 -07004373 * If intent.getClassName() cannot be found or the Intent cannot be resolved
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004374 * to a component, NameNotFoundException is thrown.
4375 *
4376 * @param intent The intent for which you would like to retrieve an icon.
4377 *
4378 * @return Returns the image of the icon, or the default activity icon if
4379 * it could not be found. Does not return null.
4380 * @throws NameNotFoundException Thrown if the resources for application
4381 * matching the given intent could not be loaded.
4382 *
4383 * @see #getActivityIcon(ComponentName)
4384 */
4385 public abstract Drawable getActivityIcon(Intent intent)
4386 throws NameNotFoundException;
4387
4388 /**
Jose Limaf78e3122014-03-06 12:13:15 -08004389 * Retrieve the banner associated with an activity. Given the full name of
4390 * an activity, retrieves the information about it and calls
4391 * {@link ComponentInfo#loadIcon ComponentInfo.loadIcon()} to return its
4392 * banner. If the activity cannot be found, NameNotFoundException is thrown.
4393 *
4394 * @param activityName Name of the activity whose banner is to be retrieved.
4395 * @return Returns the image of the banner, or null if the activity has no
4396 * banner specified.
4397 * @throws NameNotFoundException Thrown if the resources for the given
4398 * activity could not be loaded.
4399 * @see #getActivityBanner(Intent)
4400 */
4401 public abstract Drawable getActivityBanner(ComponentName activityName)
4402 throws NameNotFoundException;
4403
4404 /**
4405 * Retrieve the banner associated with an Intent. If intent.getClassName()
4406 * is set, this simply returns the result of
4407 * getActivityBanner(intent.getClassName()). Otherwise it resolves the
4408 * intent's component and returns the banner associated with the resolved
4409 * component. If intent.getClassName() cannot be found or the Intent cannot
4410 * be resolved to a component, NameNotFoundException is thrown.
4411 *
4412 * @param intent The intent for which you would like to retrieve a banner.
4413 * @return Returns the image of the banner, or null if the activity has no
4414 * banner specified.
4415 * @throws NameNotFoundException Thrown if the resources for application
4416 * matching the given intent could not be loaded.
4417 * @see #getActivityBanner(ComponentName)
4418 */
4419 public abstract Drawable getActivityBanner(Intent intent)
4420 throws NameNotFoundException;
4421
4422 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004423 * Return the generic icon for an activity that is used when no specific
4424 * icon is defined.
Adam Connors23cc04e2014-04-01 12:12:20 +01004425 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004426 * @return Drawable Image of the icon.
4427 */
4428 public abstract Drawable getDefaultActivityIcon();
4429
4430 /**
4431 * Retrieve the icon associated with an application. If it has not defined
4432 * an icon, the default app icon is returned. Does not return null.
4433 *
4434 * @param info Information about application being queried.
4435 *
4436 * @return Returns the image of the icon, or the default application icon
4437 * if it could not be found.
4438 *
4439 * @see #getApplicationIcon(String)
4440 */
4441 public abstract Drawable getApplicationIcon(ApplicationInfo info);
4442
4443 /**
4444 * Retrieve the icon associated with an application. Given the name of the
4445 * application's package, retrieves the information about it and calls
kmccormick30498b42013-03-27 17:39:17 -07004446 * getApplicationIcon() to return its icon. If the application cannot be
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004447 * found, NameNotFoundException is thrown.
4448 *
4449 * @param packageName Name of the package whose application icon is to be
4450 * retrieved.
4451 *
4452 * @return Returns the image of the icon, or the default application icon
4453 * if it could not be found. Does not return null.
4454 * @throws NameNotFoundException Thrown if the resources for the given
4455 * application could not be loaded.
4456 *
4457 * @see #getApplicationIcon(ApplicationInfo)
4458 */
4459 public abstract Drawable getApplicationIcon(String packageName)
4460 throws NameNotFoundException;
4461
4462 /**
Jose Limaf78e3122014-03-06 12:13:15 -08004463 * Retrieve the banner associated with an application.
4464 *
4465 * @param info Information about application being queried.
4466 * @return Returns the image of the banner or null if the application has no
4467 * banner specified.
4468 * @see #getApplicationBanner(String)
4469 */
4470 public abstract Drawable getApplicationBanner(ApplicationInfo info);
4471
4472 /**
4473 * Retrieve the banner associated with an application. Given the name of the
4474 * application's package, retrieves the information about it and calls
4475 * getApplicationIcon() to return its banner. If the application cannot be
4476 * found, NameNotFoundException is thrown.
4477 *
4478 * @param packageName Name of the package whose application banner is to be
4479 * retrieved.
4480 * @return Returns the image of the banner or null if the application has no
4481 * banner specified.
4482 * @throws NameNotFoundException Thrown if the resources for the given
4483 * application could not be loaded.
4484 * @see #getApplicationBanner(ApplicationInfo)
4485 */
4486 public abstract Drawable getApplicationBanner(String packageName)
4487 throws NameNotFoundException;
4488
4489 /**
4490 * Retrieve the logo associated with an activity. Given the full name of an
4491 * activity, retrieves the information about it and calls
4492 * {@link ComponentInfo#loadLogo ComponentInfo.loadLogo()} to return its
4493 * logo. If the activity cannot be found, NameNotFoundException is thrown.
Adam Powell81cd2e92010-04-21 16:35:18 -07004494 *
4495 * @param activityName Name of the activity whose logo is to be retrieved.
Jose Limaf78e3122014-03-06 12:13:15 -08004496 * @return Returns the image of the logo or null if the activity has no logo
4497 * specified.
Adam Powell81cd2e92010-04-21 16:35:18 -07004498 * @throws NameNotFoundException Thrown if the resources for the given
Jose Limaf78e3122014-03-06 12:13:15 -08004499 * activity could not be loaded.
Adam Powell81cd2e92010-04-21 16:35:18 -07004500 * @see #getActivityLogo(Intent)
4501 */
4502 public abstract Drawable getActivityLogo(ComponentName activityName)
4503 throws NameNotFoundException;
4504
4505 /**
4506 * Retrieve the logo associated with an Intent. If intent.getClassName() is
4507 * set, this simply returns the result of
4508 * getActivityLogo(intent.getClassName()). Otherwise it resolves the intent's
4509 * component and returns the logo associated with the resolved component.
kmccormick30498b42013-03-27 17:39:17 -07004510 * If intent.getClassName() cannot be found or the Intent cannot be resolved
Adam Powell81cd2e92010-04-21 16:35:18 -07004511 * to a component, NameNotFoundException is thrown.
4512 *
4513 * @param intent The intent for which you would like to retrieve a logo.
4514 *
4515 * @return Returns the image of the logo, or null if the activity has no
4516 * logo specified.
Amith Yamasani4b2e9342011-03-31 12:38:53 -07004517 *
Adam Powell81cd2e92010-04-21 16:35:18 -07004518 * @throws NameNotFoundException Thrown if the resources for application
4519 * matching the given intent could not be loaded.
4520 *
4521 * @see #getActivityLogo(ComponentName)
4522 */
4523 public abstract Drawable getActivityLogo(Intent intent)
4524 throws NameNotFoundException;
4525
4526 /**
4527 * Retrieve the logo associated with an application. If it has not specified
4528 * a logo, this method returns null.
4529 *
4530 * @param info Information about application being queried.
4531 *
4532 * @return Returns the image of the logo, or null if no logo is specified
4533 * by the application.
4534 *
4535 * @see #getApplicationLogo(String)
4536 */
4537 public abstract Drawable getApplicationLogo(ApplicationInfo info);
4538
4539 /**
4540 * Retrieve the logo associated with an application. Given the name of the
4541 * application's package, retrieves the information about it and calls
kmccormick30498b42013-03-27 17:39:17 -07004542 * getApplicationLogo() to return its logo. If the application cannot be
Adam Powell81cd2e92010-04-21 16:35:18 -07004543 * found, NameNotFoundException is thrown.
4544 *
4545 * @param packageName Name of the package whose application logo is to be
4546 * retrieved.
4547 *
4548 * @return Returns the image of the logo, or null if no application logo
4549 * has been specified.
Amith Yamasani4b2e9342011-03-31 12:38:53 -07004550 *
Adam Powell81cd2e92010-04-21 16:35:18 -07004551 * @throws NameNotFoundException Thrown if the resources for the given
4552 * application could not be loaded.
4553 *
4554 * @see #getApplicationLogo(ApplicationInfo)
4555 */
4556 public abstract Drawable getApplicationLogo(String packageName)
4557 throws NameNotFoundException;
4558
4559 /**
Tony Mak4dc008c2016-03-16 10:46:49 +00004560 * If the target user is a managed profile, then this returns a badged copy of the given icon
4561 * to be able to distinguish it from the original icon. For badging an arbitrary drawable use
Kenny Guydf77d712015-05-29 17:02:22 +01004562 * {@link #getUserBadgedDrawableForDensity(
Svetoslavc7d62f02014-09-04 15:39:54 -07004563 * android.graphics.drawable.Drawable, UserHandle, android.graphics.Rect, int)}.
4564 * <p>
4565 * If the original drawable is a BitmapDrawable and the backing bitmap is
4566 * mutable as per {@link android.graphics.Bitmap#isMutable()}, the badging
4567 * is performed in place and the original drawable is returned.
4568 * </p>
4569 *
4570 * @param icon The icon to badge.
4571 * @param user The target user.
4572 * @return A drawable that combines the original icon and a badge as
4573 * determined by the system.
4574 */
4575 public abstract Drawable getUserBadgedIcon(Drawable icon, UserHandle user);
4576
4577 /**
4578 * If the target user is a managed profile of the calling user or the caller
4579 * is itself a managed profile, then this returns a badged copy of the given
4580 * drawable allowing the user to distinguish it from the original drawable.
4581 * The caller can specify the location in the bounds of the drawable to be
4582 * badged where the badge should be applied as well as the density of the
4583 * badge to be used.
4584 * <p>
4585 * If the original drawable is a BitmapDrawable and the backing bitmap is
Vadim Tryshev66ae66a2016-02-18 15:41:21 -08004586 * mutable as per {@link android.graphics.Bitmap#isMutable()}, the badging
Svetoslavc7d62f02014-09-04 15:39:54 -07004587 * is performed in place and the original drawable is returned.
4588 * </p>
4589 *
4590 * @param drawable The drawable to badge.
4591 * @param user The target user.
4592 * @param badgeLocation Where in the bounds of the badged drawable to place
Vadim Tryshev66ae66a2016-02-18 15:41:21 -08004593 * the badge. If it's {@code null}, the badge is applied on top of the entire
Svetoslavc7d62f02014-09-04 15:39:54 -07004594 * drawable being badged.
4595 * @param badgeDensity The optional desired density for the badge as per
Vadim Tryshev66ae66a2016-02-18 15:41:21 -08004596 * {@link android.util.DisplayMetrics#densityDpi}. If it's not positive,
Svetoslavc7d62f02014-09-04 15:39:54 -07004597 * the density of the display is used.
4598 * @return A drawable that combines the original drawable and a badge as
4599 * determined by the system.
4600 */
4601 public abstract Drawable getUserBadgedDrawableForDensity(Drawable drawable,
4602 UserHandle user, Rect badgeLocation, int badgeDensity);
4603
4604 /**
4605 * If the target user is a managed profile of the calling user or the caller
4606 * is itself a managed profile, then this returns a drawable to use as a small
4607 * icon to include in a view to distinguish it from the original icon.
4608 *
4609 * @param user The target user.
4610 * @param density The optional desired density for the badge as per
4611 * {@link android.util.DisplayMetrics#densityDpi}. If not provided
4612 * the density of the current display is used.
4613 * @return the drawable or null if no drawable is required.
4614 * @hide
4615 */
4616 public abstract Drawable getUserBadgeForDensity(UserHandle user, int density);
4617
4618 /**
4619 * If the target user is a managed profile of the calling user or the caller
Selim Cineke6ff9462016-01-15 15:07:06 -08004620 * is itself a managed profile, then this returns a drawable to use as a small
4621 * icon to include in a view to distinguish it from the original icon. This version
4622 * doesn't have background protection and should be used over a light background instead of
4623 * a badge.
4624 *
4625 * @param user The target user.
4626 * @param density The optional desired density for the badge as per
4627 * {@link android.util.DisplayMetrics#densityDpi}. If not provided
4628 * the density of the current display is used.
4629 * @return the drawable or null if no drawable is required.
4630 * @hide
4631 */
4632 public abstract Drawable getUserBadgeForDensityNoBackground(UserHandle user, int density);
4633
4634 /**
4635 * If the target user is a managed profile of the calling user or the caller
Svetoslavc7d62f02014-09-04 15:39:54 -07004636 * is itself a managed profile, then this returns a copy of the label with
4637 * badging for accessibility services like talkback. E.g. passing in "Email"
4638 * and it might return "Work Email" for Email in the work profile.
4639 *
4640 * @param label The label to change.
4641 * @param user The target user.
4642 * @return A label that combines the original label and a badge as
4643 * determined by the system.
4644 */
4645 public abstract CharSequence getUserBadgedLabel(CharSequence label, UserHandle user);
4646
4647 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004648 * Retrieve text from a package. This is a low-level API used by
4649 * the various package manager info structures (such as
4650 * {@link ComponentInfo} to implement retrieval of their associated
4651 * labels and other text.
4652 *
4653 * @param packageName The name of the package that this text is coming from.
kmccormick30498b42013-03-27 17:39:17 -07004654 * Cannot be null.
4655 * @param resid The resource identifier of the desired text. Cannot be 0.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004656 * @param appInfo Overall information about <var>packageName</var>. This
4657 * may be null, in which case the application information will be retrieved
4658 * for you if needed; if you already have this information around, it can
4659 * be much more efficient to supply it here.
4660 *
4661 * @return Returns a CharSequence holding the requested text. Returns null
4662 * if the text could not be found for any reason.
4663 */
Tor Norbye7b9c9122013-05-30 16:48:33 -07004664 public abstract CharSequence getText(String packageName, @StringRes int resid,
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004665 ApplicationInfo appInfo);
4666
4667 /**
4668 * Retrieve an XML file from a package. This is a low-level API used to
4669 * retrieve XML meta data.
4670 *
4671 * @param packageName The name of the package that this xml is coming from.
kmccormick30498b42013-03-27 17:39:17 -07004672 * Cannot be null.
4673 * @param resid The resource identifier of the desired xml. Cannot be 0.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004674 * @param appInfo Overall information about <var>packageName</var>. This
4675 * may be null, in which case the application information will be retrieved
4676 * for you if needed; if you already have this information around, it can
4677 * be much more efficient to supply it here.
4678 *
4679 * @return Returns an XmlPullParser allowing you to parse out the XML
4680 * data. Returns null if the xml resource could not be found for any
4681 * reason.
4682 */
Tor Norbye7b9c9122013-05-30 16:48:33 -07004683 public abstract XmlResourceParser getXml(String packageName, @XmlRes int resid,
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004684 ApplicationInfo appInfo);
4685
4686 /**
4687 * Return the label to use for this application.
4688 *
4689 * @return Returns the label associated with this application, or null if
4690 * it could not be found for any reason.
kmccormick30498b42013-03-27 17:39:17 -07004691 * @param info The application to get the label of.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004692 */
4693 public abstract CharSequence getApplicationLabel(ApplicationInfo info);
4694
4695 /**
4696 * Retrieve the resources associated with an activity. Given the full
4697 * name of an activity, retrieves the information about it and calls
4698 * getResources() to return its application's resources. If the activity
kmccormick30498b42013-03-27 17:39:17 -07004699 * cannot be found, NameNotFoundException is thrown.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004700 *
4701 * @param activityName Name of the activity whose resources are to be
4702 * retrieved.
4703 *
4704 * @return Returns the application's Resources.
4705 * @throws NameNotFoundException Thrown if the resources for the given
4706 * application could not be loaded.
4707 *
4708 * @see #getResourcesForApplication(ApplicationInfo)
4709 */
4710 public abstract Resources getResourcesForActivity(ComponentName activityName)
4711 throws NameNotFoundException;
4712
4713 /**
4714 * Retrieve the resources for an application. Throws NameNotFoundException
4715 * if the package is no longer installed.
4716 *
4717 * @param app Information about the desired application.
4718 *
4719 * @return Returns the application's Resources.
4720 * @throws NameNotFoundException Thrown if the resources for the given
4721 * application could not be loaded (most likely because it was uninstalled).
4722 */
4723 public abstract Resources getResourcesForApplication(ApplicationInfo app)
4724 throws NameNotFoundException;
4725
4726 /**
4727 * Retrieve the resources associated with an application. Given the full
4728 * package name of an application, retrieves the information about it and
4729 * calls getResources() to return its application's resources. If the
kmccormick30498b42013-03-27 17:39:17 -07004730 * appPackageName cannot be found, NameNotFoundException is thrown.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004731 *
4732 * @param appPackageName Package name of the application whose resources
4733 * are to be retrieved.
4734 *
4735 * @return Returns the application's Resources.
4736 * @throws NameNotFoundException Thrown if the resources for the given
4737 * application could not be loaded.
4738 *
4739 * @see #getResourcesForApplication(ApplicationInfo)
4740 */
4741 public abstract Resources getResourcesForApplication(String appPackageName)
4742 throws NameNotFoundException;
4743
Amith Yamasani98edc952012-09-25 14:09:27 -07004744 /** @hide */
Jeff Sharkey8588bc12016-01-06 16:47:42 -07004745 public abstract Resources getResourcesForApplicationAsUser(String appPackageName,
4746 @UserIdInt int userId) throws NameNotFoundException;
Amith Yamasani98edc952012-09-25 14:09:27 -07004747
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004748 /**
Jeff Sharkey4347f812017-04-21 12:08:39 -06004749 * Retrieve overall information about an application package defined in a
4750 * package archive file
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004751 *
4752 * @param archiveFilePath The path to the archive file
Jeff Sharkey4347f812017-04-21 12:08:39 -06004753 * @param flags Additional option flags to modify the data returned.
4754 * @return A PackageInfo object containing information about the package
4755 * archive. If the package could not be parsed, returns null.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004756 */
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07004757 public PackageInfo getPackageArchiveInfo(String archiveFilePath, @PackageInfoFlags int flags) {
Jeff Sharkey275e0852014-06-17 18:18:49 -07004758 final PackageParser parser = new PackageParser();
Dianne Hackborncd154e92017-02-28 17:37:35 -08004759 parser.setCallback(new PackageParser.CallbackImpl(this));
Jeff Sharkey275e0852014-06-17 18:18:49 -07004760 final File apkFile = new File(archiveFilePath);
Jeff Sharkeyc4858a22014-06-16 10:51:20 -07004761 try {
Jeff Sharkey8a372a02016-03-16 16:25:45 -06004762 if ((flags & (MATCH_DIRECT_BOOT_UNAWARE | MATCH_DIRECT_BOOT_AWARE)) != 0) {
Jeff Sharkeyc3132512016-01-12 14:06:58 -07004763 // Caller expressed an explicit opinion about what encryption
4764 // aware/unaware components they want to see, so fall through and
4765 // give them what they want
4766 } else {
4767 // Caller expressed no opinion, so match everything
Jeff Sharkey8a372a02016-03-16 16:25:45 -06004768 flags |= MATCH_DIRECT_BOOT_AWARE | MATCH_DIRECT_BOOT_UNAWARE;
Jeff Sharkeyc3132512016-01-12 14:06:58 -07004769 }
4770
Jeff Sharkey275e0852014-06-17 18:18:49 -07004771 PackageParser.Package pkg = parser.parseMonolithicPackage(apkFile, 0);
Jeff Sharkeyc4858a22014-06-16 10:51:20 -07004772 if ((flags & GET_SIGNATURES) != 0) {
Victor Hsieh5f761242018-01-20 10:30:12 -08004773 PackageParser.collectCertificates(pkg, false /* skipVerify */);
Jeff Sharkeyc4858a22014-06-16 10:51:20 -07004774 }
4775 PackageUserState state = new PackageUserState();
4776 return PackageParser.generatePackageInfo(pkg, null, flags, 0, 0, null, state);
4777 } catch (PackageParserException e) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004778 return null;
4779 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004780 }
4781
4782 /**
Dianne Hackborn7767eac2012-08-23 18:25:40 -07004783 * If there is already an application with the given package name installed
4784 * on the system for other users, also install it for the calling user.
4785 * @hide
4786 */
Sunny Goyal07f41fb2017-08-09 02:56:34 -07004787 @SystemApi
Nicolas Prevot9a80e532015-09-23 15:49:28 +01004788 public abstract int installExistingPackage(String packageName) throws NameNotFoundException;
4789
4790 /**
4791 * If there is already an application with the given package name installed
Sunny Goyala31a74b2017-05-11 15:59:19 -07004792 * on the system for other users, also install it for the calling user.
4793 * @hide
4794 */
Sunny Goyal07f41fb2017-08-09 02:56:34 -07004795 @SystemApi
Sunny Goyala31a74b2017-05-11 15:59:19 -07004796 public abstract int installExistingPackage(String packageName, @InstallReason int installReason)
4797 throws NameNotFoundException;
4798
4799 /**
4800 * If there is already an application with the given package name installed
Nicolas Prevot9a80e532015-09-23 15:49:28 +01004801 * on the system for other users, also install it for the specified user.
4802 * @hide
4803 */
4804 @RequiresPermission(anyOf = {
4805 Manifest.permission.INSTALL_PACKAGES,
4806 Manifest.permission.INTERACT_ACROSS_USERS_FULL})
Jeff Sharkey8588bc12016-01-06 16:47:42 -07004807 public abstract int installExistingPackageAsUser(String packageName, @UserIdInt int userId)
Dianne Hackborn7767eac2012-08-23 18:25:40 -07004808 throws NameNotFoundException;
4809
4810 /**
Kenny Root5ab21572011-07-27 11:11:19 -07004811 * Allows a package listening to the
4812 * {@link Intent#ACTION_PACKAGE_NEEDS_VERIFICATION package verification
Kenny Root3a9b5fb2011-09-20 14:15:38 -07004813 * broadcast} to respond to the package manager. The response must include
4814 * the {@code verificationCode} which is one of
4815 * {@link PackageManager#VERIFICATION_ALLOW} or
4816 * {@link PackageManager#VERIFICATION_REJECT}.
Kenny Root5ab21572011-07-27 11:11:19 -07004817 *
4818 * @param id pending package identifier as passed via the
kmccormick30498b42013-03-27 17:39:17 -07004819 * {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra.
Kenny Root3a9b5fb2011-09-20 14:15:38 -07004820 * @param verificationCode either {@link PackageManager#VERIFICATION_ALLOW}
4821 * or {@link PackageManager#VERIFICATION_REJECT}.
rich cannings7e671512012-08-27 14:44:16 -07004822 * @throws SecurityException if the caller does not have the
Dianne Hackborn8832c182012-09-17 17:20:24 -07004823 * PACKAGE_VERIFICATION_AGENT permission.
Kenny Root5ab21572011-07-27 11:11:19 -07004824 */
Kenny Root3a9b5fb2011-09-20 14:15:38 -07004825 public abstract void verifyPendingInstall(int id, int verificationCode);
Kenny Root5ab21572011-07-27 11:11:19 -07004826
4827 /**
rich canningsd9ef3e52012-08-22 14:28:05 -07004828 * Allows a package listening to the
4829 * {@link Intent#ACTION_PACKAGE_NEEDS_VERIFICATION package verification
4830 * broadcast} to extend the default timeout for a response and declare what
4831 * action to perform after the timeout occurs. The response must include
4832 * the {@code verificationCodeAtTimeout} which is one of
4833 * {@link PackageManager#VERIFICATION_ALLOW} or
4834 * {@link PackageManager#VERIFICATION_REJECT}.
4835 *
4836 * This method may only be called once per package id. Additional calls
4837 * will have no effect.
4838 *
4839 * @param id pending package identifier as passed via the
kmccormick30498b42013-03-27 17:39:17 -07004840 * {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra.
rich canningsd9ef3e52012-08-22 14:28:05 -07004841 * @param verificationCodeAtTimeout either
4842 * {@link PackageManager#VERIFICATION_ALLOW} or
rich canningsd1b5cfc2012-08-29 14:49:51 -07004843 * {@link PackageManager#VERIFICATION_REJECT}. If
4844 * {@code verificationCodeAtTimeout} is neither
4845 * {@link PackageManager#VERIFICATION_ALLOW} or
4846 * {@link PackageManager#VERIFICATION_REJECT}, then
4847 * {@code verificationCodeAtTimeout} will default to
rich canningsd9ef3e52012-08-22 14:28:05 -07004848 * {@link PackageManager#VERIFICATION_REJECT}.
4849 * @param millisecondsToDelay the amount of time requested for the timeout.
4850 * Must be positive and less than
rich canningsd1b5cfc2012-08-29 14:49:51 -07004851 * {@link PackageManager#MAXIMUM_VERIFICATION_TIMEOUT}. If
4852 * {@code millisecondsToDelay} is out of bounds,
4853 * {@code millisecondsToDelay} will be set to the closest in
4854 * bounds value; namely, 0 or
rich canningsd9ef3e52012-08-22 14:28:05 -07004855 * {@link PackageManager#MAXIMUM_VERIFICATION_TIMEOUT}.
rich cannings7e671512012-08-27 14:44:16 -07004856 * @throws SecurityException if the caller does not have the
Dianne Hackborn8832c182012-09-17 17:20:24 -07004857 * PACKAGE_VERIFICATION_AGENT permission.
rich canningsd9ef3e52012-08-22 14:28:05 -07004858 */
4859 public abstract void extendVerificationTimeout(int id,
4860 int verificationCodeAtTimeout, long millisecondsToDelay);
4861
4862 /**
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -08004863 * Allows a package listening to the
Todd Kennedydfa93ab2016-03-03 15:24:33 -08004864 * {@link Intent#ACTION_INTENT_FILTER_NEEDS_VERIFICATION} intent filter verification
4865 * broadcast to respond to the package manager. The response must include
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -08004866 * the {@code verificationCode} which is one of
4867 * {@link PackageManager#INTENT_FILTER_VERIFICATION_SUCCESS} or
4868 * {@link PackageManager#INTENT_FILTER_VERIFICATION_FAILURE}.
4869 *
4870 * @param verificationId pending package identifier as passed via the
4871 * {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra.
4872 * @param verificationCode either {@link PackageManager#INTENT_FILTER_VERIFICATION_SUCCESS}
4873 * or {@link PackageManager#INTENT_FILTER_VERIFICATION_FAILURE}.
Todd Kennedydfa93ab2016-03-03 15:24:33 -08004874 * @param failedDomains a list of failed domains if the verificationCode is
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -08004875 * {@link PackageManager#INTENT_FILTER_VERIFICATION_FAILURE}, otherwise null;
4876 * @throws SecurityException if the caller does not have the
4877 * INTENT_FILTER_VERIFICATION_AGENT permission.
4878 *
4879 * @hide
4880 */
Fabrice Di Meglioef741da2015-05-12 16:31:38 -07004881 @SystemApi
Jeff Sharkeyd86b8fe2017-06-02 17:36:26 -06004882 @RequiresPermission(android.Manifest.permission.INTENT_FILTER_VERIFICATION_AGENT)
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -08004883 public abstract void verifyIntentFilter(int verificationId, int verificationCode,
Todd Kennedydfa93ab2016-03-03 15:24:33 -08004884 List<String> failedDomains);
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -08004885
4886 /**
4887 * Get the status of a Domain Verification Result for an IntentFilter. This is
4888 * related to the {@link android.content.IntentFilter#setAutoVerify(boolean)} and
4889 * {@link android.content.IntentFilter#getAutoVerify()}
4890 *
4891 * This is used by the ResolverActivity to change the status depending on what the User select
4892 * in the Disambiguation Dialog and also used by the Settings App for changing the default App
4893 * for a domain.
4894 *
4895 * @param packageName The package name of the Activity associated with the IntentFilter.
4896 * @param userId The user id.
4897 *
4898 * @return The status to set to. This can be
4899 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK} or
4900 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS} or
4901 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER} or
4902 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_UNDEFINED}
4903 *
4904 * @hide
4905 */
Jeff Schumacher6fd90ed2017-01-20 13:58:34 -08004906 @SystemApi
Todd Kennedydbaef6d2017-07-24 11:28:00 -07004907 @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS_FULL)
Jeff Sharkey8588bc12016-01-06 16:47:42 -07004908 public abstract int getIntentVerificationStatusAsUser(String packageName, @UserIdInt int userId);
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -08004909
4910 /**
4911 * Allow to change the status of a Intent Verification status for all IntentFilter of an App.
4912 * This is related to the {@link android.content.IntentFilter#setAutoVerify(boolean)} and
4913 * {@link android.content.IntentFilter#getAutoVerify()}
4914 *
4915 * This is used by the ResolverActivity to change the status depending on what the User select
4916 * in the Disambiguation Dialog and also used by the Settings App for changing the default App
4917 * for a domain.
4918 *
4919 * @param packageName The package name of the Activity associated with the IntentFilter.
4920 * @param status The status to set to. This can be
4921 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK} or
4922 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS} or
4923 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER}
4924 * @param userId The user id.
4925 *
4926 * @return true if the status has been set. False otherwise.
4927 *
4928 * @hide
4929 */
Jeff Schumacher6fd90ed2017-01-20 13:58:34 -08004930 @SystemApi
Jeff Sharkeyd86b8fe2017-06-02 17:36:26 -06004931 @RequiresPermission(android.Manifest.permission.SET_PREFERRED_APPLICATIONS)
Jeff Sharkeye06b4d12016-01-06 14:51:50 -07004932 public abstract boolean updateIntentVerificationStatusAsUser(String packageName, int status,
Jeff Sharkey8588bc12016-01-06 16:47:42 -07004933 @UserIdInt int userId);
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -08004934
4935 /**
4936 * Get the list of IntentFilterVerificationInfo for a specific package and User.
4937 *
4938 * @param packageName the package name. When this parameter is set to a non null value,
4939 * the results will be filtered by the package name provided.
4940 * Otherwise, there will be no filtering and it will return a list
Fabrice Di Meglio07885952015-04-06 19:41:28 -07004941 * corresponding for all packages
4942 *
4943 * @return a list of IntentFilterVerificationInfo for a specific package.
4944 *
4945 * @hide
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -08004946 */
Jeff Schumacher6fd90ed2017-01-20 13:58:34 -08004947 @SystemApi
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -08004948 public abstract List<IntentFilterVerificationInfo> getIntentFilterVerifications(
4949 String packageName);
4950
4951 /**
Fabrice Di Meglio07885952015-04-06 19:41:28 -07004952 * Get the list of IntentFilter for a specific package.
4953 *
4954 * @param packageName the package name. This parameter is set to a non null value,
4955 * the list will contain all the IntentFilter for that package.
4956 * Otherwise, the list will be empty.
4957 *
4958 * @return a list of IntentFilter for a specific package.
4959 *
4960 * @hide
4961 */
Jeff Schumacher6fd90ed2017-01-20 13:58:34 -08004962 @SystemApi
Fabrice Di Meglio07885952015-04-06 19:41:28 -07004963 public abstract List<IntentFilter> getAllIntentFilters(String packageName);
4964
4965 /**
Fabrice Di Meglio62271722015-04-10 17:24:02 -07004966 * Get the default Browser package name for a specific user.
4967 *
4968 * @param userId The user id.
4969 *
4970 * @return the package name of the default Browser for the specified user. If the user id passed
4971 * is -1 (all users) it will return a null value.
4972 *
4973 * @hide
4974 */
Jeff Sharkeya73b8fd2016-01-06 17:02:08 -07004975 @TestApi
Jeff Schumacher6fd90ed2017-01-20 13:58:34 -08004976 @SystemApi
Todd Kennedydbaef6d2017-07-24 11:28:00 -07004977 @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS_FULL)
Jeff Sharkey8588bc12016-01-06 16:47:42 -07004978 public abstract String getDefaultBrowserPackageNameAsUser(@UserIdInt int userId);
Fabrice Di Meglio62271722015-04-10 17:24:02 -07004979
4980 /**
4981 * Set the default Browser package name for a specific user.
4982 *
4983 * @param packageName The package name of the default Browser.
4984 * @param userId The user id.
4985 *
4986 * @return true if the default Browser for the specified user has been set,
4987 * otherwise return false. If the user id passed is -1 (all users) this call will not
4988 * do anything and just return false.
4989 *
4990 * @hide
4991 */
Jeff Schumacher6fd90ed2017-01-20 13:58:34 -08004992 @SystemApi
Todd Kennedydbaef6d2017-07-24 11:28:00 -07004993 @RequiresPermission(allOf = {
4994 Manifest.permission.SET_PREFERRED_APPLICATIONS,
4995 Manifest.permission.INTERACT_ACROSS_USERS_FULL})
Jeff Sharkey8588bc12016-01-06 16:47:42 -07004996 public abstract boolean setDefaultBrowserPackageNameAsUser(String packageName,
4997 @UserIdInt int userId);
Fabrice Di Meglio62271722015-04-10 17:24:02 -07004998
4999 /**
Dianne Hackborn880119b2010-11-18 22:26:40 -08005000 * Change the installer associated with a given package. There are limitations
5001 * on how the installer package can be changed; in particular:
5002 * <ul>
5003 * <li> A SecurityException will be thrown if <var>installerPackageName</var>
5004 * is not signed with the same certificate as the calling application.
5005 * <li> A SecurityException will be thrown if <var>targetPackage</var> already
5006 * has an installer package, and that installer package is not signed with
5007 * the same certificate as the calling application.
5008 * </ul>
5009 *
5010 * @param targetPackage The installed package whose installer will be changed.
5011 * @param installerPackageName The package name of the new installer. May be
5012 * null to clear the association.
5013 */
5014 public abstract void setInstallerPackageName(String targetPackage,
5015 String installerPackageName);
5016
Todd Kennedyab532892017-03-08 14:19:49 -08005017 /** @hide */
5018 @SystemApi
5019 @RequiresPermission(Manifest.permission.INSTALL_PACKAGES)
5020 public abstract void setUpdateAvailable(String packageName, boolean updateAvaialble);
5021
Dianne Hackborn880119b2010-11-18 22:26:40 -08005022 /**
Jeff Sharkey5aa86932016-01-08 19:07:49 -07005023 * Attempts to delete a package. Since this may take a little while, the
5024 * result will be posted back to the given observer. A deletion will fail if
5025 * the calling context lacks the
5026 * {@link android.Manifest.permission#DELETE_PACKAGES} permission, if the
5027 * named package cannot be found, or if the named package is a system
5028 * package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005029 *
5030 * @param packageName The name of the package to delete
Jeff Sharkey5aa86932016-01-08 19:07:49 -07005031 * @param observer An observer callback to get notified when the package
5032 * deletion is complete.
5033 * {@link android.content.pm.IPackageDeleteObserver#packageDeleted}
5034 * will be called when that happens. observer may be null to
5035 * indicate that no callback is desired.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005036 * @hide
5037 */
Svet Ganov67882122016-12-11 16:36:34 -08005038 @RequiresPermission(Manifest.permission.DELETE_PACKAGES)
Jeff Sharkey5aa86932016-01-08 19:07:49 -07005039 public abstract void deletePackage(String packageName, IPackageDeleteObserver observer,
5040 @DeleteFlags int flags);
Jacek Surazski65e13172009-04-28 15:26:38 +02005041
5042 /**
Jeff Sharkey5aa86932016-01-08 19:07:49 -07005043 * Attempts to delete a package. Since this may take a little while, the
5044 * result will be posted back to the given observer. A deletion will fail if
5045 * the named package cannot be found, or if the named package is a system
5046 * package.
Nicolas Prevot9a80e532015-09-23 15:49:28 +01005047 *
5048 * @param packageName The name of the package to delete
Jeff Sharkey5aa86932016-01-08 19:07:49 -07005049 * @param observer An observer callback to get notified when the package
5050 * deletion is complete.
5051 * {@link android.content.pm.IPackageDeleteObserver#packageDeleted}
5052 * will be called when that happens. observer may be null to
5053 * indicate that no callback is desired.
Nicolas Prevot9a80e532015-09-23 15:49:28 +01005054 * @param userId The user Id
Nicolas Prevot9a80e532015-09-23 15:49:28 +01005055 * @hide
5056 */
Svet Ganov67882122016-12-11 16:36:34 -08005057 @RequiresPermission(anyOf = {
Nicolas Prevot9a80e532015-09-23 15:49:28 +01005058 Manifest.permission.DELETE_PACKAGES,
5059 Manifest.permission.INTERACT_ACROSS_USERS_FULL})
Svet Ganov67882122016-12-11 16:36:34 -08005060 public abstract void deletePackageAsUser(@NonNull String packageName,
5061 IPackageDeleteObserver observer, @DeleteFlags int flags, @UserIdInt int userId);
Nicolas Prevot9a80e532015-09-23 15:49:28 +01005062
5063 /**
Jacek Surazski65e13172009-04-28 15:26:38 +02005064 * Retrieve the package name of the application that installed a package. This identifies
5065 * which market the package came from.
Amith Yamasani4b2e9342011-03-31 12:38:53 -07005066 *
Jacek Surazski65e13172009-04-28 15:26:38 +02005067 * @param packageName The name of the package to query
5068 */
5069 public abstract String getInstallerPackageName(String packageName);
Amith Yamasani4b2e9342011-03-31 12:38:53 -07005070
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005071 /**
5072 * Attempts to clear the user data directory of an application.
5073 * Since this may take a little while, the result will
5074 * be posted back to the given observer. A deletion will fail if the
5075 * named package cannot be found, or if the named package is a "system package".
5076 *
5077 * @param packageName The name of the package
5078 * @param observer An observer callback to get notified when the operation is finished
5079 * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)}
5080 * will be called when that happens. observer may be null to indicate that
5081 * no callback is desired.
5082 *
5083 * @hide
5084 */
5085 public abstract void clearApplicationUserData(String packageName,
5086 IPackageDataObserver observer);
5087 /**
5088 * Attempts to delete the cache files associated with an application.
5089 * Since this may take a little while, the result will
5090 * be posted back to the given observer. A deletion will fail if the calling context
5091 * lacks the {@link android.Manifest.permission#DELETE_CACHE_FILES} permission, if the
5092 * named package cannot be found, or if the named package is a "system package".
5093 *
5094 * @param packageName The name of the package to delete
5095 * @param observer An observer callback to get notified when the cache file deletion
5096 * is complete.
5097 * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)}
5098 * will be called when that happens. observer may be null to indicate that
5099 * no callback is desired.
5100 *
5101 * @hide
5102 */
5103 public abstract void deleteApplicationCacheFiles(String packageName,
5104 IPackageDataObserver observer);
5105
5106 /**
Suprabh Shukla78c9eb82016-04-12 15:51:35 -07005107 * Attempts to delete the cache files associated with an application for a given user. Since
5108 * this may take a little while, the result will be posted back to the given observer. A
5109 * deletion will fail if the calling context lacks the
5110 * {@link android.Manifest.permission#DELETE_CACHE_FILES} permission, if the named package
5111 * cannot be found, or if the named package is a "system package". If {@code userId} does not
5112 * belong to the calling user, the caller must have
5113 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} permission.
5114 *
5115 * @param packageName The name of the package to delete
5116 * @param userId the user for which the cache files needs to be deleted
5117 * @param observer An observer callback to get notified when the cache file deletion is
5118 * complete.
5119 * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)}
5120 * will be called when that happens. observer may be null to indicate that no
5121 * callback is desired.
5122 * @hide
5123 */
5124 public abstract void deleteApplicationCacheFilesAsUser(String packageName, int userId,
5125 IPackageDataObserver observer);
5126
5127 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005128 * Free storage by deleting LRU sorted list of cache files across
5129 * all applications. If the currently available free storage
5130 * on the device is greater than or equal to the requested
5131 * free storage, no cache files are cleared. If the currently
5132 * available storage on the device is less than the requested
5133 * free storage, some or all of the cache files across
5134 * all applications are deleted (based on last accessed time)
5135 * to increase the free storage space on the device to
5136 * the requested value. There is no guarantee that clearing all
5137 * the cache files from all applications will clear up
5138 * enough storage to achieve the desired value.
5139 * @param freeStorageSize The number of bytes of storage to be
5140 * freed by the system. Say if freeStorageSize is XX,
5141 * and the current free storage is YY,
5142 * if XX is less than YY, just return. if not free XX-YY number
5143 * of bytes if possible.
5144 * @param observer call back used to notify when
5145 * the operation is completed
Amith Yamasani4b2e9342011-03-31 12:38:53 -07005146 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005147 * @hide
5148 */
Jeff Sharkey529f91f2015-04-18 20:23:13 -07005149 public void freeStorageAndNotify(long freeStorageSize, IPackageDataObserver observer) {
5150 freeStorageAndNotify(null, freeStorageSize, observer);
5151 }
5152
5153 /** {@hide} */
5154 public abstract void freeStorageAndNotify(String volumeUuid, long freeStorageSize,
5155 IPackageDataObserver observer);
Suchi Amalapurapu1ccac752009-06-12 10:09:58 -07005156
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005157 /**
5158 * Free storage by deleting LRU sorted list of cache files across
5159 * all applications. If the currently available free storage
5160 * on the device is greater than or equal to the requested
5161 * free storage, no cache files are cleared. If the currently
5162 * available storage on the device is less than the requested
5163 * free storage, some or all of the cache files across
5164 * all applications are deleted (based on last accessed time)
5165 * to increase the free storage space on the device to
5166 * the requested value. There is no guarantee that clearing all
5167 * the cache files from all applications will clear up
5168 * enough storage to achieve the desired value.
5169 * @param freeStorageSize The number of bytes of storage to be
5170 * freed by the system. Say if freeStorageSize is XX,
5171 * and the current free storage is YY,
5172 * if XX is less than YY, just return. if not free XX-YY number
5173 * of bytes if possible.
Suchi Amalapurapu1ccac752009-06-12 10:09:58 -07005174 * @param pi IntentSender call back used to
5175 * notify when the operation is completed.May be null
5176 * to indicate that no call back is desired.
Amith Yamasani4b2e9342011-03-31 12:38:53 -07005177 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005178 * @hide
5179 */
Jeff Sharkey529f91f2015-04-18 20:23:13 -07005180 public void freeStorage(long freeStorageSize, IntentSender pi) {
5181 freeStorage(null, freeStorageSize, pi);
5182 }
5183
5184 /** {@hide} */
5185 public abstract void freeStorage(String volumeUuid, long freeStorageSize, IntentSender pi);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005186
5187 /**
5188 * Retrieve the size information for a package.
5189 * Since this may take a little while, the result will
5190 * be posted back to the given observer. The calling context
5191 * should have the {@link android.Manifest.permission#GET_PACKAGE_SIZE} permission.
5192 *
5193 * @param packageName The name of the package whose size information is to be retrieved
Jeff Sharkeye06b4d12016-01-06 14:51:50 -07005194 * @param userId The user whose size information should be retrieved.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005195 * @param observer An observer callback to get notified when the operation
5196 * is complete.
5197 * {@link android.content.pm.IPackageStatsObserver#onGetStatsCompleted(PackageStats, boolean)}
5198 * The observer's callback is invoked with a PackageStats object(containing the
5199 * code, data and cache sizes of the package) and a boolean value representing
5200 * the status of the operation. observer may be null to indicate that
5201 * no callback is desired.
5202 *
Jeff Sharkey60f95aa2017-03-08 13:57:15 -07005203 * @deprecated use {@link StorageStatsManager} instead.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005204 * @hide
5205 */
Jeff Sharkey60f95aa2017-03-08 13:57:15 -07005206 @Deprecated
Jeff Sharkey8588bc12016-01-06 16:47:42 -07005207 public abstract void getPackageSizeInfoAsUser(String packageName, @UserIdInt int userId,
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005208 IPackageStatsObserver observer);
5209
5210 /**
Jeff Sharkeye06b4d12016-01-06 14:51:50 -07005211 * Like {@link #getPackageSizeInfoAsUser(String, int, IPackageStatsObserver)}, but
Dianne Hackborn0c380492012-08-20 17:23:30 -07005212 * returns the size for the calling user.
5213 *
Jeff Sharkey60f95aa2017-03-08 13:57:15 -07005214 * @deprecated use {@link StorageStatsManager} instead.
Dianne Hackborn0c380492012-08-20 17:23:30 -07005215 * @hide
5216 */
Jeff Sharkey60f95aa2017-03-08 13:57:15 -07005217 @Deprecated
Dianne Hackborn0c380492012-08-20 17:23:30 -07005218 public void getPackageSizeInfo(String packageName, IPackageStatsObserver observer) {
Jeff Sharkeyad357d12018-02-02 13:25:31 -07005219 getPackageSizeInfoAsUser(packageName, getUserId(), observer);
Dianne Hackborn0c380492012-08-20 17:23:30 -07005220 }
5221
5222 /**
Dianne Hackborna7ca0e52009-12-01 14:31:55 -08005223 * @deprecated This function no longer does anything; it was an old
kmccormickac66b852013-03-28 15:17:15 -07005224 * approach to managing preferred activities, which has been superseded
5225 * by (and conflicts with) the modern activity-based preferences.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005226 */
Dianne Hackborna7ca0e52009-12-01 14:31:55 -08005227 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005228 public abstract void addPackageToPreferred(String packageName);
5229
5230 /**
Dianne Hackborna7ca0e52009-12-01 14:31:55 -08005231 * @deprecated This function no longer does anything; it was an old
kmccormickac66b852013-03-28 15:17:15 -07005232 * approach to managing preferred activities, which has been superseded
5233 * by (and conflicts with) the modern activity-based preferences.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005234 */
Dianne Hackborna7ca0e52009-12-01 14:31:55 -08005235 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005236 public abstract void removePackageFromPreferred(String packageName);
5237
5238 /**
Jeff Sharkey4347f812017-04-21 12:08:39 -06005239 * Retrieve the list of all currently configured preferred packages. The
5240 * first package on the list is the most preferred, the last is the least
5241 * preferred.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005242 *
Jeff Sharkey4347f812017-04-21 12:08:39 -06005243 * @param flags Additional option flags to modify the data returned.
5244 * @return A List of PackageInfo objects, one for each preferred
5245 * application, in order of preference.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005246 */
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07005247 public abstract List<PackageInfo> getPreferredPackages(@PackageInfoFlags int flags);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005248
5249 /**
Dianne Hackborn2ee89ea2010-03-10 18:27:09 -08005250 * @deprecated This is a protected API that should not have been available
5251 * to third party applications. It is the platform's responsibility for
kmccormick30498b42013-03-27 17:39:17 -07005252 * assigning preferred activities and this cannot be directly modified.
Amith Yamasani4b2e9342011-03-31 12:38:53 -07005253 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005254 * Add a new preferred activity mapping to the system. This will be used
5255 * to automatically select the given activity component when
5256 * {@link Context#startActivity(Intent) Context.startActivity()} finds
5257 * multiple matching activities and also matches the given filter.
5258 *
5259 * @param filter The set of intents under which this activity will be
5260 * made preferred.
5261 * @param match The IntentFilter match category that this preference
5262 * applies to.
5263 * @param set The set of activities that the user was picking from when
5264 * this preference was made.
5265 * @param activity The component name of the activity that is to be
5266 * preferred.
5267 */
Dianne Hackborn2ee89ea2010-03-10 18:27:09 -08005268 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005269 public abstract void addPreferredActivity(IntentFilter filter, int match,
5270 ComponentName[] set, ComponentName activity);
5271
5272 /**
Amith Yamasania3f133a2012-08-09 17:11:28 -07005273 * Same as {@link #addPreferredActivity(IntentFilter, int,
5274 ComponentName[], ComponentName)}, but with a specific userId to apply the preference
5275 to.
5276 * @hide
5277 */
Jeff Sharkeye06b4d12016-01-06 14:51:50 -07005278 public void addPreferredActivityAsUser(IntentFilter filter, int match,
Jeff Sharkey8588bc12016-01-06 16:47:42 -07005279 ComponentName[] set, ComponentName activity, @UserIdInt int userId) {
Amith Yamasania3f133a2012-08-09 17:11:28 -07005280 throw new RuntimeException("Not implemented. Must override in a subclass.");
5281 }
5282
5283 /**
Dianne Hackborn2ee89ea2010-03-10 18:27:09 -08005284 * @deprecated This is a protected API that should not have been available
5285 * to third party applications. It is the platform's responsibility for
kmccormick30498b42013-03-27 17:39:17 -07005286 * assigning preferred activities and this cannot be directly modified.
Amith Yamasani4b2e9342011-03-31 12:38:53 -07005287 *
Satish Sampath8dbe6122009-06-02 23:35:54 +01005288 * Replaces an existing preferred activity mapping to the system, and if that were not present
5289 * adds a new preferred activity. This will be used
5290 * to automatically select the given activity component when
5291 * {@link Context#startActivity(Intent) Context.startActivity()} finds
5292 * multiple matching activities and also matches the given filter.
5293 *
5294 * @param filter The set of intents under which this activity will be
5295 * made preferred.
5296 * @param match The IntentFilter match category that this preference
5297 * applies to.
5298 * @param set The set of activities that the user was picking from when
5299 * this preference was made.
5300 * @param activity The component name of the activity that is to be
5301 * preferred.
5302 * @hide
5303 */
Dianne Hackborn2ee89ea2010-03-10 18:27:09 -08005304 @Deprecated
Satish Sampath8dbe6122009-06-02 23:35:54 +01005305 public abstract void replacePreferredActivity(IntentFilter filter, int match,
5306 ComponentName[] set, ComponentName activity);
5307
5308 /**
Amith Yamasani41c1ded2014-08-05 11:15:05 -07005309 * @hide
5310 */
5311 @Deprecated
5312 public void replacePreferredActivityAsUser(IntentFilter filter, int match,
Jeff Sharkey8588bc12016-01-06 16:47:42 -07005313 ComponentName[] set, ComponentName activity, @UserIdInt int userId) {
Amith Yamasani41c1ded2014-08-05 11:15:05 -07005314 throw new RuntimeException("Not implemented. Must override in a subclass.");
5315 }
5316
5317 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005318 * Remove all preferred activity mappings, previously added with
5319 * {@link #addPreferredActivity}, from the
5320 * system whose activities are implemented in the given package name.
Dianne Hackborn2ee89ea2010-03-10 18:27:09 -08005321 * An application can only clear its own package(s).
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005322 *
5323 * @param packageName The name of the package whose preferred activity
5324 * mappings are to be removed.
5325 */
5326 public abstract void clearPackagePreferredActivities(String packageName);
5327
5328 /**
5329 * Retrieve all preferred activities, previously added with
5330 * {@link #addPreferredActivity}, that are
5331 * currently registered with the system.
5332 *
John Spurlock38e64252015-03-18 12:09:32 -04005333 * @param outFilters A required list in which to place the filters of all of the
5334 * preferred activities.
5335 * @param outActivities A required list in which to place the component names of
5336 * all of the preferred activities.
5337 * @param packageName An optional package in which you would like to limit
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005338 * the list. If null, all activities will be returned; if non-null, only
5339 * those activities in the given package are returned.
5340 *
5341 * @return Returns the total number of registered preferred activities
5342 * (the number of distinct IntentFilter records, not the number of unique
5343 * activity components) that were found.
5344 */
John Spurlock38e64252015-03-18 12:09:32 -04005345 public abstract int getPreferredActivities(@NonNull List<IntentFilter> outFilters,
5346 @NonNull List<ComponentName> outActivities, String packageName);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005347
5348 /**
Christopher Tatea2a0850d2013-09-05 16:38:58 -07005349 * Ask for the set of available 'home' activities and the current explicit
5350 * default, if any.
5351 * @hide
5352 */
5353 public abstract ComponentName getHomeActivities(List<ResolveInfo> outActivities);
5354
5355 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005356 * Set the enabled setting for a package component (activity, receiver, service, provider).
5357 * This setting will override any enabled state which may have been set by the component in its
5358 * manifest.
5359 *
5360 * @param componentName The component to enable
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005361 * @param newState The new enabled state for the component.
5362 * @param flags Optional behavior flags.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005363 */
5364 public abstract void setComponentEnabledSetting(ComponentName componentName,
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005365 @EnabledState int newState, @EnabledFlags int flags);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005366
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005367 /**
Amaury Medeirosdde24262014-06-03 20:06:41 -03005368 * Return the enabled setting for a package component (activity,
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005369 * receiver, service, provider). This returns the last value set by
5370 * {@link #setComponentEnabledSetting(ComponentName, int, int)}; in most
5371 * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since
5372 * the value originally specified in the manifest has not been modified.
5373 *
5374 * @param componentName The component to retrieve.
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005375 * @return Returns the current enabled state for the component.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005376 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005377 public abstract @EnabledState int getComponentEnabledSetting(
5378 ComponentName componentName);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005379
5380 /**
5381 * Set the enabled setting for an application
5382 * This setting will override any enabled state which may have been set by the application in
5383 * its manifest. It also overrides the enabled state set in the manifest for any of the
5384 * application's components. It does not override any enabled state set by
5385 * {@link #setComponentEnabledSetting} for any of the application's components.
5386 *
5387 * @param packageName The package name of the application to enable
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005388 * @param newState The new enabled state for the application.
5389 * @param flags Optional behavior flags.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005390 */
5391 public abstract void setApplicationEnabledSetting(String packageName,
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005392 @EnabledState int newState, @EnabledFlags int flags);
Amith Yamasani4b2e9342011-03-31 12:38:53 -07005393
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005394 /**
Amaury Medeirosdde24262014-06-03 20:06:41 -03005395 * Return the enabled setting for an application. This returns
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005396 * the last value set by
5397 * {@link #setApplicationEnabledSetting(String, int, int)}; in most
5398 * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since
5399 * the value originally specified in the manifest has not been modified.
5400 *
Amaury Medeirosdde24262014-06-03 20:06:41 -03005401 * @param packageName The package name of the application to retrieve.
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005402 * @return Returns the current enabled state for the application.
Mathew Inwood1b9f8d92011-09-26 13:23:56 +01005403 * @throws IllegalArgumentException if the named package does not exist.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005404 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005405 public abstract @EnabledState int getApplicationEnabledSetting(String packageName);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005406
5407 /**
Sudheer Shankabbb3ff22015-07-09 15:39:23 +01005408 * Flush the package restrictions for a given user to disk. This forces the package restrictions
5409 * like component and package enabled settings to be written to disk and avoids the delay that
5410 * is otherwise present when changing those settings.
5411 *
5412 * @param userId Ther userId of the user whose restrictions are to be flushed.
5413 * @hide
5414 */
5415 public abstract void flushPackageRestrictionsAsUser(int userId);
5416
5417 /**
Amith Yamasanie5bcff62014-07-19 15:44:09 -07005418 * Puts the package in a hidden state, which is almost like an uninstalled state,
Amith Yamasani655d0e22013-06-12 14:19:10 -07005419 * making the package unavailable, but it doesn't remove the data or the actual
Amith Yamasanie5bcff62014-07-19 15:44:09 -07005420 * package file. Application can be unhidden by either resetting the hidden state
5421 * or by installing it, such as with {@link #installExistingPackage(String)}
Amith Yamasani655d0e22013-06-12 14:19:10 -07005422 * @hide
5423 */
Amith Yamasanie5bcff62014-07-19 15:44:09 -07005424 public abstract boolean setApplicationHiddenSettingAsUser(String packageName, boolean hidden,
Amith Yamasani655d0e22013-06-12 14:19:10 -07005425 UserHandle userHandle);
5426
5427 /**
Amith Yamasanie5bcff62014-07-19 15:44:09 -07005428 * Returns the hidden state of a package.
5429 * @see #setApplicationHiddenSettingAsUser(String, boolean, UserHandle)
Amith Yamasani655d0e22013-06-12 14:19:10 -07005430 * @hide
5431 */
Amith Yamasanie5bcff62014-07-19 15:44:09 -07005432 public abstract boolean getApplicationHiddenSettingAsUser(String packageName,
Amith Yamasani655d0e22013-06-12 14:19:10 -07005433 UserHandle userHandle);
5434
5435 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005436 * Return whether the device has been booted into safe mode.
5437 */
5438 public abstract boolean isSafeMode();
Suchi Amalapurapu8946dd32010-02-19 09:19:34 -08005439
5440 /**
Svetoslavf7c06eb2015-06-10 18:43:22 -07005441 * Adds a listener for permission changes for installed packages.
5442 *
5443 * @param listener The listener to add.
5444 *
5445 * @hide
5446 */
5447 @SystemApi
5448 @RequiresPermission(Manifest.permission.OBSERVE_GRANT_REVOKE_PERMISSIONS)
5449 public abstract void addOnPermissionsChangeListener(OnPermissionsChangedListener listener);
5450
5451 /**
5452 * Remvoes a listener for permission changes for installed packages.
5453 *
5454 * @param listener The listener to remove.
5455 *
5456 * @hide
5457 */
5458 @SystemApi
Jeff Sharkeyd86b8fe2017-06-02 17:36:26 -06005459 @RequiresPermission(Manifest.permission.OBSERVE_GRANT_REVOKE_PERMISSIONS)
Svetoslavf7c06eb2015-06-10 18:43:22 -07005460 public abstract void removeOnPermissionsChangeListener(OnPermissionsChangedListener listener);
5461
5462 /**
dcashman9d2f4412014-06-09 09:27:54 -07005463 * Return the {@link KeySet} associated with the String alias for this
5464 * application.
5465 *
5466 * @param alias The alias for a given {@link KeySet} as defined in the
5467 * application's AndroidManifest.xml.
dcashmanc6f22492014-08-14 09:54:51 -07005468 * @hide
dcashman9d2f4412014-06-09 09:27:54 -07005469 */
5470 public abstract KeySet getKeySetByAlias(String packageName, String alias);
5471
Ihab Awad1ec68882014-09-12 11:09:01 -07005472 /** Return the signing {@link KeySet} for this application.
dcashmanc6f22492014-08-14 09:54:51 -07005473 * @hide
5474 */
dcashman9d2f4412014-06-09 09:27:54 -07005475 public abstract KeySet getSigningKeySet(String packageName);
5476
5477 /**
5478 * Return whether the package denoted by packageName has been signed by all
5479 * of the keys specified by the {@link KeySet} ks. This will return true if
5480 * the package has been signed by additional keys (a superset) as well.
5481 * Compare to {@link #isSignedByExactly(String packageName, KeySet ks)}.
dcashmanc6f22492014-08-14 09:54:51 -07005482 * @hide
dcashman9d2f4412014-06-09 09:27:54 -07005483 */
5484 public abstract boolean isSignedBy(String packageName, KeySet ks);
5485
5486 /**
5487 * Return whether the package denoted by packageName has been signed by all
5488 * of, and only, the keys specified by the {@link KeySet} ks. Compare to
5489 * {@link #isSignedBy(String packageName, KeySet ks)}.
dcashmanc6f22492014-08-14 09:54:51 -07005490 * @hide
dcashman9d2f4412014-06-09 09:27:54 -07005491 */
5492 public abstract boolean isSignedByExactly(String packageName, KeySet ks);
5493
5494 /**
Andrei Stingaceanueb84b182016-01-26 18:39:55 +00005495 * Puts the package in a suspended state, where attempts at starting activities are denied.
Andrei Stingaceanu1e283912015-11-26 15:26:28 +00005496 *
Andrei Stingaceanueb84b182016-01-26 18:39:55 +00005497 * <p>It doesn't remove the data or the actual package file. The application notifications
5498 * will be hidden, the application will not show up in recents, will not be able to show
5499 * toasts or dialogs or ring the device.
5500 *
Kenny Guy871f3eb2016-03-09 20:06:16 +00005501 * <p>The package must already be installed. If the package is uninstalled while suspended
5502 * the package will no longer be suspended.
5503 *
Andrei Stingaceanueb84b182016-01-26 18:39:55 +00005504 * @param packageNames The names of the packages to set the suspended status.
5505 * @param suspended If set to {@code true} than the packages will be suspended, if set to
5506 * {@code false} the packages will be unsuspended.
Andrei Stingaceanu1e283912015-11-26 15:26:28 +00005507 * @param userId The user id.
5508 *
Andrei Stingaceanueb84b182016-01-26 18:39:55 +00005509 * @return an array of package names for which the suspended status is not set as requested in
5510 * this method.
5511 *
Andrei Stingaceanu1e283912015-11-26 15:26:28 +00005512 * @hide
5513 */
Andrei Stingaceanueb84b182016-01-26 18:39:55 +00005514 public abstract String[] setPackagesSuspendedAsUser(
5515 String[] packageNames, boolean suspended, @UserIdInt int userId);
Andrei Stingaceanu1e283912015-11-26 15:26:28 +00005516
Andrei Stingaceanu355b2322016-02-12 16:43:51 +00005517 /**
5518 * @see #setPackageSuspendedAsUser(String, boolean, int)
5519 * @param packageName The name of the package to get the suspended status of.
5520 * @param userId The user id.
5521 * @return {@code true} if the package is suspended or {@code false} if the package is not
5522 * suspended or could not be found.
5523 * @hide
5524 */
5525 public abstract boolean isPackageSuspendedForUser(String packageName, int userId);
5526
Jeff Sharkey9bc89af2017-01-11 11:25:50 -07005527 /**
5528 * Provide a hint of what the {@link ApplicationInfo#category} value should
5529 * be for the given package.
5530 * <p>
5531 * This hint can only be set by the app which installed this package, as
5532 * determined by {@link #getInstallerPackageName(String)}.
Jeff Sharkey60a82cd2017-04-18 18:19:16 -06005533 *
5534 * @param packageName the package to change the category hint for.
Jeff Sharkey4347f812017-04-21 12:08:39 -06005535 * @param categoryHint the category hint to set.
Jeff Sharkey9bc89af2017-01-11 11:25:50 -07005536 */
Jeff Sharkey60a82cd2017-04-18 18:19:16 -06005537 public abstract void setApplicationCategoryHint(@NonNull String packageName,
Jeff Sharkey9bc89af2017-01-11 11:25:50 -07005538 @ApplicationInfo.Category int categoryHint);
5539
Jeff Sharkeyb2b9ab82015-04-05 21:10:42 -07005540 /** {@hide} */
Jeff Sharkey620b32b2015-04-23 19:36:02 -07005541 public static boolean isMoveStatusFinished(int status) {
5542 return (status < 0 || status > 100);
5543 }
Amith Yamasani4b2e9342011-03-31 12:38:53 -07005544
Jeff Sharkeye2d45be2015-04-15 17:14:12 -07005545 /** {@hide} */
Jeff Sharkey620b32b2015-04-23 19:36:02 -07005546 public static abstract class MoveCallback {
Jeff Sharkey50a05452015-04-29 11:24:52 -07005547 public void onCreated(int moveId, Bundle extras) {}
5548 public abstract void onStatusChanged(int moveId, int status, long estMillis);
Jeff Sharkey620b32b2015-04-23 19:36:02 -07005549 }
Jeff Sharkeye2d45be2015-04-15 17:14:12 -07005550
5551 /** {@hide} */
Jeff Sharkey620b32b2015-04-23 19:36:02 -07005552 public abstract int getMoveStatus(int moveId);
5553
5554 /** {@hide} */
5555 public abstract void registerMoveCallback(MoveCallback callback, Handler handler);
5556 /** {@hide} */
5557 public abstract void unregisterMoveCallback(MoveCallback callback);
5558
5559 /** {@hide} */
5560 public abstract int movePackage(String packageName, VolumeInfo vol);
5561 /** {@hide} */
5562 public abstract @Nullable VolumeInfo getPackageCurrentVolume(ApplicationInfo app);
5563 /** {@hide} */
5564 public abstract @NonNull List<VolumeInfo> getPackageCandidateVolumes(ApplicationInfo app);
5565
5566 /** {@hide} */
5567 public abstract int movePrimaryStorage(VolumeInfo vol);
5568 /** {@hide} */
5569 public abstract @Nullable VolumeInfo getPrimaryStorageCurrentVolume();
5570 /** {@hide} */
5571 public abstract @NonNull List<VolumeInfo> getPrimaryStorageCandidateVolumes();
Jeff Sharkeye2d45be2015-04-15 17:14:12 -07005572
Amith Yamasani4b2e9342011-03-31 12:38:53 -07005573 /**
Amith Yamasani13593602012-03-22 16:16:17 -07005574 * Returns the device identity that verifiers can use to associate their scheme to a particular
5575 * device. This should not be used by anything other than a package verifier.
Aravind Akella068b0c02013-10-12 17:39:15 -07005576 *
Kenny Root0aaa0d92011-09-12 16:42:55 -07005577 * @return identity that uniquely identifies current device
5578 * @hide
5579 */
5580 public abstract VerifierDeviceIdentity getVerifierDeviceIdentity();
Amith Yamasani742a6712011-05-04 14:49:28 -07005581
Jeff Sharkey6c833e02014-07-14 22:44:30 -07005582 /**
Jeff Hao9f60c082014-10-28 18:51:07 -07005583 * Returns true if the device is upgrading, such as first boot after OTA.
5584 *
5585 * @hide
5586 */
5587 public abstract boolean isUpgrade();
5588
5589 /**
Jeff Sharkey6c833e02014-07-14 22:44:30 -07005590 * Return interface that offers the ability to install, upgrade, and remove
5591 * applications on the device.
5592 */
Jeff Sharkey16c8e3f2014-07-24 17:08:17 -07005593 public abstract @NonNull PackageInstaller getPackageInstaller();
Jeff Sharkey3a44f3f2014-04-28 17:36:31 -07005594
Amith Yamasani742a6712011-05-04 14:49:28 -07005595 /**
Jeff Sharkey5aa86932016-01-08 19:07:49 -07005596 * Adds a {@code CrossProfileIntentFilter}. After calling this method all
5597 * intents sent from the user with id sourceUserId can also be be resolved
5598 * by activities in the user with id targetUserId if they match the
5599 * specified intent filter.
5600 *
Nicolas Prevot3f7777f2014-07-24 15:58:39 +01005601 * @param filter The {@link IntentFilter} the intent has to match
5602 * @param sourceUserId The source user id.
5603 * @param targetUserId The target user id.
Jeff Sharkey5aa86932016-01-08 19:07:49 -07005604 * @param flags The possible values are {@link #SKIP_CURRENT_PROFILE} and
5605 * {@link #ONLY_IF_NO_MATCH_FOUND}.
Nicolas Prevotc79586e2014-05-06 12:47:57 +01005606 * @hide
5607 */
Nicolas Prevot63798c52014-05-27 13:22:38 +01005608 public abstract void addCrossProfileIntentFilter(IntentFilter filter, int sourceUserId,
5609 int targetUserId, int flags);
Nicolas Prevotc79586e2014-05-06 12:47:57 +01005610
5611 /**
Jeff Sharkey5aa86932016-01-08 19:07:49 -07005612 * Clearing {@code CrossProfileIntentFilter}s which have the specified user
5613 * as their source, and have been set by the app calling this method.
5614 *
Nicolas Prevot3f7777f2014-07-24 15:58:39 +01005615 * @param sourceUserId The source user id.
Nicolas Prevotc79586e2014-05-06 12:47:57 +01005616 * @hide
5617 */
Nicolas Prevot81948992014-05-16 18:25:26 +01005618 public abstract void clearCrossProfileIntentFilters(int sourceUserId);
Alexandra Gherghina6e2ae252014-06-12 16:03:58 +01005619
5620 /**
Nicolas Prevot88cc3462014-05-14 14:51:48 +01005621 * @hide
5622 */
Nicolas Prevot7f7b0c72014-06-23 15:59:38 +01005623 public abstract Drawable loadItemIcon(PackageItemInfo itemInfo, ApplicationInfo appInfo);
Jeff Sharkey6c833e02014-07-14 22:44:30 -07005624
Benjamin Franzec2d48b2014-10-01 15:38:43 +01005625 /**
5626 * @hide
5627 */
5628 public abstract Drawable loadUnbadgedItemIcon(PackageItemInfo itemInfo, ApplicationInfo appInfo);
5629
Jeff Sharkey6c833e02014-07-14 22:44:30 -07005630 /** {@hide} */
5631 public abstract boolean isPackageAvailable(String packageName);
Jeff Sharkey16c8e3f2014-07-24 17:08:17 -07005632
5633 /** {@hide} */
Jeff Sharkeya0907432014-08-15 10:23:11 -07005634 public static String installStatusToString(int status, String msg) {
5635 final String str = installStatusToString(status);
5636 if (msg != null) {
5637 return str + ": " + msg;
5638 } else {
5639 return str;
5640 }
5641 }
5642
5643 /** {@hide} */
Jeff Sharkey16c8e3f2014-07-24 17:08:17 -07005644 public static String installStatusToString(int status) {
5645 switch (status) {
5646 case INSTALL_SUCCEEDED: return "INSTALL_SUCCEEDED";
5647 case INSTALL_FAILED_ALREADY_EXISTS: return "INSTALL_FAILED_ALREADY_EXISTS";
5648 case INSTALL_FAILED_INVALID_APK: return "INSTALL_FAILED_INVALID_APK";
5649 case INSTALL_FAILED_INVALID_URI: return "INSTALL_FAILED_INVALID_URI";
5650 case INSTALL_FAILED_INSUFFICIENT_STORAGE: return "INSTALL_FAILED_INSUFFICIENT_STORAGE";
5651 case INSTALL_FAILED_DUPLICATE_PACKAGE: return "INSTALL_FAILED_DUPLICATE_PACKAGE";
5652 case INSTALL_FAILED_NO_SHARED_USER: return "INSTALL_FAILED_NO_SHARED_USER";
5653 case INSTALL_FAILED_UPDATE_INCOMPATIBLE: return "INSTALL_FAILED_UPDATE_INCOMPATIBLE";
5654 case INSTALL_FAILED_SHARED_USER_INCOMPATIBLE: return "INSTALL_FAILED_SHARED_USER_INCOMPATIBLE";
5655 case INSTALL_FAILED_MISSING_SHARED_LIBRARY: return "INSTALL_FAILED_MISSING_SHARED_LIBRARY";
5656 case INSTALL_FAILED_REPLACE_COULDNT_DELETE: return "INSTALL_FAILED_REPLACE_COULDNT_DELETE";
5657 case INSTALL_FAILED_DEXOPT: return "INSTALL_FAILED_DEXOPT";
5658 case INSTALL_FAILED_OLDER_SDK: return "INSTALL_FAILED_OLDER_SDK";
5659 case INSTALL_FAILED_CONFLICTING_PROVIDER: return "INSTALL_FAILED_CONFLICTING_PROVIDER";
5660 case INSTALL_FAILED_NEWER_SDK: return "INSTALL_FAILED_NEWER_SDK";
5661 case INSTALL_FAILED_TEST_ONLY: return "INSTALL_FAILED_TEST_ONLY";
5662 case INSTALL_FAILED_CPU_ABI_INCOMPATIBLE: return "INSTALL_FAILED_CPU_ABI_INCOMPATIBLE";
5663 case INSTALL_FAILED_MISSING_FEATURE: return "INSTALL_FAILED_MISSING_FEATURE";
5664 case INSTALL_FAILED_CONTAINER_ERROR: return "INSTALL_FAILED_CONTAINER_ERROR";
5665 case INSTALL_FAILED_INVALID_INSTALL_LOCATION: return "INSTALL_FAILED_INVALID_INSTALL_LOCATION";
5666 case INSTALL_FAILED_MEDIA_UNAVAILABLE: return "INSTALL_FAILED_MEDIA_UNAVAILABLE";
5667 case INSTALL_FAILED_VERIFICATION_TIMEOUT: return "INSTALL_FAILED_VERIFICATION_TIMEOUT";
5668 case INSTALL_FAILED_VERIFICATION_FAILURE: return "INSTALL_FAILED_VERIFICATION_FAILURE";
5669 case INSTALL_FAILED_PACKAGE_CHANGED: return "INSTALL_FAILED_PACKAGE_CHANGED";
5670 case INSTALL_FAILED_UID_CHANGED: return "INSTALL_FAILED_UID_CHANGED";
5671 case INSTALL_FAILED_VERSION_DOWNGRADE: return "INSTALL_FAILED_VERSION_DOWNGRADE";
5672 case INSTALL_PARSE_FAILED_NOT_APK: return "INSTALL_PARSE_FAILED_NOT_APK";
5673 case INSTALL_PARSE_FAILED_BAD_MANIFEST: return "INSTALL_PARSE_FAILED_BAD_MANIFEST";
5674 case INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION: return "INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION";
5675 case INSTALL_PARSE_FAILED_NO_CERTIFICATES: return "INSTALL_PARSE_FAILED_NO_CERTIFICATES";
5676 case INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES: return "INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES";
5677 case INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING: return "INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING";
5678 case INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME: return "INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME";
5679 case INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID: return "INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID";
5680 case INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: return "INSTALL_PARSE_FAILED_MANIFEST_MALFORMED";
5681 case INSTALL_PARSE_FAILED_MANIFEST_EMPTY: return "INSTALL_PARSE_FAILED_MANIFEST_EMPTY";
5682 case INSTALL_FAILED_INTERNAL_ERROR: return "INSTALL_FAILED_INTERNAL_ERROR";
5683 case INSTALL_FAILED_USER_RESTRICTED: return "INSTALL_FAILED_USER_RESTRICTED";
5684 case INSTALL_FAILED_DUPLICATE_PERMISSION: return "INSTALL_FAILED_DUPLICATE_PERMISSION";
5685 case INSTALL_FAILED_NO_MATCHING_ABIS: return "INSTALL_FAILED_NO_MATCHING_ABIS";
Jeff Sharkeyf0600952014-08-07 17:31:53 -07005686 case INSTALL_FAILED_ABORTED: return "INSTALL_FAILED_ABORTED";
Calin Juravle3fc56c32017-12-11 18:26:13 -08005687 case INSTALL_FAILED_BAD_DEX_METADATA:
5688 return "INSTALL_FAILED_BAD_DEX_METADATA";
Jeff Sharkey16c8e3f2014-07-24 17:08:17 -07005689 default: return Integer.toString(status);
5690 }
5691 }
5692
5693 /** {@hide} */
Jeff Sharkeya0907432014-08-15 10:23:11 -07005694 public static int installStatusToPublicStatus(int status) {
Jeff Sharkey16c8e3f2014-07-24 17:08:17 -07005695 switch (status) {
Jeff Sharkeya0907432014-08-15 10:23:11 -07005696 case INSTALL_SUCCEEDED: return PackageInstaller.STATUS_SUCCESS;
5697 case INSTALL_FAILED_ALREADY_EXISTS: return PackageInstaller.STATUS_FAILURE_CONFLICT;
5698 case INSTALL_FAILED_INVALID_APK: return PackageInstaller.STATUS_FAILURE_INVALID;
5699 case INSTALL_FAILED_INVALID_URI: return PackageInstaller.STATUS_FAILURE_INVALID;
5700 case INSTALL_FAILED_INSUFFICIENT_STORAGE: return PackageInstaller.STATUS_FAILURE_STORAGE;
5701 case INSTALL_FAILED_DUPLICATE_PACKAGE: return PackageInstaller.STATUS_FAILURE_CONFLICT;
5702 case INSTALL_FAILED_NO_SHARED_USER: return PackageInstaller.STATUS_FAILURE_CONFLICT;
5703 case INSTALL_FAILED_UPDATE_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_CONFLICT;
5704 case INSTALL_FAILED_SHARED_USER_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_CONFLICT;
5705 case INSTALL_FAILED_MISSING_SHARED_LIBRARY: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
5706 case INSTALL_FAILED_REPLACE_COULDNT_DELETE: return PackageInstaller.STATUS_FAILURE_CONFLICT;
5707 case INSTALL_FAILED_DEXOPT: return PackageInstaller.STATUS_FAILURE_INVALID;
5708 case INSTALL_FAILED_OLDER_SDK: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
5709 case INSTALL_FAILED_CONFLICTING_PROVIDER: return PackageInstaller.STATUS_FAILURE_CONFLICT;
5710 case INSTALL_FAILED_NEWER_SDK: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
5711 case INSTALL_FAILED_TEST_ONLY: return PackageInstaller.STATUS_FAILURE_INVALID;
5712 case INSTALL_FAILED_CPU_ABI_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
5713 case INSTALL_FAILED_MISSING_FEATURE: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
5714 case INSTALL_FAILED_CONTAINER_ERROR: return PackageInstaller.STATUS_FAILURE_STORAGE;
5715 case INSTALL_FAILED_INVALID_INSTALL_LOCATION: return PackageInstaller.STATUS_FAILURE_STORAGE;
5716 case INSTALL_FAILED_MEDIA_UNAVAILABLE: return PackageInstaller.STATUS_FAILURE_STORAGE;
5717 case INSTALL_FAILED_VERIFICATION_TIMEOUT: return PackageInstaller.STATUS_FAILURE_ABORTED;
5718 case INSTALL_FAILED_VERIFICATION_FAILURE: return PackageInstaller.STATUS_FAILURE_ABORTED;
5719 case INSTALL_FAILED_PACKAGE_CHANGED: return PackageInstaller.STATUS_FAILURE_INVALID;
5720 case INSTALL_FAILED_UID_CHANGED: return PackageInstaller.STATUS_FAILURE_INVALID;
5721 case INSTALL_FAILED_VERSION_DOWNGRADE: return PackageInstaller.STATUS_FAILURE_INVALID;
Svetoslavd9653702015-05-13 18:02:46 -07005722 case INSTALL_FAILED_PERMISSION_MODEL_DOWNGRADE: return PackageInstaller.STATUS_FAILURE_INVALID;
Jeff Sharkeya0907432014-08-15 10:23:11 -07005723 case INSTALL_PARSE_FAILED_NOT_APK: return PackageInstaller.STATUS_FAILURE_INVALID;
5724 case INSTALL_PARSE_FAILED_BAD_MANIFEST: return PackageInstaller.STATUS_FAILURE_INVALID;
5725 case INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION: return PackageInstaller.STATUS_FAILURE_INVALID;
5726 case INSTALL_PARSE_FAILED_NO_CERTIFICATES: return PackageInstaller.STATUS_FAILURE_INVALID;
5727 case INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES: return PackageInstaller.STATUS_FAILURE_INVALID;
5728 case INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING: return PackageInstaller.STATUS_FAILURE_INVALID;
5729 case INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME: return PackageInstaller.STATUS_FAILURE_INVALID;
5730 case INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID: return PackageInstaller.STATUS_FAILURE_INVALID;
5731 case INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: return PackageInstaller.STATUS_FAILURE_INVALID;
5732 case INSTALL_PARSE_FAILED_MANIFEST_EMPTY: return PackageInstaller.STATUS_FAILURE_INVALID;
Calin Juravle3fc56c32017-12-11 18:26:13 -08005733 case INSTALL_FAILED_BAD_DEX_METADATA: return PackageInstaller.STATUS_FAILURE_INVALID;
Jeff Sharkeya0907432014-08-15 10:23:11 -07005734 case INSTALL_FAILED_INTERNAL_ERROR: return PackageInstaller.STATUS_FAILURE;
5735 case INSTALL_FAILED_USER_RESTRICTED: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
5736 case INSTALL_FAILED_DUPLICATE_PERMISSION: return PackageInstaller.STATUS_FAILURE_CONFLICT;
5737 case INSTALL_FAILED_NO_MATCHING_ABIS: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
5738 case INSTALL_FAILED_ABORTED: return PackageInstaller.STATUS_FAILURE_ABORTED;
5739 default: return PackageInstaller.STATUS_FAILURE;
5740 }
5741 }
5742
5743 /** {@hide} */
5744 public static String deleteStatusToString(int status, String msg) {
5745 final String str = deleteStatusToString(status);
5746 if (msg != null) {
5747 return str + ": " + msg;
5748 } else {
5749 return str;
Jeff Sharkey16c8e3f2014-07-24 17:08:17 -07005750 }
5751 }
5752
5753 /** {@hide} */
5754 public static String deleteStatusToString(int status) {
5755 switch (status) {
5756 case DELETE_SUCCEEDED: return "DELETE_SUCCEEDED";
5757 case DELETE_FAILED_INTERNAL_ERROR: return "DELETE_FAILED_INTERNAL_ERROR";
5758 case DELETE_FAILED_DEVICE_POLICY_MANAGER: return "DELETE_FAILED_DEVICE_POLICY_MANAGER";
5759 case DELETE_FAILED_USER_RESTRICTED: return "DELETE_FAILED_USER_RESTRICTED";
5760 case DELETE_FAILED_OWNER_BLOCKED: return "DELETE_FAILED_OWNER_BLOCKED";
Jeff Sharkeyf0600952014-08-07 17:31:53 -07005761 case DELETE_FAILED_ABORTED: return "DELETE_FAILED_ABORTED";
Svet Ganov67882122016-12-11 16:36:34 -08005762 case DELETE_FAILED_USED_SHARED_LIBRARY: return "DELETE_FAILED_USED_SHARED_LIBRARY";
Jeff Sharkey16c8e3f2014-07-24 17:08:17 -07005763 default: return Integer.toString(status);
5764 }
5765 }
Jeff Sharkeyf0600952014-08-07 17:31:53 -07005766
5767 /** {@hide} */
Jeff Sharkeya0907432014-08-15 10:23:11 -07005768 public static int deleteStatusToPublicStatus(int status) {
Jeff Sharkeyf0600952014-08-07 17:31:53 -07005769 switch (status) {
Jeff Sharkeya0907432014-08-15 10:23:11 -07005770 case DELETE_SUCCEEDED: return PackageInstaller.STATUS_SUCCESS;
5771 case DELETE_FAILED_INTERNAL_ERROR: return PackageInstaller.STATUS_FAILURE;
5772 case DELETE_FAILED_DEVICE_POLICY_MANAGER: return PackageInstaller.STATUS_FAILURE_BLOCKED;
5773 case DELETE_FAILED_USER_RESTRICTED: return PackageInstaller.STATUS_FAILURE_BLOCKED;
5774 case DELETE_FAILED_OWNER_BLOCKED: return PackageInstaller.STATUS_FAILURE_BLOCKED;
5775 case DELETE_FAILED_ABORTED: return PackageInstaller.STATUS_FAILURE_ABORTED;
Svet Ganov67882122016-12-11 16:36:34 -08005776 case DELETE_FAILED_USED_SHARED_LIBRARY: return PackageInstaller.STATUS_FAILURE_CONFLICT;
Jeff Sharkeya0907432014-08-15 10:23:11 -07005777 default: return PackageInstaller.STATUS_FAILURE;
Jeff Sharkeyf0600952014-08-07 17:31:53 -07005778 }
5779 }
Jeff Sharkey6c0b9da2014-08-07 22:07:11 -07005780
5781 /** {@hide} */
Svet Ganov77ab6a82015-07-03 12:03:02 -07005782 public static String permissionFlagToString(int flag) {
5783 switch (flag) {
Svetoslav4a5f4a22015-07-07 18:18:15 -07005784 case FLAG_PERMISSION_GRANTED_BY_DEFAULT: return "GRANTED_BY_DEFAULT";
5785 case FLAG_PERMISSION_POLICY_FIXED: return "POLICY_FIXED";
5786 case FLAG_PERMISSION_SYSTEM_FIXED: return "SYSTEM_FIXED";
5787 case FLAG_PERMISSION_USER_SET: return "USER_SET";
5788 case FLAG_PERMISSION_REVOKE_ON_UPGRADE: return "REVOKE_ON_UPGRADE";
5789 case FLAG_PERMISSION_USER_FIXED: return "USER_FIXED";
Svet Ganov9c165d72015-12-01 19:52:26 -08005790 case FLAG_PERMISSION_REVIEW_REQUIRED: return "REVIEW_REQUIRED";
Svet Ganov77ab6a82015-07-03 12:03:02 -07005791 default: return Integer.toString(flag);
5792 }
5793 }
5794
5795 /** {@hide} */
Jeff Sharkey6c0b9da2014-08-07 22:07:11 -07005796 public static class LegacyPackageDeleteObserver extends PackageDeleteObserver {
5797 private final IPackageDeleteObserver mLegacy;
5798
5799 public LegacyPackageDeleteObserver(IPackageDeleteObserver legacy) {
5800 mLegacy = legacy;
5801 }
5802
5803 @Override
5804 public void onPackageDeleted(String basePackageName, int returnCode, String msg) {
5805 if (mLegacy == null) return;
5806 try {
5807 mLegacy.packageDeleted(basePackageName, returnCode);
5808 } catch (RemoteException ignored) {
5809 }
5810 }
5811 }
Bartosz Fabianowskia34f53f2017-01-11 18:08:47 +01005812
5813 /**
Jeff Sharkey4347f812017-04-21 12:08:39 -06005814 * Return the install reason that was recorded when a package was first
5815 * installed for a specific user. Requesting the install reason for another
5816 * user will require the permission INTERACT_ACROSS_USERS_FULL.
Bartosz Fabianowskia34f53f2017-01-11 18:08:47 +01005817 *
5818 * @param packageName The package for which to retrieve the install reason
5819 * @param user The user for whom to retrieve the install reason
Jeff Sharkey4347f812017-04-21 12:08:39 -06005820 * @return The install reason. If the package is not installed for the given
5821 * user, {@code INSTALL_REASON_UNKNOWN} is returned.
Bartosz Fabianowskia34f53f2017-01-11 18:08:47 +01005822 * @hide
5823 */
5824 @TestApi
5825 public abstract @InstallReason int getInstallReason(String packageName,
5826 @NonNull UserHandle user);
Suprabh Shuklaaef25132017-01-23 18:09:03 -08005827
5828 /**
5829 * Checks whether the calling package is allowed to request package installs through package
Suprabh Shukla57528472017-04-14 19:22:45 -07005830 * installer. Apps are encouraged to call this API before launching the package installer via
Suprabh Shuklaaef25132017-01-23 18:09:03 -08005831 * intent {@link android.content.Intent#ACTION_INSTALL_PACKAGE}. Starting from Android O, the
5832 * user can explicitly choose what external sources they trust to install apps on the device.
Suprabh Shukla57528472017-04-14 19:22:45 -07005833 * If this API returns false, the install request will be blocked by the package installer and
Suprabh Shuklaaef25132017-01-23 18:09:03 -08005834 * a dialog will be shown to the user with an option to launch settings to change their
5835 * preference. An application must target Android O or higher and declare permission
Suprabh Shukla57528472017-04-14 19:22:45 -07005836 * {@link android.Manifest.permission#REQUEST_INSTALL_PACKAGES} in order to use this API.
Suprabh Shuklaaef25132017-01-23 18:09:03 -08005837 *
5838 * @return true if the calling package is trusted by the user to request install packages on
5839 * the device, false otherwise.
Suprabh Shukla57528472017-04-14 19:22:45 -07005840 * @see android.content.Intent#ACTION_INSTALL_PACKAGE
5841 * @see android.provider.Settings#ACTION_MANAGE_UNKNOWN_APP_SOURCES
Suprabh Shuklaaef25132017-01-23 18:09:03 -08005842 */
5843 public abstract boolean canRequestPackageInstalls();
Chad Brubakeraa49cb82017-03-24 15:53:09 -07005844
5845 /**
5846 * Return the {@link ComponentName} of the activity providing Settings for the Instant App
5847 * resolver.
5848 *
Todd Kennedy801e6592017-04-12 14:10:12 -07005849 * @see {@link android.content.Intent#ACTION_INSTANT_APP_RESOLVER_SETTINGS}
Chad Brubakeraa49cb82017-03-24 15:53:09 -07005850 * @hide
5851 */
5852 @SystemApi
5853 public abstract ComponentName getInstantAppResolverSettingsComponent();
Todd Kennedy801e6592017-04-12 14:10:12 -07005854
5855 /**
5856 * Return the {@link ComponentName} of the activity responsible for installing instant
5857 * applications.
5858 *
5859 * @see {@link android.content.Intent#ACTION_INSTALL_INSTANT_APP_PACKAGE}
5860 * @hide
5861 */
5862 @SystemApi
5863 public abstract ComponentName getInstantAppInstallerComponent();
Chad Brubaker0d277a72017-04-12 16:56:53 -07005864
5865 /**
5866 * Return the Android Id for a given Instant App.
5867 *
5868 * @see {@link android.provider.Settings.Secure#ANDROID_ID}
5869 * @hide
5870 */
5871 public abstract String getInstantAppAndroidId(String packageName, @NonNull UserHandle user);
Calin Juravle3d2af7f2017-04-19 19:56:21 -07005872
5873 /**
5874 * Callback use to notify the callers of module registration that the operation
5875 * has finished.
5876 *
5877 * @hide
5878 */
Jeff Sharkey90396362017-06-12 16:26:53 -06005879 @SystemApi
Calin Juravle3d2af7f2017-04-19 19:56:21 -07005880 public static abstract class DexModuleRegisterCallback {
5881 public abstract void onDexModuleRegistered(String dexModulePath, boolean success,
5882 String message);
5883 }
5884
5885 /**
5886 * Register an application dex module with the package manager.
5887 * The package manager will keep track of the given module for future optimizations.
5888 *
5889 * Dex module optimizations will disable the classpath checking at runtime. The client bares
5890 * the responsibility to ensure that the static assumptions on classes in the optimized code
5891 * hold at runtime (e.g. there's no duplicate classes in the classpath).
5892 *
5893 * Note that the package manager already keeps track of dex modules loaded with
5894 * {@link dalvik.system.DexClassLoader} and {@link dalvik.system.PathClassLoader}.
5895 * This can be called for an eager registration.
5896 *
5897 * The call might take a while and the results will be posted on the main thread, using
5898 * the given callback.
5899 *
5900 * If the module is intended to be shared with other apps, make sure that the file
5901 * permissions allow for it.
5902 * If at registration time the permissions allow for others to read it, the module would
5903 * be marked as a shared module which might undergo a different optimization strategy.
5904 * (usually shared modules will generated larger optimizations artifacts,
5905 * taking more disk space).
5906 *
5907 * @param dexModulePath the absolute path of the dex module.
5908 * @param callback if not null, {@link DexModuleRegisterCallback#onDexModuleRegistered} will
5909 * be called once the registration finishes.
5910 *
5911 * @hide
5912 */
Jeff Sharkey90396362017-06-12 16:26:53 -06005913 @SystemApi
Calin Juravle3d2af7f2017-04-19 19:56:21 -07005914 public abstract void registerDexModule(String dexModulePath,
5915 @Nullable DexModuleRegisterCallback callback);
Calin Juravle45f8b292017-11-07 18:49:43 -08005916
5917 /**
5918 * Returns the {@link ArtManager} associated with this package manager.
5919 *
5920 * @hide
5921 */
5922 @SystemApi
5923 public @NonNull ArtManager getArtManager() {
5924 throw new UnsupportedOperationException("getArtManager not implemented in subclass");
5925 }
Ben Gruver1ab3d6e2017-12-07 13:45:08 -08005926
5927 /**
5928 * Sets or clears the harmful app warning details for the given app.
5929 *
5930 * When set, any attempt to launch an activity in this package will be intercepted and a
5931 * warning dialog will be shown to the user instead, with the given warning. The user
5932 * will have the option to proceed with the activity launch, or to uninstall the application.
5933 *
5934 * @param packageName The full name of the package to warn on.
5935 * @param warning A warning string to display to the user describing the threat posed by the
5936 * application, or null to clear the warning.
5937 *
5938 * @hide
5939 */
5940 @RequiresPermission(Manifest.permission.SET_HARMFUL_APP_WARNINGS)
5941 @SystemApi
5942 public void setHarmfulAppWarning(@NonNull String packageName, @Nullable CharSequence warning) {
5943 throw new UnsupportedOperationException("setHarmfulAppWarning not implemented in subclass");
5944 }
5945
5946 /**
5947 * Returns the harmful app warning string for the given app, or null if there is none set.
5948 *
5949 * @param packageName The full name of the desired package.
5950 *
5951 * @hide
5952 */
5953 @RequiresPermission(Manifest.permission.SET_HARMFUL_APP_WARNINGS)
5954 @Nullable
5955 @SystemApi
5956 public CharSequence getHarmfulAppWarning(@NonNull String packageName) {
5957 throw new UnsupportedOperationException("getHarmfulAppWarning not implemented in subclass");
5958 }
Daniel Cashman5cdda342018-01-19 07:22:52 -08005959
5960 /** @hide */
5961 @IntDef(prefix = { "CERT_INPUT_" }, value = {
5962 CERT_INPUT_RAW_X509,
5963 CERT_INPUT_SHA256
5964 })
5965 @Retention(RetentionPolicy.SOURCE)
5966 public @interface CertificateInputType {}
5967
5968 /**
5969 * Certificate input bytes: the input bytes represent an encoded X.509 Certificate which could
5970 * be generated using an {@code CertificateFactory}
5971 */
5972 public static final int CERT_INPUT_RAW_X509 = 0;
5973
5974 /**
5975 * Certificate input bytes: the input bytes represent the SHA256 output of an encoded X.509
5976 * Certificate.
5977 */
5978 public static final int CERT_INPUT_SHA256 = 1;
5979
5980 /**
5981 * Searches the set of signing certificates by which the given package has proven to have been
5982 * signed. This should be used instead of {@code getPackageInfo} with {@code GET_SIGNATURES}
5983 * since it takes into account the possibility of signing certificate rotation, except in the
5984 * case of packages that are signed by multiple certificates, for which signing certificate
5985 * rotation is not supported.
5986 *
5987 * @param packageName package whose signing certificates to check
5988 * @param certificate signing certificate for which to search
5989 * @param type representation of the {@code certificate}
5990 * @return true if this package was or is signed by exactly the certificate {@code certificate}
5991 */
5992 public boolean hasSigningCertificate(
5993 String packageName, byte[] certificate, @CertificateInputType int type) {
5994 throw new UnsupportedOperationException(
5995 "hasSigningCertificate not implemented in subclass");
5996 }
5997
5998 /**
5999 * Searches the set of signing certificates by which the given uid has proven to have been
6000 * signed. This should be used instead of {@code getPackageInfo} with {@code GET_SIGNATURES}
6001 * since it takes into account the possibility of signing certificate rotation, except in the
6002 * case of packages that are signed by multiple certificates, for which signing certificate
6003 * rotation is not supported.
6004 *
6005 * @param uid package whose signing certificates to check
6006 * @param certificate signing certificate for which to search
6007 * @param type representation of the {@code certificate}
6008 * @return true if this package was or is signed by exactly the certificate {@code certificate}
6009 */
6010 public boolean hasSigningCertificate(
6011 int uid, byte[] certificate, @CertificateInputType int type) {
6012 throw new UnsupportedOperationException(
6013 "hasSigningCertificate not implemented in subclass");
6014 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08006015}