blob: 29added9aa51b3e70aed8991f342f41a1805eda9 [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;
18
Tor Norbyec91531a2015-04-01 17:41:55 -070019import android.annotation.AttrRes;
Tor Norbye1c2bf032015-03-02 10:57:08 -080020import android.annotation.CheckResult;
Tor Norbye3e4cda72015-06-10 08:14:31 -070021import android.annotation.ColorInt;
22import android.annotation.ColorRes;
23import android.annotation.DrawableRes;
Tor Norbyed9273d62013-05-30 15:59:53 -070024import android.annotation.IntDef;
25import android.annotation.NonNull;
26import android.annotation.Nullable;
Tor Norbye788fc2b2015-07-05 16:10:42 -070027import android.annotation.RequiresPermission;
Tor Norbyed9273d62013-05-30 15:59:53 -070028import android.annotation.StringDef;
Tor Norbye7b9c9122013-05-30 16:48:33 -070029import android.annotation.StringRes;
30import android.annotation.StyleRes;
31import android.annotation.StyleableRes;
Jinsuk Kim66d1eb22014-06-06 16:12:18 +090032import android.annotation.SystemApi;
Jeff Sharkeya73b8fd2016-01-06 17:02:08 -070033import android.annotation.TestApi;
Mathew Inwood5c0d3542018-08-14 13:54:31 +010034import android.annotation.UnsupportedAppUsage;
Jeff Sharkey8588bc12016-01-06 16:47:42 -070035import android.annotation.UserIdInt;
Selim Cinek7fa385a2018-01-24 08:35:28 -080036import android.app.ActivityManager;
Tony Mak46aabe52016-11-14 12:53:06 +000037import android.app.IApplicationThread;
38import android.app.IServiceConnection;
Zak Cohen56345f42017-01-26 13:54:28 -080039import android.app.VrManager;
Dianne Hackborn5c1e00b2009-06-18 17:10:57 -070040import android.content.pm.ApplicationInfo;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080041import android.content.pm.PackageManager;
42import android.content.res.AssetManager;
Alan Viverette45c4bbb2015-01-05 14:59:19 -080043import android.content.res.ColorStateList;
Dianne Hackborn756220b2012-08-14 16:45:30 -070044import android.content.res.Configuration;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080045import android.content.res.Resources;
46import android.content.res.TypedArray;
Vasu Nori74f170f2010-06-01 18:06:18 -070047import android.database.DatabaseErrorHandler;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080048import android.database.sqlite.SQLiteDatabase;
49import android.database.sqlite.SQLiteDatabase.CursorFactory;
50import android.graphics.Bitmap;
51import android.graphics.drawable.Drawable;
52import android.net.Uri;
Patrick Baumannef4c4072018-02-01 08:54:05 -080053import android.os.Build;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080054import android.os.Bundle;
Jeff Sharkey6feb50b2013-10-15 12:38:15 -070055import android.os.Environment;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080056import android.os.Handler;
Jeff Sharkey8439ac02017-12-12 17:26:23 -070057import android.os.HandlerExecutor;
Dianne Hackbornff170242014-11-19 10:59:01 -080058import android.os.IBinder;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080059import android.os.Looper;
Jeff Sharkey6feb50b2013-10-15 12:38:15 -070060import android.os.StatFs;
Dianne Hackborn79af1dd2012-08-16 16:42:52 -070061import android.os.UserHandle;
Jeff Sharkey8c165792012-10-22 14:08:29 -070062import android.os.UserManager;
Jeff Sharkey60a82cd2017-04-18 18:19:16 -060063import android.os.storage.StorageManager;
Jeff Sharkey2ee3c1e2014-05-30 15:38:35 -070064import android.provider.MediaStore;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080065import android.util.AttributeSet;
Jeff Browna492c3a2012-08-23 19:48:44 -070066import android.view.Display;
Jeff Sharkeye13529a2015-12-09 14:15:27 -070067import android.view.DisplayAdjustments;
Philip P. Moltmanneab62ba2017-03-20 10:55:43 -070068import android.view.View;
Jon Miranda836c0a82014-08-11 12:32:26 -070069import android.view.ViewDebug;
Jeff Browna492c3a2012-08-23 19:48:44 -070070import android.view.WindowManager;
Felipe Lemebb567ae2017-10-04 09:56:21 -070071import android.view.autofill.AutofillManager.AutofillClient;
Abodunrinwa Tokif001fef2017-01-04 23:51:42 +000072import android.view.textclassifier.TextClassificationManager;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080073
74import java.io.File;
75import java.io.FileInputStream;
76import java.io.FileNotFoundException;
77import java.io.FileOutputStream;
78import java.io.IOException;
79import java.io.InputStream;
Tor Norbyed9273d62013-05-30 15:59:53 -070080import java.lang.annotation.Retention;
81import java.lang.annotation.RetentionPolicy;
Jeff Sharkey8439ac02017-12-12 17:26:23 -070082import java.util.concurrent.Executor;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080083
84/**
85 * Interface to global information about an application environment. This is
86 * an abstract class whose implementation is provided by
87 * the Android system. It
88 * allows access to application-specific resources and classes, as well as
89 * up-calls for application-level operations such as launching activities,
90 * broadcasting and receiving intents, etc.
91 */
92public abstract class Context {
Jeff Sharkey30e06bb2017-04-24 11:18:03 -060093 /** @hide */
94 @IntDef(flag = true, prefix = { "MODE_" }, value = {
95 MODE_PRIVATE,
96 MODE_WORLD_READABLE,
97 MODE_WORLD_WRITEABLE,
98 MODE_APPEND,
99 })
100 @Retention(RetentionPolicy.SOURCE)
101 public @interface FileMode {}
102
103 /** @hide */
104 @IntDef(flag = true, prefix = { "MODE_" }, value = {
105 MODE_PRIVATE,
106 MODE_WORLD_READABLE,
107 MODE_WORLD_WRITEABLE,
108 MODE_MULTI_PROCESS,
109 })
110 @Retention(RetentionPolicy.SOURCE)
111 public @interface PreferencesMode {}
112
113 /** @hide */
114 @IntDef(flag = true, prefix = { "MODE_" }, value = {
115 MODE_PRIVATE,
116 MODE_WORLD_READABLE,
117 MODE_WORLD_WRITEABLE,
118 MODE_ENABLE_WRITE_AHEAD_LOGGING,
119 MODE_NO_LOCALIZED_COLLATORS,
120 })
121 @Retention(RetentionPolicy.SOURCE)
122 public @interface DatabaseMode {}
123
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800124 /**
125 * File creation mode: the default mode, where the created file can only
126 * be accessed by the calling application (or all applications sharing the
127 * same user ID).
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800128 */
129 public static final int MODE_PRIVATE = 0x0000;
Jeff Sharkey634dc422016-01-30 17:44:15 -0700130
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800131 /**
Jeff Sharkey634dc422016-01-30 17:44:15 -0700132 * File creation mode: allow all other applications to have read access to
133 * the created file.
134 * <p>
Dave Friedmancfe50882017-07-05 00:40:07 -0700135 * Starting from {@link android.os.Build.VERSION_CODES#N}, attempting to use this
136 * mode throws a {@link SecurityException}.
Jeff Sharkey634dc422016-01-30 17:44:15 -0700137 *
Nick Kralevich15069212013-01-09 15:54:56 -0800138 * @deprecated Creating world-readable files is very dangerous, and likely
Jeff Sharkey634dc422016-01-30 17:44:15 -0700139 * to cause security holes in applications. It is strongly
140 * discouraged; instead, applications should use more formal
141 * mechanism for interactions such as {@link ContentProvider},
142 * {@link BroadcastReceiver}, and {@link android.app.Service}.
143 * There are no guarantees that this access mode will remain on
144 * a file, such as when it goes through a backup and restore.
145 * @see android.support.v4.content.FileProvider
146 * @see Intent#FLAG_GRANT_WRITE_URI_PERMISSION
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800147 */
Dianne Hackborn556b09e2012-09-23 17:46:53 -0700148 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800149 public static final int MODE_WORLD_READABLE = 0x0001;
Jeff Sharkey634dc422016-01-30 17:44:15 -0700150
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800151 /**
Jeff Sharkey634dc422016-01-30 17:44:15 -0700152 * File creation mode: allow all other applications to have write access to
153 * the created file.
154 * <p>
Dave Friedmancfe50882017-07-05 00:40:07 -0700155 * Starting from {@link android.os.Build.VERSION_CODES#N}, attempting to use this
Jeff Sharkey634dc422016-01-30 17:44:15 -0700156 * mode will throw a {@link SecurityException}.
157 *
Nick Kralevich15069212013-01-09 15:54:56 -0800158 * @deprecated Creating world-writable files is very dangerous, and likely
Jeff Sharkey634dc422016-01-30 17:44:15 -0700159 * to cause security holes in applications. It is strongly
160 * discouraged; instead, applications should use more formal
161 * mechanism for interactions such as {@link ContentProvider},
162 * {@link BroadcastReceiver}, and {@link android.app.Service}.
163 * There are no guarantees that this access mode will remain on
164 * a file, such as when it goes through a backup and restore.
165 * @see android.support.v4.content.FileProvider
166 * @see Intent#FLAG_GRANT_WRITE_URI_PERMISSION
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800167 */
Dianne Hackborn556b09e2012-09-23 17:46:53 -0700168 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800169 public static final int MODE_WORLD_WRITEABLE = 0x0002;
Jeff Sharkey634dc422016-01-30 17:44:15 -0700170
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800171 /**
172 * File creation mode: for use with {@link #openFileOutput}, if the file
173 * already exists then write data to the end of the existing file
174 * instead of erasing it.
175 * @see #openFileOutput
176 */
177 public static final int MODE_APPEND = 0x8000;
178
179 /**
Brad Fitzpatrick4e920f72010-12-14 11:52:13 -0800180 * SharedPreference loading flag: when set, the file on disk will
181 * be checked for modification even if the shared preferences
182 * instance is already loaded in this process. This behavior is
183 * sometimes desired in cases where the application has multiple
184 * processes, all writing to the same SharedPreferences file.
185 * Generally there are better forms of communication between
186 * processes, though.
187 *
188 * <p>This was the legacy (but undocumented) behavior in and
189 * before Gingerbread (Android 2.3) and this flag is implied when
kopriva219f7dc2018-10-09 13:42:28 -0700190 * targeting such releases. For applications targeting SDK
Brad Fitzpatrick4e920f72010-12-14 11:52:13 -0800191 * versions <em>greater than</em> Android 2.3, this flag must be
192 * explicitly set if desired.
193 *
194 * @see #getSharedPreferences
Christopher Tated5748b82015-05-08 18:14:01 -0700195 *
196 * @deprecated MODE_MULTI_PROCESS does not work reliably in
197 * some versions of Android, and furthermore does not provide any
198 * mechanism for reconciling concurrent modifications across
199 * processes. Applications should not attempt to use it. Instead,
200 * they should use an explicit cross-process data management
201 * approach such as {@link android.content.ContentProvider ContentProvider}.
Brad Fitzpatrick4e920f72010-12-14 11:52:13 -0800202 */
Christopher Tated5748b82015-05-08 18:14:01 -0700203 @Deprecated
Brad Fitzpatrick4e920f72010-12-14 11:52:13 -0800204 public static final int MODE_MULTI_PROCESS = 0x0004;
205
206 /**
Jeff Brown47847f32012-03-22 19:13:11 -0700207 * Database open flag: when set, the database is opened with write-ahead
208 * logging enabled by default.
209 *
210 * @see #openOrCreateDatabase(String, int, CursorFactory)
211 * @see #openOrCreateDatabase(String, int, CursorFactory, DatabaseErrorHandler)
212 * @see SQLiteDatabase#enableWriteAheadLogging
213 */
214 public static final int MODE_ENABLE_WRITE_AHEAD_LOGGING = 0x0008;
215
Sunny Goyala21e6b22015-12-02 09:51:02 -0800216 /**
217 * Database open flag: when set, the database is opened without support for
218 * localized collators.
219 *
220 * @see #openOrCreateDatabase(String, int, CursorFactory)
221 * @see #openOrCreateDatabase(String, int, CursorFactory, DatabaseErrorHandler)
222 * @see SQLiteDatabase#NO_LOCALIZED_COLLATORS
223 */
224 public static final int MODE_NO_LOCALIZED_COLLATORS = 0x0010;
225
Tor Norbyed9273d62013-05-30 15:59:53 -0700226 /** @hide */
Jeff Sharkeyce8db992017-12-13 20:05:05 -0700227 @IntDef(flag = true, prefix = { "BIND_" }, value = {
228 BIND_AUTO_CREATE,
229 BIND_DEBUG_UNBIND,
230 BIND_NOT_FOREGROUND,
231 BIND_ABOVE_CLIENT,
232 BIND_ALLOW_OOM_MANAGEMENT,
233 BIND_WAIVE_PRIORITY,
234 BIND_IMPORTANT,
235 BIND_ADJUST_WITH_ACTIVITY
236 })
Tor Norbyed9273d62013-05-30 15:59:53 -0700237 @Retention(RetentionPolicy.SOURCE)
238 public @interface BindServiceFlags {}
239
Jeff Brown47847f32012-03-22 19:13:11 -0700240 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800241 * Flag for {@link #bindService}: automatically create the service as long
242 * as the binding exists. Note that while this will create the service,
Scott Main4b5da682010-10-21 11:49:12 -0700243 * its {@link android.app.Service#onStartCommand}
244 * method will still only be called due to an
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800245 * explicit call to {@link #startService}. Even without that, though,
246 * this still provides you with access to the service object while the
247 * service is created.
248 *
Dianne Hackbornc68c9132011-07-29 01:25:18 -0700249 * <p>Note that prior to {@link android.os.Build.VERSION_CODES#ICE_CREAM_SANDWICH},
250 * not supplying this flag would also impact how important the system
251 * consider's the target service's process to be. When set, the only way
252 * for it to be raised was by binding from a service in which case it will
253 * only be important when that activity is in the foreground. Now to
254 * achieve this behavior you must explicitly supply the new flag
255 * {@link #BIND_ADJUST_WITH_ACTIVITY}. For compatibility, old applications
256 * that don't specify {@link #BIND_AUTO_CREATE} will automatically have
257 * the flags {@link #BIND_WAIVE_PRIORITY} and
258 * {@link #BIND_ADJUST_WITH_ACTIVITY} set for them in order to achieve
259 * the same result.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800260 */
261 public static final int BIND_AUTO_CREATE = 0x0001;
262
263 /**
264 * Flag for {@link #bindService}: include debugging help for mismatched
265 * calls to unbind. When this flag is set, the callstack of the following
266 * {@link #unbindService} call is retained, to be printed if a later
267 * incorrect unbind call is made. Note that doing this requires retaining
268 * information about the binding that was made for the lifetime of the app,
269 * resulting in a leak -- this should only be used for debugging.
270 */
271 public static final int BIND_DEBUG_UNBIND = 0x0002;
272
Dianne Hackborn09c916b2009-12-08 14:50:51 -0800273 /**
274 * Flag for {@link #bindService}: don't allow this binding to raise
275 * the target service's process to the foreground scheduling priority.
Dianne Hackborn130b0d22011-07-26 22:07:48 -0700276 * It will still be raised to at least the same memory priority
Dianne Hackborn09c916b2009-12-08 14:50:51 -0800277 * as the client (so that its process will not be killable in any
278 * situation where the client is not killable), but for CPU scheduling
279 * purposes it may be left in the background. This only has an impact
280 * in the situation where the binding client is a foreground process
281 * and the target service is in a background process.
282 */
283 public static final int BIND_NOT_FOREGROUND = 0x0004;
284
Dianne Hackborn130b0d22011-07-26 22:07:48 -0700285 /**
Dianne Hackbornc68c9132011-07-29 01:25:18 -0700286 * Flag for {@link #bindService}: indicates that the client application
287 * binding to this service considers the service to be more important than
288 * the app itself. When set, the platform will try to have the out of
Dianne Hackbornb12e1352012-09-26 11:39:20 -0700289 * memory killer kill the app before it kills the service it is bound to, though
Dianne Hackbornc68c9132011-07-29 01:25:18 -0700290 * this is not guaranteed to be the case.
291 */
292 public static final int BIND_ABOVE_CLIENT = 0x0008;
293
294 /**
Dianne Hackborn130b0d22011-07-26 22:07:48 -0700295 * Flag for {@link #bindService}: allow the process hosting the bound
296 * service to go through its normal memory management. It will be
297 * treated more like a running service, allowing the system to
298 * (temporarily) expunge the process if low on memory or for some other
Dianne Hackbornc68c9132011-07-29 01:25:18 -0700299 * whim it may have, and being more aggressive about making it a candidate
300 * to be killed (and restarted) if running for a long time.
Dianne Hackborn130b0d22011-07-26 22:07:48 -0700301 */
Dianne Hackbornc68c9132011-07-29 01:25:18 -0700302 public static final int BIND_ALLOW_OOM_MANAGEMENT = 0x0010;
303
304 /**
305 * Flag for {@link #bindService}: don't impact the scheduling or
306 * memory management priority of the target service's hosting process.
307 * Allows the service's process to be managed on the background LRU list
308 * just like a regular application process in the background.
309 */
310 public static final int BIND_WAIVE_PRIORITY = 0x0020;
311
312 /**
313 * Flag for {@link #bindService}: this service is very important to
314 * the client, so should be brought to the foreground process level
315 * when the client is. Normally a process can only be raised to the
316 * visibility level by a client, even if that client is in the foreground.
317 */
318 public static final int BIND_IMPORTANT = 0x0040;
319
320 /**
321 * Flag for {@link #bindService}: If binding from an activity, allow the
322 * target service's process importance to be raised based on whether the
323 * activity is visible to the user, regardless whether another flag is
324 * used to reduce the amount that the client process's overall importance
325 * is used to impact it.
326 */
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -0700327 public static final int BIND_ADJUST_WITH_ACTIVITY = 0x0080;
328
329 /**
Amith Yamasanie5bfeee2018-09-05 18:52:35 -0700330 * Flag for {@link #bindService}: If binding from something better than perceptible,
331 * still set the adjust below perceptible. This would be used for bound services that can
332 * afford to be evicted when under extreme memory pressure, but should be restarted as soon
333 * as possible.
334 * @hide
335 */
336 public static final int BIND_ADJUST_BELOW_PERCEPTIBLE = 0x0100;
337
338 /**
Dianne Hackbornc390aa82019-01-09 16:38:22 -0800339 * @hide Flag for {@link #bindService}: the service being bound to represents a
340 * protected system component, so must have association restrictions applied to it.
341 * That is, a system config must have one or more allow-association tags limiting
342 * which packages it can interact with. If it does not have any such association
343 * restrictions, a default empty set will be created.
344 */
345 public static final int BIND_RESTRICT_ASSOCIATIONS = 0x00200000;
346
347 /**
Svet Ganovd223db32017-12-22 09:43:48 -0800348 * @hide Flag for {@link #bindService}: allows binding to a service provided
349 * by an instant app. Note that the caller may not have access to the instant
350 * app providing the service which is a violation of the instant app sandbox.
351 * This flag is intended ONLY for development/testing and should be used with
352 * great care. Only the system is allowed to use this flag.
353 */
354 public static final int BIND_ALLOW_INSTANT = 0x00400000;
355
356 /**
Dianne Hackborn83b40f62017-04-26 13:59:47 -0700357 * @hide Flag for {@link #bindService}: like {@link #BIND_NOT_FOREGROUND}, but puts it
358 * up in to the important background state (instead of transient).
359 */
360 public static final int BIND_IMPORTANT_BACKGROUND = 0x00800000;
361
362 /**
Felipe Lemea1b79bf2016-05-24 13:06:54 -0700363 * @hide Flag for {@link #bindService}: allows application hosting service to manage whitelists
364 * such as temporary allowing a {@code PendingIntent} to bypass Power Save mode.
365 */
366 public static final int BIND_ALLOW_WHITELIST_MANAGEMENT = 0x01000000;
367
368 /**
Dianne Hackbornd69e4c12015-04-24 09:54:54 -0700369 * @hide Flag for {@link #bindService}: Like {@link #BIND_FOREGROUND_SERVICE},
370 * but only applies while the device is awake.
371 */
372 public static final int BIND_FOREGROUND_SERVICE_WHILE_AWAKE = 0x02000000;
373
374 /**
375 * @hide Flag for {@link #bindService}: For only the case where the binding
376 * is coming from the system, set the process state to FOREGROUND_SERVICE
377 * instead of the normal maximum of IMPORTANT_FOREGROUND. That is, this is
378 * saying that the process shouldn't participate in the normal power reduction
379 * modes (removing network access etc).
380 */
381 public static final int BIND_FOREGROUND_SERVICE = 0x04000000;
382
383 /**
Dianne Hackbornf0f94d12014-03-17 16:04:21 -0700384 * @hide Flag for {@link #bindService}: Treat the binding as hosting
385 * an activity, an unbinding as the activity going in the background.
386 * That is, when unbinding, the process when empty will go on the activity
387 * LRU list instead of the regular one, keeping it around more aggressively
388 * than it otherwise would be. This is intended for use with IMEs to try
389 * to keep IME processes around for faster keyboard switching.
390 */
391 public static final int BIND_TREAT_LIKE_ACTIVITY = 0x08000000;
392
393 /**
Dianne Hackbornb12e1352012-09-26 11:39:20 -0700394 * @hide An idea that is not yet implemented.
395 * Flag for {@link #bindService}: If binding from an activity, consider
396 * this service to be visible like the binding activity is. That is,
397 * it will be treated as something more important to keep around than
398 * invisible background activities. This will impact the number of
399 * recent activities the user can switch between without having them
400 * restart. There is no guarantee this will be respected, as the system
401 * tries to balance such requests from one app vs. the importantance of
402 * keeping other apps around.
403 */
Dianne Hackbornc8230512013-07-13 21:32:12 -0700404 public static final int BIND_VISIBLE = 0x10000000;
405
406 /**
407 * @hide
408 * Flag for {@link #bindService}: Consider this binding to be causing the target
409 * process to be showing UI, so it will be do a UI_HIDDEN memory trim when it goes
410 * away.
411 */
412 public static final int BIND_SHOWING_UI = 0x20000000;
Dianne Hackbornb12e1352012-09-26 11:39:20 -0700413
414 /**
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -0700415 * Flag for {@link #bindService}: Don't consider the bound service to be
416 * visible, even if the caller is visible.
417 * @hide
418 */
419 public static final int BIND_NOT_VISIBLE = 0x40000000;
Dianne Hackborn130b0d22011-07-26 22:07:48 -0700420
Alan Viverette713a5cd2015-12-16 15:46:32 -0500421 /**
Robert Sesekb9a86662015-12-09 16:22:45 -0500422 * Flag for {@link #bindService}: The service being bound is an
423 * {@link android.R.attr#isolatedProcess isolated},
424 * {@link android.R.attr#externalService external} service. This binds the service into the
425 * calling application's package, rather than the package in which the service is declared.
Robert Sesek55b2d112016-05-17 18:53:13 -0400426 * <p>
427 * When using this flag, the code for the service being bound will execute under the calling
428 * application's package name and user ID. Because the service must be an isolated process,
429 * it will not have direct access to the application's data, though.
430 *
431 * The purpose of this flag is to allow applications to provide services that are attributed
432 * to the app using the service, rather than the application providing the service.
433 * </p>
Robert Sesekb9a86662015-12-09 16:22:45 -0500434 */
435 public static final int BIND_EXTERNAL_SERVICE = 0x80000000;
436
Dianne Hackborna631d562018-11-20 15:58:15 -0800437 /**
438 * These bind flags reduce the strength of the binding such that we shouldn't
439 * consider it as pulling the process up to the level of the one that is bound to it.
440 * @hide
441 */
442 public static final int BIND_REDUCTION_FLAGS =
443 Context.BIND_ALLOW_OOM_MANAGEMENT | Context.BIND_WAIVE_PRIORITY
444 | Context.BIND_ADJUST_BELOW_PERCEPTIBLE | Context.BIND_NOT_VISIBLE;
445
Chad Brubaker6d6015f2017-04-18 11:25:16 -0700446 /** @hide */
Jeff Sharkeyce8db992017-12-13 20:05:05 -0700447 @IntDef(flag = true, prefix = { "RECEIVER_VISIBLE_" }, value = {
448 RECEIVER_VISIBLE_TO_INSTANT_APPS
449 })
Chad Brubaker6d6015f2017-04-18 11:25:16 -0700450 @Retention(RetentionPolicy.SOURCE)
451 public @interface RegisterReceiverFlags {}
452
453 /**
454 * Flag for {@link #registerReceiver}: The receiver can receive broadcasts from Instant Apps.
455 */
456 public static final int RECEIVER_VISIBLE_TO_INSTANT_APPS = 0x1;
457
Robert Sesekb9a86662015-12-09 16:22:45 -0500458 /**
Alan Viverette713a5cd2015-12-16 15:46:32 -0500459 * Returns an AssetManager instance for the application's package.
460 * <p>
461 * <strong>Note:</strong> Implementations of this method should return
462 * an AssetManager instance that is consistent with the Resources instance
463 * returned by {@link #getResources()}. For example, they should share the
464 * same {@link Configuration} object.
465 *
466 * @return an AssetManager instance for the application's package
467 * @see #getResources()
468 */
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800469 public abstract AssetManager getAssets();
470
Alan Viverette713a5cd2015-12-16 15:46:32 -0500471 /**
472 * Returns a Resources instance for the application's package.
473 * <p>
474 * <strong>Note:</strong> Implementations of this method should return
475 * a Resources instance that is consistent with the AssetManager instance
476 * returned by {@link #getAssets()}. For example, they should share the
477 * same {@link Configuration} object.
478 *
479 * @return a Resources instance for the application's package
480 * @see #getAssets()
481 */
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800482 public abstract Resources getResources();
483
484 /** Return PackageManager instance to find global package information. */
485 public abstract PackageManager getPackageManager();
486
487 /** Return a ContentResolver instance for your application's package. */
488 public abstract ContentResolver getContentResolver();
489
490 /**
491 * Return the Looper for the main thread of the current process. This is
492 * the thread used to dispatch calls to application components (activities,
493 * services, etc).
Jeff Brownf9e989d2013-04-04 23:04:03 -0700494 * <p>
495 * By definition, this method returns the same result as would be obtained
496 * by calling {@link Looper#getMainLooper() Looper.getMainLooper()}.
497 * </p>
498 *
499 * @return The main looper.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800500 */
501 public abstract Looper getMainLooper();
Scott Main4b5da682010-10-21 11:49:12 -0700502
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800503 /**
Jeff Sharkey8439ac02017-12-12 17:26:23 -0700504 * Return an {@link Executor} that will run enqueued tasks on the main
505 * thread associated with this context. This is the thread used to dispatch
506 * calls to application components (activities, services, etc).
507 */
508 public Executor getMainExecutor() {
509 // This is pretty inefficient, which is why ContextImpl overrides it
510 return new HandlerExecutor(new Handler(getMainLooper()));
511 }
512
513 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800514 * Return the context of the single, global Application object of the
Dianne Hackborne83cefce2010-02-04 17:38:14 -0800515 * current process. This generally should only be used if you need a
516 * Context whose lifecycle is separate from the current context, that is
517 * tied to the lifetime of the process rather than the current component.
Scott Main4b5da682010-10-21 11:49:12 -0700518 *
Dianne Hackborne83cefce2010-02-04 17:38:14 -0800519 * <p>Consider for example how this interacts with
Brad Fitzpatrick36af7942010-12-08 11:31:07 -0800520 * {@link #registerReceiver(BroadcastReceiver, IntentFilter)}:
Dianne Hackborne83cefce2010-02-04 17:38:14 -0800521 * <ul>
522 * <li> <p>If used from an Activity context, the receiver is being registered
523 * within that activity. This means that you are expected to unregister
524 * before the activity is done being destroyed; in fact if you do not do
525 * so, the framework will clean up your leaked registration as it removes
526 * the activity and log an error. Thus, if you use the Activity context
527 * to register a receiver that is static (global to the process, not
528 * associated with an Activity instance) then that registration will be
529 * removed on you at whatever point the activity you used is destroyed.
530 * <li> <p>If used from the Context returned here, the receiver is being
531 * registered with the global state associated with your application. Thus
532 * it will never be unregistered for you. This is necessary if the receiver
533 * is associated with static data, not a particular component. However
534 * using the ApplicationContext elsewhere can easily lead to serious leaks
535 * if you forget to unregister, unbind, etc.
536 * </ul>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800537 */
538 public abstract Context getApplicationContext();
539
Phil Weaver846cda932017-06-15 10:10:06 -0700540 /** Non-activity related autofill ids are unique in the app */
541 private static int sLastAutofillId = View.NO_ID;
Philip P. Moltmanneab62ba2017-03-20 10:55:43 -0700542
543 /**
Phil Weaver846cda932017-06-15 10:10:06 -0700544 * Gets the next autofill ID.
Philip P. Moltmanneab62ba2017-03-20 10:55:43 -0700545 *
Phil Weaver846cda932017-06-15 10:10:06 -0700546 * <p>All IDs will be smaller or the same as {@link View#LAST_APP_AUTOFILL_ID}. All IDs
Philip P. Moltmanneab62ba2017-03-20 10:55:43 -0700547 * returned will be unique.
548 *
549 * @return A ID that is unique in the process
550 *
551 * {@hide}
552 */
Phil Weaver846cda932017-06-15 10:10:06 -0700553 public int getNextAutofillId() {
554 if (sLastAutofillId == View.LAST_APP_AUTOFILL_ID - 1) {
555 sLastAutofillId = View.NO_ID;
Philip P. Moltmanneab62ba2017-03-20 10:55:43 -0700556 }
557
Phil Weaver846cda932017-06-15 10:10:06 -0700558 sLastAutofillId++;
Philip P. Moltmanneab62ba2017-03-20 10:55:43 -0700559
Phil Weaver846cda932017-06-15 10:10:06 -0700560 return sLastAutofillId;
Philip P. Moltmanneab62ba2017-03-20 10:55:43 -0700561 }
562
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800563 /**
Dianne Hackbornc68c9132011-07-29 01:25:18 -0700564 * Add a new {@link ComponentCallbacks} to the base application of the
565 * Context, which will be called at the same times as the ComponentCallbacks
566 * methods of activities and other components are called. Note that you
567 * <em>must</em> be sure to use {@link #unregisterComponentCallbacks} when
568 * appropriate in the future; this will not be removed for you.
Dianne Hackborn905577f2011-09-07 18:31:28 -0700569 *
570 * @param callback The interface to call. This can be either a
571 * {@link ComponentCallbacks} or {@link ComponentCallbacks2} interface.
Dianne Hackbornc68c9132011-07-29 01:25:18 -0700572 */
573 public void registerComponentCallbacks(ComponentCallbacks callback) {
574 getApplicationContext().registerComponentCallbacks(callback);
575 }
576
577 /**
John Spurlock6098c5d2013-06-17 10:32:46 -0400578 * Remove a {@link ComponentCallbacks} object that was previously registered
Dianne Hackbornc68c9132011-07-29 01:25:18 -0700579 * with {@link #registerComponentCallbacks(ComponentCallbacks)}.
580 */
581 public void unregisterComponentCallbacks(ComponentCallbacks callback) {
582 getApplicationContext().unregisterComponentCallbacks(callback);
583 }
584
585 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800586 * Return a localized, styled CharSequence from the application's package's
587 * default string table.
588 *
589 * @param resId Resource id for the CharSequence text
590 */
Chris Craikceb26932018-02-01 15:51:34 -0800591 @NonNull
Tor Norbye7b9c9122013-05-30 16:48:33 -0700592 public final CharSequence getText(@StringRes int resId) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800593 return getResources().getText(resId);
594 }
595
596 /**
Alan Viveretteb4004df2015-04-29 16:55:42 -0700597 * Returns a localized string from the application's package's
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800598 * default string table.
599 *
600 * @param resId Resource id for the string
Alan Viveretteb4004df2015-04-29 16:55:42 -0700601 * @return The string data associated with the resource, stripped of styled
602 * text information.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800603 */
Alan Viveretteb4004df2015-04-29 16:55:42 -0700604 @NonNull
Tor Norbye7b9c9122013-05-30 16:48:33 -0700605 public final String getString(@StringRes int resId) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800606 return getResources().getString(resId);
607 }
608
609 /**
Alan Viveretteb4004df2015-04-29 16:55:42 -0700610 * Returns a localized formatted string from the application's package's
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800611 * default string table, substituting the format arguments as defined in
612 * {@link java.util.Formatter} and {@link java.lang.String#format}.
613 *
614 * @param resId Resource id for the format string
Alan Viveretteb4004df2015-04-29 16:55:42 -0700615 * @param formatArgs The format arguments that will be used for
616 * substitution.
617 * @return The string data associated with the resource, formatted and
618 * stripped of styled text information.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800619 */
Alan Viveretteb4004df2015-04-29 16:55:42 -0700620 @NonNull
Tor Norbye7b9c9122013-05-30 16:48:33 -0700621 public final String getString(@StringRes int resId, Object... formatArgs) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800622 return getResources().getString(resId, formatArgs);
623 }
624
Alan Viverette8eea3ea2014-02-03 18:40:20 -0800625 /**
Alan Viverette45c4bbb2015-01-05 14:59:19 -0800626 * Returns a color associated with a particular resource ID and styled for
627 * the current theme.
628 *
629 * @param id The desired resource identifier, as generated by the aapt
630 * tool. This integer encodes the package, type, and resource
631 * entry. The value 0 is an invalid identifier.
632 * @return A single color value in the form 0xAARRGGBB.
633 * @throws android.content.res.Resources.NotFoundException if the given ID
634 * does not exist.
635 */
Tor Norbye3e4cda72015-06-10 08:14:31 -0700636 @ColorInt
637 public final int getColor(@ColorRes int id) {
Alan Viverette45c4bbb2015-01-05 14:59:19 -0800638 return getResources().getColor(id, getTheme());
639 }
640
641 /**
642 * Returns a drawable object associated with a particular resource ID and
Alan Viverette8eea3ea2014-02-03 18:40:20 -0800643 * styled for the current theme.
644 *
645 * @param id The desired resource identifier, as generated by the aapt
646 * tool. This integer encodes the package, type, and resource
647 * entry. The value 0 is an invalid identifier.
Chris Craikceb26932018-02-01 15:51:34 -0800648 * @return An object that can be used to draw this resource.
Alan Viverette45c4bbb2015-01-05 14:59:19 -0800649 * @throws android.content.res.Resources.NotFoundException if the given ID
650 * does not exist.
Alan Viverette8eea3ea2014-02-03 18:40:20 -0800651 */
Chris Craik1194b0b2018-03-23 13:36:24 -0700652 @Nullable
Tor Norbye3e4cda72015-06-10 08:14:31 -0700653 public final Drawable getDrawable(@DrawableRes int id) {
Alan Viverette8eea3ea2014-02-03 18:40:20 -0800654 return getResources().getDrawable(id, getTheme());
655 }
656
Alan Viverette45c4bbb2015-01-05 14:59:19 -0800657 /**
658 * Returns a color state list associated with a particular resource ID and
659 * styled for the current theme.
660 *
661 * @param id The desired resource identifier, as generated by the aapt
662 * tool. This integer encodes the package, type, and resource
663 * entry. The value 0 is an invalid identifier.
Chris Craikceb26932018-02-01 15:51:34 -0800664 * @return A color state list.
Alan Viverette45c4bbb2015-01-05 14:59:19 -0800665 * @throws android.content.res.Resources.NotFoundException if the given ID
666 * does not exist.
667 */
Chris Craikceb26932018-02-01 15:51:34 -0800668 @NonNull
Tor Norbye3e4cda72015-06-10 08:14:31 -0700669 public final ColorStateList getColorStateList(@ColorRes int id) {
Alan Viverette45c4bbb2015-01-05 14:59:19 -0800670 return getResources().getColorStateList(id, getTheme());
671 }
672
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800673 /**
674 * Set the base theme for this context. Note that this should be called
675 * before any views are instantiated in the Context (for example before
676 * calling {@link android.app.Activity#setContentView} or
677 * {@link android.view.LayoutInflater#inflate}).
678 *
679 * @param resid The style resource describing the theme.
680 */
Tor Norbye7b9c9122013-05-30 16:48:33 -0700681 public abstract void setTheme(@StyleRes int resid);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800682
Dianne Hackborn247fe742011-01-08 17:25:57 -0800683 /** @hide Needed for some internal implementation... not public because
684 * you can't assume this actually means anything. */
Mathew Inwood5c0d3542018-08-14 13:54:31 +0100685 @UnsupportedAppUsage
Dianne Hackborn247fe742011-01-08 17:25:57 -0800686 public int getThemeResId() {
687 return 0;
688 }
689
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800690 /**
691 * Return the Theme object associated with this Context.
692 */
Jon Miranda836c0a82014-08-11 12:32:26 -0700693 @ViewDebug.ExportedProperty(deepExport = true)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800694 public abstract Resources.Theme getTheme();
695
696 /**
697 * Retrieve styled attribute information in this Context's theme. See
Jeff Brown6e539312015-02-24 18:53:21 -0800698 * {@link android.content.res.Resources.Theme#obtainStyledAttributes(int[])}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800699 * for more information.
700 *
Jeff Brown6e539312015-02-24 18:53:21 -0800701 * @see android.content.res.Resources.Theme#obtainStyledAttributes(int[])
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800702 */
Aurimas Liutikas77acf4b2018-12-19 17:31:03 -0800703 @NonNull
704 public final TypedArray obtainStyledAttributes(@NonNull @StyleableRes int[] attrs) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800705 return getTheme().obtainStyledAttributes(attrs);
706 }
707
708 /**
709 * Retrieve styled attribute information in this Context's theme. See
Jeff Brown6e539312015-02-24 18:53:21 -0800710 * {@link android.content.res.Resources.Theme#obtainStyledAttributes(int, int[])}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800711 * for more information.
712 *
Jeff Brown6e539312015-02-24 18:53:21 -0800713 * @see android.content.res.Resources.Theme#obtainStyledAttributes(int, int[])
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800714 */
Aurimas Liutikas77acf4b2018-12-19 17:31:03 -0800715 @NonNull
716 public final TypedArray obtainStyledAttributes(@StyleRes int resid,
717 @NonNull @StyleableRes int[] attrs) throws Resources.NotFoundException {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800718 return getTheme().obtainStyledAttributes(resid, attrs);
719 }
720
721 /**
722 * Retrieve styled attribute information in this Context's theme. See
Jeff Brown6e539312015-02-24 18:53:21 -0800723 * {@link android.content.res.Resources.Theme#obtainStyledAttributes(AttributeSet, int[], int, int)}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800724 * for more information.
725 *
Jeff Brown6e539312015-02-24 18:53:21 -0800726 * @see android.content.res.Resources.Theme#obtainStyledAttributes(AttributeSet, int[], int, int)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800727 */
Aurimas Liutikas77acf4b2018-12-19 17:31:03 -0800728 @NonNull
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800729 public final TypedArray obtainStyledAttributes(
Aurimas Liutikas77acf4b2018-12-19 17:31:03 -0800730 @Nullable AttributeSet set, @NonNull @StyleableRes int[] attrs) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800731 return getTheme().obtainStyledAttributes(set, attrs, 0, 0);
732 }
733
734 /**
735 * Retrieve styled attribute information in this Context's theme. See
Jeff Brown6e539312015-02-24 18:53:21 -0800736 * {@link android.content.res.Resources.Theme#obtainStyledAttributes(AttributeSet, int[], int, int)}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800737 * for more information.
738 *
Jeff Brown6e539312015-02-24 18:53:21 -0800739 * @see android.content.res.Resources.Theme#obtainStyledAttributes(AttributeSet, int[], int, int)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800740 */
Aurimas Liutikas77acf4b2018-12-19 17:31:03 -0800741 @NonNull
742 public final TypedArray obtainStyledAttributes(@Nullable AttributeSet set,
743 @NonNull @StyleableRes int[] attrs, @AttrRes int defStyleAttr,
Tor Norbyec91531a2015-04-01 17:41:55 -0700744 @StyleRes int defStyleRes) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800745 return getTheme().obtainStyledAttributes(
746 set, attrs, defStyleAttr, defStyleRes);
747 }
748
749 /**
750 * Return a class loader you can use to retrieve classes in this package.
751 */
752 public abstract ClassLoader getClassLoader();
753
754 /** Return the name of this application's package. */
755 public abstract String getPackageName();
756
Jaewan Kim0980c7f2018-11-28 23:55:15 +0900757 /**
758 * @hide Return the name of the base context this context is derived from.
759 * This is the same as {@link #getOpPackageName()} except in
760 * cases where system components are loaded into other app processes, in which
761 * case {@link #getOpPackageName()} will be the name of the primary package in
762 * that process (so that app ops uid verification will work with the name).
763 */
Mathew Inwood5c0d3542018-08-14 13:54:31 +0100764 @UnsupportedAppUsage
Dianne Hackbornd8e1dbb2013-01-17 17:47:37 -0800765 public abstract String getBasePackageName();
766
Jaewan Kim0980c7f2018-11-28 23:55:15 +0900767 /**
768 * Return the package name that should be used for {@link android.app.AppOpsManager} calls from
769 * this context, so that app ops manager's uid verification will work with the name.
770 * <p>
771 * This is not generally intended for third party application developers.
772 */
Adrian Roosfe6aeaf2019-01-22 16:58:56 +0100773 public String getOpPackageName() {
774 throw new RuntimeException("Not implemented. Must override in a subclass.");
775 }
Dianne Hackborn95d78532013-09-11 09:51:14 -0700776
Dianne Hackborn5c1e00b2009-06-18 17:10:57 -0700777 /** Return the full application info for this context's package. */
778 public abstract ApplicationInfo getApplicationInfo();
Scott Main4b5da682010-10-21 11:49:12 -0700779
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800780 /**
Kenny Root32148392010-01-21 15:40:47 -0800781 * Return the full path to this context's primary Android package.
782 * The Android package is a ZIP file which contains the application's
783 * primary resources.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800784 *
785 * <p>Note: this is not generally useful for applications, since they should
786 * not be directly accessing the file system.
787 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800788 * @return String Path to the resources.
789 */
790 public abstract String getPackageResourcePath();
791
792 /**
Kenny Root32148392010-01-21 15:40:47 -0800793 * Return the full path to this context's primary Android package.
794 * The Android package is a ZIP file which contains application's
795 * primary code and assets.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800796 *
797 * <p>Note: this is not generally useful for applications, since they should
798 * not be directly accessing the file system.
799 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800800 * @return String Path to the code and assets.
801 */
802 public abstract String getPackageCodePath();
803
804 /**
Jeff Sharkey6a6cdaf2015-12-07 19:25:19 -0700805 * @hide
806 * @deprecated use {@link #getSharedPreferencesPath(String)}
Joe Onorato23ecae32009-06-10 17:07:15 -0700807 */
Jeff Sharkey6a6cdaf2015-12-07 19:25:19 -0700808 @Deprecated
Mathew Inwood5c0d3542018-08-14 13:54:31 +0100809 @UnsupportedAppUsage
Jeff Sharkey6a6cdaf2015-12-07 19:25:19 -0700810 public File getSharedPrefsFile(String name) {
811 return getSharedPreferencesPath(name);
812 }
Joe Onorato23ecae32009-06-10 17:07:15 -0700813
814 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800815 * Retrieve and hold the contents of the preferences file 'name', returning
816 * a SharedPreferences through which you can retrieve and modify its
817 * values. Only one instance of the SharedPreferences object is returned
818 * to any callers for the same name, meaning they will see each other's
819 * edits as soon as they are made.
820 *
Jonathan Dormody1bca5db2017-11-16 11:25:20 -0700821 * This method is thead-safe.
822 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800823 * @param name Desired preferences file. If a preferences file by this name
824 * does not exist, it will be created when you retrieve an
825 * editor (SharedPreferences.edit()) and then commit changes (Editor.commit()).
Jeff Sharkey30e06bb2017-04-24 11:18:03 -0600826 * @param mode Operating mode.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800827 *
John Spurlock6098c5d2013-06-17 10:32:46 -0400828 * @return The single {@link SharedPreferences} instance that can be used
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800829 * to retrieve and modify the preference values.
830 *
831 * @see #MODE_PRIVATE
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800832 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -0600833 public abstract SharedPreferences getSharedPreferences(String name, @PreferencesMode int mode);
Jeff Sharkey8fc29cf2015-11-30 17:51:00 -0700834
835 /**
836 * Retrieve and hold the contents of the preferences file, returning
837 * a SharedPreferences through which you can retrieve and modify its
838 * values. Only one instance of the SharedPreferences object is returned
839 * to any callers for the same name, meaning they will see each other's
840 * edits as soon as they are made.
841 *
842 * @param file Desired preferences file. If a preferences file by this name
843 * does not exist, it will be created when you retrieve an
844 * editor (SharedPreferences.edit()) and then commit changes (Editor.commit()).
Jeff Sharkey30e06bb2017-04-24 11:18:03 -0600845 * @param mode Operating mode.
Jeff Sharkey8fc29cf2015-11-30 17:51:00 -0700846 *
847 * @return The single {@link SharedPreferences} instance that can be used
848 * to retrieve and modify the preference values.
849 *
Jeff Sharkey6a6cdaf2015-12-07 19:25:19 -0700850 * @see #getSharedPreferencesPath(String)
Jeff Sharkey8fc29cf2015-11-30 17:51:00 -0700851 * @see #MODE_PRIVATE
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -0600852 * @removed
Jeff Sharkey8fc29cf2015-11-30 17:51:00 -0700853 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -0600854 public abstract SharedPreferences getSharedPreferences(File file, @PreferencesMode int mode);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800855
856 /**
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600857 * Move an existing shared preferences file from the given source storage
Jeff Sharkey35871f22016-01-29 17:13:29 -0700858 * context to this context. This is typically used to migrate data between
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600859 * storage locations after an upgrade, such as moving to device protected
860 * storage.
Jeff Sharkey35871f22016-01-29 17:13:29 -0700861 *
862 * @param sourceContext The source context which contains the existing
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600863 * shared preferences to move.
Jeff Sharkey35871f22016-01-29 17:13:29 -0700864 * @param name The name of the shared preferences file.
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600865 * @return {@code true} if the move was successful or if the shared
Jeff Sharkey35871f22016-01-29 17:13:29 -0700866 * preferences didn't exist in the source context, otherwise
867 * {@code false}.
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600868 * @see #createDeviceProtectedStorageContext()
Jeff Sharkey35871f22016-01-29 17:13:29 -0700869 */
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600870 public abstract boolean moveSharedPreferencesFrom(Context sourceContext, String name);
871
Jeff Sharkey35871f22016-01-29 17:13:29 -0700872 /**
873 * Delete an existing shared preferences file.
874 *
875 * @param name The name (unique in the application package) of the shared
876 * preferences file.
877 * @return {@code true} if the shared preferences file was successfully
878 * deleted; else {@code false}.
879 * @see #getSharedPreferences(String, int)
880 */
881 public abstract boolean deleteSharedPreferences(String name);
882
Christopher Tatefe2368c2017-05-17 15:42:35 -0700883 /** @hide */
884 public abstract void reloadSharedPreferences();
885
Jeff Sharkey35871f22016-01-29 17:13:29 -0700886 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800887 * Open a private file associated with this Context's application package
888 * for reading.
889 *
890 * @param name The name of the file to open; can not contain path
891 * separators.
892 *
John Spurlock6098c5d2013-06-17 10:32:46 -0400893 * @return The resulting {@link FileInputStream}.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800894 *
895 * @see #openFileOutput
896 * @see #fileList
897 * @see #deleteFile
898 * @see java.io.FileInputStream#FileInputStream(String)
899 */
900 public abstract FileInputStream openFileInput(String name)
901 throws FileNotFoundException;
902
903 /**
Nick Kralevich15069212013-01-09 15:54:56 -0800904 * Open a private file associated with this Context's application package
Jeff Sharkey59d28dc82015-10-14 13:56:23 -0700905 * for writing. Creates the file if it doesn't already exist.
906 * <p>
907 * No additional permissions are required for the calling app to read or
908 * write the returned file.
Ricardo Cervera90a5f982014-04-04 10:26:05 -0700909 *
Nick Kralevich15069212013-01-09 15:54:56 -0800910 * @param name The name of the file to open; can not contain path
Jeff Sharkey59d28dc82015-10-14 13:56:23 -0700911 * separators.
Jeff Sharkey30e06bb2017-04-24 11:18:03 -0600912 * @param mode Operating mode.
John Spurlock6098c5d2013-06-17 10:32:46 -0400913 * @return The resulting {@link FileOutputStream}.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800914 * @see #MODE_APPEND
915 * @see #MODE_PRIVATE
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800916 * @see #openFileInput
917 * @see #fileList
918 * @see #deleteFile
919 * @see java.io.FileOutputStream#FileOutputStream(String)
920 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -0600921 public abstract FileOutputStream openFileOutput(String name, @FileMode int mode)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800922 throws FileNotFoundException;
923
924 /**
925 * Delete the given private file associated with this Context's
926 * application package.
927 *
928 * @param name The name of the file to delete; can not contain path
929 * separators.
930 *
John Spurlock6098c5d2013-06-17 10:32:46 -0400931 * @return {@code true} if the file was successfully deleted; else
932 * {@code false}.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800933 *
934 * @see #openFileInput
935 * @see #openFileOutput
936 * @see #fileList
937 * @see java.io.File#delete()
938 */
939 public abstract boolean deleteFile(String name);
940
941 /**
942 * Returns the absolute path on the filesystem where a file created with
943 * {@link #openFileOutput} is stored.
Jeff Sharkey59d28dc82015-10-14 13:56:23 -0700944 * <p>
945 * The returned path may change over time if the calling app is moved to an
946 * adopted storage device, so only relative paths should be persisted.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800947 *
948 * @param name The name of the file for which you would like to get
949 * its path.
950 *
John Spurlock6098c5d2013-06-17 10:32:46 -0400951 * @return An absolute path to the given file.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800952 *
953 * @see #openFileOutput
954 * @see #getFilesDir
955 * @see #getDir
956 */
957 public abstract File getFileStreamPath(String name);
958
959 /**
Jeff Sharkey6a6cdaf2015-12-07 19:25:19 -0700960 * Returns the absolute path on the filesystem where a file created with
961 * {@link #getSharedPreferences(String, int)} is stored.
962 * <p>
963 * The returned path may change over time if the calling app is moved to an
964 * adopted storage device, so only relative paths should be persisted.
965 *
966 * @param name The name of the shared preferences for which you would like
967 * to get a path.
968 * @return An absolute path to the given file.
969 * @see #getSharedPreferences(String, int)
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -0600970 * @removed
Jeff Sharkey6a6cdaf2015-12-07 19:25:19 -0700971 */
972 public abstract File getSharedPreferencesPath(String name);
973
974 /**
Jeff Sharkey2c1ba9a2016-02-17 15:29:38 -0700975 * Returns the absolute path to the directory on the filesystem where all
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -0600976 * private files belonging to this app are stored. Apps should not use this
977 * path directly; they should instead use {@link #getFilesDir()},
978 * {@link #getCacheDir()}, {@link #getDir(String, int)}, or other storage
979 * APIs on this class.
Jeff Sharkey2c1ba9a2016-02-17 15:29:38 -0700980 * <p>
981 * The returned path may change over time if the calling app is moved to an
982 * adopted storage device, so only relative paths should be persisted.
983 * <p>
984 * No additional permissions are required for the calling app to read or
985 * write files under the returned path.
986 *
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -0600987 * @see ApplicationInfo#dataDir
Jeff Sharkey2c1ba9a2016-02-17 15:29:38 -0700988 */
989 public abstract File getDataDir();
990
991 /**
Jeff Sharkey59d28dc82015-10-14 13:56:23 -0700992 * Returns the absolute path to the directory on the filesystem where files
993 * created with {@link #openFileOutput} are stored.
994 * <p>
995 * The returned path may change over time if the calling app is moved to an
996 * adopted storage device, so only relative paths should be persisted.
997 * <p>
998 * No additional permissions are required for the calling app to read or
999 * write files under the returned path.
Ricardo Cervera90a5f982014-04-04 10:26:05 -07001000 *
John Spurlock6098c5d2013-06-17 10:32:46 -04001001 * @return The path of the directory holding application files.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001002 * @see #openFileOutput
1003 * @see #getFileStreamPath
1004 * @see #getDir
1005 */
1006 public abstract File getFilesDir();
Scott Main4b5da682010-10-21 11:49:12 -07001007
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001008 /**
Christopher Tatea7835b62014-07-11 17:25:57 -07001009 * Returns the absolute path to the directory on the filesystem similar to
Jeff Sharkey59d28dc82015-10-14 13:56:23 -07001010 * {@link #getFilesDir()}. The difference is that files placed under this
1011 * directory will be excluded from automatic backup to remote storage. See
Christopher Tatea7835b62014-07-11 17:25:57 -07001012 * {@link android.app.backup.BackupAgent BackupAgent} for a full discussion
1013 * of the automatic backup mechanism in Android.
Jeff Sharkey59d28dc82015-10-14 13:56:23 -07001014 * <p>
1015 * The returned path may change over time if the calling app is moved to an
1016 * adopted storage device, so only relative paths should be persisted.
1017 * <p>
1018 * No additional permissions are required for the calling app to read or
1019 * write files under the returned path.
Christopher Tatea7835b62014-07-11 17:25:57 -07001020 *
Jeff Sharkey59d28dc82015-10-14 13:56:23 -07001021 * @return The path of the directory holding application files that will not
1022 * be automatically backed up to remote storage.
Christopher Tatea7835b62014-07-11 17:25:57 -07001023 * @see #openFileOutput
1024 * @see #getFileStreamPath
1025 * @see #getDir
1026 * @see android.app.backup.BackupAgent
1027 */
1028 public abstract File getNoBackupFilesDir();
1029
1030 /**
Jeff Sharkey59d28dc82015-10-14 13:56:23 -07001031 * Returns the absolute path to the directory on the primary shared/external
1032 * storage device where the application can place persistent files it owns.
1033 * These files are internal to the applications, and not typically visible
1034 * to the user as media.
1035 * <p>
1036 * This is like {@link #getFilesDir()} in that these files will be deleted
1037 * when the application is uninstalled, however there are some important
1038 * differences:
Dianne Hackborne83cefce2010-02-04 17:38:14 -08001039 * <ul>
Jeff Sharkey59d28dc82015-10-14 13:56:23 -07001040 * <li>Shared storage may not always be available, since removable media can
1041 * be ejected by the user. Media state can be checked using
1042 * {@link Environment#getExternalStorageState(File)}.
1043 * <li>There is no security enforced with these files. For example, any
1044 * application holding
1045 * {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} can write to
Jeff Sharkey6feb50b2013-10-15 12:38:15 -07001046 * these files.
Dianne Hackborne83cefce2010-02-04 17:38:14 -08001047 * </ul>
Jeff Sharkey59d28dc82015-10-14 13:56:23 -07001048 * <p>
1049 * If a shared storage device is emulated (as determined by
1050 * {@link Environment#isExternalStorageEmulated(File)}), it's contents are
1051 * backed by a private user data partition, which means there is little
1052 * benefit to storing data here instead of the private directories returned
1053 * by {@link #getFilesDir()}, etc.
1054 * <p>
1055 * Starting in {@link android.os.Build.VERSION_CODES#KITKAT}, no permissions
Jeff Sharkey6feb50b2013-10-15 12:38:15 -07001056 * are required to read or write to the returned path; it's always
Jeff Sharkey59d28dc82015-10-14 13:56:23 -07001057 * accessible to the calling app. This only applies to paths generated for
1058 * package name of the calling application. To access paths belonging to
1059 * other packages,
1060 * {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} and/or
1061 * {@link android.Manifest.permission#READ_EXTERNAL_STORAGE} are required.
1062 * <p>
1063 * On devices with multiple users (as described by {@link UserManager}),
1064 * each user has their own isolated shared storage. Applications only have
1065 * access to the shared storage for the user they're running as.
1066 * <p>
1067 * The returned path may change over time if different shared storage media
1068 * is inserted, so only relative paths should be persisted.
1069 * <p>
1070 * Here is an example of typical code to manipulate a file in an
1071 * application's shared storage:
1072 * </p>
Dianne Hackborne83cefce2010-02-04 17:38:14 -08001073 * {@sample development/samples/ApiDemos/src/com/example/android/apis/content/ExternalStorage.java
1074 * private_file}
Jeff Sharkey59d28dc82015-10-14 13:56:23 -07001075 * <p>
1076 * If you supply a non-null <var>type</var> to this function, the returned
1077 * file will be a path to a sub-directory of the given type. Though these
1078 * files are not automatically scanned by the media scanner, you can
1079 * explicitly add them to the media database with
1080 * {@link android.media.MediaScannerConnection#scanFile(Context, String[], String[], android.media.MediaScannerConnection.OnScanCompletedListener)
1081 * MediaScannerConnection.scanFile}. Note that this is not the same as
Dianne Hackborne83cefce2010-02-04 17:38:14 -08001082 * {@link android.os.Environment#getExternalStoragePublicDirectory
1083 * Environment.getExternalStoragePublicDirectory()}, which provides
Jeff Sharkey59d28dc82015-10-14 13:56:23 -07001084 * directories of media shared by all applications. The directories returned
1085 * here are owned by the application, and their contents will be removed
1086 * when the application is uninstalled. Unlike
Dianne Hackborne83cefce2010-02-04 17:38:14 -08001087 * {@link android.os.Environment#getExternalStoragePublicDirectory
Jeff Sharkey59d28dc82015-10-14 13:56:23 -07001088 * Environment.getExternalStoragePublicDirectory()}, the directory returned
1089 * here will be automatically created for you.
1090 * <p>
1091 * Here is an example of typical code to manipulate a picture in an
1092 * application's shared storage and add it to the media database:
1093 * </p>
Dianne Hackborne83cefce2010-02-04 17:38:14 -08001094 * {@sample development/samples/ApiDemos/src/com/example/android/apis/content/ExternalStorage.java
1095 * private_picture}
Jeff Sharkey8c165792012-10-22 14:08:29 -07001096 *
Jeff Sharkey59d28dc82015-10-14 13:56:23 -07001097 * @param type The type of files directory to return. May be {@code null}
1098 * for the root of the files directory or one of the following
1099 * constants for a subdirectory:
1100 * {@link android.os.Environment#DIRECTORY_MUSIC},
1101 * {@link android.os.Environment#DIRECTORY_PODCASTS},
1102 * {@link android.os.Environment#DIRECTORY_RINGTONES},
1103 * {@link android.os.Environment#DIRECTORY_ALARMS},
1104 * {@link android.os.Environment#DIRECTORY_NOTIFICATIONS},
1105 * {@link android.os.Environment#DIRECTORY_PICTURES}, or
1106 * {@link android.os.Environment#DIRECTORY_MOVIES}.
1107 * @return the absolute path to application-specific directory. May return
1108 * {@code null} if shared storage is not currently available.
Dianne Hackborne83cefce2010-02-04 17:38:14 -08001109 * @see #getFilesDir
Jeff Sharkey59d28dc82015-10-14 13:56:23 -07001110 * @see #getExternalFilesDirs(String)
1111 * @see Environment#getExternalStorageState(File)
1112 * @see Environment#isExternalStorageEmulated(File)
1113 * @see Environment#isExternalStorageRemovable(File)
Dianne Hackborne83cefce2010-02-04 17:38:14 -08001114 */
Tor Norbyed9273d62013-05-30 15:59:53 -07001115 @Nullable
1116 public abstract File getExternalFilesDir(@Nullable String type);
Scott Main4b5da682010-10-21 11:49:12 -07001117
Dianne Hackborne83cefce2010-02-04 17:38:14 -08001118 /**
Jeff Sharkey1abdb712013-08-11 16:28:14 -07001119 * Returns absolute paths to application-specific directories on all
Jeff Sharkey59d28dc82015-10-14 13:56:23 -07001120 * shared/external storage devices where the application can place
1121 * persistent files it owns. These files are internal to the application,
1122 * and not typically visible to the user as media.
Jeff Sharkey1abdb712013-08-11 16:28:14 -07001123 * <p>
Jeff Sharkey59d28dc82015-10-14 13:56:23 -07001124 * This is like {@link #getFilesDir()} in that these files will be deleted
1125 * when the application is uninstalled, however there are some important
1126 * differences:
Jeff Sharkey6feb50b2013-10-15 12:38:15 -07001127 * <ul>
Jeff Sharkey59d28dc82015-10-14 13:56:23 -07001128 * <li>Shared storage may not always be available, since removable media can
1129 * be ejected by the user. Media state can be checked using
1130 * {@link Environment#getExternalStorageState(File)}.
1131 * <li>There is no security enforced with these files. For example, any
1132 * application holding
1133 * {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} can write to
1134 * these files.
Jeff Sharkey6feb50b2013-10-15 12:38:15 -07001135 * </ul>
1136 * <p>
Jeff Sharkey59d28dc82015-10-14 13:56:23 -07001137 * If a shared storage device is emulated (as determined by
1138 * {@link Environment#isExternalStorageEmulated(File)}), it's contents are
1139 * backed by a private user data partition, which means there is little
1140 * benefit to storing data here instead of the private directories returned
1141 * by {@link #getFilesDir()}, etc.
Jeff Sharkey1abdb712013-08-11 16:28:14 -07001142 * <p>
Jeff Sharkey59d28dc82015-10-14 13:56:23 -07001143 * Shared storage devices returned here are considered a stable part of the
1144 * device, including physical media slots under a protective cover. The
1145 * returned paths do not include transient devices, such as USB flash drives
1146 * connected to handheld devices.
1147 * <p>
1148 * An application may store data on any or all of the returned devices. For
Jeff Sharkey6feb50b2013-10-15 12:38:15 -07001149 * example, an app may choose to store large files on the device with the
1150 * most available space, as measured by {@link StatFs}.
Jeff Sharkey1abdb712013-08-11 16:28:14 -07001151 * <p>
Jeff Sharkey59d28dc82015-10-14 13:56:23 -07001152 * No additional permissions are required for the calling app to read or
1153 * write files under the returned path. Write access outside of these paths
1154 * on secondary external storage devices is not available.
Jeff Sharkey6feb50b2013-10-15 12:38:15 -07001155 * <p>
Jeff Sharkey59d28dc82015-10-14 13:56:23 -07001156 * The returned path may change over time if different shared storage media
1157 * is inserted, so only relative paths should be persisted.
Jeff Sharkey8c165792012-10-22 14:08:29 -07001158 *
Jeff Sharkey59d28dc82015-10-14 13:56:23 -07001159 * @param type The type of files directory to return. May be {@code null}
1160 * for the root of the files directory or one of the following
1161 * constants for a subdirectory:
1162 * {@link android.os.Environment#DIRECTORY_MUSIC},
1163 * {@link android.os.Environment#DIRECTORY_PODCASTS},
1164 * {@link android.os.Environment#DIRECTORY_RINGTONES},
1165 * {@link android.os.Environment#DIRECTORY_ALARMS},
1166 * {@link android.os.Environment#DIRECTORY_NOTIFICATIONS},
1167 * {@link android.os.Environment#DIRECTORY_PICTURES}, or
1168 * {@link android.os.Environment#DIRECTORY_MOVIES}.
1169 * @return the absolute paths to application-specific directories. Some
1170 * individual paths may be {@code null} if that shared storage is
1171 * not currently available. The first path returned is the same as
1172 * {@link #getExternalFilesDir(String)}.
Jeff Sharkey1abdb712013-08-11 16:28:14 -07001173 * @see #getExternalFilesDir(String)
Jeff Sharkey4ca728c2014-01-10 16:27:19 -08001174 * @see Environment#getExternalStorageState(File)
Jeff Sharkey59d28dc82015-10-14 13:56:23 -07001175 * @see Environment#isExternalStorageEmulated(File)
1176 * @see Environment#isExternalStorageRemovable(File)
Jeff Sharkey1abdb712013-08-11 16:28:14 -07001177 */
1178 public abstract File[] getExternalFilesDirs(String type);
1179
1180 /**
Jeff Sharkey59d28dc82015-10-14 13:56:23 -07001181 * Return the primary shared/external storage directory where this
1182 * application's OBB files (if there are any) can be found. Note if the
1183 * application does not have any OBB files, this directory may not exist.
Jeff Sharkey6feb50b2013-10-15 12:38:15 -07001184 * <p>
Jeff Sharkey59d28dc82015-10-14 13:56:23 -07001185 * This is like {@link #getFilesDir()} in that these files will be deleted
1186 * when the application is uninstalled, however there are some important
1187 * differences:
Jeff Sharkey6feb50b2013-10-15 12:38:15 -07001188 * <ul>
Jeff Sharkey59d28dc82015-10-14 13:56:23 -07001189 * <li>Shared storage may not always be available, since removable media can
1190 * be ejected by the user. Media state can be checked using
1191 * {@link Environment#getExternalStorageState(File)}.
1192 * <li>There is no security enforced with these files. For example, any
1193 * application holding
1194 * {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} can write to
Jeff Sharkey6feb50b2013-10-15 12:38:15 -07001195 * these files.
1196 * </ul>
1197 * <p>
1198 * Starting in {@link android.os.Build.VERSION_CODES#KITKAT}, no permissions
Dave Friedmancfe50882017-07-05 00:40:07 -07001199 * are required to read or write to the path that this method returns.
1200 * However, starting from {@link android.os.Build.VERSION_CODES#M},
1201 * to read the OBB expansion files, you must declare the
1202 * {@link android.Manifest.permission#READ_EXTERNAL_STORAGE} permission in the app manifest and ask for
1203 * permission at runtime as follows:
1204 * </p>
Jeff Sharkey1abdb712013-08-11 16:28:14 -07001205 * <p>
Dave Friedmancfe50882017-07-05 00:40:07 -07001206 * {@code <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"
1207 * android:maxSdkVersion="23" />}
1208 * </p>
1209 * <p>
1210 * Starting from {@link android.os.Build.VERSION_CODES#N},
1211 * {@link android.Manifest.permission#READ_EXTERNAL_STORAGE}
1212 * permission is not required, so don’t ask for this
1213 * permission at runtime. To handle both cases, your app must first try to read the OBB file,
1214 * and if it fails, you must request
1215 * {@link android.Manifest.permission#READ_EXTERNAL_STORAGE} permission at runtime.
1216 * </p>
1217 *
1218 * <p>
1219 * The following code snippet shows how to do this:
1220 * </p>
1221 *
1222 * <pre>
1223 * File obb = new File(obb_filename);
1224 * boolean open_failed = false;
1225 *
1226 * try {
1227 * BufferedReader br = new BufferedReader(new FileReader(obb));
1228 * open_failed = false;
1229 * ReadObbFile(br);
1230 * } catch (IOException e) {
1231 * open_failed = true;
1232 * }
1233 *
1234 * if (open_failed) {
1235 * // request READ_EXTERNAL_STORAGE permission before reading OBB file
1236 * ReadObbFileWithPermission();
1237 * }
1238 * </pre>
1239 *
Jeff Sharkey1abdb712013-08-11 16:28:14 -07001240 * On devices with multiple users (as described by {@link UserManager}),
Jeff Sharkey8c165792012-10-22 14:08:29 -07001241 * multiple users may share the same OBB storage location. Applications
Jeff Sharkey1abdb712013-08-11 16:28:14 -07001242 * should ensure that multiple instances running under different users don't
1243 * interfere with each other.
Jeff Sharkey59d28dc82015-10-14 13:56:23 -07001244 *
1245 * @return the absolute path to application-specific directory. May return
1246 * {@code null} if shared storage is not currently available.
1247 * @see #getObbDirs()
1248 * @see Environment#getExternalStorageState(File)
1249 * @see Environment#isExternalStorageEmulated(File)
1250 * @see Environment#isExternalStorageRemovable(File)
Dianne Hackborn805fd7e2011-01-16 18:30:29 -08001251 */
1252 public abstract File getObbDir();
1253
1254 /**
Jeff Sharkey1abdb712013-08-11 16:28:14 -07001255 * Returns absolute paths to application-specific directories on all
Jeff Sharkey59d28dc82015-10-14 13:56:23 -07001256 * shared/external storage devices where the application's OBB files (if
1257 * there are any) can be found. Note if the application does not have any
1258 * OBB files, these directories may not exist.
Jeff Sharkey1abdb712013-08-11 16:28:14 -07001259 * <p>
Jeff Sharkey59d28dc82015-10-14 13:56:23 -07001260 * This is like {@link #getFilesDir()} in that these files will be deleted
1261 * when the application is uninstalled, however there are some important
1262 * differences:
Jeff Sharkey6feb50b2013-10-15 12:38:15 -07001263 * <ul>
Jeff Sharkey59d28dc82015-10-14 13:56:23 -07001264 * <li>Shared storage may not always be available, since removable media can
1265 * be ejected by the user. Media state can be checked using
1266 * {@link Environment#getExternalStorageState(File)}.
1267 * <li>There is no security enforced with these files. For example, any
1268 * application holding
1269 * {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} can write to
1270 * these files.
Jeff Sharkey6feb50b2013-10-15 12:38:15 -07001271 * </ul>
1272 * <p>
Jeff Sharkey59d28dc82015-10-14 13:56:23 -07001273 * Shared storage devices returned here are considered a stable part of the
1274 * device, including physical media slots under a protective cover. The
1275 * returned paths do not include transient devices, such as USB flash drives
1276 * connected to handheld devices.
Jeff Sharkey1abdb712013-08-11 16:28:14 -07001277 * <p>
Jeff Sharkey59d28dc82015-10-14 13:56:23 -07001278 * An application may store data on any or all of the returned devices. For
Jeff Sharkey6feb50b2013-10-15 12:38:15 -07001279 * example, an app may choose to store large files on the device with the
1280 * most available space, as measured by {@link StatFs}.
Jeff Sharkey1abdb712013-08-11 16:28:14 -07001281 * <p>
Jeff Sharkey59d28dc82015-10-14 13:56:23 -07001282 * No additional permissions are required for the calling app to read or
1283 * write files under the returned path. Write access outside of these paths
1284 * on secondary external storage devices is not available.
Jeff Sharkey1abdb712013-08-11 16:28:14 -07001285 *
Jeff Sharkey59d28dc82015-10-14 13:56:23 -07001286 * @return the absolute paths to application-specific directories. Some
1287 * individual paths may be {@code null} if that shared storage is
1288 * not currently available. The first path returned is the same as
1289 * {@link #getObbDir()}
Jeff Sharkey1abdb712013-08-11 16:28:14 -07001290 * @see #getObbDir()
Jeff Sharkey4ca728c2014-01-10 16:27:19 -08001291 * @see Environment#getExternalStorageState(File)
Jeff Sharkey59d28dc82015-10-14 13:56:23 -07001292 * @see Environment#isExternalStorageEmulated(File)
1293 * @see Environment#isExternalStorageRemovable(File)
Jeff Sharkey1abdb712013-08-11 16:28:14 -07001294 */
1295 public abstract File[] getObbDirs();
1296
1297 /**
Jeff Sharkey59d28dc82015-10-14 13:56:23 -07001298 * Returns the absolute path to the application specific cache directory on
Jeff Sharkey60a82cd2017-04-18 18:19:16 -06001299 * the filesystem.
Jeff Sharkey59d28dc82015-10-14 13:56:23 -07001300 * <p>
Jeff Sharkey60a82cd2017-04-18 18:19:16 -06001301 * The system will automatically delete files in this directory as disk
1302 * space is needed elsewhere on the device. The system will always delete
1303 * older files first, as reported by {@link File#lastModified()}. If
1304 * desired, you can exert more control over how files are deleted using
1305 * {@link StorageManager#setCacheBehaviorGroup(File, boolean)} and
1306 * {@link StorageManager#setCacheBehaviorTombstone(File, boolean)}.
1307 * <p>
1308 * Apps are strongly encouraged to keep their usage of cache space below the
1309 * quota returned by
1310 * {@link StorageManager#getCacheQuotaBytes(java.util.UUID)}. If your app
1311 * goes above this quota, your cached files will be some of the first to be
1312 * deleted when additional disk space is needed. Conversely, if your app
1313 * stays under this quota, your cached files will be some of the last to be
1314 * deleted when additional disk space is needed.
1315 * <p>
1316 * Note that your cache quota will change over time depending on how
1317 * frequently the user interacts with your app, and depending on how much
1318 * system-wide disk space is used.
Jeff Sharkey59d28dc82015-10-14 13:56:23 -07001319 * <p>
1320 * The returned path may change over time if the calling app is moved to an
1321 * adopted storage device, so only relative paths should be persisted.
1322 * <p>
1323 * Apps require no extra permissions to read or write to the returned path,
1324 * since this path lives in their private storage.
Scott Main4b5da682010-10-21 11:49:12 -07001325 *
John Spurlock6098c5d2013-06-17 10:32:46 -04001326 * @return The path of the directory holding application cache files.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001327 * @see #openFileOutput
1328 * @see #getFileStreamPath
1329 * @see #getDir
Kevin Hufnaglee9681e12016-09-23 16:44:03 -07001330 * @see #getExternalCacheDir
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001331 */
1332 public abstract File getCacheDir();
1333
1334 /**
Jeff Sharkey4ed745d2014-07-15 20:39:15 -07001335 * Returns the absolute path to the application specific cache directory on
Jeff Sharkey60a82cd2017-04-18 18:19:16 -06001336 * the filesystem designed for storing cached code.
1337 * <p>
1338 * The system will delete any files stored in this location both when your
1339 * specific application is upgraded, and when the entire platform is
1340 * upgraded.
Jeff Sharkey4ed745d2014-07-15 20:39:15 -07001341 * <p>
1342 * This location is optimal for storing compiled or optimized code generated
1343 * by your application at runtime.
1344 * <p>
Jeff Sharkey59d28dc82015-10-14 13:56:23 -07001345 * The returned path may change over time if the calling app is moved to an
1346 * adopted storage device, so only relative paths should be persisted.
1347 * <p>
Jeff Sharkey4ed745d2014-07-15 20:39:15 -07001348 * Apps require no extra permissions to read or write to the returned path,
1349 * since this path lives in their private storage.
1350 *
1351 * @return The path of the directory holding application code cache files.
1352 */
1353 public abstract File getCodeCacheDir();
1354
1355 /**
Jeff Sharkey59d28dc82015-10-14 13:56:23 -07001356 * Returns absolute path to application-specific directory on the primary
1357 * shared/external storage device where the application can place cache
1358 * files it owns. These files are internal to the application, and not
1359 * typically visible to the user as media.
1360 * <p>
1361 * This is like {@link #getCacheDir()} in that these files will be deleted
1362 * when the application is uninstalled, however there are some important
1363 * differences:
Dianne Hackborne83cefce2010-02-04 17:38:14 -08001364 * <ul>
Jeff Sharkey59d28dc82015-10-14 13:56:23 -07001365 * <li>The platform does not always monitor the space available in shared
1366 * storage, and thus may not automatically delete these files. Apps should
1367 * always manage the maximum space used in this location. Currently the only
1368 * time files here will be deleted by the platform is when running on
1369 * {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1} or later and
1370 * {@link Environment#isExternalStorageEmulated(File)} returns true.
1371 * <li>Shared storage may not always be available, since removable media can
1372 * be ejected by the user. Media state can be checked using
1373 * {@link Environment#getExternalStorageState(File)}.
1374 * <li>There is no security enforced with these files. For example, any
1375 * application holding
1376 * {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} can write to
Jeff Sharkey6feb50b2013-10-15 12:38:15 -07001377 * these files.
Dianne Hackborne83cefce2010-02-04 17:38:14 -08001378 * </ul>
Jeff Sharkey59d28dc82015-10-14 13:56:23 -07001379 * <p>
1380 * If a shared storage device is emulated (as determined by
Kevin Hufnaglee9681e12016-09-23 16:44:03 -07001381 * {@link Environment#isExternalStorageEmulated(File)}), its contents are
Jeff Sharkey59d28dc82015-10-14 13:56:23 -07001382 * backed by a private user data partition, which means there is little
1383 * benefit to storing data here instead of the private directory returned by
1384 * {@link #getCacheDir()}.
1385 * <p>
1386 * Starting in {@link android.os.Build.VERSION_CODES#KITKAT}, no permissions
Jeff Sharkey6feb50b2013-10-15 12:38:15 -07001387 * are required to read or write to the returned path; it's always
Jeff Sharkey59d28dc82015-10-14 13:56:23 -07001388 * accessible to the calling app. This only applies to paths generated for
1389 * package name of the calling application. To access paths belonging to
1390 * other packages,
1391 * {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} and/or
1392 * {@link android.Manifest.permission#READ_EXTERNAL_STORAGE} are required.
1393 * <p>
1394 * On devices with multiple users (as described by {@link UserManager}),
1395 * each user has their own isolated shared storage. Applications only have
1396 * access to the shared storage for the user they're running as.
1397 * <p>
1398 * The returned path may change over time if different shared storage media
1399 * is inserted, so only relative paths should be persisted.
Jeff Sharkey6feb50b2013-10-15 12:38:15 -07001400 *
Jeff Sharkey59d28dc82015-10-14 13:56:23 -07001401 * @return the absolute path to application-specific directory. May return
1402 * {@code null} if shared storage is not currently available.
Dianne Hackborne83cefce2010-02-04 17:38:14 -08001403 * @see #getCacheDir
Jeff Sharkey59d28dc82015-10-14 13:56:23 -07001404 * @see #getExternalCacheDirs()
1405 * @see Environment#getExternalStorageState(File)
1406 * @see Environment#isExternalStorageEmulated(File)
1407 * @see Environment#isExternalStorageRemovable(File)
Dianne Hackborne83cefce2010-02-04 17:38:14 -08001408 */
Tor Norbyed9273d62013-05-30 15:59:53 -07001409 @Nullable
Dianne Hackborne83cefce2010-02-04 17:38:14 -08001410 public abstract File getExternalCacheDir();
Scott Main4b5da682010-10-21 11:49:12 -07001411
Dianne Hackborne83cefce2010-02-04 17:38:14 -08001412 /**
Fyodor Kupolov61221292016-09-02 15:21:03 -07001413 * Returns absolute path to application-specific directory in the preloaded cache.
1414 * <p>Files stored in the cache directory can be deleted when the device runs low on storage.
1415 * There is no guarantee when these files will be deleted.
1416 * @hide
1417 */
1418 @Nullable
1419 @SystemApi
1420 public abstract File getPreloadsFileCache();
1421
1422 /**
Jeff Sharkey1abdb712013-08-11 16:28:14 -07001423 * Returns absolute paths to application-specific directories on all
Jeff Sharkey59d28dc82015-10-14 13:56:23 -07001424 * shared/external storage devices where the application can place cache
1425 * files it owns. These files are internal to the application, and not
1426 * typically visible to the user as media.
Jeff Sharkey1abdb712013-08-11 16:28:14 -07001427 * <p>
Jeff Sharkey59d28dc82015-10-14 13:56:23 -07001428 * This is like {@link #getCacheDir()} in that these files will be deleted
1429 * when the application is uninstalled, however there are some important
1430 * differences:
Jeff Sharkey6feb50b2013-10-15 12:38:15 -07001431 * <ul>
Jeff Sharkey59d28dc82015-10-14 13:56:23 -07001432 * <li>The platform does not always monitor the space available in shared
1433 * storage, and thus may not automatically delete these files. Apps should
1434 * always manage the maximum space used in this location. Currently the only
1435 * time files here will be deleted by the platform is when running on
1436 * {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1} or later and
1437 * {@link Environment#isExternalStorageEmulated(File)} returns true.
1438 * <li>Shared storage may not always be available, since removable media can
1439 * be ejected by the user. Media state can be checked using
1440 * {@link Environment#getExternalStorageState(File)}.
1441 * <li>There is no security enforced with these files. For example, any
1442 * application holding
1443 * {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} can write to
1444 * these files.
Jeff Sharkey6feb50b2013-10-15 12:38:15 -07001445 * </ul>
1446 * <p>
Jeff Sharkey59d28dc82015-10-14 13:56:23 -07001447 * If a shared storage device is emulated (as determined by
1448 * {@link Environment#isExternalStorageEmulated(File)}), it's contents are
1449 * backed by a private user data partition, which means there is little
1450 * benefit to storing data here instead of the private directory returned by
1451 * {@link #getCacheDir()}.
Jeff Sharkey1abdb712013-08-11 16:28:14 -07001452 * <p>
Jeff Sharkey59d28dc82015-10-14 13:56:23 -07001453 * Shared storage devices returned here are considered a stable part of the
1454 * device, including physical media slots under a protective cover. The
1455 * returned paths do not include transient devices, such as USB flash drives
1456 * connected to handheld devices.
1457 * <p>
1458 * An application may store data on any or all of the returned devices. For
Jeff Sharkey6feb50b2013-10-15 12:38:15 -07001459 * example, an app may choose to store large files on the device with the
1460 * most available space, as measured by {@link StatFs}.
Jeff Sharkey1abdb712013-08-11 16:28:14 -07001461 * <p>
Jeff Sharkey59d28dc82015-10-14 13:56:23 -07001462 * No additional permissions are required for the calling app to read or
1463 * write files under the returned path. Write access outside of these paths
1464 * on secondary external storage devices is not available.
Jeff Sharkey6feb50b2013-10-15 12:38:15 -07001465 * <p>
Jeff Sharkey59d28dc82015-10-14 13:56:23 -07001466 * The returned paths may change over time if different shared storage media
1467 * is inserted, so only relative paths should be persisted.
Jeff Sharkey1abdb712013-08-11 16:28:14 -07001468 *
Jeff Sharkey59d28dc82015-10-14 13:56:23 -07001469 * @return the absolute paths to application-specific directories. Some
1470 * individual paths may be {@code null} if that shared storage is
1471 * not currently available. The first path returned is the same as
1472 * {@link #getExternalCacheDir()}.
Jeff Sharkey1abdb712013-08-11 16:28:14 -07001473 * @see #getExternalCacheDir()
Jeff Sharkey4ca728c2014-01-10 16:27:19 -08001474 * @see Environment#getExternalStorageState(File)
Jeff Sharkey59d28dc82015-10-14 13:56:23 -07001475 * @see Environment#isExternalStorageEmulated(File)
1476 * @see Environment#isExternalStorageRemovable(File)
Jeff Sharkey1abdb712013-08-11 16:28:14 -07001477 */
1478 public abstract File[] getExternalCacheDirs();
1479
1480 /**
Jeff Sharkey2ee3c1e2014-05-30 15:38:35 -07001481 * Returns absolute paths to application-specific directories on all
Jeff Sharkey59d28dc82015-10-14 13:56:23 -07001482 * shared/external storage devices where the application can place media
1483 * files. These files are scanned and made available to other apps through
Jeff Sharkey2ee3c1e2014-05-30 15:38:35 -07001484 * {@link MediaStore}.
1485 * <p>
1486 * This is like {@link #getExternalFilesDirs} in that these files will be
1487 * deleted when the application is uninstalled, however there are some
1488 * important differences:
1489 * <ul>
Jeff Sharkey59d28dc82015-10-14 13:56:23 -07001490 * <li>Shared storage may not always be available, since removable media can
1491 * be ejected by the user. Media state can be checked using
1492 * {@link Environment#getExternalStorageState(File)}.
1493 * <li>There is no security enforced with these files. For example, any
1494 * application holding
1495 * {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} can write to
1496 * these files.
Jeff Sharkey2ee3c1e2014-05-30 15:38:35 -07001497 * </ul>
1498 * <p>
Jeff Sharkey59d28dc82015-10-14 13:56:23 -07001499 * Shared storage devices returned here are considered a stable part of the
1500 * device, including physical media slots under a protective cover. The
1501 * returned paths do not include transient devices, such as USB flash drives
1502 * connected to handheld devices.
Jeff Sharkey2ee3c1e2014-05-30 15:38:35 -07001503 * <p>
1504 * An application may store data on any or all of the returned devices. For
1505 * example, an app may choose to store large files on the device with the
1506 * most available space, as measured by {@link StatFs}.
1507 * <p>
Jeff Sharkey59d28dc82015-10-14 13:56:23 -07001508 * No additional permissions are required for the calling app to read or
1509 * write files under the returned path. Write access outside of these paths
1510 * on secondary external storage devices is not available.
Jeff Sharkey2ee3c1e2014-05-30 15:38:35 -07001511 * <p>
Jeff Sharkey59d28dc82015-10-14 13:56:23 -07001512 * The returned paths may change over time if different shared storage media
1513 * is inserted, so only relative paths should be persisted.
Jeff Sharkey2ee3c1e2014-05-30 15:38:35 -07001514 *
Jeff Sharkey59d28dc82015-10-14 13:56:23 -07001515 * @return the absolute paths to application-specific directories. Some
1516 * individual paths may be {@code null} if that shared storage is
1517 * not currently available.
Jeff Sharkey2ee3c1e2014-05-30 15:38:35 -07001518 * @see Environment#getExternalStorageState(File)
Jeff Sharkey59d28dc82015-10-14 13:56:23 -07001519 * @see Environment#isExternalStorageEmulated(File)
1520 * @see Environment#isExternalStorageRemovable(File)
Jeff Sharkey2ee3c1e2014-05-30 15:38:35 -07001521 */
1522 public abstract File[] getExternalMediaDirs();
1523
1524 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001525 * Returns an array of strings naming the private files associated with
1526 * this Context's application package.
1527 *
1528 * @return Array of strings naming the private files.
1529 *
1530 * @see #openFileInput
1531 * @see #openFileOutput
1532 * @see #deleteFile
1533 */
1534 public abstract String[] fileList();
1535
1536 /**
1537 * Retrieve, creating if needed, a new directory in which the application
1538 * can place its own custom data files. You can use the returned File
1539 * object to create and access files in this directory. Note that files
1540 * created through a File object will only be accessible by your own
1541 * application; you can only set the mode of the entire directory, not
1542 * of individual files.
Jeff Sharkey59d28dc82015-10-14 13:56:23 -07001543 * <p>
1544 * The returned path may change over time if the calling app is moved to an
1545 * adopted storage device, so only relative paths should be persisted.
1546 * <p>
1547 * Apps require no extra permissions to read or write to the returned path,
1548 * since this path lives in their private storage.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001549 *
Nick Kralevich92091fa2012-12-12 16:24:31 -08001550 * @param name Name of the directory to retrieve. This is a directory
Nick Kralevich15069212013-01-09 15:54:56 -08001551 * that is created as part of your application data.
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06001552 * @param mode Operating mode.
Nick Kralevich15069212013-01-09 15:54:56 -08001553 *
John Spurlock6098c5d2013-06-17 10:32:46 -04001554 * @return A {@link File} object for the requested directory. The directory
Nick Kralevich15069212013-01-09 15:54:56 -08001555 * will have been created if it does not already exist.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001556 *
1557 * @see #openFileOutput(String, int)
1558 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06001559 public abstract File getDir(String name, @FileMode int mode);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001560
1561 /**
1562 * Open a new private SQLiteDatabase associated with this Context's
Jeff Sharkey634dc422016-01-30 17:44:15 -07001563 * application package. Create the database file if it doesn't exist.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001564 *
1565 * @param name The name (unique in the application package) of the database.
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06001566 * @param mode Operating mode.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001567 * @param factory An optional factory class that is called to instantiate a
Jeff Sharkey634dc422016-01-30 17:44:15 -07001568 * cursor when query is called.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001569 * @return The contents of a newly created database with the given name.
Jeff Sharkey634dc422016-01-30 17:44:15 -07001570 * @throws android.database.sqlite.SQLiteException if the database file
1571 * could not be opened.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001572 * @see #MODE_PRIVATE
Jeff Brown47847f32012-03-22 19:13:11 -07001573 * @see #MODE_ENABLE_WRITE_AHEAD_LOGGING
Sunny Goyala21e6b22015-12-02 09:51:02 -08001574 * @see #MODE_NO_LOCALIZED_COLLATORS
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001575 * @see #deleteDatabase
1576 */
1577 public abstract SQLiteDatabase openOrCreateDatabase(String name,
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06001578 @DatabaseMode int mode, CursorFactory factory);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001579
1580 /**
Vasu Nori74f170f2010-06-01 18:06:18 -07001581 * Open a new private SQLiteDatabase associated with this Context's
Jeff Sharkey634dc422016-01-30 17:44:15 -07001582 * application package. Creates the database file if it doesn't exist.
1583 * <p>
1584 * Accepts input param: a concrete instance of {@link DatabaseErrorHandler}
1585 * to be used to handle corruption when sqlite reports database corruption.
1586 * </p>
Vasu Nori74f170f2010-06-01 18:06:18 -07001587 *
1588 * @param name The name (unique in the application package) of the database.
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06001589 * @param mode Operating mode.
Vasu Nori74f170f2010-06-01 18:06:18 -07001590 * @param factory An optional factory class that is called to instantiate a
Jeff Sharkey634dc422016-01-30 17:44:15 -07001591 * cursor when query is called.
1592 * @param errorHandler the {@link DatabaseErrorHandler} to be used when
1593 * sqlite reports database corruption. if null,
1594 * {@link android.database.DefaultDatabaseErrorHandler} is
1595 * assumed.
Vasu Nori74f170f2010-06-01 18:06:18 -07001596 * @return The contents of a newly created database with the given name.
Jeff Sharkey634dc422016-01-30 17:44:15 -07001597 * @throws android.database.sqlite.SQLiteException if the database file
1598 * could not be opened.
Vasu Nori74f170f2010-06-01 18:06:18 -07001599 * @see #MODE_PRIVATE
Jeff Brown47847f32012-03-22 19:13:11 -07001600 * @see #MODE_ENABLE_WRITE_AHEAD_LOGGING
Sunny Goyala21e6b22015-12-02 09:51:02 -08001601 * @see #MODE_NO_LOCALIZED_COLLATORS
Vasu Nori74f170f2010-06-01 18:06:18 -07001602 * @see #deleteDatabase
1603 */
1604 public abstract SQLiteDatabase openOrCreateDatabase(String name,
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06001605 @DatabaseMode int mode, CursorFactory factory,
Tor Norbyed9273d62013-05-30 15:59:53 -07001606 @Nullable DatabaseErrorHandler errorHandler);
Vasu Nori74f170f2010-06-01 18:06:18 -07001607
1608 /**
Jeff Sharkey8a372a02016-03-16 16:25:45 -06001609 * Move an existing database file from the given source storage context to
1610 * this context. This is typically used to migrate data between storage
1611 * locations after an upgrade, such as migrating to device protected
1612 * storage.
Jeff Sharkeyd21cad12016-05-20 11:30:07 -06001613 * <p>
1614 * The database must be closed before being moved.
Jeff Sharkey35871f22016-01-29 17:13:29 -07001615 *
1616 * @param sourceContext The source context which contains the existing
Jeff Sharkey8a372a02016-03-16 16:25:45 -06001617 * database to move.
Jeff Sharkey35871f22016-01-29 17:13:29 -07001618 * @param name The name of the database file.
Jeff Sharkey8a372a02016-03-16 16:25:45 -06001619 * @return {@code true} if the move was successful or if the database didn't
1620 * exist in the source context, otherwise {@code false}.
1621 * @see #createDeviceProtectedStorageContext()
Jeff Sharkey35871f22016-01-29 17:13:29 -07001622 */
Jeff Sharkey8a372a02016-03-16 16:25:45 -06001623 public abstract boolean moveDatabaseFrom(Context sourceContext, String name);
1624
Jeff Sharkey35871f22016-01-29 17:13:29 -07001625 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001626 * Delete an existing private SQLiteDatabase associated with this Context's
1627 * application package.
1628 *
1629 * @param name The name (unique in the application package) of the
1630 * database.
1631 *
John Spurlock6098c5d2013-06-17 10:32:46 -04001632 * @return {@code true} if the database was successfully deleted; else {@code false}.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001633 *
1634 * @see #openOrCreateDatabase
1635 */
1636 public abstract boolean deleteDatabase(String name);
1637
1638 /**
1639 * Returns the absolute path on the filesystem where a database created with
1640 * {@link #openOrCreateDatabase} is stored.
Jeff Sharkey59d28dc82015-10-14 13:56:23 -07001641 * <p>
1642 * The returned path may change over time if the calling app is moved to an
1643 * adopted storage device, so only relative paths should be persisted.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001644 *
1645 * @param name The name of the database for which you would like to get
1646 * its path.
1647 *
John Spurlock6098c5d2013-06-17 10:32:46 -04001648 * @return An absolute path to the given database.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001649 *
1650 * @see #openOrCreateDatabase
1651 */
1652 public abstract File getDatabasePath(String name);
1653
1654 /**
1655 * Returns an array of strings naming the private databases associated with
1656 * this Context's application package.
1657 *
1658 * @return Array of strings naming the private databases.
1659 *
1660 * @see #openOrCreateDatabase
1661 * @see #deleteDatabase
1662 */
1663 public abstract String[] databaseList();
1664
1665 /**
Dianne Hackborn4c62fc02009-08-08 20:40:27 -07001666 * @deprecated Use {@link android.app.WallpaperManager#getDrawable
Dianne Hackborn8cc6a502009-08-05 21:29:42 -07001667 * WallpaperManager.get()} instead.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001668 */
Dianne Hackborn4a51c202009-08-21 15:14:02 -07001669 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001670 public abstract Drawable getWallpaper();
1671
1672 /**
Dianne Hackborn4c62fc02009-08-08 20:40:27 -07001673 * @deprecated Use {@link android.app.WallpaperManager#peekDrawable
Dianne Hackborn8cc6a502009-08-05 21:29:42 -07001674 * WallpaperManager.peek()} instead.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001675 */
Dianne Hackborn4a51c202009-08-21 15:14:02 -07001676 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001677 public abstract Drawable peekWallpaper();
1678
1679 /**
Dianne Hackborn8cc6a502009-08-05 21:29:42 -07001680 * @deprecated Use {@link android.app.WallpaperManager#getDesiredMinimumWidth()
1681 * WallpaperManager.getDesiredMinimumWidth()} instead.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001682 */
Dianne Hackborn4a51c202009-08-21 15:14:02 -07001683 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001684 public abstract int getWallpaperDesiredMinimumWidth();
1685
1686 /**
Dianne Hackborn8cc6a502009-08-05 21:29:42 -07001687 * @deprecated Use {@link android.app.WallpaperManager#getDesiredMinimumHeight()
1688 * WallpaperManager.getDesiredMinimumHeight()} instead.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001689 */
Dianne Hackborn4a51c202009-08-21 15:14:02 -07001690 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001691 public abstract int getWallpaperDesiredMinimumHeight();
1692
1693 /**
Dianne Hackborn4c62fc02009-08-08 20:40:27 -07001694 * @deprecated Use {@link android.app.WallpaperManager#setBitmap(Bitmap)
Dianne Hackborn8cc6a502009-08-05 21:29:42 -07001695 * WallpaperManager.set()} instead.
Nicolas Falliere9530e3a2012-06-18 17:21:06 -07001696 * <p>This method requires the caller to hold the permission
1697 * {@link android.Manifest.permission#SET_WALLPAPER}.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001698 */
Dianne Hackborn4a51c202009-08-21 15:14:02 -07001699 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001700 public abstract void setWallpaper(Bitmap bitmap) throws IOException;
1701
1702 /**
Dianne Hackborn4c62fc02009-08-08 20:40:27 -07001703 * @deprecated Use {@link android.app.WallpaperManager#setStream(InputStream)
Dianne Hackborn8cc6a502009-08-05 21:29:42 -07001704 * WallpaperManager.set()} instead.
Nicolas Falliere9530e3a2012-06-18 17:21:06 -07001705 * <p>This method requires the caller to hold the permission
1706 * {@link android.Manifest.permission#SET_WALLPAPER}.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001707 */
Dianne Hackborn4a51c202009-08-21 15:14:02 -07001708 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001709 public abstract void setWallpaper(InputStream data) throws IOException;
1710
1711 /**
Dianne Hackborn8cc6a502009-08-05 21:29:42 -07001712 * @deprecated Use {@link android.app.WallpaperManager#clear
1713 * WallpaperManager.clear()} instead.
Nicolas Falliere9530e3a2012-06-18 17:21:06 -07001714 * <p>This method requires the caller to hold the permission
1715 * {@link android.Manifest.permission#SET_WALLPAPER}.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001716 */
Dianne Hackborn4a51c202009-08-21 15:14:02 -07001717 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001718 public abstract void clearWallpaper() throws IOException;
1719
1720 /**
Dianne Hackborna4972e92012-03-14 10:38:05 -07001721 * Same as {@link #startActivity(Intent, Bundle)} with no options
1722 * specified.
1723 *
1724 * @param intent The description of the activity to start.
1725 *
John Spurlock6098c5d2013-06-17 10:32:46 -04001726 * @throws ActivityNotFoundException &nbsp;
Svet Ganov1ed0e552015-06-11 01:15:43 -07001727 *`
John Spurlock6098c5d2013-06-17 10:32:46 -04001728 * @see #startActivity(Intent, Bundle)
Dianne Hackborna4972e92012-03-14 10:38:05 -07001729 * @see PackageManager#resolveActivity
1730 */
Tor Norbye788fc2b2015-07-05 16:10:42 -07001731 public abstract void startActivity(@RequiresPermission Intent intent);
Dianne Hackborna4972e92012-03-14 10:38:05 -07001732
1733 /**
Dianne Hackborn8832c182012-09-17 17:20:24 -07001734 * Version of {@link #startActivity(Intent)} that allows you to specify the
1735 * user the activity will be started for. This is not available to applications
Jeff Sharkeyd86b8fe2017-06-02 17:36:26 -06001736 * that are not pre-installed on the system image.
Amith Yamasani82644082012-08-03 13:09:11 -07001737 * @param intent The description of the activity to start.
Dianne Hackborn79af1dd2012-08-16 16:42:52 -07001738 * @param user The UserHandle of the user to start this activity for.
John Spurlock6098c5d2013-06-17 10:32:46 -04001739 * @throws ActivityNotFoundException &nbsp;
Amith Yamasani82644082012-08-03 13:09:11 -07001740 * @hide
1741 */
Jeff Sharkeyd86b8fe2017-06-02 17:36:26 -06001742 @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS_FULL)
Philip P. Moltmann4e615e62018-08-28 14:57:49 -07001743 @SystemApi
Tor Norbye788fc2b2015-07-05 16:10:42 -07001744 public void startActivityAsUser(@RequiresPermission Intent intent, UserHandle user) {
Amith Yamasani82644082012-08-03 13:09:11 -07001745 throw new RuntimeException("Not implemented. Must override in a subclass.");
1746 }
1747
1748 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001749 * Launch a new activity. You will not receive any information about when
1750 * the activity exits.
1751 *
1752 * <p>Note that if this method is being called from outside of an
1753 * {@link android.app.Activity} Context, then the Intent must include
1754 * the {@link Intent#FLAG_ACTIVITY_NEW_TASK} launch flag. This is because,
1755 * without being started from an existing Activity, there is no existing
1756 * task in which to place the new activity and thus it needs to be placed
1757 * in its own separate task.
1758 *
1759 * <p>This method throws {@link ActivityNotFoundException}
1760 * if there was no Activity found to run the given Intent.
1761 *
1762 * @param intent The description of the activity to start.
Dianne Hackborna4972e92012-03-14 10:38:05 -07001763 * @param options Additional options for how the Activity should be started.
Dianne Hackborn7a2195c2012-03-19 17:38:00 -07001764 * May be null if there are no options. See {@link android.app.ActivityOptions}
1765 * for how to build the Bundle supplied here; there are no supported definitions
1766 * for building it manually.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001767 *
John Spurlock6098c5d2013-06-17 10:32:46 -04001768 * @throws ActivityNotFoundException &nbsp;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001769 *
Scott Main60dd5202012-06-23 00:01:22 -07001770 * @see #startActivity(Intent)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001771 * @see PackageManager#resolveActivity
1772 */
Tor Norbye788fc2b2015-07-05 16:10:42 -07001773 public abstract void startActivity(@RequiresPermission Intent intent,
1774 @Nullable Bundle options);
Dianne Hackborna4972e92012-03-14 10:38:05 -07001775
1776 /**
Dianne Hackborn8832c182012-09-17 17:20:24 -07001777 * Version of {@link #startActivity(Intent, Bundle)} that allows you to specify the
1778 * user the activity will be started for. This is not available to applications
Jeff Sharkeyd86b8fe2017-06-02 17:36:26 -06001779 * that are not pre-installed on the system image.
Amith Yamasani258848d2012-08-10 17:06:33 -07001780 * @param intent The description of the activity to start.
1781 * @param options Additional options for how the Activity should be started.
1782 * May be null if there are no options. See {@link android.app.ActivityOptions}
1783 * for how to build the Bundle supplied here; there are no supported definitions
1784 * for building it manually.
Dianne Hackborn221ea892013-08-04 16:50:16 -07001785 * @param userId The UserHandle of the user to start this activity for.
John Spurlock6098c5d2013-06-17 10:32:46 -04001786 * @throws ActivityNotFoundException &nbsp;
Amith Yamasani258848d2012-08-10 17:06:33 -07001787 * @hide
1788 */
Jeff Sharkeyd86b8fe2017-06-02 17:36:26 -06001789 @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS_FULL)
Mathew Inwood5c0d3542018-08-14 13:54:31 +01001790 @UnsupportedAppUsage
Tor Norbye788fc2b2015-07-05 16:10:42 -07001791 public void startActivityAsUser(@RequiresPermission Intent intent, @Nullable Bundle options,
1792 UserHandle userId) {
Amith Yamasani258848d2012-08-10 17:06:33 -07001793 throw new RuntimeException("Not implemented. Must override in a subclass.");
1794 }
1795
1796 /**
Clara Bayarrid5bf3ed2015-03-27 17:32:45 +00001797 * Version of {@link #startActivity(Intent, Bundle)} that returns a result to the caller. This
1798 * is only supported for Views and Fragments.
1799 * @param who The identifier for the calling element that will receive the result.
1800 * @param intent The intent to start.
1801 * @param requestCode The code that will be returned with onActivityResult() identifying this
1802 * request.
1803 * @param options Additional options for how the Activity should be started.
1804 * May be null if there are no options. See {@link android.app.ActivityOptions}
1805 * for how to build the Bundle supplied here; there are no supported definitions
1806 * for building it manually.
1807 * @hide
1808 */
Mathew Inwood5c0d3542018-08-14 13:54:31 +01001809 @UnsupportedAppUsage
Clara Bayarrid5bf3ed2015-03-27 17:32:45 +00001810 public void startActivityForResult(
1811 @NonNull String who, Intent intent, int requestCode, @Nullable Bundle options) {
1812 throw new RuntimeException("This method is only implemented for Activity-based Contexts. "
1813 + "Check canStartActivityForResult() before calling.");
1814 }
1815
1816 /**
1817 * Identifies whether this Context instance will be able to process calls to
1818 * {@link #startActivityForResult(String, Intent, int, Bundle)}.
1819 * @hide
1820 */
Mathew Inwood5c0d3542018-08-14 13:54:31 +01001821 @UnsupportedAppUsage
Clara Bayarrid5bf3ed2015-03-27 17:32:45 +00001822 public boolean canStartActivityForResult() {
1823 return false;
1824 }
1825
1826 /**
Dianne Hackborna4972e92012-03-14 10:38:05 -07001827 * Same as {@link #startActivities(Intent[], Bundle)} with no options
1828 * specified.
1829 *
1830 * @param intents An array of Intents to be started.
1831 *
John Spurlock6098c5d2013-06-17 10:32:46 -04001832 * @throws ActivityNotFoundException &nbsp;
Dianne Hackborna4972e92012-03-14 10:38:05 -07001833 *
John Spurlock6098c5d2013-06-17 10:32:46 -04001834 * @see #startActivities(Intent[], Bundle)
Dianne Hackborna4972e92012-03-14 10:38:05 -07001835 * @see PackageManager#resolveActivity
1836 */
Tor Norbye788fc2b2015-07-05 16:10:42 -07001837 public abstract void startActivities(@RequiresPermission Intent[] intents);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001838
1839 /**
Dianne Hackborn621e17d2010-11-22 15:59:56 -08001840 * Launch multiple new activities. This is generally the same as calling
1841 * {@link #startActivity(Intent)} for the first Intent in the array,
1842 * that activity during its creation calling {@link #startActivity(Intent)}
1843 * for the second entry, etc. Note that unlike that approach, generally
1844 * none of the activities except the last in the array will be created
1845 * at this point, but rather will be created when the user first visits
1846 * them (due to pressing back from the activity on top).
1847 *
1848 * <p>This method throws {@link ActivityNotFoundException}
1849 * if there was no Activity found for <em>any</em> given Intent. In this
1850 * case the state of the activity stack is undefined (some Intents in the
1851 * list may be on it, some not), so you probably want to avoid such situations.
1852 *
1853 * @param intents An array of Intents to be started.
Dianne Hackborna4972e92012-03-14 10:38:05 -07001854 * @param options Additional options for how the Activity should be started.
Elliot Waite54de7742017-01-11 15:30:35 -08001855 * See {@link android.content.Context#startActivity(Intent, Bundle)}
Dianne Hackborn7a2195c2012-03-19 17:38:00 -07001856 * Context.startActivity(Intent, Bundle)} for more details.
Dianne Hackborn621e17d2010-11-22 15:59:56 -08001857 *
John Spurlock6098c5d2013-06-17 10:32:46 -04001858 * @throws ActivityNotFoundException &nbsp;
Dianne Hackborn621e17d2010-11-22 15:59:56 -08001859 *
John Spurlock6098c5d2013-06-17 10:32:46 -04001860 * @see #startActivities(Intent[])
Dianne Hackborn621e17d2010-11-22 15:59:56 -08001861 * @see PackageManager#resolveActivity
1862 */
Tor Norbye788fc2b2015-07-05 16:10:42 -07001863 public abstract void startActivities(@RequiresPermission Intent[] intents, Bundle options);
Dianne Hackborn621e17d2010-11-22 15:59:56 -08001864
1865 /**
Amith Yamasaniea7e9152012-09-24 16:11:18 -07001866 * @hide
1867 * Launch multiple new activities. This is generally the same as calling
1868 * {@link #startActivity(Intent)} for the first Intent in the array,
1869 * that activity during its creation calling {@link #startActivity(Intent)}
1870 * for the second entry, etc. Note that unlike that approach, generally
1871 * none of the activities except the last in the array will be created
1872 * at this point, but rather will be created when the user first visits
1873 * them (due to pressing back from the activity on top).
1874 *
1875 * <p>This method throws {@link ActivityNotFoundException}
1876 * if there was no Activity found for <em>any</em> given Intent. In this
1877 * case the state of the activity stack is undefined (some Intents in the
1878 * list may be on it, some not), so you probably want to avoid such situations.
1879 *
1880 * @param intents An array of Intents to be started.
1881 * @param options Additional options for how the Activity should be started.
1882 * @param userHandle The user for whom to launch the activities
Elliot Waite54de7742017-01-11 15:30:35 -08001883 * See {@link android.content.Context#startActivity(Intent, Bundle)}
Amith Yamasaniea7e9152012-09-24 16:11:18 -07001884 * Context.startActivity(Intent, Bundle)} for more details.
1885 *
Selim Cinek7fa385a2018-01-24 08:35:28 -08001886 * @return The corresponding flag {@link ActivityManager#START_CANCELED},
1887 * {@link ActivityManager#START_SUCCESS} etc. indicating whether the launch was
1888 * successful.
1889 *
John Spurlock6098c5d2013-06-17 10:32:46 -04001890 * @throws ActivityNotFoundException &nbsp;
Amith Yamasaniea7e9152012-09-24 16:11:18 -07001891 *
John Spurlock6098c5d2013-06-17 10:32:46 -04001892 * @see #startActivities(Intent[])
Amith Yamasaniea7e9152012-09-24 16:11:18 -07001893 * @see PackageManager#resolveActivity
1894 */
Jeff Sharkeyd86b8fe2017-06-02 17:36:26 -06001895 @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS_FULL)
Selim Cinek7fa385a2018-01-24 08:35:28 -08001896 public int startActivitiesAsUser(Intent[] intents, Bundle options, UserHandle userHandle) {
Amith Yamasaniea7e9152012-09-24 16:11:18 -07001897 throw new RuntimeException("Not implemented. Must override in a subclass.");
1898 }
1899
1900 /**
Dianne Hackborna4972e92012-03-14 10:38:05 -07001901 * Same as {@link #startIntentSender(IntentSender, Intent, int, int, int, Bundle)}
1902 * with no options specified.
1903 *
1904 * @param intent The IntentSender to launch.
1905 * @param fillInIntent If non-null, this will be provided as the
1906 * intent parameter to {@link IntentSender#sendIntent}.
1907 * @param flagsMask Intent flags in the original IntentSender that you
1908 * would like to change.
1909 * @param flagsValues Desired values for any bits set in
1910 * <var>flagsMask</var>
1911 * @param extraFlags Always set to 0.
1912 *
1913 * @see #startActivity(Intent)
1914 * @see #startIntentSender(IntentSender, Intent, int, int, int, Bundle)
1915 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06001916 public abstract void startIntentSender(IntentSender intent, @Nullable Intent fillInIntent,
1917 @Intent.MutableFlags int flagsMask, @Intent.MutableFlags int flagsValues,
1918 int extraFlags) throws IntentSender.SendIntentException;
Dianne Hackborna4972e92012-03-14 10:38:05 -07001919
1920 /**
1921 * Like {@link #startActivity(Intent, Bundle)}, but taking a IntentSender
Dianne Hackbornfa82f222009-09-17 15:14:12 -07001922 * to start. If the IntentSender is for an activity, that activity will be started
Dianne Hackbornae22c052009-09-17 18:46:22 -07001923 * as if you had called the regular {@link #startActivity(Intent)}
Dianne Hackbornfa82f222009-09-17 15:14:12 -07001924 * here; otherwise, its associated action will be executed (such as
1925 * sending a broadcast) as if you had called
1926 * {@link IntentSender#sendIntent IntentSender.sendIntent} on it.
Scott Main4b5da682010-10-21 11:49:12 -07001927 *
Dianne Hackbornfa82f222009-09-17 15:14:12 -07001928 * @param intent The IntentSender to launch.
1929 * @param fillInIntent If non-null, this will be provided as the
1930 * intent parameter to {@link IntentSender#sendIntent}.
1931 * @param flagsMask Intent flags in the original IntentSender that you
1932 * would like to change.
1933 * @param flagsValues Desired values for any bits set in
1934 * <var>flagsMask</var>
1935 * @param extraFlags Always set to 0.
Dianne Hackborna4972e92012-03-14 10:38:05 -07001936 * @param options Additional options for how the Activity should be started.
Elliot Waite54de7742017-01-11 15:30:35 -08001937 * See {@link android.content.Context#startActivity(Intent, Bundle)}
Dianne Hackborn7a2195c2012-03-19 17:38:00 -07001938 * Context.startActivity(Intent, Bundle)} for more details. If options
1939 * have also been supplied by the IntentSender, options given here will
1940 * override any that conflict with those given by the IntentSender.
Dianne Hackborna4972e92012-03-14 10:38:05 -07001941 *
1942 * @see #startActivity(Intent, Bundle)
1943 * @see #startIntentSender(IntentSender, Intent, int, int, int)
Dianne Hackbornfa82f222009-09-17 15:14:12 -07001944 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06001945 public abstract void startIntentSender(IntentSender intent, @Nullable Intent fillInIntent,
1946 @Intent.MutableFlags int flagsMask, @Intent.MutableFlags int flagsValues,
1947 int extraFlags, @Nullable Bundle options) throws IntentSender.SendIntentException;
Dianne Hackbornfa82f222009-09-17 15:14:12 -07001948
1949 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001950 * Broadcast the given intent to all interested BroadcastReceivers. This
1951 * call is asynchronous; it returns immediately, and you will continue
1952 * executing while the receivers are run. No results are propagated from
1953 * receivers and receivers can not abort the broadcast. If you want
1954 * to allow receivers to propagate results or abort the broadcast, you must
1955 * send an ordered broadcast using
1956 * {@link #sendOrderedBroadcast(Intent, String)}.
1957 *
1958 * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts.
1959 *
1960 * @param intent The Intent to broadcast; all receivers matching this
1961 * Intent will receive the broadcast.
1962 *
1963 * @see android.content.BroadcastReceiver
1964 * @see #registerReceiver
1965 * @see #sendBroadcast(Intent, String)
1966 * @see #sendOrderedBroadcast(Intent, String)
1967 * @see #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle)
1968 */
Tor Norbye788fc2b2015-07-05 16:10:42 -07001969 public abstract void sendBroadcast(@RequiresPermission Intent intent);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001970
1971 /**
1972 * Broadcast the given intent to all interested BroadcastReceivers, allowing
1973 * an optional required permission to be enforced. This
1974 * call is asynchronous; it returns immediately, and you will continue
1975 * executing while the receivers are run. No results are propagated from
1976 * receivers and receivers can not abort the broadcast. If you want
1977 * to allow receivers to propagate results or abort the broadcast, you must
1978 * send an ordered broadcast using
1979 * {@link #sendOrderedBroadcast(Intent, String)}.
1980 *
1981 * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts.
1982 *
1983 * @param intent The Intent to broadcast; all receivers matching this
1984 * Intent will receive the broadcast.
Brad Fitzpatrick26b71be2010-12-07 14:52:58 -08001985 * @param receiverPermission (optional) String naming a permission that
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001986 * a receiver must hold in order to receive your broadcast.
1987 * If null, no permission is required.
1988 *
1989 * @see android.content.BroadcastReceiver
1990 * @see #registerReceiver
1991 * @see #sendBroadcast(Intent)
1992 * @see #sendOrderedBroadcast(Intent, String)
1993 * @see #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle)
1994 */
Tor Norbye788fc2b2015-07-05 16:10:42 -07001995 public abstract void sendBroadcast(@RequiresPermission Intent intent,
Tor Norbyed9273d62013-05-30 15:59:53 -07001996 @Nullable String receiverPermission);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001997
Fyodor Kupolovd4fd8c72015-07-13 19:19:25 -07001998
1999 /**
2000 * Broadcast the given intent to all interested BroadcastReceivers, allowing
2001 * an array of required permissions to be enforced. This call is asynchronous; it returns
2002 * immediately, and you will continue executing while the receivers are run. No results are
2003 * propagated from receivers and receivers can not abort the broadcast. If you want to allow
2004 * receivers to propagate results or abort the broadcast, you must send an ordered broadcast
2005 * using {@link #sendOrderedBroadcast(Intent, String)}.
2006 *
2007 * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts.
2008 *
2009 * @param intent The Intent to broadcast; all receivers matching this
2010 * Intent will receive the broadcast.
2011 * @param receiverPermissions Array of names of permissions that a receiver must hold
2012 * in order to receive your broadcast.
2013 * If null or empty, no permissions are required.
2014 *
2015 * @see android.content.BroadcastReceiver
2016 * @see #registerReceiver
2017 * @see #sendBroadcast(Intent)
2018 * @see #sendOrderedBroadcast(Intent, String)
2019 * @see #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle)
2020 * @hide
2021 */
2022 public abstract void sendBroadcastMultiplePermissions(Intent intent,
2023 String[] receiverPermissions);
2024
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002025 /**
Dianne Hackborna750a632015-06-16 17:18:23 -07002026 * Broadcast the given intent to all interested BroadcastReceivers, allowing
Tyler Gunnf955e562018-04-26 14:43:31 -07002027 * an array of required permissions to be enforced. This call is asynchronous; it returns
2028 * immediately, and you will continue executing while the receivers are run. No results are
2029 * propagated from receivers and receivers can not abort the broadcast. If you want to allow
2030 * receivers to propagate results or abort the broadcast, you must send an ordered broadcast
2031 * using {@link #sendOrderedBroadcast(Intent, String)}.
2032 *
2033 * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts.
2034 *
2035 * @param intent The Intent to broadcast; all receivers matching this
2036 * Intent will receive the broadcast.
2037 * @param user The user to send the broadcast to.
2038 * @param receiverPermissions Array of names of permissions that a receiver must hold
2039 * in order to receive your broadcast.
2040 * If null or empty, no permissions are required.
2041 *
2042 * @see android.content.BroadcastReceiver
2043 * @see #registerReceiver
2044 * @see #sendBroadcast(Intent)
2045 * @see #sendOrderedBroadcast(Intent, String)
2046 * @see #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle)
2047 * @hide
2048 */
2049 public abstract void sendBroadcastAsUserMultiplePermissions(Intent intent, UserHandle user,
2050 String[] receiverPermissions);
2051
2052 /**
2053 * Broadcast the given intent to all interested BroadcastReceivers, allowing
Dianne Hackborna750a632015-06-16 17:18:23 -07002054 * an optional required permission to be enforced. This
2055 * call is asynchronous; it returns immediately, and you will continue
2056 * executing while the receivers are run. No results are propagated from
2057 * receivers and receivers can not abort the broadcast. If you want
2058 * to allow receivers to propagate results or abort the broadcast, you must
2059 * send an ordered broadcast using
2060 * {@link #sendOrderedBroadcast(Intent, String)}.
2061 *
2062 * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts.
2063 *
2064 * @param intent The Intent to broadcast; all receivers matching this
2065 * Intent will receive the broadcast.
2066 * @param receiverPermission (optional) String naming a permission that
2067 * a receiver must hold in order to receive your broadcast.
2068 * If null, no permission is required.
2069 * @param options (optional) Additional sending options, generated from a
2070 * {@link android.app.BroadcastOptions}.
2071 *
2072 * @see android.content.BroadcastReceiver
2073 * @see #registerReceiver
2074 * @see #sendBroadcast(Intent)
2075 * @see #sendOrderedBroadcast(Intent, String)
2076 * @see #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle)
2077 * @hide
2078 */
2079 @SystemApi
2080 public abstract void sendBroadcast(Intent intent,
2081 @Nullable String receiverPermission,
2082 @Nullable Bundle options);
2083
2084 /**
Dianne Hackbornf51f6122013-02-04 18:23:34 -08002085 * Like {@link #sendBroadcast(Intent, String)}, but also allows specification
Tor Norbyed9273d62013-05-30 15:59:53 -07002086 * of an associated app op as per {@link android.app.AppOpsManager}.
Dianne Hackbornf51f6122013-02-04 18:23:34 -08002087 * @hide
2088 */
Mathew Inwood5c0d3542018-08-14 13:54:31 +01002089 @UnsupportedAppUsage
Dianne Hackbornf51f6122013-02-04 18:23:34 -08002090 public abstract void sendBroadcast(Intent intent,
2091 String receiverPermission, int appOp);
2092
2093 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002094 * Broadcast the given intent to all interested BroadcastReceivers, delivering
2095 * them one at a time to allow more preferred receivers to consume the
2096 * broadcast before it is delivered to less preferred receivers. This
2097 * call is asynchronous; it returns immediately, and you will continue
2098 * executing while the receivers are run.
2099 *
2100 * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts.
2101 *
2102 * @param intent The Intent to broadcast; all receivers matching this
2103 * Intent will receive the broadcast.
2104 * @param receiverPermission (optional) String naming a permissions that
2105 * a receiver must hold in order to receive your broadcast.
2106 * If null, no permission is required.
2107 *
2108 * @see android.content.BroadcastReceiver
2109 * @see #registerReceiver
2110 * @see #sendBroadcast(Intent)
2111 * @see #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle)
2112 */
Tor Norbye788fc2b2015-07-05 16:10:42 -07002113 public abstract void sendOrderedBroadcast(@RequiresPermission Intent intent,
Tor Norbyed9273d62013-05-30 15:59:53 -07002114 @Nullable String receiverPermission);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002115
2116 /**
2117 * Version of {@link #sendBroadcast(Intent)} that allows you to
2118 * receive data back from the broadcast. This is accomplished by
2119 * supplying your own BroadcastReceiver when calling, which will be
2120 * treated as a final receiver at the end of the broadcast -- its
2121 * {@link BroadcastReceiver#onReceive} method will be called with
Dianne Hackbornefa199f2009-09-19 12:03:15 -07002122 * the result values collected from the other receivers. The broadcast will
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002123 * be serialized in the same way as calling
2124 * {@link #sendOrderedBroadcast(Intent, String)}.
2125 *
2126 * <p>Like {@link #sendBroadcast(Intent)}, this method is
2127 * asynchronous; it will return before
2128 * resultReceiver.onReceive() is called.
2129 *
2130 * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts.
2131 *
2132 * @param intent The Intent to broadcast; all receivers matching this
2133 * Intent will receive the broadcast.
2134 * @param receiverPermission String naming a permissions that
2135 * a receiver must hold in order to receive your broadcast.
2136 * If null, no permission is required.
2137 * @param resultReceiver Your own BroadcastReceiver to treat as the final
2138 * receiver of the broadcast.
2139 * @param scheduler A custom Handler with which to schedule the
2140 * resultReceiver callback; if null it will be
2141 * scheduled in the Context's main thread.
2142 * @param initialCode An initial value for the result code. Often
2143 * Activity.RESULT_OK.
2144 * @param initialData An initial value for the result data. Often
2145 * null.
2146 * @param initialExtras An initial value for the result extras. Often
2147 * null.
2148 *
2149 * @see #sendBroadcast(Intent)
2150 * @see #sendBroadcast(Intent, String)
2151 * @see #sendOrderedBroadcast(Intent, String)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002152 * @see android.content.BroadcastReceiver
2153 * @see #registerReceiver
2154 * @see android.app.Activity#RESULT_OK
2155 */
Tor Norbye788fc2b2015-07-05 16:10:42 -07002156 public abstract void sendOrderedBroadcast(@RequiresPermission @NonNull Intent intent,
Dianne Hackborna750a632015-06-16 17:18:23 -07002157 @Nullable String receiverPermission, @Nullable BroadcastReceiver resultReceiver,
Tor Norbyed9273d62013-05-30 15:59:53 -07002158 @Nullable Handler scheduler, int initialCode, @Nullable String initialData,
2159 @Nullable Bundle initialExtras);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002160
2161 /**
Dianne Hackborna750a632015-06-16 17:18:23 -07002162 * Version of {@link #sendBroadcast(Intent)} that allows you to
2163 * receive data back from the broadcast. This is accomplished by
2164 * supplying your own BroadcastReceiver when calling, which will be
2165 * treated as a final receiver at the end of the broadcast -- its
2166 * {@link BroadcastReceiver#onReceive} method will be called with
2167 * the result values collected from the other receivers. The broadcast will
2168 * be serialized in the same way as calling
2169 * {@link #sendOrderedBroadcast(Intent, String)}.
2170 *
2171 * <p>Like {@link #sendBroadcast(Intent)}, this method is
2172 * asynchronous; it will return before
2173 * resultReceiver.onReceive() is called.
2174 *
2175 * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts.
2176 *
2177 *
2178 * @param intent The Intent to broadcast; all receivers matching this
2179 * Intent will receive the broadcast.
2180 * @param receiverPermission String naming a permissions that
2181 * a receiver must hold in order to receive your broadcast.
2182 * If null, no permission is required.
2183 * @param options (optional) Additional sending options, generated from a
2184 * {@link android.app.BroadcastOptions}.
2185 * @param resultReceiver Your own BroadcastReceiver to treat as the final
2186 * receiver of the broadcast.
2187 * @param scheduler A custom Handler with which to schedule the
2188 * resultReceiver callback; if null it will be
2189 * scheduled in the Context's main thread.
2190 * @param initialCode An initial value for the result code. Often
2191 * Activity.RESULT_OK.
2192 * @param initialData An initial value for the result data. Often
2193 * null.
2194 * @param initialExtras An initial value for the result extras. Often
2195 * null.
2196 * @see #sendBroadcast(Intent)
2197 * @see #sendBroadcast(Intent, String)
2198 * @see #sendOrderedBroadcast(Intent, String)
2199 * @see android.content.BroadcastReceiver
2200 * @see #registerReceiver
2201 * @see android.app.Activity#RESULT_OK
2202 * @hide
2203 */
2204 @SystemApi
2205 public abstract void sendOrderedBroadcast(@NonNull Intent intent,
2206 @Nullable String receiverPermission, @Nullable Bundle options,
2207 @Nullable BroadcastReceiver resultReceiver, @Nullable Handler scheduler,
2208 int initialCode, @Nullable String initialData, @Nullable Bundle initialExtras);
2209
2210 /**
Dianne Hackbornf51f6122013-02-04 18:23:34 -08002211 * Like {@link #sendOrderedBroadcast(Intent, String, BroadcastReceiver, android.os.Handler,
2212 * int, String, android.os.Bundle)}, but also allows specification
Tor Norbyed9273d62013-05-30 15:59:53 -07002213 * of an associated app op as per {@link android.app.AppOpsManager}.
Dianne Hackbornf51f6122013-02-04 18:23:34 -08002214 * @hide
2215 */
Mathew Inwood5c0d3542018-08-14 13:54:31 +01002216 @UnsupportedAppUsage
Dianne Hackbornf51f6122013-02-04 18:23:34 -08002217 public abstract void sendOrderedBroadcast(Intent intent,
2218 String receiverPermission, int appOp, BroadcastReceiver resultReceiver,
2219 Handler scheduler, int initialCode, String initialData,
2220 Bundle initialExtras);
2221
2222 /**
Dianne Hackborn8832c182012-09-17 17:20:24 -07002223 * Version of {@link #sendBroadcast(Intent)} that allows you to specify the
2224 * user the broadcast will be sent to. This is not available to applications
Jeff Sharkeyd86b8fe2017-06-02 17:36:26 -06002225 * that are not pre-installed on the system image.
Dianne Hackborn7d19e022012-08-07 19:12:33 -07002226 * @param intent The intent to broadcast
Dianne Hackborn79af1dd2012-08-16 16:42:52 -07002227 * @param user UserHandle to send the intent to.
Dianne Hackborn7d19e022012-08-07 19:12:33 -07002228 * @see #sendBroadcast(Intent)
2229 */
Jeff Sharkeyd86b8fe2017-06-02 17:36:26 -06002230 @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS)
Tor Norbye788fc2b2015-07-05 16:10:42 -07002231 public abstract void sendBroadcastAsUser(@RequiresPermission Intent intent,
2232 UserHandle user);
Dianne Hackborn7d19e022012-08-07 19:12:33 -07002233
2234 /**
Dianne Hackborn8832c182012-09-17 17:20:24 -07002235 * Version of {@link #sendBroadcast(Intent, String)} that allows you to specify the
2236 * user the broadcast will be sent to. This is not available to applications
Jeff Sharkeyd86b8fe2017-06-02 17:36:26 -06002237 * that are not pre-installed on the system image.
Dianne Hackborn5ac72a22012-08-29 18:32:08 -07002238 *
2239 * @param intent The Intent to broadcast; all receivers matching this
2240 * Intent will receive the broadcast.
2241 * @param user UserHandle to send the intent to.
2242 * @param receiverPermission (optional) String naming a permission that
2243 * a receiver must hold in order to receive your broadcast.
2244 * If null, no permission is required.
2245 *
2246 * @see #sendBroadcast(Intent, String)
2247 */
Jeff Sharkeyd86b8fe2017-06-02 17:36:26 -06002248 @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS)
Tor Norbye788fc2b2015-07-05 16:10:42 -07002249 public abstract void sendBroadcastAsUser(@RequiresPermission Intent intent,
2250 UserHandle user, @Nullable String receiverPermission);
Dianne Hackborn5ac72a22012-08-29 18:32:08 -07002251
Chad Brubaker52c8edc2016-07-25 14:30:26 -07002252 /**
2253 * Version of {@link #sendBroadcast(Intent, String, Bundle)} that allows you to specify the
2254 * user the broadcast will be sent to. This is not available to applications
Jeff Sharkeyd86b8fe2017-06-02 17:36:26 -06002255 * that are not pre-installed on the system image.
Chad Brubaker52c8edc2016-07-25 14:30:26 -07002256 *
2257 * @param intent The Intent to broadcast; all receivers matching this
2258 * Intent will receive the broadcast.
2259 * @param user UserHandle to send the intent to.
2260 * @param receiverPermission (optional) String naming a permission that
2261 * a receiver must hold in order to receive your broadcast.
2262 * If null, no permission is required.
2263 * @param options (optional) Additional sending options, generated from a
2264 * {@link android.app.BroadcastOptions}.
2265 *
2266 * @see #sendBroadcast(Intent, String, Bundle)
2267 * @hide
2268 */
2269 @SystemApi
Jeff Sharkeyd86b8fe2017-06-02 17:36:26 -06002270 @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS)
Chad Brubaker52c8edc2016-07-25 14:30:26 -07002271 public abstract void sendBroadcastAsUser(@RequiresPermission Intent intent,
2272 UserHandle user, @Nullable String receiverPermission, @Nullable Bundle options);
Svet Ganov16a16892015-04-16 10:32:04 -07002273
2274 /**
2275 * Version of {@link #sendBroadcast(Intent, String)} that allows you to specify the
2276 * user the broadcast will be sent to. This is not available to applications
Jeff Sharkeyd86b8fe2017-06-02 17:36:26 -06002277 * that are not pre-installed on the system image.
Svet Ganov16a16892015-04-16 10:32:04 -07002278 *
2279 * @param intent The Intent to broadcast; all receivers matching this
2280 * Intent will receive the broadcast.
2281 * @param user UserHandle to send the intent to.
2282 * @param receiverPermission (optional) String naming a permission that
2283 * a receiver must hold in order to receive your broadcast.
2284 * If null, no permission is required.
2285 * @param appOp The app op associated with the broadcast.
2286 *
2287 * @see #sendBroadcast(Intent, String)
2288 *
2289 * @hide
2290 */
Jeff Sharkeyd86b8fe2017-06-02 17:36:26 -06002291 @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS)
Mathew Inwood5c0d3542018-08-14 13:54:31 +01002292 @UnsupportedAppUsage
Tor Norbye788fc2b2015-07-05 16:10:42 -07002293 public abstract void sendBroadcastAsUser(@RequiresPermission Intent intent,
2294 UserHandle user, @Nullable String receiverPermission, int appOp);
Svet Ganov16a16892015-04-16 10:32:04 -07002295
Dianne Hackborn5ac72a22012-08-29 18:32:08 -07002296 /**
Dianne Hackborn8832c182012-09-17 17:20:24 -07002297 * Version of
2298 * {@link #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle)}
2299 * that allows you to specify the
2300 * user the broadcast will be sent to. This is not available to applications
Jeff Sharkeyd86b8fe2017-06-02 17:36:26 -06002301 * that are not pre-installed on the system image.
Dianne Hackborn7d19e022012-08-07 19:12:33 -07002302 *
2303 * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts.
2304 *
2305 * @param intent The Intent to broadcast; all receivers matching this
2306 * Intent will receive the broadcast.
Dianne Hackborn79af1dd2012-08-16 16:42:52 -07002307 * @param user UserHandle to send the intent to.
Dianne Hackborn5ac72a22012-08-29 18:32:08 -07002308 * @param receiverPermission String naming a permissions that
2309 * a receiver must hold in order to receive your broadcast.
2310 * If null, no permission is required.
Dianne Hackborn7d19e022012-08-07 19:12:33 -07002311 * @param resultReceiver Your own BroadcastReceiver to treat as the final
2312 * receiver of the broadcast.
2313 * @param scheduler A custom Handler with which to schedule the
2314 * resultReceiver callback; if null it will be
2315 * scheduled in the Context's main thread.
2316 * @param initialCode An initial value for the result code. Often
2317 * Activity.RESULT_OK.
2318 * @param initialData An initial value for the result data. Often
2319 * null.
2320 * @param initialExtras An initial value for the result extras. Often
2321 * null.
2322 *
2323 * @see #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle)
2324 */
Jeff Sharkeyd86b8fe2017-06-02 17:36:26 -06002325 @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS)
Tor Norbye788fc2b2015-07-05 16:10:42 -07002326 public abstract void sendOrderedBroadcastAsUser(@RequiresPermission Intent intent,
2327 UserHandle user, @Nullable String receiverPermission, BroadcastReceiver resultReceiver,
Tor Norbyed9273d62013-05-30 15:59:53 -07002328 @Nullable Handler scheduler, int initialCode, @Nullable String initialData,
2329 @Nullable Bundle initialExtras);
Dianne Hackborn7d19e022012-08-07 19:12:33 -07002330
2331 /**
Amith Yamasani3cf75722014-05-16 12:37:29 -07002332 * Similar to above but takes an appOp as well, to enforce restrictions.
2333 * @see #sendOrderedBroadcastAsUser(Intent, UserHandle, String,
2334 * BroadcastReceiver, Handler, int, String, Bundle)
2335 * @hide
2336 */
Jeff Sharkeyd86b8fe2017-06-02 17:36:26 -06002337 @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS)
Mathew Inwood5c0d3542018-08-14 13:54:31 +01002338 @UnsupportedAppUsage
Amith Yamasani3cf75722014-05-16 12:37:29 -07002339 public abstract void sendOrderedBroadcastAsUser(Intent intent, UserHandle user,
2340 @Nullable String receiverPermission, int appOp, BroadcastReceiver resultReceiver,
2341 @Nullable Handler scheduler, int initialCode, @Nullable String initialData,
2342 @Nullable Bundle initialExtras);
2343
2344 /**
Dianne Hackbornfd854ee2015-07-13 18:00:37 -07002345 * Similar to above but takes an appOp as well, to enforce restrictions, and an options Bundle.
2346 * @see #sendOrderedBroadcastAsUser(Intent, UserHandle, String,
2347 * BroadcastReceiver, Handler, int, String, Bundle)
2348 * @hide
2349 */
Jeff Sharkeyd86b8fe2017-06-02 17:36:26 -06002350 @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS)
Mathew Inwood5c0d3542018-08-14 13:54:31 +01002351 @UnsupportedAppUsage
Dianne Hackbornfd854ee2015-07-13 18:00:37 -07002352 public abstract void sendOrderedBroadcastAsUser(Intent intent, UserHandle user,
2353 @Nullable String receiverPermission, int appOp, @Nullable Bundle options,
2354 BroadcastReceiver resultReceiver, @Nullable Handler scheduler, int initialCode,
2355 @Nullable String initialData, @Nullable Bundle initialExtras);
2356
2357 /**
Dianne Hackborn2c353002014-08-29 15:13:30 -07002358 * <p>Perform a {@link #sendBroadcast(Intent)} that is "sticky," meaning the
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002359 * Intent you are sending stays around after the broadcast is complete,
2360 * so that others can quickly retrieve that data through the return
2361 * value of {@link #registerReceiver(BroadcastReceiver, IntentFilter)}. In
2362 * all other ways, this behaves the same as
2363 * {@link #sendBroadcast(Intent)}.
2364 *
Dianne Hackborn2c353002014-08-29 15:13:30 -07002365 * @deprecated Sticky broadcasts should not be used. They provide no security (anyone
2366 * can access them), no protection (anyone can modify them), and many other problems.
2367 * The recommended pattern is to use a non-sticky broadcast to report that <em>something</em>
2368 * has changed, with another mechanism for apps to retrieve the current value whenever
2369 * desired.
2370 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002371 * @param intent The Intent to broadcast; all receivers matching this
2372 * Intent will receive the broadcast, and the Intent will be held to
2373 * be re-broadcast to future receivers.
2374 *
2375 * @see #sendBroadcast(Intent)
Dianne Hackbornefa199f2009-09-19 12:03:15 -07002376 * @see #sendStickyOrderedBroadcast(Intent, BroadcastReceiver, Handler, int, String, Bundle)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002377 */
Dianne Hackborn2c353002014-08-29 15:13:30 -07002378 @Deprecated
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06002379 @RequiresPermission(android.Manifest.permission.BROADCAST_STICKY)
Tor Norbye788fc2b2015-07-05 16:10:42 -07002380 public abstract void sendStickyBroadcast(@RequiresPermission Intent intent);
Scott Main4b5da682010-10-21 11:49:12 -07002381
Dianne Hackbornefa199f2009-09-19 12:03:15 -07002382 /**
Dianne Hackborn2c353002014-08-29 15:13:30 -07002383 * <p>Version of {@link #sendStickyBroadcast} that allows you to
Dianne Hackbornefa199f2009-09-19 12:03:15 -07002384 * receive data back from the broadcast. This is accomplished by
2385 * supplying your own BroadcastReceiver when calling, which will be
2386 * treated as a final receiver at the end of the broadcast -- its
2387 * {@link BroadcastReceiver#onReceive} method will be called with
2388 * the result values collected from the other receivers. The broadcast will
2389 * be serialized in the same way as calling
2390 * {@link #sendOrderedBroadcast(Intent, String)}.
2391 *
2392 * <p>Like {@link #sendBroadcast(Intent)}, this method is
2393 * asynchronous; it will return before
2394 * resultReceiver.onReceive() is called. Note that the sticky data
2395 * stored is only the data you initially supply to the broadcast, not
2396 * the result of any changes made by the receivers.
2397 *
2398 * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts.
2399 *
Dianne Hackborn2c353002014-08-29 15:13:30 -07002400 * @deprecated Sticky broadcasts should not be used. They provide no security (anyone
2401 * can access them), no protection (anyone can modify them), and many other problems.
2402 * The recommended pattern is to use a non-sticky broadcast to report that <em>something</em>
2403 * has changed, with another mechanism for apps to retrieve the current value whenever
2404 * desired.
2405 *
Dianne Hackbornefa199f2009-09-19 12:03:15 -07002406 * @param intent The Intent to broadcast; all receivers matching this
2407 * Intent will receive the broadcast.
2408 * @param resultReceiver Your own BroadcastReceiver to treat as the final
2409 * receiver of the broadcast.
2410 * @param scheduler A custom Handler with which to schedule the
2411 * resultReceiver callback; if null it will be
2412 * scheduled in the Context's main thread.
2413 * @param initialCode An initial value for the result code. Often
2414 * Activity.RESULT_OK.
2415 * @param initialData An initial value for the result data. Often
2416 * null.
2417 * @param initialExtras An initial value for the result extras. Often
2418 * null.
2419 *
2420 * @see #sendBroadcast(Intent)
2421 * @see #sendBroadcast(Intent, String)
2422 * @see #sendOrderedBroadcast(Intent, String)
2423 * @see #sendStickyBroadcast(Intent)
2424 * @see android.content.BroadcastReceiver
2425 * @see #registerReceiver
2426 * @see android.app.Activity#RESULT_OK
2427 */
Dianne Hackborn2c353002014-08-29 15:13:30 -07002428 @Deprecated
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06002429 @RequiresPermission(android.Manifest.permission.BROADCAST_STICKY)
Tor Norbye788fc2b2015-07-05 16:10:42 -07002430 public abstract void sendStickyOrderedBroadcast(@RequiresPermission Intent intent,
Dianne Hackbornefa199f2009-09-19 12:03:15 -07002431 BroadcastReceiver resultReceiver,
Tor Norbyed9273d62013-05-30 15:59:53 -07002432 @Nullable Handler scheduler, int initialCode, @Nullable String initialData,
2433 @Nullable Bundle initialExtras);
Dianne Hackbornefa199f2009-09-19 12:03:15 -07002434
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002435 /**
Dianne Hackborn2c353002014-08-29 15:13:30 -07002436 * <p>Remove the data previously sent with {@link #sendStickyBroadcast},
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002437 * so that it is as if the sticky broadcast had never happened.
2438 *
Dianne Hackborn2c353002014-08-29 15:13:30 -07002439 * @deprecated Sticky broadcasts should not be used. They provide no security (anyone
2440 * can access them), no protection (anyone can modify them), and many other problems.
2441 * The recommended pattern is to use a non-sticky broadcast to report that <em>something</em>
2442 * has changed, with another mechanism for apps to retrieve the current value whenever
2443 * desired.
2444 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002445 * @param intent The Intent that was previously broadcast.
2446 *
2447 * @see #sendStickyBroadcast
2448 */
Dianne Hackborn2c353002014-08-29 15:13:30 -07002449 @Deprecated
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06002450 @RequiresPermission(android.Manifest.permission.BROADCAST_STICKY)
Tor Norbye788fc2b2015-07-05 16:10:42 -07002451 public abstract void removeStickyBroadcast(@RequiresPermission Intent intent);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002452
2453 /**
Dianne Hackborn2c353002014-08-29 15:13:30 -07002454 * <p>Version of {@link #sendStickyBroadcast(Intent)} that allows you to specify the
Dianne Hackborn8832c182012-09-17 17:20:24 -07002455 * user the broadcast will be sent to. This is not available to applications
Jeff Sharkeyd86b8fe2017-06-02 17:36:26 -06002456 * that are not pre-installed on the system image.
Dianne Hackborn5ac72a22012-08-29 18:32:08 -07002457 *
Dianne Hackborn2c353002014-08-29 15:13:30 -07002458 * @deprecated Sticky broadcasts should not be used. They provide no security (anyone
2459 * can access them), no protection (anyone can modify them), and many other problems.
2460 * The recommended pattern is to use a non-sticky broadcast to report that <em>something</em>
2461 * has changed, with another mechanism for apps to retrieve the current value whenever
2462 * desired.
2463 *
Dianne Hackborn5ac72a22012-08-29 18:32:08 -07002464 * @param intent The Intent to broadcast; all receivers matching this
2465 * Intent will receive the broadcast, and the Intent will be held to
2466 * be re-broadcast to future receivers.
2467 * @param user UserHandle to send the intent to.
2468 *
2469 * @see #sendBroadcast(Intent)
2470 */
Dianne Hackborn2c353002014-08-29 15:13:30 -07002471 @Deprecated
Jeff Sharkeyd86b8fe2017-06-02 17:36:26 -06002472 @RequiresPermission(allOf = {
2473 android.Manifest.permission.INTERACT_ACROSS_USERS,
2474 android.Manifest.permission.BROADCAST_STICKY
2475 })
Tor Norbye788fc2b2015-07-05 16:10:42 -07002476 public abstract void sendStickyBroadcastAsUser(@RequiresPermission Intent intent,
2477 UserHandle user);
Dianne Hackborn5ac72a22012-08-29 18:32:08 -07002478
2479 /**
Dianne Hackborne0e413e2015-12-09 17:22:26 -08002480 * @hide
2481 * This is just here for sending CONNECTIVITY_ACTION.
2482 */
2483 @Deprecated
Jeff Sharkeyd86b8fe2017-06-02 17:36:26 -06002484 @RequiresPermission(allOf = {
2485 android.Manifest.permission.INTERACT_ACROSS_USERS,
2486 android.Manifest.permission.BROADCAST_STICKY
2487 })
Dianne Hackborne0e413e2015-12-09 17:22:26 -08002488 public abstract void sendStickyBroadcastAsUser(@RequiresPermission Intent intent,
2489 UserHandle user, Bundle options);
2490
2491 /**
Dianne Hackborn2c353002014-08-29 15:13:30 -07002492 * <p>Version of
Dianne Hackborn8832c182012-09-17 17:20:24 -07002493 * {@link #sendStickyOrderedBroadcast(Intent, BroadcastReceiver, Handler, int, String, Bundle)}
2494 * that allows you to specify the
2495 * user the broadcast will be sent to. This is not available to applications
Jeff Sharkeyd86b8fe2017-06-02 17:36:26 -06002496 * that are not pre-installed on the system image.
Dianne Hackborn5ac72a22012-08-29 18:32:08 -07002497 *
2498 * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts.
2499 *
Dianne Hackborn2c353002014-08-29 15:13:30 -07002500 * @deprecated Sticky broadcasts should not be used. They provide no security (anyone
2501 * can access them), no protection (anyone can modify them), and many other problems.
2502 * The recommended pattern is to use a non-sticky broadcast to report that <em>something</em>
2503 * has changed, with another mechanism for apps to retrieve the current value whenever
2504 * desired.
2505 *
Dianne Hackborn5ac72a22012-08-29 18:32:08 -07002506 * @param intent The Intent to broadcast; all receivers matching this
2507 * Intent will receive the broadcast.
2508 * @param user UserHandle to send the intent to.
2509 * @param resultReceiver Your own BroadcastReceiver to treat as the final
2510 * receiver of the broadcast.
2511 * @param scheduler A custom Handler with which to schedule the
2512 * resultReceiver callback; if null it will be
2513 * scheduled in the Context's main thread.
2514 * @param initialCode An initial value for the result code. Often
2515 * Activity.RESULT_OK.
2516 * @param initialData An initial value for the result data. Often
2517 * null.
2518 * @param initialExtras An initial value for the result extras. Often
2519 * null.
2520 *
2521 * @see #sendStickyOrderedBroadcast(Intent, BroadcastReceiver, Handler, int, String, Bundle)
2522 */
Dianne Hackborn2c353002014-08-29 15:13:30 -07002523 @Deprecated
Jeff Sharkeyd86b8fe2017-06-02 17:36:26 -06002524 @RequiresPermission(allOf = {
2525 android.Manifest.permission.INTERACT_ACROSS_USERS,
2526 android.Manifest.permission.BROADCAST_STICKY
2527 })
Tor Norbye788fc2b2015-07-05 16:10:42 -07002528 public abstract void sendStickyOrderedBroadcastAsUser(@RequiresPermission Intent intent,
Dianne Hackborn5ac72a22012-08-29 18:32:08 -07002529 UserHandle user, BroadcastReceiver resultReceiver,
Tor Norbyed9273d62013-05-30 15:59:53 -07002530 @Nullable Handler scheduler, int initialCode, @Nullable String initialData,
2531 @Nullable Bundle initialExtras);
Dianne Hackborn5ac72a22012-08-29 18:32:08 -07002532
2533 /**
Dianne Hackborn2c353002014-08-29 15:13:30 -07002534 * <p>Version of {@link #removeStickyBroadcast(Intent)} that allows you to specify the
Dianne Hackborn8832c182012-09-17 17:20:24 -07002535 * user the broadcast will be sent to. This is not available to applications
Jeff Sharkeyd86b8fe2017-06-02 17:36:26 -06002536 * that are not pre-installed on the system image.
Dianne Hackborn5ac72a22012-08-29 18:32:08 -07002537 *
2538 * <p>You must hold the {@link android.Manifest.permission#BROADCAST_STICKY}
2539 * permission in order to use this API. If you do not hold that
2540 * permission, {@link SecurityException} will be thrown.
2541 *
Dianne Hackborn2c353002014-08-29 15:13:30 -07002542 * @deprecated Sticky broadcasts should not be used. They provide no security (anyone
2543 * can access them), no protection (anyone can modify them), and many other problems.
2544 * The recommended pattern is to use a non-sticky broadcast to report that <em>something</em>
2545 * has changed, with another mechanism for apps to retrieve the current value whenever
2546 * desired.
2547 *
Dianne Hackborn5ac72a22012-08-29 18:32:08 -07002548 * @param intent The Intent that was previously broadcast.
2549 * @param user UserHandle to remove the sticky broadcast from.
2550 *
2551 * @see #sendStickyBroadcastAsUser
2552 */
Dianne Hackborn2c353002014-08-29 15:13:30 -07002553 @Deprecated
Jeff Sharkeyd86b8fe2017-06-02 17:36:26 -06002554 @RequiresPermission(allOf = {
2555 android.Manifest.permission.INTERACT_ACROSS_USERS,
2556 android.Manifest.permission.BROADCAST_STICKY
2557 })
Tor Norbye788fc2b2015-07-05 16:10:42 -07002558 public abstract void removeStickyBroadcastAsUser(@RequiresPermission Intent intent,
2559 UserHandle user);
Dianne Hackborn5ac72a22012-08-29 18:32:08 -07002560
2561 /**
Chris Tatea34df8a22009-04-02 23:15:58 -07002562 * Register a BroadcastReceiver to be run in the main activity thread. The
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002563 * <var>receiver</var> will be called with any broadcast Intent that
2564 * matches <var>filter</var>, in the main application thread.
2565 *
2566 * <p>The system may broadcast Intents that are "sticky" -- these stay
Kweku Adams86f39a42016-11-16 12:50:38 -08002567 * around after the broadcast has finished, to be sent to any later
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002568 * registrations. If your IntentFilter matches one of these sticky
2569 * Intents, that Intent will be returned by this function
2570 * <strong>and</strong> sent to your <var>receiver</var> as if it had just
2571 * been broadcast.
2572 *
2573 * <p>There may be multiple sticky Intents that match <var>filter</var>,
2574 * in which case each of these will be sent to <var>receiver</var>. In
2575 * this case, only one of these can be returned directly by the function;
2576 * which of these that is returned is arbitrarily decided by the system.
2577 *
2578 * <p>If you know the Intent your are registering for is sticky, you can
2579 * supply null for your <var>receiver</var>. In this case, no receiver is
2580 * registered -- the function simply returns the sticky Intent that
2581 * matches <var>filter</var>. In the case of multiple matches, the same
2582 * rules as described above apply.
2583 *
2584 * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts.
2585 *
Dianne Hackborn6c418d52011-06-29 14:05:33 -07002586 * <p>As of {@link android.os.Build.VERSION_CODES#ICE_CREAM_SANDWICH}, receivers
2587 * registered with this method will correctly respect the
2588 * {@link Intent#setPackage(String)} specified for an Intent being broadcast.
2589 * Prior to that, it would be ignored and delivered to all matching registered
2590 * receivers. Be careful if using this for security.</p>
2591 *
Chris Tatea34df8a22009-04-02 23:15:58 -07002592 * <p class="note">Note: this method <em>cannot be called from a
2593 * {@link BroadcastReceiver} component;</em> that is, from a BroadcastReceiver
2594 * that is declared in an application's manifest. It is okay, however, to call
2595 * this method from another BroadcastReceiver that has itself been registered
2596 * at run time with {@link #registerReceiver}, since the lifetime of such a
2597 * registered BroadcastReceiver is tied to the object that registered it.</p>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002598 *
2599 * @param receiver The BroadcastReceiver to handle the broadcast.
2600 * @param filter Selects the Intent broadcasts to be received.
2601 *
2602 * @return The first sticky intent found that matches <var>filter</var>,
2603 * or null if there are none.
2604 *
2605 * @see #registerReceiver(BroadcastReceiver, IntentFilter, String, Handler)
2606 * @see #sendBroadcast
2607 * @see #unregisterReceiver
2608 */
Tor Norbyed9273d62013-05-30 15:59:53 -07002609 @Nullable
2610 public abstract Intent registerReceiver(@Nullable BroadcastReceiver receiver,
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002611 IntentFilter filter);
2612
2613 /**
Chad Brubaker816c83b2017-03-02 10:27:59 -08002614 * Register to receive intent broadcasts, with the receiver optionally being
2615 * exposed to Instant Apps. See
2616 * {@link #registerReceiver(BroadcastReceiver, IntentFilter)} for more
2617 * information. By default Instant Apps cannot interact with receivers in other
2618 * applications, this allows you to expose a receiver that Instant Apps can
2619 * interact with.
2620 *
2621 * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts.
2622 *
2623 * <p>As of {@link android.os.Build.VERSION_CODES#ICE_CREAM_SANDWICH}, receivers
2624 * registered with this method will correctly respect the
2625 * {@link Intent#setPackage(String)} specified for an Intent being broadcast.
2626 * Prior to that, it would be ignored and delivered to all matching registered
2627 * receivers. Be careful if using this for security.</p>
2628 *
2629 * @param receiver The BroadcastReceiver to handle the broadcast.
2630 * @param filter Selects the Intent broadcasts to be received.
Chad Brubaker6d6015f2017-04-18 11:25:16 -07002631 * @param flags Additional options for the receiver. May be 0 or
2632 * {@link #RECEIVER_VISIBLE_TO_INSTANT_APPS}.
Chad Brubaker816c83b2017-03-02 10:27:59 -08002633 *
2634 * @return The first sticky intent found that matches <var>filter</var>,
2635 * or null if there are none.
2636 *
2637 * @see #registerReceiver(BroadcastReceiver, IntentFilter)
2638 * @see #sendBroadcast
2639 * @see #unregisterReceiver
2640 */
2641 @Nullable
2642 public abstract Intent registerReceiver(@Nullable BroadcastReceiver receiver,
2643 IntentFilter filter,
Chad Brubaker6d6015f2017-04-18 11:25:16 -07002644 @RegisterReceiverFlags int flags);
Chad Brubaker816c83b2017-03-02 10:27:59 -08002645
2646 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002647 * Register to receive intent broadcasts, to run in the context of
2648 * <var>scheduler</var>. See
2649 * {@link #registerReceiver(BroadcastReceiver, IntentFilter)} for more
2650 * information. This allows you to enforce permissions on who can
2651 * broadcast intents to your receiver, or have the receiver run in
2652 * a different thread than the main application thread.
2653 *
2654 * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts.
2655 *
Dianne Hackborn6c418d52011-06-29 14:05:33 -07002656 * <p>As of {@link android.os.Build.VERSION_CODES#ICE_CREAM_SANDWICH}, receivers
2657 * registered with this method will correctly respect the
2658 * {@link Intent#setPackage(String)} specified for an Intent being broadcast.
2659 * Prior to that, it would be ignored and delivered to all matching registered
2660 * receivers. Be careful if using this for security.</p>
2661 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002662 * @param receiver The BroadcastReceiver to handle the broadcast.
2663 * @param filter Selects the Intent broadcasts to be received.
2664 * @param broadcastPermission String naming a permissions that a
2665 * broadcaster must hold in order to send an Intent to you. If null,
2666 * no permission is required.
2667 * @param scheduler Handler identifying the thread that will receive
2668 * the Intent. If null, the main thread of the process will be used.
2669 *
2670 * @return The first sticky intent found that matches <var>filter</var>,
2671 * or null if there are none.
2672 *
2673 * @see #registerReceiver(BroadcastReceiver, IntentFilter)
2674 * @see #sendBroadcast
2675 * @see #unregisterReceiver
2676 */
Tor Norbyed9273d62013-05-30 15:59:53 -07002677 @Nullable
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002678 public abstract Intent registerReceiver(BroadcastReceiver receiver,
Tor Norbyed9273d62013-05-30 15:59:53 -07002679 IntentFilter filter, @Nullable String broadcastPermission,
2680 @Nullable Handler scheduler);
Dianne Hackborn20e80982012-08-31 19:00:44 -07002681
2682 /**
Chad Brubaker6d6015f2017-04-18 11:25:16 -07002683 * Register to receive intent broadcasts, to run in the context of
2684 * <var>scheduler</var>. See
2685 * {@link #registerReceiver(BroadcastReceiver, IntentFilter, int)} and
Chad Brubaker816c83b2017-03-02 10:27:59 -08002686 * {@link #registerReceiver(BroadcastReceiver, IntentFilter, String, Handler)}
2687 * for more information.
2688 *
2689 * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts.
2690 *
2691 * <p>As of {@link android.os.Build.VERSION_CODES#ICE_CREAM_SANDWICH}, receivers
2692 * registered with this method will correctly respect the
2693 * {@link Intent#setPackage(String)} specified for an Intent being broadcast.
2694 * Prior to that, it would be ignored and delivered to all matching registered
2695 * receivers. Be careful if using this for security.</p>
2696 *
2697 * @param receiver The BroadcastReceiver to handle the broadcast.
2698 * @param filter Selects the Intent broadcasts to be received.
2699 * @param broadcastPermission String naming a permissions that a
2700 * broadcaster must hold in order to send an Intent to you. If null,
2701 * no permission is required.
2702 * @param scheduler Handler identifying the thread that will receive
2703 * the Intent. If null, the main thread of the process will be used.
Chad Brubaker6d6015f2017-04-18 11:25:16 -07002704 * @param flags Additional options for the receiver. May be 0 or
2705 * {@link #RECEIVER_VISIBLE_TO_INSTANT_APPS}.
Chad Brubaker816c83b2017-03-02 10:27:59 -08002706 *
2707 * @return The first sticky intent found that matches <var>filter</var>,
2708 * or null if there are none.
2709 *
Chad Brubaker6d6015f2017-04-18 11:25:16 -07002710 * @see #registerReceiver(BroadcastReceiver, IntentFilter, int)
Chad Brubaker816c83b2017-03-02 10:27:59 -08002711 * @see #registerReceiver(BroadcastReceiver, IntentFilter, String, Handler)
2712 * @see #sendBroadcast
2713 * @see #unregisterReceiver
2714 */
2715 @Nullable
2716 public abstract Intent registerReceiver(BroadcastReceiver receiver,
2717 IntentFilter filter, @Nullable String broadcastPermission,
Chad Brubaker6d6015f2017-04-18 11:25:16 -07002718 @Nullable Handler scheduler, @RegisterReceiverFlags int flags);
Chad Brubaker816c83b2017-03-02 10:27:59 -08002719
2720 /**
Dianne Hackborn20e80982012-08-31 19:00:44 -07002721 * @hide
2722 * Same as {@link #registerReceiver(BroadcastReceiver, IntentFilter, String, Handler)
2723 * but for a specific user. This receiver will receiver broadcasts that
Jeff Sharkeyd86b8fe2017-06-02 17:36:26 -06002724 * are sent to the requested user.
Dianne Hackborn20e80982012-08-31 19:00:44 -07002725 *
2726 * @param receiver The BroadcastReceiver to handle the broadcast.
2727 * @param user UserHandle to send the intent to.
2728 * @param filter Selects the Intent broadcasts to be received.
2729 * @param broadcastPermission String naming a permissions that a
2730 * broadcaster must hold in order to send an Intent to you. If null,
2731 * no permission is required.
2732 * @param scheduler Handler identifying the thread that will receive
2733 * the Intent. If null, the main thread of the process will be used.
2734 *
2735 * @return The first sticky intent found that matches <var>filter</var>,
2736 * or null if there are none.
2737 *
Jeff Brown6e539312015-02-24 18:53:21 -08002738 * @see #registerReceiver(BroadcastReceiver, IntentFilter, String, Handler)
Dianne Hackborn20e80982012-08-31 19:00:44 -07002739 * @see #sendBroadcast
2740 * @see #unregisterReceiver
2741 */
Tor Norbyed9273d62013-05-30 15:59:53 -07002742 @Nullable
Jeff Sharkeyd86b8fe2017-06-02 17:36:26 -06002743 @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS_FULL)
Mathew Inwood5c0d3542018-08-14 13:54:31 +01002744 @UnsupportedAppUsage
Dianne Hackborn20e80982012-08-31 19:00:44 -07002745 public abstract Intent registerReceiverAsUser(BroadcastReceiver receiver,
Tor Norbyed9273d62013-05-30 15:59:53 -07002746 UserHandle user, IntentFilter filter, @Nullable String broadcastPermission,
2747 @Nullable Handler scheduler);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002748
2749 /**
2750 * Unregister a previously registered BroadcastReceiver. <em>All</em>
2751 * filters that have been registered for this BroadcastReceiver will be
2752 * removed.
2753 *
2754 * @param receiver The BroadcastReceiver to unregister.
2755 *
2756 * @see #registerReceiver
2757 */
2758 public abstract void unregisterReceiver(BroadcastReceiver receiver);
2759
2760 /**
2761 * Request that a given application service be started. The Intent
Hans Boehmfb9f6ac2016-05-05 13:09:28 -07002762 * should either contain the complete class name of a specific service
2763 * implementation to start, or a specific package name to target. If the
2764 * Intent is less specified, it logs a warning about this. In this case any of the
2765 * multiple matching services may be used. If this service
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002766 * is not already running, it will be instantiated and started (creating a
2767 * process for it if needed); if it is running then it remains running.
2768 *
2769 * <p>Every call to this method will result in a corresponding call to
Scott Main4b5da682010-10-21 11:49:12 -07002770 * the target service's {@link android.app.Service#onStartCommand} method,
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002771 * with the <var>intent</var> given here. This provides a convenient way
2772 * to submit jobs to a service without having to bind and call on to its
2773 * interface.
2774 *
2775 * <p>Using startService() overrides the default service lifetime that is
2776 * managed by {@link #bindService}: it requires the service to remain
2777 * running until {@link #stopService} is called, regardless of whether
2778 * any clients are connected to it. Note that calls to startService()
Hans Boehmfb9f6ac2016-05-05 13:09:28 -07002779 * do not nest: no matter how many times you call startService(),
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002780 * a single call to {@link #stopService} will stop it.
2781 *
2782 * <p>The system attempts to keep running services around as much as
2783 * possible. The only time they should be stopped is if the current
2784 * foreground application is using so many resources that the service needs
2785 * to be killed. If any errors happen in the service's process, it will
2786 * automatically be restarted.
2787 *
2788 * <p>This function will throw {@link SecurityException} if you do not
2789 * have permission to start the given service.
2790 *
Chris Craik1e353522016-04-18 10:20:50 -07002791 * <p class="note"><strong>Note:</strong> Each call to startService()
2792 * results in significant work done by the system to manage service
2793 * lifecycle surrounding the processing of the intent, which can take
2794 * multiple milliseconds of CPU time. Due to this cost, startService()
2795 * should not be used for frequent intent delivery to a service, and only
2796 * for scheduling significant work. Use {@link #bindService bound services}
2797 * for high frequency calls.
2798 * </p>
2799 *
Mark Lu94ebbe02016-12-13 16:29:51 -08002800 * @param service Identifies the service to be started. The Intent must be
2801 * fully explicit (supplying a component name). Additional values
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002802 * may be included in the Intent extras to supply arguments along with
2803 * this specific start call.
2804 *
2805 * @return If the service is being started or is already running, the
2806 * {@link ComponentName} of the actual service that was started is
2807 * returned; else if the service does not exist null is returned.
2808 *
Christopher Tate08992ac2017-03-21 11:37:06 -07002809 * @throws SecurityException If the caller does not have permission to access the service
Dianne Hackborn85e35642017-01-12 15:10:57 -08002810 * or the service can not be found.
2811 * @throws IllegalStateException If the application is in a state where the service
2812 * can not be started (such as not in the foreground in a state when services are allowed).
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002813 *
2814 * @see #stopService
2815 * @see #bindService
2816 */
Tor Norbyed9273d62013-05-30 15:59:53 -07002817 @Nullable
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002818 public abstract ComponentName startService(Intent service);
2819
2820 /**
Christopher Tate08992ac2017-03-21 11:37:06 -07002821 * Similar to {@link #startService(Intent)}, but with an implicit promise that the
Neil Fullerfe6ec562017-03-16 18:29:36 +00002822 * Service will call {@link android.app.Service#startForeground(int, android.app.Notification)
2823 * startForeground(int, android.app.Notification)} once it begins running. The service is given
Christopher Tate08992ac2017-03-21 11:37:06 -07002824 * an amount of time comparable to the ANR interval to do this, otherwise the system
2825 * will automatically stop the service and declare the app ANR.
2826 *
2827 * <p>Unlike the ordinary {@link #startService(Intent)}, this method can be used
2828 * at any time, regardless of whether the app hosting the service is in a foreground
2829 * state.
2830 *
2831 * @param service Identifies the service to be started. The Intent must be
2832 * fully explicit (supplying a component name). Additional values
2833 * may be included in the Intent extras to supply arguments along with
2834 * this specific start call.
2835 *
2836 * @return If the service is being started or is already running, the
2837 * {@link ComponentName} of the actual service that was started is
2838 * returned; else if the service does not exist null is returned.
2839 *
2840 * @throws SecurityException If the caller does not have permission to access the service
2841 * or the service can not be found.
2842 *
2843 * @see #stopService
Neil Fullerfe6ec562017-03-16 18:29:36 +00002844 * @see android.app.Service#startForeground(int, android.app.Notification)
Christopher Tate08992ac2017-03-21 11:37:06 -07002845 */
2846 @Nullable
2847 public abstract ComponentName startForegroundService(Intent service);
2848
2849 /**
2850 * @hide like {@link #startForegroundService(Intent)} but for a specific user.
2851 */
2852 @Nullable
Jeff Sharkeyd86b8fe2017-06-02 17:36:26 -06002853 @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS)
Christopher Tate08992ac2017-03-21 11:37:06 -07002854 public abstract ComponentName startForegroundServiceAsUser(Intent service, UserHandle user);
2855
2856 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002857 * Request that a given application service be stopped. If the service is
2858 * not running, nothing happens. Otherwise it is stopped. Note that calls
2859 * to startService() are not counted -- this stops the service no matter
2860 * how many times it was started.
2861 *
2862 * <p>Note that if a stopped service still has {@link ServiceConnection}
2863 * objects bound to it with the {@link #BIND_AUTO_CREATE} set, it will
2864 * not be destroyed until all of these bindings are removed. See
2865 * the {@link android.app.Service} documentation for more details on a
2866 * service's lifecycle.
2867 *
2868 * <p>This function will throw {@link SecurityException} if you do not
2869 * have permission to stop the given service.
2870 *
Dianne Hackborn221ea892013-08-04 16:50:16 -07002871 * @param service Description of the service to be stopped. The Intent must be either
2872 * fully explicit (supplying a component name) or specify a specific package
kopriva219f7dc2018-10-09 13:42:28 -07002873 * name it is targeted to.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002874 *
2875 * @return If there is a service matching the given Intent that is already
John Spurlock6098c5d2013-06-17 10:32:46 -04002876 * running, then it is stopped and {@code true} is returned; else {@code false} is returned.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002877 *
Christopher Tate08992ac2017-03-21 11:37:06 -07002878 * @throws SecurityException If the caller does not have permission to access the service
Dianne Hackborn85e35642017-01-12 15:10:57 -08002879 * or the service can not be found.
2880 * @throws IllegalStateException If the application is in a state where the service
2881 * can not be started (such as not in the foreground in a state when services are allowed).
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002882 *
2883 * @see #startService
2884 */
2885 public abstract boolean stopService(Intent service);
2886
2887 /**
Dianne Hackborn7767eac2012-08-23 18:25:40 -07002888 * @hide like {@link #startService(Intent)} but for a specific user.
2889 */
Christopher Tate42a386b2016-11-07 12:21:21 -08002890 @Nullable
Jeff Sharkeyd86b8fe2017-06-02 17:36:26 -06002891 @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS)
Mathew Inwood5c0d3542018-08-14 13:54:31 +01002892 @UnsupportedAppUsage
Dianne Hackborn7767eac2012-08-23 18:25:40 -07002893 public abstract ComponentName startServiceAsUser(Intent service, UserHandle user);
2894
2895 /**
2896 * @hide like {@link #stopService(Intent)} but for a specific user.
2897 */
Jeff Sharkeyd86b8fe2017-06-02 17:36:26 -06002898 @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS)
Dianne Hackborn7767eac2012-08-23 18:25:40 -07002899 public abstract boolean stopServiceAsUser(Intent service, UserHandle user);
RoboErik01fe6612014-02-13 14:19:04 -08002900
Dianne Hackborn7767eac2012-08-23 18:25:40 -07002901 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002902 * Connect to an application service, creating it if needed. This defines
2903 * a dependency between your application and the service. The given
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002904 * <var>conn</var> will receive the service object when it is created and be
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002905 * told if it dies and restarts. The service will be considered required
2906 * by the system only for as long as the calling context exists. For
2907 * example, if this Context is an Activity that is stopped, the service will
2908 * not be required to continue running until the Activity is resumed.
2909 *
Christopher Tate5d73b6d2017-10-06 16:15:34 -07002910 * <p>If the service does not support binding, it may return {@code null} from
2911 * its {@link android.app.Service#onBind(Intent) onBind()} method. If it does, then
2912 * the ServiceConnection's
2913 * {@link ServiceConnection#onNullBinding(ComponentName) onNullBinding()} method
2914 * will be invoked instead of
2915 * {@link ServiceConnection#onServiceConnected(ComponentName, IBinder) onServiceConnected()}.
2916 *
2917 * <p>This method will throw {@link SecurityException} if the calling app does not
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002918 * have permission to bind to the given service.
2919 *
Christopher Tate5d73b6d2017-10-06 16:15:34 -07002920 * <p class="note">Note: this method <em>cannot be called from a
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002921 * {@link BroadcastReceiver} component</em>. A pattern you can use to
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002922 * communicate from a BroadcastReceiver to a Service is to call
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002923 * {@link #startService} with the arguments containing the command to be
2924 * sent, with the service calling its
2925 * {@link android.app.Service#stopSelf(int)} method when done executing
2926 * that command. See the API demo App/Service/Service Start Arguments
2927 * Controller for an illustration of this. It is okay, however, to use
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002928 * this method from a BroadcastReceiver that has been registered with
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002929 * {@link #registerReceiver}, since the lifetime of this BroadcastReceiver
2930 * is tied to another object (the one that registered it).</p>
2931 *
Mark Lu94ebbe02016-12-13 16:29:51 -08002932 * @param service Identifies the service to connect to. The Intent must
2933 * specify an explicit component name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002934 * @param conn Receives information as the service is started and stopped.
Christopher Tate79b33172012-06-18 14:54:21 -07002935 * This must be a valid ServiceConnection object; it must not be null.
Scott Main4b5da682010-10-21 11:49:12 -07002936 * @param flags Operation options for the binding. May be 0,
Dianne Hackbornc68c9132011-07-29 01:25:18 -07002937 * {@link #BIND_AUTO_CREATE}, {@link #BIND_DEBUG_UNBIND},
2938 * {@link #BIND_NOT_FOREGROUND}, {@link #BIND_ABOVE_CLIENT},
Dianne Hackborn27b4d942018-11-12 15:01:40 -08002939 * {@link #BIND_ALLOW_OOM_MANAGEMENT}, {@link #BIND_WAIVE_PRIORITY}.
2940 * {@link #BIND_IMPORTANT}, or
2941 * {@link #BIND_ADJUST_WITH_ACTIVITY}.
Kevin Hufnagle34acbc9b2017-06-29 15:58:48 -07002942 * @return {@code true} if the system is in the process of bringing up a
2943 * service that your client has permission to bind to; {@code false}
2944 * if the system couldn't find the service or if your client doesn't
2945 * have permission to bind to it. If this value is {@code true}, you
2946 * should later call {@link #unbindService} to release the
2947 * connection.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002948 *
Christopher Tate08992ac2017-03-21 11:37:06 -07002949 * @throws SecurityException If the caller does not have permission to access the service
Dianne Hackborn85e35642017-01-12 15:10:57 -08002950 * or the service can not be found.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002951 *
2952 * @see #unbindService
2953 * @see #startService
2954 * @see #BIND_AUTO_CREATE
Scott Main4b5da682010-10-21 11:49:12 -07002955 * @see #BIND_DEBUG_UNBIND
2956 * @see #BIND_NOT_FOREGROUND
Dianne Hackborn27b4d942018-11-12 15:01:40 -08002957 * @see #BIND_ABOVE_CLIENT
2958 * @see #BIND_ALLOW_OOM_MANAGEMENT
2959 * @see #BIND_WAIVE_PRIORITY
2960 * @see #BIND_IMPORTANT
2961 * @see #BIND_ADJUST_WITH_ACTIVITY
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002962 */
Tor Norbye788fc2b2015-07-05 16:10:42 -07002963 public abstract boolean bindService(@RequiresPermission Intent service,
2964 @NonNull ServiceConnection conn, @BindServiceFlags int flags);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002965
2966 /**
Dianne Hackborn27b4d942018-11-12 15:01:40 -08002967 * Variation of {@link #bindService} that, in the specific case of isolated
2968 * services, allows the caller to generate multiple instances of a service
2969 * from a single component declaration.
2970 *
2971 * @param service Identifies the service to connect to. The Intent must
2972 * specify an explicit component name.
2973 * @param conn Receives information as the service is started and stopped.
2974 * This must be a valid ServiceConnection object; it must not be null.
2975 * @param flags Operation options for the binding as per {@link #bindService}.
2976 * @param instanceName Unique identifier for the service instance. Each unique
2977 * name here will result in a different service instance being created.
2978 * @return Returns success of binding as per {@link #bindService}.
2979 *
2980 * @throws SecurityException If the caller does not have permission to access the service
2981 *
2982 * @see #bindService
2983 */
Adrian Roosfe6aeaf2019-01-22 16:58:56 +01002984 public boolean bindIsolatedService(@RequiresPermission Intent service,
Dianne Hackborn27b4d942018-11-12 15:01:40 -08002985 @NonNull ServiceConnection conn, @BindServiceFlags int flags,
Adrian Roosfe6aeaf2019-01-22 16:58:56 +01002986 @NonNull String instanceName) {
2987 throw new RuntimeException("Not implemented. Must override in a subclass.");
2988 }
Dianne Hackborn27b4d942018-11-12 15:01:40 -08002989
2990 /**
Dianne Hackborn7d19e022012-08-07 19:12:33 -07002991 * Same as {@link #bindService(Intent, ServiceConnection, int)}, but with an explicit userHandle
Amith Yamasani37ce3a82012-02-06 12:04:42 -08002992 * argument for use by system server and other multi-user aware code.
2993 * @hide
2994 */
Amith Yamasanic85029f2014-09-11 16:47:17 -07002995 @SystemApi
Jeff Brown6e539312015-02-24 18:53:21 -08002996 @SuppressWarnings("unused")
Jeff Sharkeyd86b8fe2017-06-02 17:36:26 -06002997 @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS)
Tor Norbye788fc2b2015-07-05 16:10:42 -07002998 public boolean bindServiceAsUser(@RequiresPermission Intent service, ServiceConnection conn,
Jeff Brown6e539312015-02-24 18:53:21 -08002999 int flags, UserHandle user) {
Amith Yamasani37ce3a82012-02-06 12:04:42 -08003000 throw new RuntimeException("Not implemented. Must override in a subclass.");
3001 }
3002
3003 /**
Dianne Hackborn27b4d942018-11-12 15:01:40 -08003004 * Same as {@link #bindServiceAsUser(Intent, ServiceConnection, int, UserHandle)}, but with an
Adrian Roos691546e2016-02-09 10:13:41 -08003005 * explicit non-null Handler to run the ServiceConnection callbacks on.
3006 *
3007 * @hide
3008 */
Jeff Sharkeyd86b8fe2017-06-02 17:36:26 -06003009 @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS)
Mathew Inwood5c0d3542018-08-14 13:54:31 +01003010 @UnsupportedAppUsage
Adrian Roos691546e2016-02-09 10:13:41 -08003011 public boolean bindServiceAsUser(Intent service, ServiceConnection conn, int flags,
3012 Handler handler, UserHandle user) {
3013 throw new RuntimeException("Not implemented. Must override in a subclass.");
3014 }
3015
3016 /**
Dianne Hackborna631d562018-11-20 15:58:15 -08003017 * For a service previously bound with {@link #bindService} or a related method, change
3018 * how the system manages that service's process in relation to other processes. This
3019 * doesn't modify the original bind flags that were passed in when binding, but adjusts
3020 * how the process will be managed in some cases based on those flags. Currently only
3021 * works on isolated processes (will be ignored for non-isolated processes).
3022 *
Dianne Hackborn2f55e5a2018-11-30 16:31:31 -08003023 * <p>Note that this call does not take immediate effect, but will be applied the next
3024 * time the impacted process is adjusted for some other reason. Typically you would
3025 * call this before then calling a new {@link #bindIsolatedService} on the service
3026 * of interest, with that binding causing the process to be shuffled accordingly.</p>
3027 *
Dianne Hackborna631d562018-11-20 15:58:15 -08003028 * @param conn The connection interface previously supplied to bindService(). This
3029 * parameter must not be null.
3030 * @param group A group to put this connection's process in. Upon calling here, this
3031 * will override any previous group that was set for that process. The group
3032 * tells the system about processes that are logically grouped together, so
3033 * should be managed as one unit of importance (such as when being considered
3034 * a recently used app). All processes in the same app with the same group
3035 * are considered to be related. Supplying 0 reverts to the default behavior
3036 * of not grouping.
3037 * @param importance Additional importance of the processes within a group. Upon calling
3038 * here, this will override any previous group that was set for that
3039 * process. This fine-tunes process killing of all processes within
3040 * a related groups -- higher importance values will be killed before
3041 * lower ones.
3042 */
Adrian Roosfe6aeaf2019-01-22 16:58:56 +01003043 public void updateServiceGroup(@NonNull ServiceConnection conn, int group,
3044 int importance) {
3045 throw new RuntimeException("Not implemented. Must override in a subclass.");
3046 }
Dianne Hackborna631d562018-11-20 15:58:15 -08003047
3048 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003049 * Disconnect from an application service. You will no longer receive
3050 * calls as the service is restarted, and the service is now allowed to
3051 * stop at any time.
3052 *
3053 * @param conn The connection interface previously supplied to
Christopher Tate79b33172012-06-18 14:54:21 -07003054 * bindService(). This parameter must not be null.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003055 *
3056 * @see #bindService
3057 */
Tor Norbyed9273d62013-05-30 15:59:53 -07003058 public abstract void unbindService(@NonNull ServiceConnection conn);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003059
3060 /**
3061 * Start executing an {@link android.app.Instrumentation} class. The given
3062 * Instrumentation component will be run by killing its target application
3063 * (if currently running), starting the target process, instantiating the
3064 * instrumentation component, and then letting it drive the application.
3065 *
3066 * <p>This function is not synchronous -- it returns as soon as the
3067 * instrumentation has started and while it is running.
3068 *
3069 * <p>Instrumentation is normally only allowed to run against a package
3070 * that is either unsigned or signed with a signature that the
3071 * the instrumentation package is also signed with (ensuring the target
3072 * trusts the instrumentation).
3073 *
3074 * @param className Name of the Instrumentation component to be run.
3075 * @param profileFile Optional path to write profiling data as the
3076 * instrumentation runs, or null for no profiling.
3077 * @param arguments Additional optional arguments to pass to the
3078 * instrumentation, or null.
3079 *
John Spurlock6098c5d2013-06-17 10:32:46 -04003080 * @return {@code true} if the instrumentation was successfully started,
3081 * else {@code false} if it could not be found.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003082 */
Tor Norbyed9273d62013-05-30 15:59:53 -07003083 public abstract boolean startInstrumentation(@NonNull ComponentName className,
3084 @Nullable String profileFile, @Nullable Bundle arguments);
3085
3086 /** @hide */
Jeff Sharkey5db9a912017-12-08 17:32:32 -07003087 @StringDef(suffix = { "_SERVICE" }, value = {
Tor Norbyed9273d62013-05-30 15:59:53 -07003088 POWER_SERVICE,
3089 WINDOW_SERVICE,
3090 LAYOUT_INFLATER_SERVICE,
3091 ACCOUNT_SERVICE,
3092 ACTIVITY_SERVICE,
3093 ALARM_SERVICE,
3094 NOTIFICATION_SERVICE,
3095 ACCESSIBILITY_SERVICE,
3096 CAPTIONING_SERVICE,
3097 KEYGUARD_SERVICE,
3098 LOCATION_SERVICE,
3099 //@hide: COUNTRY_DETECTOR,
3100 SEARCH_SERVICE,
3101 SENSOR_SERVICE,
Chad Brubaker90f391f2018-10-19 10:26:19 -07003102 SENSOR_PRIVACY_SERVICE,
Tor Norbyed9273d62013-05-30 15:59:53 -07003103 STORAGE_SERVICE,
Jeff Sharkeye8cece92017-01-04 11:33:33 -07003104 STORAGE_STATS_SERVICE,
Tor Norbyed9273d62013-05-30 15:59:53 -07003105 WALLPAPER_SERVICE,
Neil Fullerfe6ec562017-03-16 18:29:36 +00003106 TIME_ZONE_RULES_MANAGER_SERVICE,
Tor Norbyed9273d62013-05-30 15:59:53 -07003107 VIBRATOR_SERVICE,
3108 //@hide: STATUS_BAR_SERVICE,
3109 CONNECTIVITY_SERVICE,
Chalard Jean8c141bd2018-12-04 20:20:56 +09003110 //@hide: IP_MEMORY_STORE_SERVICE,
Nathan Harold330e1082017-01-12 18:38:57 -08003111 IPSEC_SERVICE,
Tor Norbyed9273d62013-05-30 15:59:53 -07003112 //@hide: UPDATE_LOCK_SERVICE,
3113 //@hide: NETWORKMANAGEMENT_SERVICE,
Zoltan Szatmary-Ban9c5dfa52015-02-23 17:20:20 +00003114 NETWORK_STATS_SERVICE,
Tor Norbyed9273d62013-05-30 15:59:53 -07003115 //@hide: NETWORK_POLICY_SERVICE,
3116 WIFI_SERVICE,
Etan Cohen04133272016-10-26 11:22:06 -07003117 WIFI_AWARE_SERVICE,
Tor Norbyed9273d62013-05-30 15:59:53 -07003118 WIFI_P2P_SERVICE,
Vinit Deshapnde011e1b32014-05-07 21:09:11 -07003119 WIFI_SCANNING_SERVICE,
Robert Quattlebaum87a71042017-05-15 15:45:20 -07003120 //@hide: LOWPAN_SERVICE,
Tor Norbyebf44ce22015-02-12 11:47:32 -08003121 //@hide: WIFI_RTT_SERVICE,
Lorenzo Colittibd8a3742014-05-22 11:51:27 -07003122 //@hide: ETHERNET_SERVICE,
Etan Cohen46efb482017-12-07 13:50:57 -08003123 WIFI_RTT_RANGING_SERVICE,
Tor Norbyed9273d62013-05-30 15:59:53 -07003124 NSD_SERVICE,
3125 AUDIO_SERVICE,
Jim Millerce7eb6d2015-04-03 19:29:13 -07003126 FINGERPRINT_SERVICE,
Gilad Brettercb51b8b2018-03-22 17:04:51 +02003127 //@hide: FACE_SERVICE,
Kevin Chyn05c21502018-09-18 13:07:19 -07003128 BIOMETRIC_SERVICE,
Tor Norbyed9273d62013-05-30 15:59:53 -07003129 MEDIA_ROUTER_SERVICE,
3130 TELEPHONY_SERVICE,
Tor Norbyebf44ce22015-02-12 11:47:32 -08003131 TELEPHONY_SUBSCRIPTION_SERVICE,
Jonathan Basseri9a1c9b62015-02-25 13:01:52 -08003132 CARRIER_CONFIG_SERVICE,
Tyler Gunnef9f6f92014-09-12 22:16:17 -07003133 TELECOM_SERVICE,
Tor Norbyed9273d62013-05-30 15:59:53 -07003134 CLIPBOARD_SERVICE,
3135 INPUT_METHOD_SERVICE,
3136 TEXT_SERVICES_MANAGER_SERVICE,
Abodunrinwa Toki3de110b2017-05-04 16:29:04 +01003137 TEXT_CLASSIFICATION_SERVICE,
Svetoslav976e8bd2014-07-16 15:12:03 -07003138 APPWIDGET_SERVICE,
Tor Norbyebf44ce22015-02-12 11:47:32 -08003139 //@hide: VOICE_INTERACTION_MANAGER_SERVICE,
Tor Norbyed9273d62013-05-30 15:59:53 -07003140 //@hide: BACKUP_SERVICE,
Richard Uhlerb29f1452018-09-12 16:38:15 +01003141 ROLLBACK_SERVICE,
Tor Norbyed9273d62013-05-30 15:59:53 -07003142 DROPBOX_SERVICE,
Dianne Hackborn1958e5e2015-06-12 18:11:41 -07003143 //@hide: DEVICE_IDLE_CONTROLLER,
Tor Norbyed9273d62013-05-30 15:59:53 -07003144 DEVICE_POLICY_SERVICE,
3145 UI_MODE_SERVICE,
3146 DOWNLOAD_SERVICE,
3147 NFC_SERVICE,
3148 BLUETOOTH_SERVICE,
3149 //@hide: SIP_SERVICE,
3150 USB_SERVICE,
Amith Yamasani4f582632014-02-19 14:31:52 -08003151 LAUNCHER_APPS_SERVICE,
Tor Norbyed9273d62013-05-30 15:59:53 -07003152 //@hide: SERIAL_SERVICE,
Tor Norbyebf44ce22015-02-12 11:47:32 -08003153 //@hide: HDMI_CONTROL_SERVICE,
Tor Norbyed9273d62013-05-30 15:59:53 -07003154 INPUT_SERVICE,
3155 DISPLAY_SERVICE,
Christine Franks39b03112018-07-03 14:46:07 -07003156 //@hide COLOR_DISPLAY_SERVICE,
Tor Norbyed9273d62013-05-30 15:59:53 -07003157 USER_SERVICE,
Tor Norbyebf44ce22015-02-12 11:47:32 -08003158 RESTRICTIONS_SERVICE,
3159 APP_OPS_SERVICE,
Hai Zhangb7776682018-09-25 15:10:57 -07003160 ROLE_SERVICE,
Tor Norbyed9273d62013-05-30 15:59:53 -07003161 CAMERA_SERVICE,
RoboErik01fe6612014-02-13 14:19:04 -08003162 PRINT_SERVICE,
Tor Norbyebf44ce22015-02-12 11:47:32 -08003163 CONSUMER_IR_SERVICE,
3164 //@hide: TRUST_SERVICE,
3165 TV_INPUT_SERVICE,
3166 //@hide: NETWORK_SCORE_SERVICE,
3167 USAGE_STATS_SERVICE,
RoboErik01fe6612014-02-13 14:19:04 -08003168 MEDIA_SESSION_SERVICE,
Todd Poynore35872d2013-12-10 11:57:21 -08003169 BATTERY_SERVICE,
Christopher Tate7060b042014-06-09 19:50:00 -07003170 JOB_SCHEDULER_SERVICE,
Tor Norbyebf44ce22015-02-12 11:47:32 -08003171 //@hide: PERSISTENT_DATA_BLOCK_SERVICE,
Andrew Scull3b8b46f2017-02-13 18:12:15 +00003172 //@hide: OEM_LOCK_SERVICE,
Michael Wright446e0192014-12-22 09:38:43 -08003173 MEDIA_PROJECTION_SERVICE,
Mike Lockwood67f8e8b2014-12-01 13:54:59 -08003174 MIDI_SERVICE,
Eric Laurent2035ac82015-03-05 15:18:44 -08003175 RADIO_SERVICE,
Polina Bondarenko965ecbb2015-11-13 15:34:28 +01003176 HARDWARE_PROPERTIES_SERVICE,
Arunesh Mishraa772e5f2016-01-25 10:33:11 -08003177 //@hide: SOUND_TRIGGER_SERVICE,
Makoto Onuki6f7362d92016-03-04 13:39:41 -08003178 SHORTCUT_SERVICE,
Peng Xu9ff7d222016-02-11 13:02:05 -08003179 //@hide: CONTEXTHUB_SERVICE,
Joe Onorato1754d742016-11-21 17:51:35 -08003180 SYSTEM_HEALTH_SERVICE,
Tor Norbye8246c072017-07-07 10:21:09 -07003181 //@hide: INCIDENT_SERVICE,
Joe Onoratoe21ab7e2018-12-18 15:00:25 -08003182 //@hide: INCIDENT_COMPANION_SERVICE,
Bookatz94726412017-08-31 09:26:15 -07003183 //@hide: STATS_COMPANION_SERVICE,
Tony Mak9240c7f2017-12-29 11:02:02 +00003184 COMPANION_DEVICE_SERVICE,
Tao Bao07342dc2017-01-24 15:08:21 -08003185 CROSS_PROFILE_APPS_SERVICE,
3186 //@hide: SYSTEM_UPDATE_SERVICE,
Neil Fullerfeeee682018-05-30 14:35:24 +01003187 //@hide: TIME_DETECTOR_SERVICE,
Philip P. Moltmann039678e2018-09-18 13:04:38 -07003188 PERMISSION_SERVICE,
Tor Norbyed9273d62013-05-30 15:59:53 -07003189 })
3190 @Retention(RetentionPolicy.SOURCE)
3191 public @interface ServiceName {}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003192
3193 /**
3194 * Return the handle to a system-level service by name. The class of the
3195 * returned object varies by the requested name. Currently available names
3196 * are:
Scott Main4b5da682010-10-21 11:49:12 -07003197 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003198 * <dl>
3199 * <dt> {@link #WINDOW_SERVICE} ("window")
3200 * <dd> The top-level window manager in which you can place custom
3201 * windows. The returned object is a {@link android.view.WindowManager}.
3202 * <dt> {@link #LAYOUT_INFLATER_SERVICE} ("layout_inflater")
3203 * <dd> A {@link android.view.LayoutInflater} for inflating layout resources
3204 * in this context.
3205 * <dt> {@link #ACTIVITY_SERVICE} ("activity")
3206 * <dd> A {@link android.app.ActivityManager} for interacting with the
3207 * global activity state of the system.
3208 * <dt> {@link #POWER_SERVICE} ("power")
3209 * <dd> A {@link android.os.PowerManager} for controlling power
3210 * management.
3211 * <dt> {@link #ALARM_SERVICE} ("alarm")
3212 * <dd> A {@link android.app.AlarmManager} for receiving intents at the
3213 * time of your choosing.
3214 * <dt> {@link #NOTIFICATION_SERVICE} ("notification")
3215 * <dd> A {@link android.app.NotificationManager} for informing the user
3216 * of background events.
3217 * <dt> {@link #KEYGUARD_SERVICE} ("keyguard")
3218 * <dd> A {@link android.app.KeyguardManager} for controlling keyguard.
3219 * <dt> {@link #LOCATION_SERVICE} ("location")
3220 * <dd> A {@link android.location.LocationManager} for controlling location
3221 * (e.g., GPS) updates.
3222 * <dt> {@link #SEARCH_SERVICE} ("search")
3223 * <dd> A {@link android.app.SearchManager} for handling search.
3224 * <dt> {@link #VIBRATOR_SERVICE} ("vibrator")
3225 * <dd> A {@link android.os.Vibrator} for interacting with the vibrator
3226 * hardware.
3227 * <dt> {@link #CONNECTIVITY_SERVICE} ("connection")
3228 * <dd> A {@link android.net.ConnectivityManager ConnectivityManager} for
3229 * handling management of network connections.
Nathan Haroldd999d222017-09-11 19:53:33 -07003230 * <dt> {@link #IPSEC_SERVICE} ("ipsec")
3231 * <dd> A {@link android.net.IpSecManager IpSecManager} for managing IPSec on
3232 * sockets and networks.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003233 * <dt> {@link #WIFI_SERVICE} ("wifi")
Paul Stewart0e164b12016-08-08 10:20:13 -07003234 * <dd> A {@link android.net.wifi.WifiManager WifiManager} for management of Wi-Fi
3235 * connectivity. On releases before NYC, it should only be obtained from an application
3236 * context, and not from any other derived context to avoid memory leaks within the calling
3237 * process.
Etan Cohen6a4b3232017-01-09 21:47:32 -08003238 * <dt> {@link #WIFI_AWARE_SERVICE} ("wifiaware")
3239 * <dd> A {@link android.net.wifi.aware.WifiAwareManager WifiAwareManager} for management of
3240 * Wi-Fi Aware discovery and connectivity.
Vinit Deshapnde011e1b32014-05-07 21:09:11 -07003241 * <dt> {@link #WIFI_P2P_SERVICE} ("wifip2p")
3242 * <dd> A {@link android.net.wifi.p2p.WifiP2pManager WifiP2pManager} for management of
3243 * Wi-Fi Direct connectivity.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003244 * <dt> {@link #INPUT_METHOD_SERVICE} ("input_method")
3245 * <dd> An {@link android.view.inputmethod.InputMethodManager InputMethodManager}
3246 * for management of input methods.
Tobias Haamel53332882010-02-18 16:15:43 -08003247 * <dt> {@link #UI_MODE_SERVICE} ("uimode")
3248 * <dd> An {@link android.app.UiModeManager} for controlling UI modes.
Steve Howard7083c422010-07-28 16:01:23 -07003249 * <dt> {@link #DOWNLOAD_SERVICE} ("download")
Steve Howardd58429f2010-09-27 16:32:39 -07003250 * <dd> A {@link android.app.DownloadManager} for requesting HTTP downloads
Todd Poynore35872d2013-12-10 11:57:21 -08003251 * <dt> {@link #BATTERY_SERVICE} ("batterymanager")
Todd Poynor99f7e122014-04-15 16:03:42 -07003252 * <dd> A {@link android.os.BatteryManager} for managing battery state
Christopher Tate7060b042014-06-09 19:50:00 -07003253 * <dt> {@link #JOB_SCHEDULER_SERVICE} ("taskmanager")
3254 * <dd> A {@link android.app.job.JobScheduler} for managing scheduled tasks
Zoltan Szatmary-Ban9c5dfa52015-02-23 17:20:20 +00003255 * <dt> {@link #NETWORK_STATS_SERVICE} ("netstats")
3256 * <dd> A {@link android.app.usage.NetworkStatsManager NetworkStatsManager} for querying network
3257 * usage statistics.
Polina Bondarenko8333c732016-03-09 18:08:42 +01003258 * <dt> {@link #HARDWARE_PROPERTIES_SERVICE} ("hardware_properties")
Polina Bondarenko965ecbb2015-11-13 15:34:28 +01003259 * <dd> A {@link android.os.HardwarePropertiesManager} for accessing hardware properties.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003260 * </dl>
Scott Main4b5da682010-10-21 11:49:12 -07003261 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003262 * <p>Note: System services obtained via this API may be closely associated with
3263 * the Context in which they are obtained from. In general, do not share the
3264 * service objects between various different contexts (Activities, Applications,
3265 * Services, Providers, etc.)
3266 *
Svet Ganov8f90bcc2017-12-22 23:29:24 -08003267 * <p>Note: Instant apps, for which {@link PackageManager#isInstantApp()} returns true,
3268 * don't have access to the following system services: {@link #DEVICE_POLICY_SERVICE},
Donald Chaiee4c91c2018-09-19 14:42:41 -07003269 * {@link #FINGERPRINT_SERVICE}, {@link #KEYGUARD_SERVICE}, {@link #SHORTCUT_SERVICE},
3270 * {@link #USB_SERVICE}, {@link #WALLPAPER_SERVICE}, {@link #WIFI_P2P_SERVICE},
3271 * {@link #WIFI_SERVICE}, {@link #WIFI_AWARE_SERVICE}. For these services this method will
3272 * return <code>null</code>. Generally, if you are running as an instant app you should always
3273 * check whether the result of this method is null.
Svet Ganov8f90bcc2017-12-22 23:29:24 -08003274 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003275 * @param name The name of the desired service.
Scott Main4b5da682010-10-21 11:49:12 -07003276 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003277 * @return The service or null if the name does not exist.
Scott Main4b5da682010-10-21 11:49:12 -07003278 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003279 * @see #WINDOW_SERVICE
3280 * @see android.view.WindowManager
3281 * @see #LAYOUT_INFLATER_SERVICE
3282 * @see android.view.LayoutInflater
3283 * @see #ACTIVITY_SERVICE
3284 * @see android.app.ActivityManager
3285 * @see #POWER_SERVICE
3286 * @see android.os.PowerManager
3287 * @see #ALARM_SERVICE
3288 * @see android.app.AlarmManager
3289 * @see #NOTIFICATION_SERVICE
3290 * @see android.app.NotificationManager
3291 * @see #KEYGUARD_SERVICE
3292 * @see android.app.KeyguardManager
3293 * @see #LOCATION_SERVICE
3294 * @see android.location.LocationManager
3295 * @see #SEARCH_SERVICE
3296 * @see android.app.SearchManager
3297 * @see #SENSOR_SERVICE
3298 * @see android.hardware.SensorManager
San Mehatc9d81752010-02-01 10:23:27 -08003299 * @see #STORAGE_SERVICE
San Mehatb1043402010-02-05 08:26:50 -08003300 * @see android.os.storage.StorageManager
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003301 * @see #VIBRATOR_SERVICE
3302 * @see android.os.Vibrator
3303 * @see #CONNECTIVITY_SERVICE
3304 * @see android.net.ConnectivityManager
3305 * @see #WIFI_SERVICE
3306 * @see android.net.wifi.WifiManager
3307 * @see #AUDIO_SERVICE
3308 * @see android.media.AudioManager
Dianne Hackbornb58b8f82012-06-11 15:08:39 -07003309 * @see #MEDIA_ROUTER_SERVICE
3310 * @see android.media.MediaRouter
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003311 * @see #TELEPHONY_SERVICE
3312 * @see android.telephony.TelephonyManager
Wink Savilled09c4ca2014-11-22 10:08:16 -08003313 * @see #TELEPHONY_SUBSCRIPTION_SERVICE
3314 * @see android.telephony.SubscriptionManager
Jonathan Basseri9a1c9b62015-02-25 13:01:52 -08003315 * @see #CARRIER_CONFIG_SERVICE
3316 * @see android.telephony.CarrierConfigManager
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003317 * @see #INPUT_METHOD_SERVICE
3318 * @see android.view.inputmethod.InputMethodManager
Tobias Haamel53332882010-02-18 16:15:43 -08003319 * @see #UI_MODE_SERVICE
3320 * @see android.app.UiModeManager
Steve Howard7083c422010-07-28 16:01:23 -07003321 * @see #DOWNLOAD_SERVICE
Steve Howardd58429f2010-09-27 16:32:39 -07003322 * @see android.app.DownloadManager
Todd Poynore35872d2013-12-10 11:57:21 -08003323 * @see #BATTERY_SERVICE
3324 * @see android.os.BatteryManager
Christopher Tate7060b042014-06-09 19:50:00 -07003325 * @see #JOB_SCHEDULER_SERVICE
3326 * @see android.app.job.JobScheduler
Zoltan Szatmary-Ban9c5dfa52015-02-23 17:20:20 +00003327 * @see #NETWORK_STATS_SERVICE
3328 * @see android.app.usage.NetworkStatsManager
Polina Bondarenko965ecbb2015-11-13 15:34:28 +01003329 * @see android.os.HardwarePropertiesManager
3330 * @see #HARDWARE_PROPERTIES_SERVICE
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003331 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06003332 public abstract @Nullable Object getSystemService(@ServiceName @NonNull String name);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003333
3334 /**
Jeff Brown6e539312015-02-24 18:53:21 -08003335 * Return the handle to a system-level service by class.
3336 * <p>
3337 * Currently available classes are:
3338 * {@link android.view.WindowManager}, {@link android.view.LayoutInflater},
3339 * {@link android.app.ActivityManager}, {@link android.os.PowerManager},
3340 * {@link android.app.AlarmManager}, {@link android.app.NotificationManager},
3341 * {@link android.app.KeyguardManager}, {@link android.location.LocationManager},
3342 * {@link android.app.SearchManager}, {@link android.os.Vibrator},
3343 * {@link android.net.ConnectivityManager},
3344 * {@link android.net.wifi.WifiManager},
3345 * {@link android.media.AudioManager}, {@link android.media.MediaRouter},
3346 * {@link android.telephony.TelephonyManager}, {@link android.telephony.SubscriptionManager},
3347 * {@link android.view.inputmethod.InputMethodManager},
3348 * {@link android.app.UiModeManager}, {@link android.app.DownloadManager},
Zoltan Szatmary-Ban9c5dfa52015-02-23 17:20:20 +00003349 * {@link android.os.BatteryManager}, {@link android.app.job.JobScheduler},
3350 * {@link android.app.usage.NetworkStatsManager}.
Jeff Brown6e539312015-02-24 18:53:21 -08003351 * </p><p>
3352 * Note: System services obtained via this API may be closely associated with
3353 * the Context in which they are obtained from. In general, do not share the
3354 * service objects between various different contexts (Activities, Applications,
3355 * Services, Providers, etc.)
3356 * </p>
3357 *
Svet Ganov8f90bcc2017-12-22 23:29:24 -08003358 * <p>Note: Instant apps, for which {@link PackageManager#isInstantApp()} returns true,
3359 * don't have access to the following system services: {@link #DEVICE_POLICY_SERVICE},
Donald Chaiee4c91c2018-09-19 14:42:41 -07003360 * {@link #FINGERPRINT_SERVICE}, {@link #KEYGUARD_SERVICE}, {@link #SHORTCUT_SERVICE},
3361 * {@link #USB_SERVICE}, {@link #WALLPAPER_SERVICE}, {@link #WIFI_P2P_SERVICE},
3362 * {@link #WIFI_SERVICE}, {@link #WIFI_AWARE_SERVICE}. For these services this method will
3363 * return <code>null</code>. Generally, if you are running as an instant app you should always
3364 * check whether the result of this method is null.
Svet Ganov8f90bcc2017-12-22 23:29:24 -08003365 *
Jeff Brown6e539312015-02-24 18:53:21 -08003366 * @param serviceClass The class of the desired service.
3367 * @return The service or null if the class is not a supported system service.
3368 */
3369 @SuppressWarnings("unchecked")
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06003370 public final @Nullable <T> T getSystemService(@NonNull Class<T> serviceClass) {
Jeff Brown6e539312015-02-24 18:53:21 -08003371 // Because subclasses may override getSystemService(String) we cannot
3372 // perform a lookup by class alone. We must first map the class to its
3373 // service name then invoke the string-based method.
3374 String serviceName = getSystemServiceName(serviceClass);
3375 return serviceName != null ? (T)getSystemService(serviceName) : null;
3376 }
3377
3378 /**
3379 * Gets the name of the system-level service that is represented by the specified class.
3380 *
3381 * @param serviceClass The class of the desired service.
3382 * @return The service name or null if the class is not a supported system service.
Jeff Brown6e539312015-02-24 18:53:21 -08003383 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06003384 public abstract @Nullable String getSystemServiceName(@NonNull Class<?> serviceClass);
Jeff Brown6e539312015-02-24 18:53:21 -08003385
3386 /**
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08003387 * Use with {@link #getSystemService(String)} to retrieve a
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003388 * {@link android.os.PowerManager} for controlling power management,
3389 * including "wake locks," which let you keep the device on while
3390 * you're running long tasks.
3391 */
3392 public static final String POWER_SERVICE = "power";
Scott Main4b5da682010-10-21 11:49:12 -07003393
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003394 /**
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08003395 * Use with {@link #getSystemService(String)} to retrieve a
Tao Baoe8a403d2015-12-31 07:44:55 -08003396 * {@link android.os.RecoverySystem} for accessing the recovery system
3397 * service.
3398 *
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08003399 * @see #getSystemService(String)
Tao Baoe8a403d2015-12-31 07:44:55 -08003400 * @hide
3401 */
3402 public static final String RECOVERY_SERVICE = "recovery";
3403
3404 /**
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08003405 * Use with {@link #getSystemService(String)} to retrieve a
Tao Bao07342dc2017-01-24 15:08:21 -08003406 * {@link android.os.SystemUpdateManager} for accessing the system update
3407 * manager service.
3408 *
3409 * @see #getSystemService(String)
3410 * @hide
3411 */
3412 @SystemApi
3413 public static final String SYSTEM_UPDATE_SERVICE = "system_update";
3414
3415 /**
3416 * Use with {@link #getSystemService(String)} to retrieve a
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003417 * {@link android.view.WindowManager} for accessing the system's window
3418 * manager.
3419 *
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08003420 * @see #getSystemService(String)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003421 * @see android.view.WindowManager
3422 */
3423 public static final String WINDOW_SERVICE = "window";
Scott Main4b5da682010-10-21 11:49:12 -07003424
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003425 /**
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08003426 * Use with {@link #getSystemService(String)} to retrieve a
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003427 * {@link android.view.LayoutInflater} for inflating layout resources in this
3428 * context.
3429 *
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08003430 * @see #getSystemService(String)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003431 * @see android.view.LayoutInflater
3432 */
3433 public static final String LAYOUT_INFLATER_SERVICE = "layout_inflater";
Scott Main4b5da682010-10-21 11:49:12 -07003434
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003435 /**
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08003436 * Use with {@link #getSystemService(String)} to retrieve a
Fred Quintana60307342009-03-24 22:48:12 -07003437 * {@link android.accounts.AccountManager} for receiving intents at a
3438 * time of your choosing.
Fred Quintana60307342009-03-24 22:48:12 -07003439 *
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08003440 * @see #getSystemService(String)
Fred Quintana60307342009-03-24 22:48:12 -07003441 * @see android.accounts.AccountManager
3442 */
3443 public static final String ACCOUNT_SERVICE = "account";
Scott Main4b5da682010-10-21 11:49:12 -07003444
Fred Quintana60307342009-03-24 22:48:12 -07003445 /**
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08003446 * Use with {@link #getSystemService(String)} to retrieve a
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003447 * {@link android.app.ActivityManager} for interacting with the global
3448 * system state.
3449 *
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08003450 * @see #getSystemService(String)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003451 * @see android.app.ActivityManager
3452 */
3453 public static final String ACTIVITY_SERVICE = "activity";
Scott Main4b5da682010-10-21 11:49:12 -07003454
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003455 /**
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08003456 * Use with {@link #getSystemService(String)} to retrieve a
Wale Ogunwale65ebd952018-04-25 15:41:44 -07003457 * {@link android.app.ActivityTaskManager} for interacting with the global system state.
3458 *
3459 * @see #getSystemService(String)
3460 * @see android.app.ActivityTaskManager
3461 * @hide
3462 */
3463 public static final String ACTIVITY_TASK_SERVICE = "activity_task";
3464
3465 /**
3466 * Use with {@link #getSystemService(String)} to retrieve a
Wale Ogunwale6d50dcc2018-07-21 23:00:40 -07003467 * {@link android.app.UriGrantsManager} for interacting with the global system state.
3468 *
3469 * @see #getSystemService(String)
3470 * @see android.app.UriGrantsManager
3471 * @hide
3472 */
3473 public static final String URI_GRANTS_SERVICE = "uri_grants";
3474
3475 /**
3476 * Use with {@link #getSystemService(String)} to retrieve a
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003477 * {@link android.app.AlarmManager} for receiving intents at a
3478 * time of your choosing.
3479 *
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08003480 * @see #getSystemService(String)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003481 * @see android.app.AlarmManager
3482 */
3483 public static final String ALARM_SERVICE = "alarm";
Scott Main4b5da682010-10-21 11:49:12 -07003484
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003485 /**
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08003486 * Use with {@link #getSystemService(String)} to retrieve a
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003487 * {@link android.app.NotificationManager} for informing the user of
3488 * background events.
3489 *
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08003490 * @see #getSystemService(String)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003491 * @see android.app.NotificationManager
3492 */
3493 public static final String NOTIFICATION_SERVICE = "notification";
Scott Main4b5da682010-10-21 11:49:12 -07003494
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003495 /**
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08003496 * Use with {@link #getSystemService(String)} to retrieve a
svetoslavganov75986cf2009-05-14 22:28:01 -07003497 * {@link android.view.accessibility.AccessibilityManager} for giving the user
3498 * feedback for UI events through the registered event listeners.
3499 *
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08003500 * @see #getSystemService(String)
svetoslavganov75986cf2009-05-14 22:28:01 -07003501 * @see android.view.accessibility.AccessibilityManager
3502 */
3503 public static final String ACCESSIBILITY_SERVICE = "accessibility";
Scott Main4b5da682010-10-21 11:49:12 -07003504
svetoslavganov75986cf2009-05-14 22:28:01 -07003505 /**
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08003506 * Use with {@link #getSystemService(String)} to retrieve a
Alan Viverette69ce69b2013-08-29 12:23:48 -07003507 * {@link android.view.accessibility.CaptioningManager} for obtaining
3508 * captioning properties and listening for changes in captioning
3509 * preferences.
3510 *
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08003511 * @see #getSystemService(String)
Alan Viverette69ce69b2013-08-29 12:23:48 -07003512 * @see android.view.accessibility.CaptioningManager
3513 */
3514 public static final String CAPTIONING_SERVICE = "captioning";
3515
3516 /**
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08003517 * Use with {@link #getSystemService(String)} to retrieve a
kopriva5495dbb2018-09-13 14:18:34 -07003518 * {@link android.app.KeyguardManager} for controlling keyguard.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003519 *
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08003520 * @see #getSystemService(String)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003521 * @see android.app.KeyguardManager
3522 */
3523 public static final String KEYGUARD_SERVICE = "keyguard";
Scott Main4b5da682010-10-21 11:49:12 -07003524
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003525 /**
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08003526 * Use with {@link #getSystemService(String)} to retrieve a {@link
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003527 * android.location.LocationManager} for controlling location
3528 * updates.
3529 *
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08003530 * @see #getSystemService(String)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003531 * @see android.location.LocationManager
3532 */
3533 public static final String LOCATION_SERVICE = "location";
Bai Taoa58a8752010-07-13 15:32:16 +08003534
3535 /**
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08003536 * Use with {@link #getSystemService(String)} to retrieve a
Bai Taoa58a8752010-07-13 15:32:16 +08003537 * {@link android.location.CountryDetector} for detecting the country that
3538 * the user is in.
3539 *
3540 * @hide
3541 */
Mathew Inwood8c854f82018-09-14 12:35:36 +01003542 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
Bai Taoa58a8752010-07-13 15:32:16 +08003543 public static final String COUNTRY_DETECTOR = "country_detector";
3544
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003545 /**
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08003546 * Use with {@link #getSystemService(String)} to retrieve a {@link
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003547 * android.app.SearchManager} for handling searches.
3548 *
Erik Wolsheimerac5cecd2017-12-05 13:11:50 -08003549 * <p>
3550 * {@link Configuration#UI_MODE_TYPE_WATCH} does not support
3551 * {@link android.app.SearchManager}.
3552 *
3553 * @see #getSystemService
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003554 * @see android.app.SearchManager
3555 */
3556 public static final String SEARCH_SERVICE = "search";
Scott Main4b5da682010-10-21 11:49:12 -07003557
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003558 /**
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08003559 * Use with {@link #getSystemService(String)} to retrieve a {@link
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003560 * android.hardware.SensorManager} for accessing sensors.
3561 *
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08003562 * @see #getSystemService(String)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003563 * @see android.hardware.SensorManager
3564 */
3565 public static final String SENSOR_SERVICE = "sensor";
Scott Main4b5da682010-10-21 11:49:12 -07003566
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003567 /**
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08003568 * Use with {@link #getSystemService(String)} to retrieve a {@link
Chad Brubaker90f391f2018-10-19 10:26:19 -07003569 * android.hardware.SensorPrivacyManager} for accessing sensor privacy
3570 * functions.
3571 *
3572 * @see #getSystemService(String)
3573 * @see android.hardware.SensorPrivacyManager
3574 *
3575 * @hide
3576 */
3577 public static final String SENSOR_PRIVACY_SERVICE = "sensor_privacy";
3578
3579 /**
3580 * Use with {@link #getSystemService(String)} to retrieve a {@link
Kenny Root02c87302010-07-01 08:10:18 -07003581 * android.os.storage.StorageManager} for accessing system storage
San Mehatc9d81752010-02-01 10:23:27 -08003582 * functions.
3583 *
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08003584 * @see #getSystemService(String)
San Mehatb1043402010-02-05 08:26:50 -08003585 * @see android.os.storage.StorageManager
San Mehatc9d81752010-02-01 10:23:27 -08003586 */
3587 public static final String STORAGE_SERVICE = "storage";
3588
3589 /**
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08003590 * Use with {@link #getSystemService(String)} to retrieve a {@link
Jeff Sharkeye8cece92017-01-04 11:33:33 -07003591 * android.app.usage.StorageStatsManager} for accessing system storage
3592 * statistics.
3593 *
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08003594 * @see #getSystemService(String)
Jeff Sharkeye8cece92017-01-04 11:33:33 -07003595 * @see android.app.usage.StorageStatsManager
3596 */
3597 public static final String STORAGE_STATS_SERVICE = "storagestats";
3598
3599 /**
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08003600 * Use with {@link #getSystemService(String)} to retrieve a
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003601 * com.android.server.WallpaperService for accessing wallpapers.
3602 *
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08003603 * @see #getSystemService(String)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003604 */
3605 public static final String WALLPAPER_SERVICE = "wallpaper";
Scott Main4b5da682010-10-21 11:49:12 -07003606
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003607 /**
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08003608 * Use with {@link #getSystemService(String)} to retrieve a {@link
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003609 * android.os.Vibrator} for interacting with the vibration hardware.
3610 *
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08003611 * @see #getSystemService(String)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003612 * @see android.os.Vibrator
3613 */
3614 public static final String VIBRATOR_SERVICE = "vibrator";
Robert Greenwalt9e696c22010-04-01 14:45:18 -07003615
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003616 /**
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08003617 * Use with {@link #getSystemService(String)} to retrieve a {@link
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003618 * android.app.StatusBarManager} for interacting with the status bar.
3619 *
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08003620 * @see #getSystemService(String)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003621 * @see android.app.StatusBarManager
Evan Lairdedd016f2019-01-23 18:36:29 -05003622 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003623 * @hide
3624 */
Evan Lairdedd016f2019-01-23 18:36:29 -05003625 @SystemApi
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003626 public static final String STATUS_BAR_SERVICE = "statusbar";
3627
3628 /**
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08003629 * Use with {@link #getSystemService(String)} to retrieve a {@link
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003630 * android.net.ConnectivityManager} for handling management of
3631 * network connections.
3632 *
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08003633 * @see #getSystemService(String)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003634 * @see android.net.ConnectivityManager
3635 */
3636 public static final String CONNECTIVITY_SERVICE = "connectivity";
3637
3638 /**
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08003639 * Use with {@link #getSystemService(String)} to retrieve a
Remi NGUYEN VAN31935982019-01-28 11:40:08 +09003640 * {@link android.net.INetd} for communicating with the network stack
3641 * @hide
3642 * @see #getSystemService(String)
3643 * @hide
3644 */
3645 @SystemApi
3646 public static final String NETD_SERVICE = "netd";
3647
3648 /**
Remi NGUYEN VAN310da6f2019-02-14 18:04:20 +09003649 * Use with {@link android.os.ServiceManager.getService()} to retrieve a
3650 * {@link NetworkStackClient} IBinder for communicating with the network stack
Remi NGUYEN VANc094a542018-12-07 16:52:24 +09003651 * @hide
Remi NGUYEN VAN310da6f2019-02-14 18:04:20 +09003652 * @see NetworkStackClient
Remi NGUYEN VANc094a542018-12-07 16:52:24 +09003653 */
3654 public static final String NETWORK_STACK_SERVICE = "network_stack";
3655
3656 /**
3657 * Use with {@link #getSystemService(String)} to retrieve a
Chalard Jean8c141bd2018-12-04 20:20:56 +09003658 * {@link android.net.IpMemoryStore} to store and read information about
3659 * known networks.
3660 * @hide
3661 */
3662 public static final String IP_MEMORY_STORE_SERVICE = "ipmemorystore";
3663
3664 /**
3665 * Use with {@link #getSystemService(String)} to retrieve a
Nathan Harold330e1082017-01-12 18:38:57 -08003666 * {@link android.net.IpSecManager} for encrypting Sockets or Networks with
3667 * IPSec.
3668 *
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08003669 * @see #getSystemService(String)
Nathan Harold330e1082017-01-12 18:38:57 -08003670 */
3671 public static final String IPSEC_SERVICE = "ipsec";
3672
3673 /**
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08003674 * Use with {@link #getSystemService(String)} to retrieve a {@link
Christopher Tate8662cab52012-02-23 14:59:36 -08003675 * android.os.IUpdateLock} for managing runtime sequences that
3676 * must not be interrupted by headless OTA application or similar.
3677 *
3678 * @hide
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08003679 * @see #getSystemService(String)
Christopher Tate8662cab52012-02-23 14:59:36 -08003680 * @see android.os.UpdateLock
3681 */
3682 public static final String UPDATE_LOCK_SERVICE = "updatelock";
3683
3684 /**
Dianne Hackborn35f72be2013-09-16 10:57:39 -07003685 * Constant for the internal network management service, not really a Context service.
Dianne Hackborn0a6a80f2013-09-16 15:20:27 -07003686 * @hide
San Mehatd1df8ac2010-01-26 06:17:26 -08003687 */
3688 public static final String NETWORKMANAGEMENT_SERVICE = "network_management";
3689
Zoltan Szatmary-Ban9c5dfa52015-02-23 17:20:20 +00003690 /**
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08003691 * Use with {@link #getSystemService(String)} to retrieve a
Jason Monk8f5f7ff2017-10-17 14:12:42 -04003692 * {@link com.android.server.slice.SliceManagerService} for managing slices.
3693 * @hide
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08003694 * @see #getSystemService(String)
Jason Monk8f5f7ff2017-10-17 14:12:42 -04003695 */
3696 public static final String SLICE_SERVICE = "slice";
3697
3698 /**
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08003699 * Use with {@link #getSystemService(String)} to retrieve a {@link
Zoltan Szatmary-Ban9c5dfa52015-02-23 17:20:20 +00003700 * android.app.usage.NetworkStatsManager} for querying network usage stats.
3701 *
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08003702 * @see #getSystemService(String)
Zoltan Szatmary-Ban9c5dfa52015-02-23 17:20:20 +00003703 * @see android.app.usage.NetworkStatsManager
3704 */
Jeff Sharkey75279902011-05-24 18:39:45 -07003705 public static final String NETWORK_STATS_SERVICE = "netstats";
3706 /** {@hide} */
Jeff Sharkeyeedcb952011-05-17 14:55:15 -07003707 public static final String NETWORK_POLICY_SERVICE = "netpolicy";
Ricky Wai1a6e6672017-10-27 14:46:01 +01003708 /** {@hide} */
3709 public static final String NETWORK_WATCHLIST_SERVICE = "network_watchlist";
Jeff Sharkeyeedcb952011-05-17 14:55:15 -07003710
San Mehatd1df8ac2010-01-26 06:17:26 -08003711 /**
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08003712 * Use with {@link #getSystemService(String)} to retrieve a {@link
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003713 * android.net.wifi.WifiManager} for handling management of
3714 * Wi-Fi access.
3715 *
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08003716 * @see #getSystemService(String)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003717 * @see android.net.wifi.WifiManager
3718 */
3719 public static final String WIFI_SERVICE = "wifi";
Scott Main4b5da682010-10-21 11:49:12 -07003720
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003721 /**
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08003722 * Use with {@link #getSystemService(String)} to retrieve a {@link
repo sync55bc5f32011-06-24 14:23:07 -07003723 * android.net.wifi.p2p.WifiP2pManager} for handling management of
Irfan Sheriff651cdfc2011-09-07 00:31:20 -07003724 * Wi-Fi peer-to-peer connections.
repo sync55bc5f32011-06-24 14:23:07 -07003725 *
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08003726 * @see #getSystemService(String)
repo sync55bc5f32011-06-24 14:23:07 -07003727 * @see android.net.wifi.p2p.WifiP2pManager
repo sync55bc5f32011-06-24 14:23:07 -07003728 */
3729 public static final String WIFI_P2P_SERVICE = "wifip2p";
3730
3731 /**
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08003732 * Use with {@link #getSystemService(String)} to retrieve a
Etan Cohen04133272016-10-26 11:22:06 -07003733 * {@link android.net.wifi.aware.WifiAwareManager} for handling management of
3734 * Wi-Fi Aware.
Etan Cohen20d329b2015-09-29 13:49:02 -07003735 *
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08003736 * @see #getSystemService(String)
Etan Cohen04133272016-10-26 11:22:06 -07003737 * @see android.net.wifi.aware.WifiAwareManager
Etan Cohen20d329b2015-09-29 13:49:02 -07003738 */
Etan Cohen04133272016-10-26 11:22:06 -07003739 public static final String WIFI_AWARE_SERVICE = "wifiaware";
Etan Cohen20d329b2015-09-29 13:49:02 -07003740
3741 /**
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08003742 * Use with {@link #getSystemService(String)} to retrieve a {@link
Vinit Deshapnde011e1b32014-05-07 21:09:11 -07003743 * android.net.wifi.WifiScanner} for scanning the wifi universe
3744 *
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08003745 * @see #getSystemService(String)
Vinit Deshapnde011e1b32014-05-07 21:09:11 -07003746 * @see android.net.wifi.WifiScanner
3747 * @hide
3748 */
Wei Wang35d552f2014-07-08 21:37:01 -07003749 @SystemApi
Vinit Deshapnde011e1b32014-05-07 21:09:11 -07003750 public static final String WIFI_SCANNING_SERVICE = "wifiscanner";
3751
3752 /**
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08003753 * Use with {@link #getSystemService(String)} to retrieve a {@link
Vinit Deshpande7686c062014-06-30 15:25:01 -07003754 * android.net.wifi.RttManager} for ranging devices with wifi
3755 *
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08003756 * @see #getSystemService(String)
Vinit Deshpande7686c062014-06-30 15:25:01 -07003757 * @see android.net.wifi.RttManager
3758 * @hide
3759 */
3760 @SystemApi
Etan Cohend0acccd2018-01-31 08:36:33 -08003761 @Deprecated
Vinit Deshpande7686c062014-06-30 15:25:01 -07003762 public static final String WIFI_RTT_SERVICE = "rttmanager";
3763
3764 /**
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08003765 * Use with {@link #getSystemService(String)} to retrieve a {@link
Etan Cohen17ba4722017-08-21 10:52:17 -07003766 * android.net.wifi.rtt.WifiRttManager} for ranging devices with wifi
3767 *
3768 * Note: this is a replacement for WIFI_RTT_SERVICE above. It will
3769 * be renamed once final implementation in place.
3770 *
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08003771 * @see #getSystemService(String)
Etan Cohen17ba4722017-08-21 10:52:17 -07003772 * @see android.net.wifi.rtt.WifiRttManager
Etan Cohen17ba4722017-08-21 10:52:17 -07003773 */
Etan Cohen091d7772018-01-04 17:47:37 -08003774 public static final String WIFI_RTT_RANGING_SERVICE = "wifirtt";
Etan Cohen17ba4722017-08-21 10:52:17 -07003775
3776 /**
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08003777 * Use with {@link #getSystemService(String)} to retrieve a {@link
Robert Quattlebaum87a71042017-05-15 15:45:20 -07003778 * android.net.lowpan.LowpanManager} for handling management of
3779 * LoWPAN access.
3780 *
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08003781 * @see #getSystemService(String)
Robert Quattlebaum87a71042017-05-15 15:45:20 -07003782 * @see android.net.lowpan.LowpanManager
3783 *
3784 * @hide
3785 */
3786 public static final String LOWPAN_SERVICE = "lowpan";
3787
3788 /**
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08003789 * Use with {@link #getSystemService(String)} to retrieve a {@link
Dianne Hackbornfee756f2014-07-16 17:31:10 -07003790 * android.net.EthernetManager} for handling management of
Lorenzo Colittif9ff2c92014-05-21 16:32:11 -07003791 * Ethernet access.
3792 *
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08003793 * @see #getSystemService(String)
Dianne Hackbornfee756f2014-07-16 17:31:10 -07003794 * @see android.net.EthernetManager
Lorenzo Colittif9ff2c92014-05-21 16:32:11 -07003795 *
3796 * @hide
3797 */
Mathew Inwood5c0d3542018-08-14 13:54:31 +01003798 @UnsupportedAppUsage
Lorenzo Colittif9ff2c92014-05-21 16:32:11 -07003799 public static final String ETHERNET_SERVICE = "ethernet";
3800
3801 /**
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08003802 * Use with {@link #getSystemService(String)} to retrieve a {@link
Irfan Sheriff60309fc2012-04-24 14:52:37 -07003803 * android.net.nsd.NsdManager} for handling management of network service
Irfan Sheriff7d024d32012-03-22 17:01:39 -07003804 * discovery
3805 *
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08003806 * @see #getSystemService(String)
Irfan Sheriff60309fc2012-04-24 14:52:37 -07003807 * @see android.net.nsd.NsdManager
Irfan Sheriff7d024d32012-03-22 17:01:39 -07003808 */
3809 public static final String NSD_SERVICE = "servicediscovery";
3810
Irfan Sheriff7d024d32012-03-22 17:01:39 -07003811 /**
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08003812 * Use with {@link #getSystemService(String)} to retrieve a
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003813 * {@link android.media.AudioManager} for handling management of volume,
3814 * ringer modes and audio routing.
Scott Main4b5da682010-10-21 11:49:12 -07003815 *
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08003816 * @see #getSystemService(String)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003817 * @see android.media.AudioManager
3818 */
3819 public static final String AUDIO_SERVICE = "audio";
Scott Main4b5da682010-10-21 11:49:12 -07003820
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003821 /**
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08003822 * Use with {@link #getSystemService(String)} to retrieve a
Jim Millerce7eb6d2015-04-03 19:29:13 -07003823 * {@link android.hardware.fingerprint.FingerprintManager} for handling management
Jim Miller08fa40c2014-04-29 18:18:47 -07003824 * of fingerprints.
3825 *
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08003826 * @see #getSystemService(String)
Jim Millerce7eb6d2015-04-03 19:29:13 -07003827 * @see android.hardware.fingerprint.FingerprintManager
Jim Miller08fa40c2014-04-29 18:18:47 -07003828 */
3829 public static final String FINGERPRINT_SERVICE = "fingerprint";
3830
3831 /**
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08003832 * Use with {@link #getSystemService(String)} to retrieve a
Gilad Brettercb51b8b2018-03-22 17:04:51 +02003833 * {@link android.hardware.face.FaceManager} for handling management
3834 * of face authentication.
3835 *
3836 * @hide
3837 * @see #getSystemService
3838 * @see android.hardware.face.FaceManager
3839 */
3840 public static final String FACE_SERVICE = "face";
3841
3842 /**
Kevin Chyn05c21502018-09-18 13:07:19 -07003843 * Use with {@link #getSystemService(String)} to retrieve a
Kevin Chyn51676d22018-11-05 18:00:43 -08003844 * {@link android.hardware.iris.IrisManager} for handling management
3845 * of iris authentication.
3846 *
3847 * @hide
3848 * @see #getSystemService
3849 * @see android.hardware.iris.IrisManager
3850 */
3851 public static final String IRIS_SERVICE = "iris";
3852
3853 /**
3854 * Use with {@link #getSystemService(String)} to retrieve a
Kevin Chyn05c21502018-09-18 13:07:19 -07003855 * {@link android.hardware.biometrics.BiometricManager} for handling management
3856 * of face authentication.
3857 *
3858 * @see #getSystemService
3859 * @see android.hardware.biometrics.BiometricManager
3860 */
3861 public static final String BIOMETRIC_SERVICE = "biometric";
3862
3863 /**
Gilad Brettercb51b8b2018-03-22 17:04:51 +02003864 * Use with {@link #getSystemService} to retrieve a
Dianne Hackbornb58b8f82012-06-11 15:08:39 -07003865 * {@link android.media.MediaRouter} for controlling and managing
3866 * routing of media.
3867 *
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08003868 * @see #getSystemService(String)
Dianne Hackbornb58b8f82012-06-11 15:08:39 -07003869 * @see android.media.MediaRouter
3870 */
3871 public static final String MEDIA_ROUTER_SERVICE = "media_router";
3872
3873 /**
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08003874 * Use with {@link #getSystemService(String)} to retrieve a
RoboErik42ea7ee2014-05-16 16:27:35 -07003875 * {@link android.media.session.MediaSessionManager} for managing media Sessions.
RoboErik01fe6612014-02-13 14:19:04 -08003876 *
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08003877 * @see #getSystemService(String)
RoboErik42ea7ee2014-05-16 16:27:35 -07003878 * @see android.media.session.MediaSessionManager
RoboErik01fe6612014-02-13 14:19:04 -08003879 */
3880 public static final String MEDIA_SESSION_SERVICE = "media_session";
3881
3882 /**
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08003883 * Use with {@link #getSystemService(String)} to retrieve a
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003884 * {@link android.telephony.TelephonyManager} for handling management the
3885 * telephony features of the device.
Scott Main4b5da682010-10-21 11:49:12 -07003886 *
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08003887 * @see #getSystemService(String)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003888 * @see android.telephony.TelephonyManager
3889 */
3890 public static final String TELEPHONY_SERVICE = "phone";
3891
3892 /**
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08003893 * Use with {@link #getSystemService(String)} to retrieve a
Wink Savilled09c4ca2014-11-22 10:08:16 -08003894 * {@link android.telephony.SubscriptionManager} for handling management the
3895 * telephony subscriptions of the device.
3896 *
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08003897 * @see #getSystemService(String)
Wink Savilled09c4ca2014-11-22 10:08:16 -08003898 * @see android.telephony.SubscriptionManager
3899 */
3900 public static final String TELEPHONY_SUBSCRIPTION_SERVICE = "telephony_subscription_service";
3901
3902 /**
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08003903 * Use with {@link #getSystemService(String)} to retrieve a
Tyler Gunnef9f6f92014-09-12 22:16:17 -07003904 * {@link android.telecom.TelecomManager} to manage telecom-related features
Yorke Leeb4ce1432014-06-09 13:53:23 -07003905 * of the device.
3906 *
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08003907 * @see #getSystemService(String)
Tyler Gunnef9f6f92014-09-12 22:16:17 -07003908 * @see android.telecom.TelecomManager
Yorke Leeb4ce1432014-06-09 13:53:23 -07003909 */
Tyler Gunnef9f6f92014-09-12 22:16:17 -07003910 public static final String TELECOM_SERVICE = "telecom";
Yorke Leeb4ce1432014-06-09 13:53:23 -07003911
3912 /**
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08003913 * Use with {@link #getSystemService(String)} to retrieve a
Jonathan Basseri9a1c9b62015-02-25 13:01:52 -08003914 * {@link android.telephony.CarrierConfigManager} for reading carrier configuration values.
3915 *
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08003916 * @see #getSystemService(String)
Jonathan Basseri9a1c9b62015-02-25 13:01:52 -08003917 * @see android.telephony.CarrierConfigManager
3918 */
3919 public static final String CARRIER_CONFIG_SERVICE = "carrier_config";
3920
3921 /**
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08003922 * Use with {@link #getSystemService(String)} to retrieve a
Jeff Davidson35cda392017-02-27 09:46:00 -08003923 * {@link android.telephony.euicc.EuiccManager} to manage the device eUICC (embedded SIM).
3924 *
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08003925 * @see #getSystemService(String)
Jeff Davidson35cda392017-02-27 09:46:00 -08003926 * @see android.telephony.euicc.EuiccManager
Jeff Davidson35cda392017-02-27 09:46:00 -08003927 */
Holly Jiuyu Sun4f73b9c2017-12-12 20:17:09 -08003928 public static final String EUICC_SERVICE = "euicc";
Jeff Davidson35cda392017-02-27 09:46:00 -08003929
3930 /**
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08003931 * Use with {@link #getSystemService(String)} to retrieve a
Holly Jiuyu Sun5c110242017-12-21 18:44:59 -08003932 * {@link android.telephony.euicc.EuiccCardManager} to access the device eUICC (embedded SIM).
3933 *
3934 * @see #getSystemService(String)
3935 * @see android.telephony.euicc.EuiccCardManager
Holly Jiuyu Sun5c110242017-12-21 18:44:59 -08003936 * @hide
3937 */
Holly Jiuyu Sun4f73b9c2017-12-12 20:17:09 -08003938 @SystemApi
3939 public static final String EUICC_CARD_SERVICE = "euicc_card";
Holly Jiuyu Sun5c110242017-12-21 18:44:59 -08003940
3941 /**
3942 * Use with {@link #getSystemService(String)} to retrieve a
Jeff Brown6e539312015-02-24 18:53:21 -08003943 * {@link android.content.ClipboardManager} for accessing and modifying
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003944 * the contents of the global clipboard.
Scott Main4b5da682010-10-21 11:49:12 -07003945 *
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08003946 * @see #getSystemService(String)
Jeff Brown6e539312015-02-24 18:53:21 -08003947 * @see android.content.ClipboardManager
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003948 */
3949 public static final String CLIPBOARD_SERVICE = "clipboard";
3950
3951 /**
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08003952 * Use with {@link #getSystemService(String)} to retrieve a
Abodunrinwa Tokif001fef2017-01-04 23:51:42 +00003953 * {@link TextClassificationManager} for text classification services.
Abodunrinwa Toki8158af52016-11-23 20:41:09 +00003954 *
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08003955 * @see #getSystemService(String)
Abodunrinwa Tokif001fef2017-01-04 23:51:42 +00003956 * @see TextClassificationManager
Abodunrinwa Toki8158af52016-11-23 20:41:09 +00003957 */
3958 public static final String TEXT_CLASSIFICATION_SERVICE = "textclassification";
3959
3960 /**
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08003961 * Use with {@link #getSystemService(String)} to retrieve a
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003962 * {@link android.view.inputmethod.InputMethodManager} for accessing input
3963 * methods.
3964 *
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08003965 * @see #getSystemService(String)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003966 */
3967 public static final String INPUT_METHOD_SERVICE = "input_method";
3968
3969 /**
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08003970 * Use with {@link #getSystemService(String)} to retrieve a
satok988323c2011-06-22 16:38:13 +09003971 * {@link android.view.textservice.TextServicesManager} for accessing
3972 * text services.
3973 *
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08003974 * @see #getSystemService(String)
satok988323c2011-06-22 16:38:13 +09003975 */
3976 public static final String TEXT_SERVICES_MANAGER_SERVICE = "textservices";
3977
3978 /**
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08003979 * Use with {@link #getSystemService(String)} to retrieve a
Dan Egnore38d58b2009-12-30 19:29:03 -08003980 * {@link android.appwidget.AppWidgetManager} for accessing AppWidgets.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003981 *
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08003982 * @see #getSystemService(String)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003983 */
The Android Open Source Projectc39a6e02009-03-11 12:11:56 -07003984 public static final String APPWIDGET_SERVICE = "appwidget";
Dan Egnor95240272009-10-27 18:23:39 -07003985
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003986 /**
Dianne Hackborn91097de2014-04-04 18:02:06 -07003987 * Official published name of the (internal) voice interaction manager service.
3988 *
3989 * @hide
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08003990 * @see #getSystemService(String)
Dianne Hackborn91097de2014-04-04 18:02:06 -07003991 */
3992 public static final String VOICE_INTERACTION_MANAGER_SERVICE = "voiceinteraction";
3993
3994 /**
Felipe Leme640f30a2017-03-06 15:44:06 -08003995 * Official published name of the (internal) autofill service.
Felipe Leme5381aa42016-10-13 09:02:32 -07003996 *
3997 * @hide
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08003998 * @see #getSystemService(String)
Felipe Leme5381aa42016-10-13 09:02:32 -07003999 */
Felipe Leme640f30a2017-03-06 15:44:06 -08004000 public static final String AUTOFILL_MANAGER_SERVICE = "autofill";
Felipe Leme5381aa42016-10-13 09:02:32 -07004001
4002 /**
Felipe Leme749b8892018-12-03 16:30:30 -08004003 * Official published name of the content capture service.
Felipe Lemee348dc32018-11-05 12:35:29 -08004004 *
4005 * @hide
4006 * @see #getSystemService(String)
4007 */
Felipe Leme749b8892018-12-03 16:30:30 -08004008 public static final String CONTENT_CAPTURE_MANAGER_SERVICE = "content_capture";
Felipe Lemee348dc32018-11-05 12:35:29 -08004009
4010 /**
Winson Chung3fb0f252019-01-08 17:41:55 -08004011 * Used for getting content selections and classifications for task snapshots.
4012 *
4013 * @hide
4014 * @see #getSystemService(String)
4015 */
4016 @SystemApi
4017 public static final String CONTENT_SUGGESTIONS_SERVICE = "content_suggestions";
4018
4019 /**
Sunny Goyal54e91342018-11-14 11:59:02 -08004020 * Official published name of the app prediction service.
4021 *
4022 * @hide
4023 * @see #getSystemService(String)
4024 */
4025 @SystemApi
4026 public static final String APP_PREDICTION_SERVICE = "app_prediction";
4027
4028 /**
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08004029 * Use with {@link #getSystemService(String)} to access the
Arunesh Mishraa772e5f2016-01-25 10:33:11 -08004030 * {@link com.android.server.voiceinteraction.SoundTriggerService}.
4031 *
4032 * @hide
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08004033 * @see #getSystemService(String)
Arunesh Mishraa772e5f2016-01-25 10:33:11 -08004034 */
4035 public static final String SOUND_TRIGGER_SERVICE = "soundtrigger";
4036
Philip P. Moltmann039678e2018-09-18 13:04:38 -07004037 /**
4038 * Official published name of the (internal) permission service.
4039 *
4040 * @see #getSystemService(String)
4041 * @hide
4042 */
4043 @SystemApi
4044 public static final String PERMISSION_SERVICE = "permission";
Arunesh Mishraa772e5f2016-01-25 10:33:11 -08004045
4046 /**
Philip P. Moltmannbc054d82018-12-21 09:41:58 -08004047 * Official published name of the (internal) permission controller service.
4048 *
4049 * @see #getSystemService(String)
4050 * @hide
4051 */
4052 public static final String PERMISSION_CONTROLLER_SERVICE = "permission_controller";
4053
4054 /**
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08004055 * Use with {@link #getSystemService(String)} to retrieve an
Christopher Tate45281862010-03-05 15:46:30 -08004056 * {@link android.app.backup.IBackupManager IBackupManager} for communicating
Christopher Tate487529a2009-04-29 14:03:25 -07004057 * with the backup mechanism.
Dianne Hackborn7f205432009-07-28 00:13:47 -07004058 * @hide
Scott Main4b5da682010-10-21 11:49:12 -07004059 *
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08004060 * @see #getSystemService(String)
Christopher Tate487529a2009-04-29 14:03:25 -07004061 */
Christopher Tated5cf7222014-07-29 16:53:09 -07004062 @SystemApi
Christopher Tate487529a2009-04-29 14:03:25 -07004063 public static final String BACKUP_SERVICE = "backup";
Dan Egnor95240272009-10-27 18:23:39 -07004064
4065 /**
Richard Uhlerb29f1452018-09-12 16:38:15 +01004066 * Use with {@link #getSystemService(String)} to retrieve an
4067 * {@link android.content.rollback.RollbackManager} for communicating
4068 * with the rollback manager
4069 *
4070 * @see #getSystemService(String)
Richard Uhlerc739c8c2018-12-12 11:03:34 +00004071 * @hide
Richard Uhlerb29f1452018-09-12 16:38:15 +01004072 */
Richard Uhlerc739c8c2018-12-12 11:03:34 +00004073 @SystemApi
Richard Uhlerb29f1452018-09-12 16:38:15 +01004074 public static final String ROLLBACK_SERVICE = "rollback";
4075
4076 /**
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08004077 * Use with {@link #getSystemService(String)} to retrieve a
Dan Egnor1337b012010-01-04 11:01:44 -08004078 * {@link android.os.DropBoxManager} instance for recording
Dan Egnor95240272009-10-27 18:23:39 -07004079 * diagnostic logs.
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08004080 * @see #getSystemService(String)
Dan Egnor95240272009-10-27 18:23:39 -07004081 */
4082 public static final String DROPBOX_SERVICE = "dropbox";
4083
Christopher Tate487529a2009-04-29 14:03:25 -07004084 /**
Philip P. Moltmannf80809f2018-04-04 11:20:44 -07004085 * System service name for the DeviceIdleManager.
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08004086 * @see #getSystemService(String)
Dianne Hackborn1958e5e2015-06-12 18:11:41 -07004087 * @hide
4088 */
4089 public static final String DEVICE_IDLE_CONTROLLER = "deviceidle";
4090
4091 /**
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08004092 * Use with {@link #getSystemService(String)} to retrieve a
Dianne Hackborn87bba1e2010-02-26 17:25:54 -08004093 * {@link android.app.admin.DevicePolicyManager} for working with global
Dianne Hackbornd6847842010-01-12 18:14:19 -08004094 * device policy management.
4095 *
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08004096 * @see #getSystemService(String)
Dianne Hackbornd6847842010-01-12 18:14:19 -08004097 */
4098 public static final String DEVICE_POLICY_SERVICE = "device_policy";
4099
4100 /**
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08004101 * Use with {@link #getSystemService(String)} to retrieve a
Tobias Haamel53332882010-02-18 16:15:43 -08004102 * {@link android.app.UiModeManager} for controlling UI modes.
4103 *
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08004104 * @see #getSystemService(String)
Tobias Haamel53332882010-02-18 16:15:43 -08004105 */
4106 public static final String UI_MODE_SERVICE = "uimode";
4107
4108 /**
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08004109 * Use with {@link #getSystemService(String)} to retrieve a
Steve Howardd58429f2010-09-27 16:32:39 -07004110 * {@link android.app.DownloadManager} for requesting HTTP downloads.
Steve Howarda2709362010-07-02 17:12:48 -07004111 *
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08004112 * @see #getSystemService(String)
Steve Howarda2709362010-07-02 17:12:48 -07004113 */
4114 public static final String DOWNLOAD_SERVICE = "download";
4115
4116 /**
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08004117 * Use with {@link #getSystemService(String)} to retrieve a
Todd Poynore35872d2013-12-10 11:57:21 -08004118 * {@link android.os.BatteryManager} for managing battery state.
4119 *
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08004120 * @see #getSystemService(String)
Todd Poynore35872d2013-12-10 11:57:21 -08004121 */
4122 public static final String BATTERY_SERVICE = "batterymanager";
4123
4124 /**
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08004125 * Use with {@link #getSystemService(String)} to retrieve a
Nick Pelly50b4d8f2010-12-07 22:40:28 -08004126 * {@link android.nfc.NfcManager} for using NFC.
4127 *
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08004128 * @see #getSystemService(String)
Nick Pelly50b4d8f2010-12-07 22:40:28 -08004129 */
4130 public static final String NFC_SERVICE = "nfc";
4131
4132 /**
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08004133 * Use with {@link #getSystemService(String)} to retrieve a
Florian Salbrechter084da9b2015-03-25 11:00:55 +00004134 * {@link android.bluetooth.BluetoothManager} for using Bluetooth.
Jaikumar Ganesh1abb1cb2012-01-25 16:14:50 -08004135 *
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08004136 * @see #getSystemService(String)
Jaikumar Ganesh1abb1cb2012-01-25 16:14:50 -08004137 */
4138 public static final String BLUETOOTH_SERVICE = "bluetooth";
4139
4140 /**
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08004141 * Use with {@link #getSystemService(String)} to retrieve a
Chung-yih Wang2d942312010-08-05 12:17:37 +08004142 * {@link android.net.sip.SipManager} for accessing the SIP related service.
4143 *
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08004144 * @see #getSystemService(String)
Chung-yih Wang2d942312010-08-05 12:17:37 +08004145 */
4146 /** @hide */
4147 public static final String SIP_SERVICE = "sip";
4148
4149 /**
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08004150 * Use with {@link #getSystemService(String)} to retrieve a {@link
Mike Lockwoodc4308f02011-03-01 08:04:54 -08004151 * android.hardware.usb.UsbManager} for access to USB devices (as a USB host)
Mike Lockwoode7d511e2010-12-30 13:39:37 -05004152 * and for controlling this device's behavior as a USB device.
4153 *
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08004154 * @see #getSystemService(String)
John Spurlock6098c5d2013-06-17 10:32:46 -04004155 * @see android.hardware.usb.UsbManager
Mike Lockwoode7d511e2010-12-30 13:39:37 -05004156 */
4157 public static final String USB_SERVICE = "usb";
4158
4159 /**
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08004160 * Use with {@link #getSystemService(String)} to retrieve a {@link
Kenny Rootf74bfde2018-01-18 15:42:48 -08004161 * Use with {@link #getSystemService} to retrieve a {@link
4162 * android.debug.AdbManager} for access to ADB debug functions.
4163 *
4164 * @see #getSystemService(String)
4165 * @see android.debug.AdbManager
4166 *
4167 * @hide
4168 */
4169 public static final String ADB_SERVICE = "adb";
4170
4171 /**
4172 * Use with {@link #getSystemService(String)} to retrieve a {@link
Mike Lockwoodb01e8bf2011-08-29 20:11:07 -04004173 * android.hardware.SerialManager} for access to serial ports.
4174 *
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08004175 * @see #getSystemService(String)
Dianne Hackborn35f72be2013-09-16 10:57:39 -07004176 * @see android.hardware.SerialManager
Mike Lockwoodb01e8bf2011-08-29 20:11:07 -04004177 *
4178 * @hide
4179 */
4180 public static final String SERIAL_SERVICE = "serial";
4181
4182 /**
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08004183 * Use with {@link #getSystemService(String)} to retrieve a
Jinsuk Kim91120c52014-05-08 17:12:51 +09004184 * {@link android.hardware.hdmi.HdmiControlManager} for controlling and managing
4185 * HDMI-CEC protocol.
4186 *
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08004187 * @see #getSystemService(String)
Jinsuk Kim91120c52014-05-08 17:12:51 +09004188 * @see android.hardware.hdmi.HdmiControlManager
Jinsuk Kim66d1eb22014-06-06 16:12:18 +09004189 * @hide
Jinsuk Kim91120c52014-05-08 17:12:51 +09004190 */
Jinsuk Kim66d1eb22014-06-06 16:12:18 +09004191 @SystemApi
Jinsuk Kim91120c52014-05-08 17:12:51 +09004192 public static final String HDMI_CONTROL_SERVICE = "hdmi_control";
Jinsuk Kimfbcd5032014-03-21 16:25:13 +09004193
4194 /**
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08004195 * Use with {@link #getSystemService(String)} to retrieve a
Jeff Brown9df6e7a2012-04-05 11:49:26 -07004196 * {@link android.hardware.input.InputManager} for interacting with input devices.
4197 *
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08004198 * @see #getSystemService(String)
Jeff Brown9df6e7a2012-04-05 11:49:26 -07004199 * @see android.hardware.input.InputManager
4200 */
4201 public static final String INPUT_SERVICE = "input";
4202
4203 /**
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08004204 * Use with {@link #getSystemService(String)} to retrieve a
Jeff Brownfa25bf52012-07-23 19:26:30 -07004205 * {@link android.hardware.display.DisplayManager} for interacting with display devices.
4206 *
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08004207 * @see #getSystemService(String)
Jeff Brownfa25bf52012-07-23 19:26:30 -07004208 * @see android.hardware.display.DisplayManager
4209 */
4210 public static final String DISPLAY_SERVICE = "display";
4211
4212 /**
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08004213 * Use with {@link #getSystemService(String)} to retrieve a
Christine Franks39b03112018-07-03 14:46:07 -07004214 * {@link android.hardware.display.ColorDisplayManager} for controlling color transforms.
4215 *
4216 * @see #getSystemService(String)
4217 * @see android.hardware.display.ColorDisplayManager
4218 * @hide
4219 */
4220 public static final String COLOR_DISPLAY_SERVICE = "color_display";
4221
4222 /**
4223 * Use with {@link #getSystemService(String)} to retrieve a
Amith Yamasani258848d2012-08-10 17:06:33 -07004224 * {@link android.os.UserManager} for managing users on devices that support multiple users.
4225 *
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08004226 * @see #getSystemService(String)
Amith Yamasani258848d2012-08-10 17:06:33 -07004227 * @see android.os.UserManager
4228 */
4229 public static final String USER_SERVICE = "user";
4230
4231 /**
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08004232 * Use with {@link #getSystemService(String)} to retrieve a
Amith Yamasani4f582632014-02-19 14:31:52 -08004233 * {@link android.content.pm.LauncherApps} for querying and monitoring launchable apps across
4234 * profiles of a user.
4235 *
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08004236 * @see #getSystemService(String)
Amith Yamasani4f582632014-02-19 14:31:52 -08004237 * @see android.content.pm.LauncherApps
4238 */
4239 public static final String LAUNCHER_APPS_SERVICE = "launcherapps";
4240
4241 /**
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08004242 * Use with {@link #getSystemService(String)} to retrieve a
Amith Yamasanif20d6402014-05-24 15:34:37 -07004243 * {@link android.content.RestrictionsManager} for retrieving application restrictions
4244 * and requesting permissions for restricted operations.
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08004245 * @see #getSystemService(String)
Amith Yamasanif20d6402014-05-24 15:34:37 -07004246 * @see android.content.RestrictionsManager
4247 */
4248 public static final String RESTRICTIONS_SERVICE = "restrictions";
4249
4250 /**
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08004251 * Use with {@link #getSystemService(String)} to retrieve a
Dianne Hackborna06de0f2012-12-11 16:34:47 -08004252 * {@link android.app.AppOpsManager} for tracking application operations
4253 * on the device.
4254 *
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08004255 * @see #getSystemService(String)
Dianne Hackborna06de0f2012-12-11 16:34:47 -08004256 * @see android.app.AppOpsManager
Dianne Hackborna06de0f2012-12-11 16:34:47 -08004257 */
4258 public static final String APP_OPS_SERVICE = "appops";
4259
4260 /**
Hai Zhangb7776682018-09-25 15:10:57 -07004261 * Use with {@link #getSystemService(String)} to retrieve a {@link android.app.role.RoleManager}
4262 * for managing roles.
4263 *
4264 * @see #getSystemService(String)
4265 * @see android.app.role.RoleManager
4266 */
4267 public static final String ROLE_SERVICE = "role";
4268
4269 /**
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08004270 * Use with {@link #getSystemService(String)} to retrieve a
Eino-Ville Talvala2f1a2e42013-07-25 17:12:05 -07004271 * {@link android.hardware.camera2.CameraManager} for interacting with
Eino-Ville Talvalab2675542012-12-12 13:29:45 -08004272 * camera devices.
4273 *
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08004274 * @see #getSystemService(String)
Dianne Hackborn221ea892013-08-04 16:50:16 -07004275 * @see android.hardware.camera2.CameraManager
Eino-Ville Talvalab2675542012-12-12 13:29:45 -08004276 */
4277 public static final String CAMERA_SERVICE = "camera";
4278
4279 /**
Svetoslav Ganov4b9a4d12013-06-11 15:20:06 -07004280 * {@link android.print.PrintManager} for printing and managing
Jeff Brown511cd352013-08-23 17:43:37 -07004281 * printers and print tasks.
Svetoslav Ganov4b9a4d12013-06-11 15:20:06 -07004282 *
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08004283 * @see #getSystemService(String)
Svetoslav Ganov4b9a4d12013-06-11 15:20:06 -07004284 * @see android.print.PrintManager
4285 */
4286 public static final String PRINT_SERVICE = "print";
4287
4288 /**
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08004289 * Use with {@link #getSystemService(String)} to retrieve a
Eugene Susla6ed45d82017-01-22 13:52:51 -08004290 * {@link android.companion.CompanionDeviceManager} for managing companion devices
4291 *
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08004292 * @see #getSystemService(String)
Eugene Susla6ed45d82017-01-22 13:52:51 -08004293 * @see android.companion.CompanionDeviceManager
4294 */
Eugene Suslad7355cc2017-04-20 11:14:45 -07004295 public static final String COMPANION_DEVICE_SERVICE = "companiondevice";
Eugene Susla6ed45d82017-01-22 13:52:51 -08004296
4297 /**
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08004298 * Use with {@link #getSystemService(String)} to retrieve a
Erik Gilling51e95df2013-06-26 11:06:51 -07004299 * {@link android.hardware.ConsumerIrManager} for transmitting infrared
4300 * signals from the device.
4301 *
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08004302 * @see #getSystemService(String)
Erik Gilling51e95df2013-06-26 11:06:51 -07004303 * @see android.hardware.ConsumerIrManager
4304 */
4305 public static final String CONSUMER_IR_SERVICE = "consumer_ir";
4306
4307 /**
Adrian Roos82142c22014-03-27 14:56:59 +01004308 * {@link android.app.trust.TrustManager} for managing trust agents.
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08004309 * @see #getSystemService(String)
Adrian Roos82142c22014-03-27 14:56:59 +01004310 * @see android.app.trust.TrustManager
4311 * @hide
4312 */
4313 public static final String TRUST_SERVICE = "trust";
4314
4315 /**
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08004316 * Use with {@link #getSystemService(String)} to retrieve a
Jae Seod5cc4a22014-05-30 16:57:43 -07004317 * {@link android.media.tv.TvInputManager} for interacting with TV inputs
4318 * on the device.
Jae Seo39570912014-02-20 18:23:25 -08004319 *
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08004320 * @see #getSystemService(String)
Jae Seod5cc4a22014-05-30 16:57:43 -07004321 * @see android.media.tv.TvInputManager
Jae Seo39570912014-02-20 18:23:25 -08004322 */
4323 public static final String TV_INPUT_SERVICE = "tv_input";
4324
4325 /**
Jeff Davidsonb51e0a62014-04-09 12:38:15 -07004326 * {@link android.net.NetworkScoreManager} for managing network scoring.
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08004327 * @see #getSystemService(String)
Jeff Davidsonb51e0a62014-04-09 12:38:15 -07004328 * @see android.net.NetworkScoreManager
4329 * @hide
4330 */
Jeff Davidson5ad20792014-07-21 13:55:42 -07004331 @SystemApi
Jeff Davidsonb51e0a62014-04-09 12:38:15 -07004332 public static final String NETWORK_SCORE_SERVICE = "network_score";
4333
4334 /**
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08004335 * Use with {@link #getSystemService(String)} to retrieve a {@link
Adam Lesinskiaa607672014-11-24 11:27:50 -08004336 * android.app.usage.UsageStatsManager} for querying device usage stats.
Dianne Hackborne22b3b12014-05-07 18:06:44 -07004337 *
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08004338 * @see #getSystemService(String)
Dianne Hackbornff170242014-11-19 10:59:01 -08004339 * @see android.app.usage.UsageStatsManager
Dianne Hackborne22b3b12014-05-07 18:06:44 -07004340 */
4341 public static final String USAGE_STATS_SERVICE = "usagestats";
4342
4343 /**
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08004344 * Use with {@link #getSystemService(String)} to retrieve a {@link
Christopher Tate7060b042014-06-09 19:50:00 -07004345 * android.app.job.JobScheduler} instance for managing occasional
Christopher Tatefa380e92014-05-19 13:46:29 -07004346 * background tasks.
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08004347 * @see #getSystemService(String)
Christopher Tate7060b042014-06-09 19:50:00 -07004348 * @see android.app.job.JobScheduler
Christopher Tatefa380e92014-05-19 13:46:29 -07004349 */
Christopher Tate7060b042014-06-09 19:50:00 -07004350 public static final String JOB_SCHEDULER_SERVICE = "jobscheduler";
Christopher Tatefa380e92014-05-19 13:46:29 -07004351
4352 /**
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08004353 * Use with {@link #getSystemService(String)} to retrieve a {@link
Andres Morales33df9372014-09-26 17:08:59 -07004354 * android.service.persistentdata.PersistentDataBlockManager} instance
4355 * for interacting with a storage device that lives across factory resets.
4356 *
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08004357 * @see #getSystemService(String)
Andres Morales68d4acd2014-07-01 19:40:41 -07004358 * @see android.service.persistentdata.PersistentDataBlockManager
4359 * @hide
4360 */
Andres Morales33df9372014-09-26 17:08:59 -07004361 @SystemApi
Andres Morales68d4acd2014-07-01 19:40:41 -07004362 public static final String PERSISTENT_DATA_BLOCK_SERVICE = "persistent_data_block";
4363
4364 /**
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08004365 * Use with {@link #getSystemService(String)} to retrieve a {@link
Andrew Scull3b8b46f2017-02-13 18:12:15 +00004366 * android.service.oemlock.OemLockManager} instance for managing the OEM lock.
4367 *
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08004368 * @see #getSystemService(String)
Andrew Scull3b8b46f2017-02-13 18:12:15 +00004369 * @see android.service.oemlock.OemLockManager
4370 * @hide
4371 */
4372 @SystemApi
4373 public static final String OEM_LOCK_SERVICE = "oem_lock";
4374
4375 /**
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08004376 * Use with {@link #getSystemService(String)} to retrieve a {@link
Michael Wrightc39d47a2014-07-08 18:07:36 -07004377 * android.media.projection.MediaProjectionManager} instance for managing
4378 * media projection sessions.
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08004379 * @see #getSystemService(String)
Jeff Brown6e539312015-02-24 18:53:21 -08004380 * @see android.media.projection.MediaProjectionManager
Michael Wrightc39d47a2014-07-08 18:07:36 -07004381 */
4382 public static final String MEDIA_PROJECTION_SERVICE = "media_projection";
4383
4384 /**
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08004385 * Use with {@link #getSystemService(String)} to retrieve a
Mike Lockwoodb6737702015-02-20 08:28:47 -08004386 * {@link android.media.midi.MidiManager} for accessing the MIDI service.
Mike Lockwood67f8e8b2014-12-01 13:54:59 -08004387 *
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08004388 * @see #getSystemService(String)
Mike Lockwood67f8e8b2014-12-01 13:54:59 -08004389 */
4390 public static final String MIDI_SERVICE = "midi";
4391
Eric Laurent2035ac82015-03-05 15:18:44 -08004392
4393 /**
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08004394 * Use with {@link #getSystemService(String)} to retrieve a
Eric Laurent2035ac82015-03-05 15:18:44 -08004395 * {@link android.hardware.radio.RadioManager} for accessing the broadcast radio service.
4396 *
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08004397 * @see #getSystemService(String)
Eric Laurent2035ac82015-03-05 15:18:44 -08004398 * @hide
4399 */
Tomasz Wasilczyk9110df72017-06-22 07:57:20 -07004400 public static final String RADIO_SERVICE = "broadcastradio";
Eric Laurent2035ac82015-03-05 15:18:44 -08004401
Paul McLeana33be212015-02-20 07:52:45 -08004402 /**
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08004403 * Use with {@link #getSystemService(String)} to retrieve a
Polina Bondarenko965ecbb2015-11-13 15:34:28 +01004404 * {@link android.os.HardwarePropertiesManager} for accessing the hardware properties service.
4405 *
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08004406 * @see #getSystemService(String)
Polina Bondarenko965ecbb2015-11-13 15:34:28 +01004407 */
Polina Bondarenko8333c732016-03-09 18:08:42 +01004408 public static final String HARDWARE_PROPERTIES_SERVICE = "hardware_properties";
Polina Bondarenko965ecbb2015-11-13 15:34:28 +01004409
4410 /**
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08004411 * Use with {@link #getSystemService(String)} to retrieve a
Wei Wangbad7c202018-11-01 11:57:39 -07004412 * {@link android.os.ThermalService} for accessing the thermal service.
4413 *
4414 * @see #getSystemService(String)
4415 * @hide
4416 */
4417 public static final String THERMAL_SERVICE = "thermalservice";
4418
4419 /**
4420 * Use with {@link #getSystemService(String)} to retrieve a
Makoto Onukib5a012f2016-06-21 11:13:53 -07004421 * {@link android.content.pm.ShortcutManager} for accessing the launcher shortcut service.
Makoto Onuki6f7362d92016-03-04 13:39:41 -08004422 *
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08004423 * @see #getSystemService(String)
Makoto Onuki6f7362d92016-03-04 13:39:41 -08004424 * @see android.content.pm.ShortcutManager
4425 */
4426 public static final String SHORTCUT_SERVICE = "shortcut";
4427
4428 /**
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08004429 * Use with {@link #getSystemService(String)} to retrieve a {@link
Peng Xu9ff7d222016-02-11 13:02:05 -08004430 * android.hardware.location.ContextHubManager} for accessing context hubs.
4431 *
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08004432 * @see #getSystemService(String)
Peng Xu9ff7d222016-02-11 13:02:05 -08004433 * @see android.hardware.location.ContextHubManager
4434 *
4435 * @hide
4436 */
4437 @SystemApi
4438 public static final String CONTEXTHUB_SERVICE = "contexthub";
4439
4440 /**
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08004441 * Use with {@link #getSystemService(String)} to retrieve a
Joe Onorato713fec82016-03-04 10:34:02 -08004442 * {@link android.os.health.SystemHealthManager} for accessing system health (battery, power,
4443 * memory, etc) metrics.
4444 *
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08004445 * @see #getSystemService(String)
Joe Onorato713fec82016-03-04 10:34:02 -08004446 */
4447 public static final String SYSTEM_HEALTH_SERVICE = "systemhealth";
4448
4449 /**
Amith Yamasanid04aaa32016-06-13 12:09:36 -07004450 * Gatekeeper Service.
4451 * @hide
4452 */
4453 public static final String GATEKEEPER_SERVICE = "android.service.gatekeeper.IGateKeeperService";
4454
4455 /**
Svet Ganov37e43272016-09-09 16:01:32 -07004456 * Service defining the policy for access to device identifiers.
4457 * @hide
4458 */
4459 public static final String DEVICE_IDENTIFIERS_SERVICE = "device_identifiers";
4460
4461 /**
Joe Onorato1754d742016-11-21 17:51:35 -08004462 * Service to report a system health "incident"
4463 * @hide
4464 */
4465 public static final String INCIDENT_SERVICE = "incident";
4466
4467 /**
Joe Onoratoe21ab7e2018-12-18 15:00:25 -08004468 * Service to assist incidentd and dumpstated in reporting status to the user
4469 * and in confirming authorization to take an incident report or bugreport
4470 * @hide
4471 */
4472 public static final String INCIDENT_COMPANION_SERVICE = "incidentcompanion";
4473
4474 /**
Bookatz94726412017-08-31 09:26:15 -07004475 * Service to assist statsd in obtaining general stats.
4476 * @hide
4477 */
4478 public static final String STATS_COMPANION_SERVICE = "statscompanion";
4479
4480 /**
Bookatzc6977972018-01-16 16:55:05 -08004481 * Use with {@link #getSystemService(String)} to retrieve an {@link android.app.StatsManager}.
David Chenadaf8b32017-11-03 15:42:08 -07004482 * @hide
4483 */
4484 @SystemApi
4485 public static final String STATS_MANAGER = "stats";
4486
4487 /**
Nandana Duttd11850c2018-12-12 17:26:57 +00004488 * Service to capture a bugreport.
4489 * @see #getSystemService(String)
4490 * @see android.os.BugreportManager
4491 * @hide
4492 */
4493 // TODO: Expose API when the implementation is more complete.
4494 // @SystemApi
4495 public static final String BUGREPORT_SERVICE = "bugreport";
4496
4497 /**
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08004498 * Use with {@link #getSystemService(String)} to retrieve a {@link
MÃ¥rten Kongstadeabc9e92015-12-15 16:40:23 +01004499 * android.content.om.OverlayManager} for managing overlay packages.
4500 *
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08004501 * @see #getSystemService(String)
MÃ¥rten Kongstadeabc9e92015-12-15 16:40:23 +01004502 * @see android.content.om.OverlayManager
4503 * @hide
4504 */
4505 public static final String OVERLAY_SERVICE = "overlay";
4506
4507 /**
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08004508 * Use with {@link #getSystemService(String)} to retrieve a
MÃ¥rten Kongstad06a1ac82018-09-20 13:09:47 +02004509 * {android.os.IIdmap2} for managing idmap files (used by overlay
4510 * packages).
4511 *
4512 * @see #getSystemService(String)
4513 * @hide
4514 */
4515 public static final String IDMAP_SERVICE = "idmap";
4516
4517 /**
4518 * Use with {@link #getSystemService(String)} to retrieve a
Zak Cohen56345f42017-01-26 13:54:28 -08004519 * {@link VrManager} for accessing the VR service.
4520 *
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08004521 * @see #getSystemService(String)
Zak Cohen56345f42017-01-26 13:54:28 -08004522 * @hide
4523 */
4524 @SystemApi
4525 public static final String VR_SERVICE = "vrmanager";
4526
4527 /**
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08004528 * Use with {@link #getSystemService(String)} to retrieve an
Neil Fullerfe6ec562017-03-16 18:29:36 +00004529 * {@link android.app.timezone.ITimeZoneRulesManager}.
4530 * @hide
4531 *
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08004532 * @see #getSystemService(String)
Neil Fullerfe6ec562017-03-16 18:29:36 +00004533 */
4534 public static final String TIME_ZONE_RULES_MANAGER_SERVICE = "timezone";
4535
4536 /**
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08004537 * Use with {@link #getSystemService(String)} to retrieve a
Tony Makb0d22622018-01-18 12:49:49 +00004538 * {@link android.content.pm.CrossProfileApps} for cross profile operations.
Tony Mak1b708e62017-10-12 10:59:11 +01004539 *
Ng Zhi Anf7c1e2b2018-01-08 11:18:08 -08004540 * @see #getSystemService(String)
Tony Mak1b708e62017-10-12 10:59:11 +01004541 */
4542 public static final String CROSS_PROFILE_APPS_SERVICE = "crossprofileapps";
4543
4544 /**
Ruchi Kandoi6149b0f2018-01-03 16:14:57 -08004545 * Use with {@link #getSystemService} to retrieve a
4546 * {@link android.se.omapi.ISecureElementService}
4547 * for accessing the SecureElementService.
4548 *
4549 * @hide
4550 */
4551 @SystemApi
4552 public static final String SECURE_ELEMENT_SERVICE = "secure_element";
4553
4554 /**
Neil Fullerfeeee682018-05-30 14:35:24 +01004555 * Use with {@link #getSystemService(String)} to retrieve an
4556 * {@link android.app.timedetector.ITimeDetectorService}.
4557 * @hide
4558 *
4559 * @see #getSystemService(String)
4560 */
4561 public static final String TIME_DETECTOR_SERVICE = "time_detector";
4562
4563 /**
Makoto Onukidf7e4812018-09-24 14:31:25 -07004564 * Binder service name for {@link AppBindingService}.
4565 * @hide
4566 */
4567 public static final String APP_BINDING_SERVICE = "app_binding";
4568
4569 /**
Sahin Caliskan9458ebc2018-10-31 13:23:29 -07004570 * Use with {@link #getSystemService(String)} to retrieve an
Sahin Caliskan84dd3062018-12-03 14:06:39 -08004571 * {@link android.telephony.ims.RcsManager}.
Sahin Caliskan9458ebc2018-10-31 13:23:29 -07004572 * @hide
4573 */
4574 public static final String TELEPHONY_RCS_SERVICE = "ircs";
4575
Howard Chen0a947642019-01-07 14:10:44 +08004576 /**
4577 * Use with {@link #getSystemService(String)} to retrieve an
4578 * {@link android.os.DynamicAndroidManager}.
4579 * @hide
4580 */
4581 @SystemApi
4582 public static final String DYNAMIC_ANDROID_SERVICE = "dynamic_android";
4583
Sahin Caliskan9458ebc2018-10-31 13:23:29 -07004584 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004585 * Determine whether the given permission is allowed for a particular
4586 * process and user ID running in the system.
4587 *
4588 * @param permission The name of the permission being checked.
4589 * @param pid The process ID being checked against. Must be > 0.
4590 * @param uid The user ID being checked against. A uid of 0 is the root
4591 * user, which will pass every permission check.
4592 *
John Spurlock6098c5d2013-06-17 10:32:46 -04004593 * @return {@link PackageManager#PERMISSION_GRANTED} if the given
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004594 * pid/uid is allowed that permission, or
4595 * {@link PackageManager#PERMISSION_DENIED} if it is not.
4596 *
4597 * @see PackageManager#checkPermission(String, String)
4598 * @see #checkCallingPermission
4599 */
Tor Norbye1c2bf032015-03-02 10:57:08 -08004600 @CheckResult(suggest="#enforcePermission(String,int,int,String)")
Tor Norbyed9273d62013-05-30 15:59:53 -07004601 @PackageManager.PermissionResult
4602 public abstract int checkPermission(@NonNull String permission, int pid, int uid);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004603
Dianne Hackbornff170242014-11-19 10:59:01 -08004604 /** @hide */
4605 @PackageManager.PermissionResult
Mathew Inwood5c0d3542018-08-14 13:54:31 +01004606 @UnsupportedAppUsage
Dianne Hackbornff170242014-11-19 10:59:01 -08004607 public abstract int checkPermission(@NonNull String permission, int pid, int uid,
4608 IBinder callerToken);
4609
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004610 /**
4611 * Determine whether the calling process of an IPC you are handling has been
4612 * granted a particular permission. This is basically the same as calling
4613 * {@link #checkPermission(String, int, int)} with the pid and uid returned
4614 * by {@link android.os.Binder#getCallingPid} and
4615 * {@link android.os.Binder#getCallingUid}. One important difference
4616 * is that if you are not currently processing an IPC, this function
4617 * will always fail. This is done to protect against accidentally
4618 * leaking permissions; you can use {@link #checkCallingOrSelfPermission}
4619 * to avoid this protection.
4620 *
4621 * @param permission The name of the permission being checked.
4622 *
John Spurlock6098c5d2013-06-17 10:32:46 -04004623 * @return {@link PackageManager#PERMISSION_GRANTED} if the calling
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004624 * pid/uid is allowed that permission, or
4625 * {@link PackageManager#PERMISSION_DENIED} if it is not.
4626 *
4627 * @see PackageManager#checkPermission(String, String)
4628 * @see #checkPermission
4629 * @see #checkCallingOrSelfPermission
4630 */
Tor Norbye1c2bf032015-03-02 10:57:08 -08004631 @CheckResult(suggest="#enforceCallingPermission(String,String)")
Tor Norbyed9273d62013-05-30 15:59:53 -07004632 @PackageManager.PermissionResult
4633 public abstract int checkCallingPermission(@NonNull String permission);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004634
4635 /**
4636 * Determine whether the calling process of an IPC <em>or you</em> have been
4637 * granted a particular permission. This is the same as
4638 * {@link #checkCallingPermission}, except it grants your own permissions
4639 * if you are not currently processing an IPC. Use with care!
4640 *
4641 * @param permission The name of the permission being checked.
4642 *
John Spurlock6098c5d2013-06-17 10:32:46 -04004643 * @return {@link PackageManager#PERMISSION_GRANTED} if the calling
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004644 * pid/uid is allowed that permission, or
4645 * {@link PackageManager#PERMISSION_DENIED} if it is not.
4646 *
4647 * @see PackageManager#checkPermission(String, String)
4648 * @see #checkPermission
4649 * @see #checkCallingPermission
4650 */
Tor Norbye1c2bf032015-03-02 10:57:08 -08004651 @CheckResult(suggest="#enforceCallingOrSelfPermission(String,String)")
Tor Norbyed9273d62013-05-30 15:59:53 -07004652 @PackageManager.PermissionResult
4653 public abstract int checkCallingOrSelfPermission(@NonNull String permission);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004654
4655 /**
Svetoslavc6d1c342015-02-26 14:44:43 -08004656 * Determine whether <em>you</em> have been granted a particular permission.
4657 *
4658 * @param permission The name of the permission being checked.
4659 *
4660 * @return {@link PackageManager#PERMISSION_GRANTED} if you have the
4661 * permission, or {@link PackageManager#PERMISSION_DENIED} if not.
4662 *
4663 * @see PackageManager#checkPermission(String, String)
4664 * @see #checkCallingPermission(String)
4665 */
4666 @PackageManager.PermissionResult
4667 public abstract int checkSelfPermission(@NonNull String permission);
4668
4669 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004670 * If the given permission is not allowed for a particular process
4671 * and user ID running in the system, throw a {@link SecurityException}.
4672 *
4673 * @param permission The name of the permission being checked.
4674 * @param pid The process ID being checked against. Must be &gt; 0.
4675 * @param uid The user ID being checked against. A uid of 0 is the root
4676 * user, which will pass every permission check.
4677 * @param message A message to include in the exception if it is thrown.
4678 *
4679 * @see #checkPermission(String, int, int)
4680 */
4681 public abstract void enforcePermission(
Tor Norbyed9273d62013-05-30 15:59:53 -07004682 @NonNull String permission, int pid, int uid, @Nullable String message);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004683
4684 /**
4685 * If the calling process of an IPC you are handling has not been
4686 * granted a particular permission, throw a {@link
4687 * SecurityException}. This is basically the same as calling
4688 * {@link #enforcePermission(String, int, int, String)} with the
4689 * pid and uid returned by {@link android.os.Binder#getCallingPid}
4690 * and {@link android.os.Binder#getCallingUid}. One important
4691 * difference is that if you are not currently processing an IPC,
4692 * this function will always throw the SecurityException. This is
4693 * done to protect against accidentally leaking permissions; you
4694 * can use {@link #enforceCallingOrSelfPermission} to avoid this
4695 * protection.
4696 *
4697 * @param permission The name of the permission being checked.
4698 * @param message A message to include in the exception if it is thrown.
4699 *
4700 * @see #checkCallingPermission(String)
4701 */
4702 public abstract void enforceCallingPermission(
Tor Norbyed9273d62013-05-30 15:59:53 -07004703 @NonNull String permission, @Nullable String message);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004704
4705 /**
4706 * If neither you nor the calling process of an IPC you are
4707 * handling has been granted a particular permission, throw a
4708 * {@link SecurityException}. This is the same as {@link
4709 * #enforceCallingPermission}, except it grants your own
4710 * permissions if you are not currently processing an IPC. Use
4711 * with care!
4712 *
4713 * @param permission The name of the permission being checked.
4714 * @param message A message to include in the exception if it is thrown.
4715 *
4716 * @see #checkCallingOrSelfPermission(String)
4717 */
4718 public abstract void enforceCallingOrSelfPermission(
Tor Norbyed9273d62013-05-30 15:59:53 -07004719 @NonNull String permission, @Nullable String message);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004720
4721 /**
4722 * Grant permission to access a specific Uri to another package, regardless
4723 * of whether that package has general permission to access the Uri's
4724 * content provider. This can be used to grant specific, temporary
4725 * permissions, typically in response to user interaction (such as the
4726 * user opening an attachment that you would like someone else to
4727 * display).
4728 *
4729 * <p>Normally you should use {@link Intent#FLAG_GRANT_READ_URI_PERMISSION
4730 * Intent.FLAG_GRANT_READ_URI_PERMISSION} or
4731 * {@link Intent#FLAG_GRANT_WRITE_URI_PERMISSION
4732 * Intent.FLAG_GRANT_WRITE_URI_PERMISSION} with the Intent being used to
4733 * start an activity instead of this function directly. If you use this
4734 * function directly, you should be sure to call
4735 * {@link #revokeUriPermission} when the target should no longer be allowed
4736 * to access it.
4737 *
4738 * <p>To succeed, the content provider owning the Uri must have set the
4739 * {@link android.R.styleable#AndroidManifestProvider_grantUriPermissions
4740 * grantUriPermissions} attribute in its manifest or included the
4741 * {@link android.R.styleable#AndroidManifestGrantUriPermission
4742 * &lt;grant-uri-permissions&gt;} tag.
4743 *
4744 * @param toPackage The package you would like to allow to access the Uri.
4745 * @param uri The Uri you would like to grant access to.
Jeff Sharkey6503bd82017-04-19 23:24:18 -06004746 * @param modeFlags The desired access modes.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004747 *
4748 * @see #revokeUriPermission
4749 */
4750 public abstract void grantUriPermission(String toPackage, Uri uri,
Tor Norbyed9273d62013-05-30 15:59:53 -07004751 @Intent.GrantUriMode int modeFlags);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004752
4753 /**
4754 * Remove all permissions to access a particular content provider Uri
Dianne Hackborna47223f2017-03-30 13:49:13 -07004755 * that were previously added with {@link #grantUriPermission} or <em>any other</em> mechanism.
4756 * The given Uri will match all previously granted Uris that are the same or a
Jeff Sharkey328ebf22013-03-21 18:09:39 -07004757 * sub-path of the given Uri. That is, revoking "content://foo/target" will
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004758 * revoke both "content://foo/target" and "content://foo/target/sub", but not
Jeff Sharkey846318a2014-04-04 12:12:41 -07004759 * "content://foo". It will not remove any prefix grants that exist at a
4760 * higher level.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004761 *
Dianne Hackborn955d8d62014-10-07 20:17:19 -07004762 * <p>Prior to {@link android.os.Build.VERSION_CODES#LOLLIPOP}, if you did not have
Dianne Hackborn192679a2014-09-10 14:28:48 -07004763 * regular permission access to a Uri, but had received access to it through
4764 * a specific Uri permission grant, you could not revoke that grant with this
4765 * function and a {@link SecurityException} would be thrown. As of
Dianne Hackborna47223f2017-03-30 13:49:13 -07004766 * {@link android.os.Build.VERSION_CODES#LOLLIPOP}, this function will not throw a security
4767 * exception, but will remove whatever permission grants to the Uri had been given to the app
Dianne Hackborn192679a2014-09-10 14:28:48 -07004768 * (or none).</p>
4769 *
Dianne Hackborna47223f2017-03-30 13:49:13 -07004770 * <p>Unlike {@link #revokeUriPermission(String, Uri, int)}, this method impacts all permission
4771 * grants matching the given Uri, for any package they had been granted to, through any
4772 * mechanism this had happened (such as indirectly through the clipboard, activity launch,
4773 * service start, etc). That means this can be potentially dangerous to use, as it can
4774 * revoke grants that another app could be strongly expecting to stick around.</p>
4775 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004776 * @param uri The Uri you would like to revoke access to.
Jeff Sharkey6503bd82017-04-19 23:24:18 -06004777 * @param modeFlags The access modes to revoke.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004778 *
4779 * @see #grantUriPermission
4780 */
Jeff Sharkey846318a2014-04-04 12:12:41 -07004781 public abstract void revokeUriPermission(Uri uri, @Intent.AccessUriMode int modeFlags);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004782
4783 /**
Dianne Hackborna47223f2017-03-30 13:49:13 -07004784 * Remove permissions to access a particular content provider Uri
4785 * that were previously added with {@link #grantUriPermission} for a specific target
4786 * package. The given Uri will match all previously granted Uris that are the same or a
4787 * sub-path of the given Uri. That is, revoking "content://foo/target" will
4788 * revoke both "content://foo/target" and "content://foo/target/sub", but not
4789 * "content://foo". It will not remove any prefix grants that exist at a
4790 * higher level.
4791 *
4792 * <p>Unlike {@link #revokeUriPermission(Uri, int)}, this method will <em>only</em>
4793 * revoke permissions that had been explicitly granted through {@link #grantUriPermission}
4794 * and only for the package specified. Any matching grants that have happened through
4795 * other mechanisms (clipboard, activity launching, service starting, etc) will not be
4796 * removed.</p>
4797 *
4798 * @param toPackage The package you had previously granted access to.
4799 * @param uri The Uri you would like to revoke access to.
Jeff Sharkey6503bd82017-04-19 23:24:18 -06004800 * @param modeFlags The access modes to revoke.
Dianne Hackborna47223f2017-03-30 13:49:13 -07004801 *
4802 * @see #grantUriPermission
4803 */
4804 public abstract void revokeUriPermission(String toPackage, Uri uri,
4805 @Intent.AccessUriMode int modeFlags);
4806
4807 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004808 * Determine whether a particular process and user ID has been granted
4809 * permission to access a specific URI. This only checks for permissions
4810 * that have been explicitly granted -- if the given process/uid has
4811 * more general access to the URI's content provider then this check will
4812 * always fail.
4813 *
4814 * @param uri The uri that is being checked.
4815 * @param pid The process ID being checked against. Must be &gt; 0.
4816 * @param uid The user ID being checked against. A uid of 0 is the root
4817 * user, which will pass every permission check.
Jeff Sharkey6503bd82017-04-19 23:24:18 -06004818 * @param modeFlags The access modes to check.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004819 *
John Spurlock6098c5d2013-06-17 10:32:46 -04004820 * @return {@link PackageManager#PERMISSION_GRANTED} if the given
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004821 * pid/uid is allowed to access that uri, or
4822 * {@link PackageManager#PERMISSION_DENIED} if it is not.
4823 *
4824 * @see #checkCallingUriPermission
4825 */
Tor Norbye1c2bf032015-03-02 10:57:08 -08004826 @CheckResult(suggest="#enforceUriPermission(Uri,int,int,String)")
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06004827 @PackageManager.PermissionResult
Tor Norbyed9273d62013-05-30 15:59:53 -07004828 public abstract int checkUriPermission(Uri uri, int pid, int uid,
Jeff Sharkey846318a2014-04-04 12:12:41 -07004829 @Intent.AccessUriMode int modeFlags);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004830
Dianne Hackbornff170242014-11-19 10:59:01 -08004831 /** @hide */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06004832 @PackageManager.PermissionResult
Dianne Hackbornff170242014-11-19 10:59:01 -08004833 public abstract int checkUriPermission(Uri uri, int pid, int uid,
4834 @Intent.AccessUriMode int modeFlags, IBinder callerToken);
4835
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004836 /**
4837 * Determine whether the calling process and user ID has been
4838 * granted permission to access a specific URI. This is basically
4839 * the same as calling {@link #checkUriPermission(Uri, int, int,
4840 * int)} with the pid and uid returned by {@link
4841 * android.os.Binder#getCallingPid} and {@link
4842 * android.os.Binder#getCallingUid}. One important difference is
4843 * that if you are not currently processing an IPC, this function
4844 * will always fail.
4845 *
4846 * @param uri The uri that is being checked.
Jeff Sharkey6503bd82017-04-19 23:24:18 -06004847 * @param modeFlags The access modes to check.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004848 *
John Spurlock6098c5d2013-06-17 10:32:46 -04004849 * @return {@link PackageManager#PERMISSION_GRANTED} if the caller
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004850 * is allowed to access that uri, or
4851 * {@link PackageManager#PERMISSION_DENIED} if it is not.
4852 *
4853 * @see #checkUriPermission(Uri, int, int, int)
4854 */
Tor Norbye1c2bf032015-03-02 10:57:08 -08004855 @CheckResult(suggest="#enforceCallingUriPermission(Uri,int,String)")
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06004856 @PackageManager.PermissionResult
Jeff Sharkey846318a2014-04-04 12:12:41 -07004857 public abstract int checkCallingUriPermission(Uri uri, @Intent.AccessUriMode int modeFlags);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004858
4859 /**
4860 * Determine whether the calling process of an IPC <em>or you</em> has been granted
4861 * permission to access a specific URI. This is the same as
4862 * {@link #checkCallingUriPermission}, except it grants your own permissions
4863 * if you are not currently processing an IPC. Use with care!
4864 *
4865 * @param uri The uri that is being checked.
Jeff Sharkey6503bd82017-04-19 23:24:18 -06004866 * @param modeFlags The access modes to check.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004867 *
John Spurlock6098c5d2013-06-17 10:32:46 -04004868 * @return {@link PackageManager#PERMISSION_GRANTED} if the caller
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004869 * is allowed to access that uri, or
4870 * {@link PackageManager#PERMISSION_DENIED} if it is not.
4871 *
4872 * @see #checkCallingUriPermission
4873 */
Tor Norbye1c2bf032015-03-02 10:57:08 -08004874 @CheckResult(suggest="#enforceCallingOrSelfUriPermission(Uri,int,String)")
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06004875 @PackageManager.PermissionResult
Tor Norbyed9273d62013-05-30 15:59:53 -07004876 public abstract int checkCallingOrSelfUriPermission(Uri uri,
Jeff Sharkey846318a2014-04-04 12:12:41 -07004877 @Intent.AccessUriMode int modeFlags);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004878
4879 /**
4880 * Check both a Uri and normal permission. This allows you to perform
4881 * both {@link #checkPermission} and {@link #checkUriPermission} in one
4882 * call.
4883 *
4884 * @param uri The Uri whose permission is to be checked, or null to not
4885 * do this check.
4886 * @param readPermission The permission that provides overall read access,
4887 * or null to not do this check.
4888 * @param writePermission The permission that provides overall write
Tor Norbyed9273d62013-05-30 15:59:53 -07004889 * access, or null to not do this check.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004890 * @param pid The process ID being checked against. Must be &gt; 0.
4891 * @param uid The user ID being checked against. A uid of 0 is the root
4892 * user, which will pass every permission check.
Jeff Sharkey6503bd82017-04-19 23:24:18 -06004893 * @param modeFlags The access modes to check.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004894 *
John Spurlock6098c5d2013-06-17 10:32:46 -04004895 * @return {@link PackageManager#PERMISSION_GRANTED} if the caller
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004896 * is allowed to access that uri or holds one of the given permissions, or
4897 * {@link PackageManager#PERMISSION_DENIED} if it is not.
4898 */
Tor Norbye1c2bf032015-03-02 10:57:08 -08004899 @CheckResult(suggest="#enforceUriPermission(Uri,String,String,int,int,int,String)")
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06004900 @PackageManager.PermissionResult
Tor Norbyed9273d62013-05-30 15:59:53 -07004901 public abstract int checkUriPermission(@Nullable Uri uri, @Nullable String readPermission,
4902 @Nullable String writePermission, int pid, int uid,
Jeff Sharkey846318a2014-04-04 12:12:41 -07004903 @Intent.AccessUriMode int modeFlags);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004904
4905 /**
4906 * If a particular process and user ID has not been granted
4907 * permission to access a specific URI, throw {@link
4908 * SecurityException}. This only checks for permissions that have
4909 * been explicitly granted -- if the given process/uid has more
4910 * general access to the URI's content provider then this check
4911 * will always fail.
4912 *
4913 * @param uri The uri that is being checked.
4914 * @param pid The process ID being checked against. Must be &gt; 0.
4915 * @param uid The user ID being checked against. A uid of 0 is the root
4916 * user, which will pass every permission check.
Jeff Sharkey6503bd82017-04-19 23:24:18 -06004917 * @param modeFlags The access modes to enforce.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004918 * @param message A message to include in the exception if it is thrown.
4919 *
4920 * @see #checkUriPermission(Uri, int, int, int)
4921 */
4922 public abstract void enforceUriPermission(
Jeff Sharkey846318a2014-04-04 12:12:41 -07004923 Uri uri, int pid, int uid, @Intent.AccessUriMode int modeFlags, String message);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004924
4925 /**
4926 * If the calling process and user ID has not been granted
4927 * permission to access a specific URI, throw {@link
4928 * SecurityException}. This is basically the same as calling
4929 * {@link #enforceUriPermission(Uri, int, int, int, String)} with
4930 * the pid and uid returned by {@link
4931 * android.os.Binder#getCallingPid} and {@link
4932 * android.os.Binder#getCallingUid}. One important difference is
4933 * that if you are not currently processing an IPC, this function
4934 * will always throw a SecurityException.
4935 *
4936 * @param uri The uri that is being checked.
Jeff Sharkey6503bd82017-04-19 23:24:18 -06004937 * @param modeFlags The access modes to enforce.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004938 * @param message A message to include in the exception if it is thrown.
4939 *
4940 * @see #checkCallingUriPermission(Uri, int)
4941 */
4942 public abstract void enforceCallingUriPermission(
Jeff Sharkey846318a2014-04-04 12:12:41 -07004943 Uri uri, @Intent.AccessUriMode int modeFlags, String message);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004944
4945 /**
4946 * If the calling process of an IPC <em>or you</em> has not been
4947 * granted permission to access a specific URI, throw {@link
4948 * SecurityException}. This is the same as {@link
4949 * #enforceCallingUriPermission}, except it grants your own
4950 * permissions if you are not currently processing an IPC. Use
4951 * with care!
Scott Main4b5da682010-10-21 11:49:12 -07004952 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004953 * @param uri The uri that is being checked.
Jeff Sharkey6503bd82017-04-19 23:24:18 -06004954 * @param modeFlags The access modes to enforce.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004955 * @param message A message to include in the exception if it is thrown.
4956 *
4957 * @see #checkCallingOrSelfUriPermission(Uri, int)
4958 */
4959 public abstract void enforceCallingOrSelfUriPermission(
Jeff Sharkey846318a2014-04-04 12:12:41 -07004960 Uri uri, @Intent.AccessUriMode int modeFlags, String message);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004961
4962 /**
4963 * Enforce both a Uri and normal permission. This allows you to perform
4964 * both {@link #enforcePermission} and {@link #enforceUriPermission} in one
4965 * call.
Scott Main4b5da682010-10-21 11:49:12 -07004966 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004967 * @param uri The Uri whose permission is to be checked, or null to not
4968 * do this check.
4969 * @param readPermission The permission that provides overall read access,
4970 * or null to not do this check.
4971 * @param writePermission The permission that provides overall write
Tor Norbyed9273d62013-05-30 15:59:53 -07004972 * access, or null to not do this check.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004973 * @param pid The process ID being checked against. Must be &gt; 0.
4974 * @param uid The user ID being checked against. A uid of 0 is the root
4975 * user, which will pass every permission check.
Jeff Sharkey6503bd82017-04-19 23:24:18 -06004976 * @param modeFlags The access modes to enforce.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004977 * @param message A message to include in the exception if it is thrown.
4978 *
4979 * @see #checkUriPermission(Uri, String, String, int, int, int)
4980 */
4981 public abstract void enforceUriPermission(
Tor Norbyed9273d62013-05-30 15:59:53 -07004982 @Nullable Uri uri, @Nullable String readPermission,
Jeff Sharkey846318a2014-04-04 12:12:41 -07004983 @Nullable String writePermission, int pid, int uid, @Intent.AccessUriMode int modeFlags,
Tor Norbyed9273d62013-05-30 15:59:53 -07004984 @Nullable String message);
4985
4986 /** @hide */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06004987 @IntDef(flag = true, prefix = { "CONTEXT_" }, value = {
4988 CONTEXT_INCLUDE_CODE,
4989 CONTEXT_IGNORE_SECURITY,
4990 CONTEXT_RESTRICTED,
4991 CONTEXT_DEVICE_PROTECTED_STORAGE,
4992 CONTEXT_CREDENTIAL_PROTECTED_STORAGE,
4993 CONTEXT_REGISTER_PACKAGE,
4994 })
Tor Norbyed9273d62013-05-30 15:59:53 -07004995 @Retention(RetentionPolicy.SOURCE)
4996 public @interface CreatePackageOptions {}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004997
4998 /**
4999 * Flag for use with {@link #createPackageContext}: include the application
5000 * code with the context. This means loading code into the caller's
5001 * process, so that {@link #getClassLoader()} can be used to instantiate
5002 * the application's classes. Setting this flags imposes security
5003 * restrictions on what application context you can access; if the
5004 * requested application can not be safely loaded into your process,
5005 * java.lang.SecurityException will be thrown. If this flag is not set,
5006 * there will be no restrictions on the packages that can be loaded,
5007 * but {@link #getClassLoader} will always return the default system
5008 * class loader.
5009 */
5010 public static final int CONTEXT_INCLUDE_CODE = 0x00000001;
5011
5012 /**
5013 * Flag for use with {@link #createPackageContext}: ignore any security
5014 * restrictions on the Context being requested, allowing it to always
5015 * be loaded. For use with {@link #CONTEXT_INCLUDE_CODE} to allow code
5016 * to be loaded into a process even when it isn't safe to do so. Use
5017 * with extreme care!
5018 */
5019 public static final int CONTEXT_IGNORE_SECURITY = 0x00000002;
Scott Main4b5da682010-10-21 11:49:12 -07005020
Romain Guy870e09f2009-07-06 16:35:25 -07005021 /**
5022 * Flag for use with {@link #createPackageContext}: a restricted context may
5023 * disable specific features. For instance, a View associated with a restricted
5024 * context would ignore particular XML attributes.
5025 */
5026 public static final int CONTEXT_RESTRICTED = 0x00000004;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005027
5028 /**
Jeff Sharkey7a30a302015-12-08 14:20:06 -07005029 * Flag for use with {@link #createPackageContext}: point all file APIs at
Jeff Sharkey8a372a02016-03-16 16:25:45 -06005030 * device-protected storage.
Jeff Sharkey7a30a302015-12-08 14:20:06 -07005031 *
5032 * @hide
5033 */
Jeff Sharkey8a372a02016-03-16 16:25:45 -06005034 public static final int CONTEXT_DEVICE_PROTECTED_STORAGE = 0x00000008;
Jeff Sharkey7a30a302015-12-08 14:20:06 -07005035
5036 /**
5037 * Flag for use with {@link #createPackageContext}: point all file APIs at
Jeff Sharkey8a372a02016-03-16 16:25:45 -06005038 * credential-protected storage.
Jeff Sharkey7a30a302015-12-08 14:20:06 -07005039 *
5040 * @hide
5041 */
Jeff Sharkey8a372a02016-03-16 16:25:45 -06005042 public static final int CONTEXT_CREDENTIAL_PROTECTED_STORAGE = 0x00000010;
Jeff Sharkey7a30a302015-12-08 14:20:06 -07005043
5044 /**
Dianne Hackbornfee756f2014-07-16 17:31:10 -07005045 * @hide Used to indicate we should tell the activity manager about the process
5046 * loading this code.
5047 */
5048 public static final int CONTEXT_REGISTER_PACKAGE = 0x40000000;
5049
5050 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005051 * Return a new Context object for the given application name. This
5052 * Context is the same as what the named application gets when it is
5053 * launched, containing the same resources and class loader. Each call to
5054 * this method returns a new instance of a Context object; Context objects
5055 * are not shared, however they share common state (Resources, ClassLoader,
5056 * etc) so the Context instance itself is fairly lightweight.
5057 *
Jeff Brown6e539312015-02-24 18:53:21 -08005058 * <p>Throws {@link android.content.pm.PackageManager.NameNotFoundException} if there is no
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005059 * application with the given package name.
5060 *
5061 * <p>Throws {@link java.lang.SecurityException} if the Context requested
5062 * can not be loaded into the caller's process for security reasons (see
5063 * {@link #CONTEXT_INCLUDE_CODE} for more information}.
5064 *
5065 * @param packageName Name of the application's package.
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005066 * @param flags Option flags.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005067 *
John Spurlock6098c5d2013-06-17 10:32:46 -04005068 * @return A {@link Context} for the application.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005069 *
John Spurlock6098c5d2013-06-17 10:32:46 -04005070 * @throws SecurityException &nbsp;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005071 * @throws PackageManager.NameNotFoundException if there is no application with
John Spurlock6098c5d2013-06-17 10:32:46 -04005072 * the given package name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005073 */
5074 public abstract Context createPackageContext(String packageName,
Tor Norbyed9273d62013-05-30 15:59:53 -07005075 @CreatePackageOptions int flags) throws PackageManager.NameNotFoundException;
Romain Guy870e09f2009-07-06 16:35:25 -07005076
5077 /**
Jeff Sharkey6d515712012-09-20 16:06:08 -07005078 * Similar to {@link #createPackageContext(String, int)}, but with a
5079 * different {@link UserHandle}. For example, {@link #getContentResolver()}
5080 * will open any {@link Uri} as the given user.
5081 *
5082 * @hide
5083 */
Patrick Baumannef4c4072018-02-01 08:54:05 -08005084 @SystemApi
Jeff Sharkeyec5f7d12018-08-08 09:15:04 -06005085 @TestApi
Patrick Baumannef4c4072018-02-01 08:54:05 -08005086 public Context createPackageContextAsUser(
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005087 String packageName, @CreatePackageOptions int flags, UserHandle user)
Patrick Baumannef4c4072018-02-01 08:54:05 -08005088 throws PackageManager.NameNotFoundException {
5089 if (Build.IS_ENG) {
5090 throw new IllegalStateException("createPackageContextAsUser not overridden!");
5091 }
5092 return this;
5093 }
Jeff Sharkey6d515712012-09-20 16:06:08 -07005094
5095 /**
Svetoslav976e8bd2014-07-16 15:12:03 -07005096 * Creates a context given an {@link android.content.pm.ApplicationInfo}.
5097 *
5098 * @hide
5099 */
Mathew Inwood5c0d3542018-08-14 13:54:31 +01005100 @UnsupportedAppUsage
Svetoslav976e8bd2014-07-16 15:12:03 -07005101 public abstract Context createApplicationContext(ApplicationInfo application,
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005102 @CreatePackageOptions int flags) throws PackageManager.NameNotFoundException;
Svetoslav976e8bd2014-07-16 15:12:03 -07005103
5104 /**
Adam Lesinski4e862812016-11-21 16:02:24 -08005105 * Return a new Context object for the given split name. The new Context has a ClassLoader and
5106 * Resources object that can access the split's and all of its dependencies' code/resources.
5107 * Each call to this method returns a new instance of a Context object;
5108 * Context objects are not shared, however common state (ClassLoader, other Resources for
5109 * the same split) may be so the Context itself can be fairly lightweight.
5110 *
5111 * @param splitName The name of the split to include, as declared in the split's
5112 * <code>AndroidManifest.xml</code>.
5113 * @return A {@link Context} with the given split's code and/or resources loaded.
5114 */
5115 public abstract Context createContextForSplit(String splitName)
5116 throws PackageManager.NameNotFoundException;
5117
5118 /**
Jeff Sharkeyad357d12018-02-02 13:25:31 -07005119 * Get the user associated with this context
Jim Millera75a8832013-02-07 16:53:32 -08005120 * @hide
5121 */
Jeff Sharkeya73b8fd2016-01-06 17:02:08 -07005122 @TestApi
Jeff Sharkeyad357d12018-02-02 13:25:31 -07005123 public UserHandle getUser() {
5124 return android.os.Process.myUserHandle();
5125 }
5126
5127 /**
5128 * Get the user associated with this context
5129 * @hide
5130 */
5131 @TestApi
5132 public @UserIdInt int getUserId() {
5133 return android.os.UserHandle.myUserId();
5134 }
Jim Millera75a8832013-02-07 16:53:32 -08005135
5136 /**
Dianne Hackborn756220b2012-08-14 16:45:30 -07005137 * Return a new Context object for the current Context but whose resources
5138 * are adjusted to match the given Configuration. Each call to this method
Jeff Browna492c3a2012-08-23 19:48:44 -07005139 * returns a new instance of a Context object; Context objects are not
Dianne Hackborn756220b2012-08-14 16:45:30 -07005140 * shared, however common state (ClassLoader, other Resources for the
5141 * same configuration) may be so the Context itself can be fairly lightweight.
5142 *
5143 * @param overrideConfiguration A {@link Configuration} specifying what
5144 * values to modify in the base Configuration of the original Context's
5145 * resources. If the base configuration changes (such as due to an
5146 * orientation change), the resources of this context will also change except
5147 * for those that have been explicitly overridden with a value here.
5148 *
John Spurlock6098c5d2013-06-17 10:32:46 -04005149 * @return A {@link Context} with the given configuration override.
Dianne Hackborn756220b2012-08-14 16:45:30 -07005150 */
Tor Norbyed9273d62013-05-30 15:59:53 -07005151 public abstract Context createConfigurationContext(
5152 @NonNull Configuration overrideConfiguration);
Dianne Hackborn756220b2012-08-14 16:45:30 -07005153
5154 /**
Jeff Browna492c3a2012-08-23 19:48:44 -07005155 * Return a new Context object for the current Context but whose resources
5156 * are adjusted to match the metrics of the given Display. Each call to this method
5157 * returns a new instance of a Context object; Context objects are not
5158 * shared, however common state (ClassLoader, other Resources for the
5159 * same configuration) may be so the Context itself can be fairly lightweight.
5160 *
5161 * The returned display Context provides a {@link WindowManager}
5162 * (see {@link #getSystemService(String)}) that is configured to show windows
5163 * on the given display. The WindowManager's {@link WindowManager#getDefaultDisplay}
5164 * method can be used to retrieve the Display from the returned Context.
5165 *
5166 * @param display A {@link Display} object specifying the display
5167 * for whose metrics the Context's resources should be tailored and upon which
5168 * new windows should be shown.
5169 *
John Spurlock6098c5d2013-06-17 10:32:46 -04005170 * @return A {@link Context} for the display.
Jeff Browna492c3a2012-08-23 19:48:44 -07005171 */
Tor Norbyed9273d62013-05-30 15:59:53 -07005172 public abstract Context createDisplayContext(@NonNull Display display);
Jeff Browna492c3a2012-08-23 19:48:44 -07005173
5174 /**
Jeff Sharkey7a30a302015-12-08 14:20:06 -07005175 * Return a new Context object for the current Context but whose storage
Jeff Sharkey8a372a02016-03-16 16:25:45 -06005176 * APIs are backed by device-protected storage.
Jeff Sharkey7a30a302015-12-08 14:20:06 -07005177 * <p>
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06005178 * On devices with direct boot, data stored in this location is encrypted
Jeff Sharkey8a372a02016-03-16 16:25:45 -06005179 * with a key tied to the physical device, and it can be accessed
5180 * immediately after the device has booted successfully, both
5181 * <em>before and after</em> the user has authenticated with their
5182 * credentials (such as a lock pattern or PIN).
5183 * <p>
5184 * Because device-protected data is available without user authentication,
5185 * you should carefully limit the data you store using this Context. For
5186 * example, storing sensitive authentication tokens or passwords in the
5187 * device-protected area is strongly discouraged.
Jeff Sharkey7a30a302015-12-08 14:20:06 -07005188 * <p>
Jeff Sharkey3ea44a52016-01-09 15:19:56 -07005189 * If the underlying device does not have the ability to store
Jeff Sharkey8a372a02016-03-16 16:25:45 -06005190 * device-protected and credential-protected data using different keys, then
5191 * both storage areas will become available at the same time. They remain as
5192 * two distinct storage locations on disk, and only the window of
5193 * availability changes.
Jeff Sharkey3ea44a52016-01-09 15:19:56 -07005194 * <p>
Jeff Sharkey7a30a302015-12-08 14:20:06 -07005195 * Each call to this method returns a new instance of a Context object;
5196 * Context objects are not shared, however common state (ClassLoader, other
5197 * Resources for the same configuration) may be so the Context itself can be
5198 * fairly lightweight.
5199 *
Jeff Sharkey8a372a02016-03-16 16:25:45 -06005200 * @see #isDeviceProtectedStorage()
Jeff Sharkey7a30a302015-12-08 14:20:06 -07005201 */
Jeff Sharkey8a372a02016-03-16 16:25:45 -06005202 public abstract Context createDeviceProtectedStorageContext();
5203
Jeff Sharkey7a30a302015-12-08 14:20:06 -07005204 /**
5205 * Return a new Context object for the current Context but whose storage
Jeff Sharkey8a372a02016-03-16 16:25:45 -06005206 * APIs are backed by credential-protected storage. This is the default
5207 * storage area for apps unless
5208 * {@link android.R.attr#defaultToDeviceProtectedStorage} was requested.
Jeff Sharkey7a30a302015-12-08 14:20:06 -07005209 * <p>
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06005210 * On devices with direct boot, data stored in this location is encrypted
Jeff Sharkey8a372a02016-03-16 16:25:45 -06005211 * with a key tied to user credentials, which can be accessed
Jeff Sharkey7a30a302015-12-08 14:20:06 -07005212 * <em>only after</em> the user has entered their credentials (such as a
5213 * lock pattern or PIN).
5214 * <p>
Jeff Sharkey3ea44a52016-01-09 15:19:56 -07005215 * If the underlying device does not have the ability to store
Jeff Sharkey8a372a02016-03-16 16:25:45 -06005216 * device-protected and credential-protected data using different keys, then
5217 * both storage areas will become available at the same time. They remain as
5218 * two distinct storage locations on disk, and only the window of
5219 * availability changes.
Jeff Sharkey3ea44a52016-01-09 15:19:56 -07005220 * <p>
Jeff Sharkey7a30a302015-12-08 14:20:06 -07005221 * Each call to this method returns a new instance of a Context object;
5222 * Context objects are not shared, however common state (ClassLoader, other
5223 * Resources for the same configuration) may be so the Context itself can be
5224 * fairly lightweight.
5225 *
Jeff Sharkey8a372a02016-03-16 16:25:45 -06005226 * @see #isCredentialProtectedStorage()
Jeff Sharkeye13529a2015-12-09 14:15:27 -07005227 * @hide
Jeff Sharkey7a30a302015-12-08 14:20:06 -07005228 */
Jeff Sharkeye13529a2015-12-09 14:15:27 -07005229 @SystemApi
Jeff Sharkey8a372a02016-03-16 16:25:45 -06005230 public abstract Context createCredentialProtectedStorageContext();
5231
Jeff Sharkey7a30a302015-12-08 14:20:06 -07005232 /**
Craig Mautner48d0d182013-06-11 07:53:06 -07005233 * Gets the display adjustments holder for this context. This information
5234 * is provided on a per-application or activity basis and is used to simulate lower density
5235 * display metrics for legacy applications and restricted screen sizes.
Jeff Brown98365d72012-08-19 20:30:52 -07005236 *
Jeff Browna492c3a2012-08-23 19:48:44 -07005237 * @param displayId The display id for which to get compatibility info.
Jeff Brown98365d72012-08-19 20:30:52 -07005238 * @return The compatibility info holder, or null if not required by the application.
5239 * @hide
5240 */
Craig Mautner48d0d182013-06-11 07:53:06 -07005241 public abstract DisplayAdjustments getDisplayAdjustments(int displayId);
Jeff Brown98365d72012-08-19 20:30:52 -07005242
5243 /**
Wale Ogunwale691af682019-02-11 03:09:10 -08005244 * @return Returns the {@link Display} object this context is associated with.
Adam Lesinski4ece3d62016-06-16 18:05:41 -07005245 * @hide
5246 */
Wale Ogunwale691af682019-02-11 03:09:10 -08005247 @TestApi
Adam Lesinski4ece3d62016-06-16 18:05:41 -07005248 public abstract Display getDisplay();
5249
5250 /**
Yohei Yukawa5281b6b2018-10-15 07:38:25 +08005251 * Gets the display ID.
5252 *
5253 * @return display ID associated with this {@link Context}.
5254 * @hide
5255 */
5256 public abstract int getDisplayId();
5257
5258 /**
Andrii Kulianb047b8b2017-02-08 18:38:26 -08005259 * @hide
5260 */
5261 public abstract void updateDisplay(int displayId);
5262
5263 /**
Romain Guy870e09f2009-07-06 16:35:25 -07005264 * Indicates whether this Context is restricted.
Scott Main4b5da682010-10-21 11:49:12 -07005265 *
John Spurlock6098c5d2013-06-17 10:32:46 -04005266 * @return {@code true} if this Context is restricted, {@code false} otherwise.
Scott Main4b5da682010-10-21 11:49:12 -07005267 *
Romain Guy870e09f2009-07-06 16:35:25 -07005268 * @see #CONTEXT_RESTRICTED
5269 */
5270 public boolean isRestricted() {
5271 return false;
5272 }
Jeff Sharkey7a30a302015-12-08 14:20:06 -07005273
5274 /**
5275 * Indicates if the storage APIs of this Context are backed by
Jeff Sharkey8a372a02016-03-16 16:25:45 -06005276 * device-protected storage.
Jeff Sharkey7a30a302015-12-08 14:20:06 -07005277 *
Jeff Sharkey8a372a02016-03-16 16:25:45 -06005278 * @see #createDeviceProtectedStorageContext()
Jeff Sharkey7a30a302015-12-08 14:20:06 -07005279 */
Jeff Sharkey8a372a02016-03-16 16:25:45 -06005280 public abstract boolean isDeviceProtectedStorage();
5281
Jeff Sharkey7a30a302015-12-08 14:20:06 -07005282 /**
5283 * Indicates if the storage APIs of this Context are backed by
Jeff Sharkey8a372a02016-03-16 16:25:45 -06005284 * credential-protected storage.
Jeff Sharkey7a30a302015-12-08 14:20:06 -07005285 *
Jeff Sharkey8a372a02016-03-16 16:25:45 -06005286 * @see #createCredentialProtectedStorageContext()
Jeff Sharkeye13529a2015-12-09 14:15:27 -07005287 * @hide
Jeff Sharkey7a30a302015-12-08 14:20:06 -07005288 */
Jeff Sharkeye13529a2015-12-09 14:15:27 -07005289 @SystemApi
Jeff Sharkey8a372a02016-03-16 16:25:45 -06005290 public abstract boolean isCredentialProtectedStorage();
5291
Tony Mak46aabe52016-11-14 12:53:06 +00005292 /**
Seigo Nonaka6d6cd682017-06-22 08:22:18 -07005293 * Returns true if the context can load unsafe resources, e.g. fonts.
5294 * @hide
5295 */
5296 public abstract boolean canLoadUnsafeResources();
5297
5298 /**
Tony Mak46aabe52016-11-14 12:53:06 +00005299 * @hide
5300 */
5301 public IBinder getActivityToken() {
5302 throw new RuntimeException("Not implemented. Must override in a subclass.");
5303 }
5304
5305 /**
5306 * @hide
5307 */
5308 @Nullable
5309 public IServiceConnection getServiceDispatcher(ServiceConnection conn, Handler handler,
5310 int flags) {
5311 throw new RuntimeException("Not implemented. Must override in a subclass.");
5312 }
5313
5314 /**
5315 * @hide
5316 */
5317 public IApplicationThread getIApplicationThread() {
5318 throw new RuntimeException("Not implemented. Must override in a subclass.");
5319 }
Tony Makbf9928d2016-12-22 11:02:45 +00005320
5321 /**
5322 * @hide
5323 */
5324 public Handler getMainThreadHandler() {
5325 throw new RuntimeException("Not implemented. Must override in a subclass.");
5326 }
Adam Lesinskia82b6262017-03-21 16:56:17 -07005327
5328 /**
Felipe Lemebb567ae2017-10-04 09:56:21 -07005329 * @hide
5330 */
5331 public AutofillClient getAutofillClient() {
5332 return null;
5333 }
5334
5335 /**
5336 * @hide
5337 */
Svet Ganov47b37aa2018-02-16 00:11:39 -08005338 public void setAutofillClient(@SuppressWarnings("unused") AutofillClient client) {
Felipe Lemebb567ae2017-10-04 09:56:21 -07005339 }
5340
5341 /**
Svetoslav Ganov24c90452017-12-27 15:17:14 -08005342 * @hide
5343 */
Felipe Lemea4f39cd2019-02-19 15:08:59 -08005344 public final boolean isAutofillCompatibilityEnabled() {
5345 final AutofillOptions options = getAutofillOptions();
5346 return options != null && options.compatModeEnabled;
5347 }
5348
5349 /**
5350 * @hide
5351 */
5352 @Nullable
5353 public AutofillOptions getAutofillOptions() {
5354 return null;
Svetoslav Ganov24c90452017-12-27 15:17:14 -08005355 }
5356
5357 /**
5358 * @hide
5359 */
Svet Ganov47b37aa2018-02-16 00:11:39 -08005360 @TestApi
Felipe Lemea4f39cd2019-02-19 15:08:59 -08005361 public void setAutofillOptions(@SuppressWarnings("unused") @Nullable AutofillOptions options) {
Svetoslav Ganov24c90452017-12-27 15:17:14 -08005362 }
5363
5364 /**
Felipe Leme326f15a2019-02-19 09:42:24 -08005365 * Gets the Content Capture options for this context, or {@code null} if it's not whitelisted.
Felipe Lemeecb08be2018-11-27 15:48:47 -08005366 *
5367 * @hide
5368 */
Felipe Leme326f15a2019-02-19 09:42:24 -08005369 @Nullable
5370 public ContentCaptureOptions getContentCaptureOptions() {
5371 return null;
Felipe Lemeecb08be2018-11-27 15:48:47 -08005372 }
5373
5374 /**
5375 * @hide
5376 */
Felipe Leme326f15a2019-02-19 09:42:24 -08005377 @TestApi
5378 public void setContentCaptureOptions(
5379 @SuppressWarnings("unused") @Nullable ContentCaptureOptions options) {
Felipe Lemeecb08be2018-11-27 15:48:47 -08005380 }
5381
5382 /**
Adam Lesinskia82b6262017-03-21 16:56:17 -07005383 * Throws an exception if the Context is using system resources,
5384 * which are non-runtime-overlay-themable and may show inconsistent UI.
5385 * @hide
5386 */
5387 public void assertRuntimeOverlayThemable() {
5388 // Resources.getSystem() is a singleton and the only Resources not managed by
5389 // ResourcesManager; therefore Resources.getSystem() is not themable.
5390 if (getResources() == Resources.getSystem()) {
5391 throw new IllegalArgumentException("Non-UI context used to display UI; "
5392 + "get a UI context from ActivityThread#getSystemUiContext()");
5393 }
5394 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005395}