The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2006 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package android.content; |
| 18 | |
Tor Norbye | c91531a | 2015-04-01 17:41:55 -0700 | [diff] [blame] | 19 | import android.annotation.AttrRes; |
Bo Liu | 58a5766 | 2019-03-06 20:21:45 +0000 | [diff] [blame] | 20 | import android.annotation.CallbackExecutor; |
Tor Norbye | 1c2bf03 | 2015-03-02 10:57:08 -0800 | [diff] [blame] | 21 | import android.annotation.CheckResult; |
Tor Norbye | 3e4cda7 | 2015-06-10 08:14:31 -0700 | [diff] [blame] | 22 | import android.annotation.ColorInt; |
| 23 | import android.annotation.ColorRes; |
| 24 | import android.annotation.DrawableRes; |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 25 | import android.annotation.IntDef; |
| 26 | import android.annotation.NonNull; |
| 27 | import android.annotation.Nullable; |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 28 | import android.annotation.RequiresPermission; |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 29 | import android.annotation.StringDef; |
Tor Norbye | 7b9c912 | 2013-05-30 16:48:33 -0700 | [diff] [blame] | 30 | import android.annotation.StringRes; |
| 31 | import android.annotation.StyleRes; |
| 32 | import android.annotation.StyleableRes; |
Jinsuk Kim | 66d1eb2 | 2014-06-06 16:12:18 +0900 | [diff] [blame] | 33 | import android.annotation.SystemApi; |
Jeff Sharkey | a73b8fd | 2016-01-06 17:02:08 -0700 | [diff] [blame] | 34 | import android.annotation.TestApi; |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 35 | import android.annotation.UnsupportedAppUsage; |
Jeff Sharkey | 8588bc1 | 2016-01-06 16:47:42 -0700 | [diff] [blame] | 36 | import android.annotation.UserIdInt; |
Selim Cinek | 7fa385a | 2018-01-24 08:35:28 -0800 | [diff] [blame] | 37 | import android.app.ActivityManager; |
Tony Mak | 46aabe5 | 2016-11-14 12:53:06 +0000 | [diff] [blame] | 38 | import android.app.IApplicationThread; |
| 39 | import android.app.IServiceConnection; |
Zak Cohen | 56345f4 | 2017-01-26 13:54:28 -0800 | [diff] [blame] | 40 | import android.app.VrManager; |
Dianne Hackborn | 5c1e00b | 2009-06-18 17:10:57 -0700 | [diff] [blame] | 41 | import android.content.pm.ApplicationInfo; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 42 | import android.content.pm.PackageManager; |
| 43 | import android.content.res.AssetManager; |
Alan Viverette | 45c4bbb | 2015-01-05 14:59:19 -0800 | [diff] [blame] | 44 | import android.content.res.ColorStateList; |
Dianne Hackborn | 756220b | 2012-08-14 16:45:30 -0700 | [diff] [blame] | 45 | import android.content.res.Configuration; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 46 | import android.content.res.Resources; |
| 47 | import android.content.res.TypedArray; |
Vasu Nori | 74f170f | 2010-06-01 18:06:18 -0700 | [diff] [blame] | 48 | import android.database.DatabaseErrorHandler; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 49 | import android.database.sqlite.SQLiteDatabase; |
| 50 | import android.database.sqlite.SQLiteDatabase.CursorFactory; |
| 51 | import android.graphics.Bitmap; |
| 52 | import android.graphics.drawable.Drawable; |
| 53 | import android.net.Uri; |
Patrick Baumann | ef4c407 | 2018-02-01 08:54:05 -0800 | [diff] [blame] | 54 | import android.os.Build; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 55 | import android.os.Bundle; |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 56 | import android.os.Environment; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 57 | import android.os.Handler; |
Jeff Sharkey | 8439ac0 | 2017-12-12 17:26:23 -0700 | [diff] [blame] | 58 | import android.os.HandlerExecutor; |
Dianne Hackborn | ff17024 | 2014-11-19 10:59:01 -0800 | [diff] [blame] | 59 | import android.os.IBinder; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 60 | import android.os.Looper; |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 61 | import android.os.StatFs; |
Dianne Hackborn | 79af1dd | 2012-08-16 16:42:52 -0700 | [diff] [blame] | 62 | import android.os.UserHandle; |
Jeff Sharkey | 8c16579 | 2012-10-22 14:08:29 -0700 | [diff] [blame] | 63 | import android.os.UserManager; |
Jeff Sharkey | 60a82cd | 2017-04-18 18:19:16 -0600 | [diff] [blame] | 64 | import android.os.storage.StorageManager; |
Jeff Sharkey | 2ee3c1e | 2014-05-30 15:38:35 -0700 | [diff] [blame] | 65 | import android.provider.MediaStore; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 66 | import android.util.AttributeSet; |
Jeff Brown | a492c3a | 2012-08-23 19:48:44 -0700 | [diff] [blame] | 67 | import android.view.Display; |
Jeff Sharkey | e13529a | 2015-12-09 14:15:27 -0700 | [diff] [blame] | 68 | import android.view.DisplayAdjustments; |
Philip P. Moltmann | eab62ba | 2017-03-20 10:55:43 -0700 | [diff] [blame] | 69 | import android.view.View; |
Jon Miranda | 836c0a8 | 2014-08-11 12:32:26 -0700 | [diff] [blame] | 70 | import android.view.ViewDebug; |
Jeff Brown | a492c3a | 2012-08-23 19:48:44 -0700 | [diff] [blame] | 71 | import android.view.WindowManager; |
Felipe Leme | bb567ae | 2017-10-04 09:56:21 -0700 | [diff] [blame] | 72 | import android.view.autofill.AutofillManager.AutofillClient; |
Felipe Leme | cbf7f26 | 2019-04-17 13:57:59 -0700 | [diff] [blame] | 73 | import android.view.contentcapture.ContentCaptureManager.ContentCaptureClient; |
Abodunrinwa Toki | f001fef | 2017-01-04 23:51:42 +0000 | [diff] [blame] | 74 | import android.view.textclassifier.TextClassificationManager; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 75 | |
atrost | a6a4d60 | 2019-08-21 16:48:56 +0100 | [diff] [blame] | 76 | import com.android.internal.compat.IPlatformCompat; |
atrost | ff948d8 | 2019-10-10 19:27:31 +0100 | [diff] [blame] | 77 | import com.android.internal.compat.IPlatformCompatNative; |
atrost | a6a4d60 | 2019-08-21 16:48:56 +0100 | [diff] [blame] | 78 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 79 | import java.io.File; |
| 80 | import java.io.FileInputStream; |
| 81 | import java.io.FileNotFoundException; |
| 82 | import java.io.FileOutputStream; |
| 83 | import java.io.IOException; |
| 84 | import java.io.InputStream; |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 85 | import java.lang.annotation.Retention; |
| 86 | import java.lang.annotation.RetentionPolicy; |
Jeff Sharkey | 8439ac0 | 2017-12-12 17:26:23 -0700 | [diff] [blame] | 87 | import java.util.concurrent.Executor; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 88 | |
| 89 | /** |
| 90 | * Interface to global information about an application environment. This is |
| 91 | * an abstract class whose implementation is provided by |
| 92 | * the Android system. It |
| 93 | * allows access to application-specific resources and classes, as well as |
| 94 | * up-calls for application-level operations such as launching activities, |
| 95 | * broadcasting and receiving intents, etc. |
| 96 | */ |
| 97 | public abstract class Context { |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 98 | /** @hide */ |
| 99 | @IntDef(flag = true, prefix = { "MODE_" }, value = { |
| 100 | MODE_PRIVATE, |
| 101 | MODE_WORLD_READABLE, |
| 102 | MODE_WORLD_WRITEABLE, |
| 103 | MODE_APPEND, |
| 104 | }) |
| 105 | @Retention(RetentionPolicy.SOURCE) |
| 106 | public @interface FileMode {} |
| 107 | |
| 108 | /** @hide */ |
| 109 | @IntDef(flag = true, prefix = { "MODE_" }, value = { |
| 110 | MODE_PRIVATE, |
| 111 | MODE_WORLD_READABLE, |
| 112 | MODE_WORLD_WRITEABLE, |
| 113 | MODE_MULTI_PROCESS, |
| 114 | }) |
| 115 | @Retention(RetentionPolicy.SOURCE) |
| 116 | public @interface PreferencesMode {} |
| 117 | |
| 118 | /** @hide */ |
| 119 | @IntDef(flag = true, prefix = { "MODE_" }, value = { |
| 120 | MODE_PRIVATE, |
| 121 | MODE_WORLD_READABLE, |
| 122 | MODE_WORLD_WRITEABLE, |
| 123 | MODE_ENABLE_WRITE_AHEAD_LOGGING, |
| 124 | MODE_NO_LOCALIZED_COLLATORS, |
| 125 | }) |
| 126 | @Retention(RetentionPolicy.SOURCE) |
| 127 | public @interface DatabaseMode {} |
| 128 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 129 | /** |
| 130 | * File creation mode: the default mode, where the created file can only |
| 131 | * be accessed by the calling application (or all applications sharing the |
| 132 | * same user ID). |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 133 | */ |
| 134 | public static final int MODE_PRIVATE = 0x0000; |
Jeff Sharkey | 634dc42 | 2016-01-30 17:44:15 -0700 | [diff] [blame] | 135 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 136 | /** |
Jeff Sharkey | 634dc42 | 2016-01-30 17:44:15 -0700 | [diff] [blame] | 137 | * File creation mode: allow all other applications to have read access to |
| 138 | * the created file. |
| 139 | * <p> |
Dave Friedman | cfe5088 | 2017-07-05 00:40:07 -0700 | [diff] [blame] | 140 | * Starting from {@link android.os.Build.VERSION_CODES#N}, attempting to use this |
| 141 | * mode throws a {@link SecurityException}. |
Jeff Sharkey | 634dc42 | 2016-01-30 17:44:15 -0700 | [diff] [blame] | 142 | * |
Nick Kralevich | 1506921 | 2013-01-09 15:54:56 -0800 | [diff] [blame] | 143 | * @deprecated Creating world-readable files is very dangerous, and likely |
Jeff Sharkey | 634dc42 | 2016-01-30 17:44:15 -0700 | [diff] [blame] | 144 | * to cause security holes in applications. It is strongly |
| 145 | * discouraged; instead, applications should use more formal |
| 146 | * mechanism for interactions such as {@link ContentProvider}, |
| 147 | * {@link BroadcastReceiver}, and {@link android.app.Service}. |
| 148 | * There are no guarantees that this access mode will remain on |
| 149 | * a file, such as when it goes through a backup and restore. |
| 150 | * @see android.support.v4.content.FileProvider |
| 151 | * @see Intent#FLAG_GRANT_WRITE_URI_PERMISSION |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 152 | */ |
Dianne Hackborn | 556b09e | 2012-09-23 17:46:53 -0700 | [diff] [blame] | 153 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 154 | public static final int MODE_WORLD_READABLE = 0x0001; |
Jeff Sharkey | 634dc42 | 2016-01-30 17:44:15 -0700 | [diff] [blame] | 155 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 156 | /** |
Jeff Sharkey | 634dc42 | 2016-01-30 17:44:15 -0700 | [diff] [blame] | 157 | * File creation mode: allow all other applications to have write access to |
| 158 | * the created file. |
| 159 | * <p> |
Dave Friedman | cfe5088 | 2017-07-05 00:40:07 -0700 | [diff] [blame] | 160 | * Starting from {@link android.os.Build.VERSION_CODES#N}, attempting to use this |
Jeff Sharkey | 634dc42 | 2016-01-30 17:44:15 -0700 | [diff] [blame] | 161 | * mode will throw a {@link SecurityException}. |
| 162 | * |
Nick Kralevich | 1506921 | 2013-01-09 15:54:56 -0800 | [diff] [blame] | 163 | * @deprecated Creating world-writable files is very dangerous, and likely |
Jeff Sharkey | 634dc42 | 2016-01-30 17:44:15 -0700 | [diff] [blame] | 164 | * to cause security holes in applications. It is strongly |
| 165 | * discouraged; instead, applications should use more formal |
| 166 | * mechanism for interactions such as {@link ContentProvider}, |
| 167 | * {@link BroadcastReceiver}, and {@link android.app.Service}. |
| 168 | * There are no guarantees that this access mode will remain on |
| 169 | * a file, such as when it goes through a backup and restore. |
| 170 | * @see android.support.v4.content.FileProvider |
| 171 | * @see Intent#FLAG_GRANT_WRITE_URI_PERMISSION |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 172 | */ |
Dianne Hackborn | 556b09e | 2012-09-23 17:46:53 -0700 | [diff] [blame] | 173 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 174 | public static final int MODE_WORLD_WRITEABLE = 0x0002; |
Jeff Sharkey | 634dc42 | 2016-01-30 17:44:15 -0700 | [diff] [blame] | 175 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 176 | /** |
| 177 | * File creation mode: for use with {@link #openFileOutput}, if the file |
| 178 | * already exists then write data to the end of the existing file |
| 179 | * instead of erasing it. |
| 180 | * @see #openFileOutput |
| 181 | */ |
| 182 | public static final int MODE_APPEND = 0x8000; |
| 183 | |
| 184 | /** |
Brad Fitzpatrick | 4e920f7 | 2010-12-14 11:52:13 -0800 | [diff] [blame] | 185 | * SharedPreference loading flag: when set, the file on disk will |
| 186 | * be checked for modification even if the shared preferences |
| 187 | * instance is already loaded in this process. This behavior is |
| 188 | * sometimes desired in cases where the application has multiple |
| 189 | * processes, all writing to the same SharedPreferences file. |
| 190 | * Generally there are better forms of communication between |
| 191 | * processes, though. |
| 192 | * |
| 193 | * <p>This was the legacy (but undocumented) behavior in and |
| 194 | * before Gingerbread (Android 2.3) and this flag is implied when |
kopriva | 219f7dc | 2018-10-09 13:42:28 -0700 | [diff] [blame] | 195 | * targeting such releases. For applications targeting SDK |
Brad Fitzpatrick | 4e920f7 | 2010-12-14 11:52:13 -0800 | [diff] [blame] | 196 | * versions <em>greater than</em> Android 2.3, this flag must be |
| 197 | * explicitly set if desired. |
| 198 | * |
| 199 | * @see #getSharedPreferences |
Christopher Tate | d5748b8 | 2015-05-08 18:14:01 -0700 | [diff] [blame] | 200 | * |
| 201 | * @deprecated MODE_MULTI_PROCESS does not work reliably in |
| 202 | * some versions of Android, and furthermore does not provide any |
| 203 | * mechanism for reconciling concurrent modifications across |
| 204 | * processes. Applications should not attempt to use it. Instead, |
| 205 | * they should use an explicit cross-process data management |
| 206 | * approach such as {@link android.content.ContentProvider ContentProvider}. |
Brad Fitzpatrick | 4e920f7 | 2010-12-14 11:52:13 -0800 | [diff] [blame] | 207 | */ |
Christopher Tate | d5748b8 | 2015-05-08 18:14:01 -0700 | [diff] [blame] | 208 | @Deprecated |
Brad Fitzpatrick | 4e920f7 | 2010-12-14 11:52:13 -0800 | [diff] [blame] | 209 | public static final int MODE_MULTI_PROCESS = 0x0004; |
| 210 | |
| 211 | /** |
Jeff Brown | 47847f3 | 2012-03-22 19:13:11 -0700 | [diff] [blame] | 212 | * Database open flag: when set, the database is opened with write-ahead |
| 213 | * logging enabled by default. |
| 214 | * |
| 215 | * @see #openOrCreateDatabase(String, int, CursorFactory) |
| 216 | * @see #openOrCreateDatabase(String, int, CursorFactory, DatabaseErrorHandler) |
| 217 | * @see SQLiteDatabase#enableWriteAheadLogging |
| 218 | */ |
| 219 | public static final int MODE_ENABLE_WRITE_AHEAD_LOGGING = 0x0008; |
| 220 | |
Sunny Goyal | a21e6b2 | 2015-12-02 09:51:02 -0800 | [diff] [blame] | 221 | /** |
| 222 | * Database open flag: when set, the database is opened without support for |
| 223 | * localized collators. |
| 224 | * |
| 225 | * @see #openOrCreateDatabase(String, int, CursorFactory) |
| 226 | * @see #openOrCreateDatabase(String, int, CursorFactory, DatabaseErrorHandler) |
| 227 | * @see SQLiteDatabase#NO_LOCALIZED_COLLATORS |
| 228 | */ |
| 229 | public static final int MODE_NO_LOCALIZED_COLLATORS = 0x0010; |
| 230 | |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 231 | /** @hide */ |
Jeff Sharkey | ce8db99 | 2017-12-13 20:05:05 -0700 | [diff] [blame] | 232 | @IntDef(flag = true, prefix = { "BIND_" }, value = { |
| 233 | BIND_AUTO_CREATE, |
| 234 | BIND_DEBUG_UNBIND, |
| 235 | BIND_NOT_FOREGROUND, |
| 236 | BIND_ABOVE_CLIENT, |
| 237 | BIND_ALLOW_OOM_MANAGEMENT, |
| 238 | BIND_WAIVE_PRIORITY, |
| 239 | BIND_IMPORTANT, |
Amith Yamasani | 5016a78 | 2019-06-17 16:20:24 -0700 | [diff] [blame] | 240 | BIND_ADJUST_WITH_ACTIVITY, |
| 241 | BIND_NOT_PERCEPTIBLE, |
| 242 | BIND_INCLUDE_CAPABILITIES |
Jeff Sharkey | ce8db99 | 2017-12-13 20:05:05 -0700 | [diff] [blame] | 243 | }) |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 244 | @Retention(RetentionPolicy.SOURCE) |
| 245 | public @interface BindServiceFlags {} |
| 246 | |
Jeff Brown | 47847f3 | 2012-03-22 19:13:11 -0700 | [diff] [blame] | 247 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 248 | * Flag for {@link #bindService}: automatically create the service as long |
| 249 | * as the binding exists. Note that while this will create the service, |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 250 | * its {@link android.app.Service#onStartCommand} |
| 251 | * method will still only be called due to an |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 252 | * explicit call to {@link #startService}. Even without that, though, |
| 253 | * this still provides you with access to the service object while the |
| 254 | * service is created. |
| 255 | * |
Dianne Hackborn | c68c913 | 2011-07-29 01:25:18 -0700 | [diff] [blame] | 256 | * <p>Note that prior to {@link android.os.Build.VERSION_CODES#ICE_CREAM_SANDWICH}, |
| 257 | * not supplying this flag would also impact how important the system |
| 258 | * consider's the target service's process to be. When set, the only way |
| 259 | * for it to be raised was by binding from a service in which case it will |
| 260 | * only be important when that activity is in the foreground. Now to |
| 261 | * achieve this behavior you must explicitly supply the new flag |
| 262 | * {@link #BIND_ADJUST_WITH_ACTIVITY}. For compatibility, old applications |
| 263 | * that don't specify {@link #BIND_AUTO_CREATE} will automatically have |
| 264 | * the flags {@link #BIND_WAIVE_PRIORITY} and |
| 265 | * {@link #BIND_ADJUST_WITH_ACTIVITY} set for them in order to achieve |
| 266 | * the same result. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 267 | */ |
| 268 | public static final int BIND_AUTO_CREATE = 0x0001; |
| 269 | |
| 270 | /** |
| 271 | * Flag for {@link #bindService}: include debugging help for mismatched |
| 272 | * calls to unbind. When this flag is set, the callstack of the following |
| 273 | * {@link #unbindService} call is retained, to be printed if a later |
| 274 | * incorrect unbind call is made. Note that doing this requires retaining |
| 275 | * information about the binding that was made for the lifetime of the app, |
| 276 | * resulting in a leak -- this should only be used for debugging. |
| 277 | */ |
| 278 | public static final int BIND_DEBUG_UNBIND = 0x0002; |
| 279 | |
Dianne Hackborn | 09c916b | 2009-12-08 14:50:51 -0800 | [diff] [blame] | 280 | /** |
| 281 | * Flag for {@link #bindService}: don't allow this binding to raise |
| 282 | * the target service's process to the foreground scheduling priority. |
Dianne Hackborn | 130b0d2 | 2011-07-26 22:07:48 -0700 | [diff] [blame] | 283 | * It will still be raised to at least the same memory priority |
Dianne Hackborn | 09c916b | 2009-12-08 14:50:51 -0800 | [diff] [blame] | 284 | * as the client (so that its process will not be killable in any |
| 285 | * situation where the client is not killable), but for CPU scheduling |
| 286 | * purposes it may be left in the background. This only has an impact |
| 287 | * in the situation where the binding client is a foreground process |
| 288 | * and the target service is in a background process. |
| 289 | */ |
| 290 | public static final int BIND_NOT_FOREGROUND = 0x0004; |
| 291 | |
Dianne Hackborn | 130b0d2 | 2011-07-26 22:07:48 -0700 | [diff] [blame] | 292 | /** |
Dianne Hackborn | c68c913 | 2011-07-29 01:25:18 -0700 | [diff] [blame] | 293 | * Flag for {@link #bindService}: indicates that the client application |
| 294 | * binding to this service considers the service to be more important than |
| 295 | * the app itself. When set, the platform will try to have the out of |
Dianne Hackborn | b12e135 | 2012-09-26 11:39:20 -0700 | [diff] [blame] | 296 | * memory killer kill the app before it kills the service it is bound to, though |
Dianne Hackborn | c68c913 | 2011-07-29 01:25:18 -0700 | [diff] [blame] | 297 | * this is not guaranteed to be the case. |
| 298 | */ |
| 299 | public static final int BIND_ABOVE_CLIENT = 0x0008; |
| 300 | |
| 301 | /** |
Dianne Hackborn | 130b0d2 | 2011-07-26 22:07:48 -0700 | [diff] [blame] | 302 | * Flag for {@link #bindService}: allow the process hosting the bound |
| 303 | * service to go through its normal memory management. It will be |
| 304 | * treated more like a running service, allowing the system to |
| 305 | * (temporarily) expunge the process if low on memory or for some other |
Dianne Hackborn | c68c913 | 2011-07-29 01:25:18 -0700 | [diff] [blame] | 306 | * whim it may have, and being more aggressive about making it a candidate |
| 307 | * to be killed (and restarted) if running for a long time. |
Dianne Hackborn | 130b0d2 | 2011-07-26 22:07:48 -0700 | [diff] [blame] | 308 | */ |
Dianne Hackborn | c68c913 | 2011-07-29 01:25:18 -0700 | [diff] [blame] | 309 | public static final int BIND_ALLOW_OOM_MANAGEMENT = 0x0010; |
| 310 | |
| 311 | /** |
| 312 | * Flag for {@link #bindService}: don't impact the scheduling or |
| 313 | * memory management priority of the target service's hosting process. |
| 314 | * Allows the service's process to be managed on the background LRU list |
| 315 | * just like a regular application process in the background. |
| 316 | */ |
| 317 | public static final int BIND_WAIVE_PRIORITY = 0x0020; |
| 318 | |
| 319 | /** |
| 320 | * Flag for {@link #bindService}: this service is very important to |
| 321 | * the client, so should be brought to the foreground process level |
| 322 | * when the client is. Normally a process can only be raised to the |
| 323 | * visibility level by a client, even if that client is in the foreground. |
| 324 | */ |
| 325 | public static final int BIND_IMPORTANT = 0x0040; |
| 326 | |
| 327 | /** |
| 328 | * Flag for {@link #bindService}: If binding from an activity, allow the |
| 329 | * target service's process importance to be raised based on whether the |
| 330 | * activity is visible to the user, regardless whether another flag is |
| 331 | * used to reduce the amount that the client process's overall importance |
| 332 | * is used to impact it. |
| 333 | */ |
Dianne Hackborn | 2c84cfc | 2011-10-31 15:39:59 -0700 | [diff] [blame] | 334 | public static final int BIND_ADJUST_WITH_ACTIVITY = 0x0080; |
| 335 | |
| 336 | /** |
Amith Yamasani | 5016a78 | 2019-06-17 16:20:24 -0700 | [diff] [blame] | 337 | * Flag for {@link #bindService}: If binding from an app that is visible or user-perceptible, |
| 338 | * lower the target service's importance to below the perceptible level. This allows |
| 339 | * the system to (temporarily) expunge the bound process from memory to make room for more |
| 340 | * important user-perceptible processes. |
| 341 | */ |
| 342 | public static final int BIND_NOT_PERCEPTIBLE = 0x00000100; |
| 343 | |
| 344 | /** |
Amith Yamasani | f178c96 | 2019-03-21 19:40:11 -0700 | [diff] [blame] | 345 | * Flag for {@link #bindService}: If binding from an app that has specific capabilities |
| 346 | * due to its foreground state such as an activity or foreground service, then this flag will |
| 347 | * allow the bound app to get the same capabilities, as long as it has the required permissions |
| 348 | * as well. |
| 349 | */ |
Amith Yamasani | 5016a78 | 2019-06-17 16:20:24 -0700 | [diff] [blame] | 350 | public static final int BIND_INCLUDE_CAPABILITIES = 0x000001000; |
Amith Yamasani | f178c96 | 2019-03-21 19:40:11 -0700 | [diff] [blame] | 351 | |
Amith Yamasani | 0b3ae0e | 2019-05-10 10:29:47 -0700 | [diff] [blame] | 352 | /*********** Public flags above this line ***********/ |
| 353 | /*********** Hidden flags below this line ***********/ |
| 354 | |
| 355 | /** |
Yohei Yukawa | 5973096 | 2019-03-18 10:47:22 -0700 | [diff] [blame] | 356 | * Flag for {@link #bindService}: This flag is intended to be used only by the system to adjust |
| 357 | * the scheduling policy for IMEs (and any other out-of-process user-visible components that |
| 358 | * work closely with the top app) so that UI hosted in such services can have the same |
| 359 | * scheduling policy (e.g. SCHED_FIFO when it is enabled and TOP_APP_PRIORITY_BOOST otherwise) |
| 360 | * as the actual top-app. |
| 361 | * @hide |
| 362 | */ |
| 363 | public static final int BIND_SCHEDULE_LIKE_TOP_APP = 0x00080000; |
| 364 | |
| 365 | /** |
Michal Karpinski | e069b00 | 2019-03-07 16:15:14 +0000 | [diff] [blame] | 366 | * Flag for {@link #bindService}: allow background activity starts from the bound service's |
| 367 | * process. |
| 368 | * This flag is only respected if the caller is holding |
| 369 | * {@link android.Manifest.permission#START_ACTIVITIES_FROM_BACKGROUND}. |
| 370 | * @hide |
| 371 | */ |
| 372 | public static final int BIND_ALLOW_BACKGROUND_ACTIVITY_STARTS = 0x00100000; |
| 373 | |
| 374 | /** |
Dianne Hackborn | c390aa8 | 2019-01-09 16:38:22 -0800 | [diff] [blame] | 375 | * @hide Flag for {@link #bindService}: the service being bound to represents a |
| 376 | * protected system component, so must have association restrictions applied to it. |
| 377 | * That is, a system config must have one or more allow-association tags limiting |
| 378 | * which packages it can interact with. If it does not have any such association |
| 379 | * restrictions, a default empty set will be created. |
| 380 | */ |
| 381 | public static final int BIND_RESTRICT_ASSOCIATIONS = 0x00200000; |
| 382 | |
| 383 | /** |
Svet Ganov | d223db3 | 2017-12-22 09:43:48 -0800 | [diff] [blame] | 384 | * @hide Flag for {@link #bindService}: allows binding to a service provided |
| 385 | * by an instant app. Note that the caller may not have access to the instant |
| 386 | * app providing the service which is a violation of the instant app sandbox. |
| 387 | * This flag is intended ONLY for development/testing and should be used with |
| 388 | * great care. Only the system is allowed to use this flag. |
| 389 | */ |
| 390 | public static final int BIND_ALLOW_INSTANT = 0x00400000; |
| 391 | |
| 392 | /** |
Dianne Hackborn | 83b40f6 | 2017-04-26 13:59:47 -0700 | [diff] [blame] | 393 | * @hide Flag for {@link #bindService}: like {@link #BIND_NOT_FOREGROUND}, but puts it |
| 394 | * up in to the important background state (instead of transient). |
| 395 | */ |
| 396 | public static final int BIND_IMPORTANT_BACKGROUND = 0x00800000; |
| 397 | |
| 398 | /** |
Felipe Leme | a1b79bf | 2016-05-24 13:06:54 -0700 | [diff] [blame] | 399 | * @hide Flag for {@link #bindService}: allows application hosting service to manage whitelists |
| 400 | * such as temporary allowing a {@code PendingIntent} to bypass Power Save mode. |
| 401 | */ |
| 402 | public static final int BIND_ALLOW_WHITELIST_MANAGEMENT = 0x01000000; |
| 403 | |
| 404 | /** |
Dianne Hackborn | d69e4c1 | 2015-04-24 09:54:54 -0700 | [diff] [blame] | 405 | * @hide Flag for {@link #bindService}: Like {@link #BIND_FOREGROUND_SERVICE}, |
| 406 | * but only applies while the device is awake. |
| 407 | */ |
| 408 | public static final int BIND_FOREGROUND_SERVICE_WHILE_AWAKE = 0x02000000; |
| 409 | |
| 410 | /** |
| 411 | * @hide Flag for {@link #bindService}: For only the case where the binding |
| 412 | * is coming from the system, set the process state to FOREGROUND_SERVICE |
| 413 | * instead of the normal maximum of IMPORTANT_FOREGROUND. That is, this is |
| 414 | * saying that the process shouldn't participate in the normal power reduction |
| 415 | * modes (removing network access etc). |
| 416 | */ |
| 417 | public static final int BIND_FOREGROUND_SERVICE = 0x04000000; |
| 418 | |
| 419 | /** |
Dianne Hackborn | f0f94d1 | 2014-03-17 16:04:21 -0700 | [diff] [blame] | 420 | * @hide Flag for {@link #bindService}: Treat the binding as hosting |
| 421 | * an activity, an unbinding as the activity going in the background. |
| 422 | * That is, when unbinding, the process when empty will go on the activity |
| 423 | * LRU list instead of the regular one, keeping it around more aggressively |
| 424 | * than it otherwise would be. This is intended for use with IMEs to try |
| 425 | * to keep IME processes around for faster keyboard switching. |
| 426 | */ |
| 427 | public static final int BIND_TREAT_LIKE_ACTIVITY = 0x08000000; |
| 428 | |
| 429 | /** |
Dianne Hackborn | b12e135 | 2012-09-26 11:39:20 -0700 | [diff] [blame] | 430 | * @hide An idea that is not yet implemented. |
| 431 | * Flag for {@link #bindService}: If binding from an activity, consider |
| 432 | * this service to be visible like the binding activity is. That is, |
| 433 | * it will be treated as something more important to keep around than |
| 434 | * invisible background activities. This will impact the number of |
| 435 | * recent activities the user can switch between without having them |
| 436 | * restart. There is no guarantee this will be respected, as the system |
Amith Yamasani | f235d0b | 2019-03-20 22:49:43 -0700 | [diff] [blame] | 437 | * tries to balance such requests from one app vs. the importance of |
Dianne Hackborn | b12e135 | 2012-09-26 11:39:20 -0700 | [diff] [blame] | 438 | * keeping other apps around. |
| 439 | */ |
Dianne Hackborn | c823051 | 2013-07-13 21:32:12 -0700 | [diff] [blame] | 440 | public static final int BIND_VISIBLE = 0x10000000; |
| 441 | |
| 442 | /** |
| 443 | * @hide |
| 444 | * Flag for {@link #bindService}: Consider this binding to be causing the target |
| 445 | * process to be showing UI, so it will be do a UI_HIDDEN memory trim when it goes |
| 446 | * away. |
| 447 | */ |
| 448 | public static final int BIND_SHOWING_UI = 0x20000000; |
Dianne Hackborn | b12e135 | 2012-09-26 11:39:20 -0700 | [diff] [blame] | 449 | |
| 450 | /** |
Dianne Hackborn | 2c84cfc | 2011-10-31 15:39:59 -0700 | [diff] [blame] | 451 | * Flag for {@link #bindService}: Don't consider the bound service to be |
| 452 | * visible, even if the caller is visible. |
| 453 | * @hide |
| 454 | */ |
| 455 | public static final int BIND_NOT_VISIBLE = 0x40000000; |
Dianne Hackborn | 130b0d2 | 2011-07-26 22:07:48 -0700 | [diff] [blame] | 456 | |
Alan Viverette | 713a5cd | 2015-12-16 15:46:32 -0500 | [diff] [blame] | 457 | /** |
Robert Sesek | b9a8666 | 2015-12-09 16:22:45 -0500 | [diff] [blame] | 458 | * Flag for {@link #bindService}: The service being bound is an |
| 459 | * {@link android.R.attr#isolatedProcess isolated}, |
| 460 | * {@link android.R.attr#externalService external} service. This binds the service into the |
| 461 | * calling application's package, rather than the package in which the service is declared. |
Robert Sesek | 55b2d11 | 2016-05-17 18:53:13 -0400 | [diff] [blame] | 462 | * <p> |
| 463 | * When using this flag, the code for the service being bound will execute under the calling |
| 464 | * application's package name and user ID. Because the service must be an isolated process, |
| 465 | * it will not have direct access to the application's data, though. |
| 466 | * |
| 467 | * The purpose of this flag is to allow applications to provide services that are attributed |
| 468 | * to the app using the service, rather than the application providing the service. |
| 469 | * </p> |
Robert Sesek | b9a8666 | 2015-12-09 16:22:45 -0500 | [diff] [blame] | 470 | */ |
| 471 | public static final int BIND_EXTERNAL_SERVICE = 0x80000000; |
| 472 | |
Dianne Hackborn | a631d56 | 2018-11-20 15:58:15 -0800 | [diff] [blame] | 473 | /** |
| 474 | * These bind flags reduce the strength of the binding such that we shouldn't |
| 475 | * consider it as pulling the process up to the level of the one that is bound to it. |
| 476 | * @hide |
| 477 | */ |
| 478 | public static final int BIND_REDUCTION_FLAGS = |
| 479 | Context.BIND_ALLOW_OOM_MANAGEMENT | Context.BIND_WAIVE_PRIORITY |
Amith Yamasani | 5016a78 | 2019-06-17 16:20:24 -0700 | [diff] [blame] | 480 | | Context.BIND_NOT_PERCEPTIBLE | Context.BIND_NOT_VISIBLE; |
Dianne Hackborn | a631d56 | 2018-11-20 15:58:15 -0800 | [diff] [blame] | 481 | |
Chad Brubaker | 6d6015f | 2017-04-18 11:25:16 -0700 | [diff] [blame] | 482 | /** @hide */ |
Jeff Sharkey | ce8db99 | 2017-12-13 20:05:05 -0700 | [diff] [blame] | 483 | @IntDef(flag = true, prefix = { "RECEIVER_VISIBLE_" }, value = { |
| 484 | RECEIVER_VISIBLE_TO_INSTANT_APPS |
| 485 | }) |
Chad Brubaker | 6d6015f | 2017-04-18 11:25:16 -0700 | [diff] [blame] | 486 | @Retention(RetentionPolicy.SOURCE) |
| 487 | public @interface RegisterReceiverFlags {} |
| 488 | |
| 489 | /** |
| 490 | * Flag for {@link #registerReceiver}: The receiver can receive broadcasts from Instant Apps. |
| 491 | */ |
| 492 | public static final int RECEIVER_VISIBLE_TO_INSTANT_APPS = 0x1; |
| 493 | |
Robert Sesek | b9a8666 | 2015-12-09 16:22:45 -0500 | [diff] [blame] | 494 | /** |
Alan Viverette | 713a5cd | 2015-12-16 15:46:32 -0500 | [diff] [blame] | 495 | * Returns an AssetManager instance for the application's package. |
| 496 | * <p> |
| 497 | * <strong>Note:</strong> Implementations of this method should return |
| 498 | * an AssetManager instance that is consistent with the Resources instance |
| 499 | * returned by {@link #getResources()}. For example, they should share the |
| 500 | * same {@link Configuration} object. |
| 501 | * |
| 502 | * @return an AssetManager instance for the application's package |
| 503 | * @see #getResources() |
| 504 | */ |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 505 | public abstract AssetManager getAssets(); |
| 506 | |
Alan Viverette | 713a5cd | 2015-12-16 15:46:32 -0500 | [diff] [blame] | 507 | /** |
| 508 | * Returns a Resources instance for the application's package. |
| 509 | * <p> |
| 510 | * <strong>Note:</strong> Implementations of this method should return |
| 511 | * a Resources instance that is consistent with the AssetManager instance |
| 512 | * returned by {@link #getAssets()}. For example, they should share the |
| 513 | * same {@link Configuration} object. |
| 514 | * |
| 515 | * @return a Resources instance for the application's package |
| 516 | * @see #getAssets() |
| 517 | */ |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 518 | public abstract Resources getResources(); |
| 519 | |
| 520 | /** Return PackageManager instance to find global package information. */ |
| 521 | public abstract PackageManager getPackageManager(); |
| 522 | |
| 523 | /** Return a ContentResolver instance for your application's package. */ |
| 524 | public abstract ContentResolver getContentResolver(); |
| 525 | |
| 526 | /** |
| 527 | * Return the Looper for the main thread of the current process. This is |
| 528 | * the thread used to dispatch calls to application components (activities, |
| 529 | * services, etc). |
Jeff Brown | f9e989d | 2013-04-04 23:04:03 -0700 | [diff] [blame] | 530 | * <p> |
| 531 | * By definition, this method returns the same result as would be obtained |
| 532 | * by calling {@link Looper#getMainLooper() Looper.getMainLooper()}. |
| 533 | * </p> |
| 534 | * |
| 535 | * @return The main looper. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 536 | */ |
| 537 | public abstract Looper getMainLooper(); |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 538 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 539 | /** |
Jeff Sharkey | 8439ac0 | 2017-12-12 17:26:23 -0700 | [diff] [blame] | 540 | * Return an {@link Executor} that will run enqueued tasks on the main |
| 541 | * thread associated with this context. This is the thread used to dispatch |
| 542 | * calls to application components (activities, services, etc). |
| 543 | */ |
| 544 | public Executor getMainExecutor() { |
| 545 | // This is pretty inefficient, which is why ContextImpl overrides it |
| 546 | return new HandlerExecutor(new Handler(getMainLooper())); |
| 547 | } |
| 548 | |
| 549 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 550 | * Return the context of the single, global Application object of the |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 551 | * current process. This generally should only be used if you need a |
| 552 | * Context whose lifecycle is separate from the current context, that is |
| 553 | * tied to the lifetime of the process rather than the current component. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 554 | * |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 555 | * <p>Consider for example how this interacts with |
Brad Fitzpatrick | 36af794 | 2010-12-08 11:31:07 -0800 | [diff] [blame] | 556 | * {@link #registerReceiver(BroadcastReceiver, IntentFilter)}: |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 557 | * <ul> |
| 558 | * <li> <p>If used from an Activity context, the receiver is being registered |
| 559 | * within that activity. This means that you are expected to unregister |
| 560 | * before the activity is done being destroyed; in fact if you do not do |
| 561 | * so, the framework will clean up your leaked registration as it removes |
| 562 | * the activity and log an error. Thus, if you use the Activity context |
| 563 | * to register a receiver that is static (global to the process, not |
| 564 | * associated with an Activity instance) then that registration will be |
| 565 | * removed on you at whatever point the activity you used is destroyed. |
| 566 | * <li> <p>If used from the Context returned here, the receiver is being |
| 567 | * registered with the global state associated with your application. Thus |
| 568 | * it will never be unregistered for you. This is necessary if the receiver |
| 569 | * is associated with static data, not a particular component. However |
| 570 | * using the ApplicationContext elsewhere can easily lead to serious leaks |
| 571 | * if you forget to unregister, unbind, etc. |
| 572 | * </ul> |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 573 | */ |
| 574 | public abstract Context getApplicationContext(); |
| 575 | |
Phil Weaver | 846cda93 | 2017-06-15 10:10:06 -0700 | [diff] [blame] | 576 | /** Non-activity related autofill ids are unique in the app */ |
| 577 | private static int sLastAutofillId = View.NO_ID; |
Philip P. Moltmann | eab62ba | 2017-03-20 10:55:43 -0700 | [diff] [blame] | 578 | |
| 579 | /** |
Phil Weaver | 846cda93 | 2017-06-15 10:10:06 -0700 | [diff] [blame] | 580 | * Gets the next autofill ID. |
Philip P. Moltmann | eab62ba | 2017-03-20 10:55:43 -0700 | [diff] [blame] | 581 | * |
Phil Weaver | 846cda93 | 2017-06-15 10:10:06 -0700 | [diff] [blame] | 582 | * <p>All IDs will be smaller or the same as {@link View#LAST_APP_AUTOFILL_ID}. All IDs |
Philip P. Moltmann | eab62ba | 2017-03-20 10:55:43 -0700 | [diff] [blame] | 583 | * returned will be unique. |
| 584 | * |
| 585 | * @return A ID that is unique in the process |
| 586 | * |
| 587 | * {@hide} |
| 588 | */ |
Phil Weaver | 846cda93 | 2017-06-15 10:10:06 -0700 | [diff] [blame] | 589 | public int getNextAutofillId() { |
| 590 | if (sLastAutofillId == View.LAST_APP_AUTOFILL_ID - 1) { |
| 591 | sLastAutofillId = View.NO_ID; |
Philip P. Moltmann | eab62ba | 2017-03-20 10:55:43 -0700 | [diff] [blame] | 592 | } |
| 593 | |
Phil Weaver | 846cda93 | 2017-06-15 10:10:06 -0700 | [diff] [blame] | 594 | sLastAutofillId++; |
Philip P. Moltmann | eab62ba | 2017-03-20 10:55:43 -0700 | [diff] [blame] | 595 | |
Phil Weaver | 846cda93 | 2017-06-15 10:10:06 -0700 | [diff] [blame] | 596 | return sLastAutofillId; |
Philip P. Moltmann | eab62ba | 2017-03-20 10:55:43 -0700 | [diff] [blame] | 597 | } |
| 598 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 599 | /** |
Dianne Hackborn | c68c913 | 2011-07-29 01:25:18 -0700 | [diff] [blame] | 600 | * Add a new {@link ComponentCallbacks} to the base application of the |
| 601 | * Context, which will be called at the same times as the ComponentCallbacks |
| 602 | * methods of activities and other components are called. Note that you |
| 603 | * <em>must</em> be sure to use {@link #unregisterComponentCallbacks} when |
| 604 | * appropriate in the future; this will not be removed for you. |
Dianne Hackborn | 905577f | 2011-09-07 18:31:28 -0700 | [diff] [blame] | 605 | * |
| 606 | * @param callback The interface to call. This can be either a |
| 607 | * {@link ComponentCallbacks} or {@link ComponentCallbacks2} interface. |
Dianne Hackborn | c68c913 | 2011-07-29 01:25:18 -0700 | [diff] [blame] | 608 | */ |
| 609 | public void registerComponentCallbacks(ComponentCallbacks callback) { |
| 610 | getApplicationContext().registerComponentCallbacks(callback); |
| 611 | } |
| 612 | |
| 613 | /** |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 614 | * Remove a {@link ComponentCallbacks} object that was previously registered |
Dianne Hackborn | c68c913 | 2011-07-29 01:25:18 -0700 | [diff] [blame] | 615 | * with {@link #registerComponentCallbacks(ComponentCallbacks)}. |
| 616 | */ |
| 617 | public void unregisterComponentCallbacks(ComponentCallbacks callback) { |
| 618 | getApplicationContext().unregisterComponentCallbacks(callback); |
| 619 | } |
| 620 | |
| 621 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 622 | * Return a localized, styled CharSequence from the application's package's |
| 623 | * default string table. |
| 624 | * |
| 625 | * @param resId Resource id for the CharSequence text |
| 626 | */ |
Chris Craik | ceb2693 | 2018-02-01 15:51:34 -0800 | [diff] [blame] | 627 | @NonNull |
Tor Norbye | 7b9c912 | 2013-05-30 16:48:33 -0700 | [diff] [blame] | 628 | public final CharSequence getText(@StringRes int resId) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 629 | return getResources().getText(resId); |
| 630 | } |
| 631 | |
| 632 | /** |
Alan Viverette | b4004df | 2015-04-29 16:55:42 -0700 | [diff] [blame] | 633 | * Returns a localized string from the application's package's |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 634 | * default string table. |
| 635 | * |
| 636 | * @param resId Resource id for the string |
Alan Viverette | b4004df | 2015-04-29 16:55:42 -0700 | [diff] [blame] | 637 | * @return The string data associated with the resource, stripped of styled |
| 638 | * text information. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 639 | */ |
Alan Viverette | b4004df | 2015-04-29 16:55:42 -0700 | [diff] [blame] | 640 | @NonNull |
Tor Norbye | 7b9c912 | 2013-05-30 16:48:33 -0700 | [diff] [blame] | 641 | public final String getString(@StringRes int resId) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 642 | return getResources().getString(resId); |
| 643 | } |
| 644 | |
| 645 | /** |
Alan Viverette | b4004df | 2015-04-29 16:55:42 -0700 | [diff] [blame] | 646 | * Returns a localized formatted string from the application's package's |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 647 | * default string table, substituting the format arguments as defined in |
| 648 | * {@link java.util.Formatter} and {@link java.lang.String#format}. |
| 649 | * |
| 650 | * @param resId Resource id for the format string |
Alan Viverette | b4004df | 2015-04-29 16:55:42 -0700 | [diff] [blame] | 651 | * @param formatArgs The format arguments that will be used for |
| 652 | * substitution. |
| 653 | * @return The string data associated with the resource, formatted and |
| 654 | * stripped of styled text information. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 655 | */ |
Alan Viverette | b4004df | 2015-04-29 16:55:42 -0700 | [diff] [blame] | 656 | @NonNull |
Tor Norbye | 7b9c912 | 2013-05-30 16:48:33 -0700 | [diff] [blame] | 657 | public final String getString(@StringRes int resId, Object... formatArgs) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 658 | return getResources().getString(resId, formatArgs); |
| 659 | } |
| 660 | |
Alan Viverette | 8eea3ea | 2014-02-03 18:40:20 -0800 | [diff] [blame] | 661 | /** |
Alan Viverette | 45c4bbb | 2015-01-05 14:59:19 -0800 | [diff] [blame] | 662 | * Returns a color associated with a particular resource ID and styled for |
| 663 | * the current theme. |
| 664 | * |
| 665 | * @param id The desired resource identifier, as generated by the aapt |
| 666 | * tool. This integer encodes the package, type, and resource |
| 667 | * entry. The value 0 is an invalid identifier. |
| 668 | * @return A single color value in the form 0xAARRGGBB. |
| 669 | * @throws android.content.res.Resources.NotFoundException if the given ID |
| 670 | * does not exist. |
| 671 | */ |
Tor Norbye | 3e4cda7 | 2015-06-10 08:14:31 -0700 | [diff] [blame] | 672 | @ColorInt |
| 673 | public final int getColor(@ColorRes int id) { |
Alan Viverette | 45c4bbb | 2015-01-05 14:59:19 -0800 | [diff] [blame] | 674 | return getResources().getColor(id, getTheme()); |
| 675 | } |
| 676 | |
| 677 | /** |
| 678 | * Returns a drawable object associated with a particular resource ID and |
Alan Viverette | 8eea3ea | 2014-02-03 18:40:20 -0800 | [diff] [blame] | 679 | * styled for the current theme. |
| 680 | * |
| 681 | * @param id The desired resource identifier, as generated by the aapt |
| 682 | * tool. This integer encodes the package, type, and resource |
| 683 | * entry. The value 0 is an invalid identifier. |
Chris Craik | ceb2693 | 2018-02-01 15:51:34 -0800 | [diff] [blame] | 684 | * @return An object that can be used to draw this resource. |
Alan Viverette | 45c4bbb | 2015-01-05 14:59:19 -0800 | [diff] [blame] | 685 | * @throws android.content.res.Resources.NotFoundException if the given ID |
| 686 | * does not exist. |
Alan Viverette | 8eea3ea | 2014-02-03 18:40:20 -0800 | [diff] [blame] | 687 | */ |
Chris Craik | 1194b0b | 2018-03-23 13:36:24 -0700 | [diff] [blame] | 688 | @Nullable |
Tor Norbye | 3e4cda7 | 2015-06-10 08:14:31 -0700 | [diff] [blame] | 689 | public final Drawable getDrawable(@DrawableRes int id) { |
Alan Viverette | 8eea3ea | 2014-02-03 18:40:20 -0800 | [diff] [blame] | 690 | return getResources().getDrawable(id, getTheme()); |
| 691 | } |
| 692 | |
Alan Viverette | 45c4bbb | 2015-01-05 14:59:19 -0800 | [diff] [blame] | 693 | /** |
| 694 | * Returns a color state list associated with a particular resource ID and |
| 695 | * styled for the current theme. |
| 696 | * |
| 697 | * @param id The desired resource identifier, as generated by the aapt |
| 698 | * tool. This integer encodes the package, type, and resource |
| 699 | * entry. The value 0 is an invalid identifier. |
Chris Craik | ceb2693 | 2018-02-01 15:51:34 -0800 | [diff] [blame] | 700 | * @return A color state list. |
Alan Viverette | 45c4bbb | 2015-01-05 14:59:19 -0800 | [diff] [blame] | 701 | * @throws android.content.res.Resources.NotFoundException if the given ID |
| 702 | * does not exist. |
| 703 | */ |
Chris Craik | ceb2693 | 2018-02-01 15:51:34 -0800 | [diff] [blame] | 704 | @NonNull |
Tor Norbye | 3e4cda7 | 2015-06-10 08:14:31 -0700 | [diff] [blame] | 705 | public final ColorStateList getColorStateList(@ColorRes int id) { |
Alan Viverette | 45c4bbb | 2015-01-05 14:59:19 -0800 | [diff] [blame] | 706 | return getResources().getColorStateList(id, getTheme()); |
| 707 | } |
| 708 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 709 | /** |
| 710 | * Set the base theme for this context. Note that this should be called |
| 711 | * before any views are instantiated in the Context (for example before |
| 712 | * calling {@link android.app.Activity#setContentView} or |
| 713 | * {@link android.view.LayoutInflater#inflate}). |
| 714 | * |
| 715 | * @param resid The style resource describing the theme. |
| 716 | */ |
Tor Norbye | 7b9c912 | 2013-05-30 16:48:33 -0700 | [diff] [blame] | 717 | public abstract void setTheme(@StyleRes int resid); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 718 | |
Dianne Hackborn | 247fe74 | 2011-01-08 17:25:57 -0800 | [diff] [blame] | 719 | /** @hide Needed for some internal implementation... not public because |
| 720 | * you can't assume this actually means anything. */ |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 721 | @UnsupportedAppUsage |
Dianne Hackborn | 247fe74 | 2011-01-08 17:25:57 -0800 | [diff] [blame] | 722 | public int getThemeResId() { |
| 723 | return 0; |
| 724 | } |
| 725 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 726 | /** |
| 727 | * Return the Theme object associated with this Context. |
| 728 | */ |
Jon Miranda | 836c0a8 | 2014-08-11 12:32:26 -0700 | [diff] [blame] | 729 | @ViewDebug.ExportedProperty(deepExport = true) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 730 | public abstract Resources.Theme getTheme(); |
| 731 | |
| 732 | /** |
| 733 | * Retrieve styled attribute information in this Context's theme. See |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 734 | * {@link android.content.res.Resources.Theme#obtainStyledAttributes(int[])} |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 735 | * for more information. |
| 736 | * |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 737 | * @see android.content.res.Resources.Theme#obtainStyledAttributes(int[]) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 738 | */ |
Aurimas Liutikas | 77acf4b | 2018-12-19 17:31:03 -0800 | [diff] [blame] | 739 | @NonNull |
| 740 | public final TypedArray obtainStyledAttributes(@NonNull @StyleableRes int[] attrs) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 741 | return getTheme().obtainStyledAttributes(attrs); |
| 742 | } |
| 743 | |
| 744 | /** |
| 745 | * Retrieve styled attribute information in this Context's theme. See |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 746 | * {@link android.content.res.Resources.Theme#obtainStyledAttributes(int, int[])} |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 747 | * for more information. |
| 748 | * |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 749 | * @see android.content.res.Resources.Theme#obtainStyledAttributes(int, int[]) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 750 | */ |
Aurimas Liutikas | 77acf4b | 2018-12-19 17:31:03 -0800 | [diff] [blame] | 751 | @NonNull |
| 752 | public final TypedArray obtainStyledAttributes(@StyleRes int resid, |
| 753 | @NonNull @StyleableRes int[] attrs) throws Resources.NotFoundException { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 754 | return getTheme().obtainStyledAttributes(resid, attrs); |
| 755 | } |
| 756 | |
| 757 | /** |
| 758 | * Retrieve styled attribute information in this Context's theme. See |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 759 | * {@link android.content.res.Resources.Theme#obtainStyledAttributes(AttributeSet, int[], int, int)} |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 760 | * for more information. |
| 761 | * |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 762 | * @see android.content.res.Resources.Theme#obtainStyledAttributes(AttributeSet, int[], int, int) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 763 | */ |
Aurimas Liutikas | 77acf4b | 2018-12-19 17:31:03 -0800 | [diff] [blame] | 764 | @NonNull |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 765 | public final TypedArray obtainStyledAttributes( |
Aurimas Liutikas | 77acf4b | 2018-12-19 17:31:03 -0800 | [diff] [blame] | 766 | @Nullable AttributeSet set, @NonNull @StyleableRes int[] attrs) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 767 | return getTheme().obtainStyledAttributes(set, attrs, 0, 0); |
| 768 | } |
| 769 | |
| 770 | /** |
| 771 | * Retrieve styled attribute information in this Context's theme. See |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 772 | * {@link android.content.res.Resources.Theme#obtainStyledAttributes(AttributeSet, int[], int, int)} |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 773 | * for more information. |
| 774 | * |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 775 | * @see android.content.res.Resources.Theme#obtainStyledAttributes(AttributeSet, int[], int, int) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 776 | */ |
Aurimas Liutikas | 77acf4b | 2018-12-19 17:31:03 -0800 | [diff] [blame] | 777 | @NonNull |
| 778 | public final TypedArray obtainStyledAttributes(@Nullable AttributeSet set, |
| 779 | @NonNull @StyleableRes int[] attrs, @AttrRes int defStyleAttr, |
Tor Norbye | c91531a | 2015-04-01 17:41:55 -0700 | [diff] [blame] | 780 | @StyleRes int defStyleRes) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 781 | return getTheme().obtainStyledAttributes( |
| 782 | set, attrs, defStyleAttr, defStyleRes); |
| 783 | } |
| 784 | |
| 785 | /** |
| 786 | * Return a class loader you can use to retrieve classes in this package. |
| 787 | */ |
| 788 | public abstract ClassLoader getClassLoader(); |
| 789 | |
| 790 | /** Return the name of this application's package. */ |
| 791 | public abstract String getPackageName(); |
| 792 | |
Jaewan Kim | 0980c7f | 2018-11-28 23:55:15 +0900 | [diff] [blame] | 793 | /** |
| 794 | * @hide Return the name of the base context this context is derived from. |
| 795 | * This is the same as {@link #getOpPackageName()} except in |
| 796 | * cases where system components are loaded into other app processes, in which |
| 797 | * case {@link #getOpPackageName()} will be the name of the primary package in |
| 798 | * that process (so that app ops uid verification will work with the name). |
| 799 | */ |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 800 | @UnsupportedAppUsage |
Dianne Hackborn | d8e1dbb | 2013-01-17 17:47:37 -0800 | [diff] [blame] | 801 | public abstract String getBasePackageName(); |
| 802 | |
Jaewan Kim | 0980c7f | 2018-11-28 23:55:15 +0900 | [diff] [blame] | 803 | /** |
| 804 | * Return the package name that should be used for {@link android.app.AppOpsManager} calls from |
| 805 | * this context, so that app ops manager's uid verification will work with the name. |
| 806 | * <p> |
| 807 | * This is not generally intended for third party application developers. |
| 808 | */ |
Adrian Roos | ebc927c | 2019-02-28 16:21:18 +0100 | [diff] [blame] | 809 | @NonNull |
Adrian Roos | fe6aeaf | 2019-01-22 16:58:56 +0100 | [diff] [blame] | 810 | public String getOpPackageName() { |
| 811 | throw new RuntimeException("Not implemented. Must override in a subclass."); |
| 812 | } |
Dianne Hackborn | 95d7853 | 2013-09-11 09:51:14 -0700 | [diff] [blame] | 813 | |
Dianne Hackborn | 5c1e00b | 2009-06-18 17:10:57 -0700 | [diff] [blame] | 814 | /** Return the full application info for this context's package. */ |
| 815 | public abstract ApplicationInfo getApplicationInfo(); |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 816 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 817 | /** |
Kenny Root | 3214839 | 2010-01-21 15:40:47 -0800 | [diff] [blame] | 818 | * Return the full path to this context's primary Android package. |
| 819 | * The Android package is a ZIP file which contains the application's |
| 820 | * primary resources. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 821 | * |
| 822 | * <p>Note: this is not generally useful for applications, since they should |
| 823 | * not be directly accessing the file system. |
| 824 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 825 | * @return String Path to the resources. |
| 826 | */ |
| 827 | public abstract String getPackageResourcePath(); |
| 828 | |
| 829 | /** |
Kenny Root | 3214839 | 2010-01-21 15:40:47 -0800 | [diff] [blame] | 830 | * Return the full path to this context's primary Android package. |
| 831 | * The Android package is a ZIP file which contains application's |
| 832 | * primary code and assets. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 833 | * |
| 834 | * <p>Note: this is not generally useful for applications, since they should |
| 835 | * not be directly accessing the file system. |
| 836 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 837 | * @return String Path to the code and assets. |
| 838 | */ |
| 839 | public abstract String getPackageCodePath(); |
| 840 | |
| 841 | /** |
Jeff Sharkey | 6a6cdaf | 2015-12-07 19:25:19 -0700 | [diff] [blame] | 842 | * @hide |
| 843 | * @deprecated use {@link #getSharedPreferencesPath(String)} |
Joe Onorato | 23ecae3 | 2009-06-10 17:07:15 -0700 | [diff] [blame] | 844 | */ |
Jeff Sharkey | 6a6cdaf | 2015-12-07 19:25:19 -0700 | [diff] [blame] | 845 | @Deprecated |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 846 | @UnsupportedAppUsage |
Jeff Sharkey | 6a6cdaf | 2015-12-07 19:25:19 -0700 | [diff] [blame] | 847 | public File getSharedPrefsFile(String name) { |
| 848 | return getSharedPreferencesPath(name); |
| 849 | } |
Joe Onorato | 23ecae3 | 2009-06-10 17:07:15 -0700 | [diff] [blame] | 850 | |
| 851 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 852 | * Retrieve and hold the contents of the preferences file 'name', returning |
| 853 | * a SharedPreferences through which you can retrieve and modify its |
| 854 | * values. Only one instance of the SharedPreferences object is returned |
| 855 | * to any callers for the same name, meaning they will see each other's |
| 856 | * edits as soon as they are made. |
| 857 | * |
Jonathan Dormody | 1bca5db | 2017-11-16 11:25:20 -0700 | [diff] [blame] | 858 | * This method is thead-safe. |
| 859 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 860 | * @param name Desired preferences file. If a preferences file by this name |
| 861 | * does not exist, it will be created when you retrieve an |
| 862 | * editor (SharedPreferences.edit()) and then commit changes (Editor.commit()). |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 863 | * @param mode Operating mode. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 864 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 865 | * @return The single {@link SharedPreferences} instance that can be used |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 866 | * to retrieve and modify the preference values. |
| 867 | * |
| 868 | * @see #MODE_PRIVATE |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 869 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 870 | public abstract SharedPreferences getSharedPreferences(String name, @PreferencesMode int mode); |
Jeff Sharkey | 8fc29cf | 2015-11-30 17:51:00 -0700 | [diff] [blame] | 871 | |
| 872 | /** |
| 873 | * Retrieve and hold the contents of the preferences file, returning |
| 874 | * a SharedPreferences through which you can retrieve and modify its |
| 875 | * values. Only one instance of the SharedPreferences object is returned |
| 876 | * to any callers for the same name, meaning they will see each other's |
| 877 | * edits as soon as they are made. |
| 878 | * |
| 879 | * @param file Desired preferences file. If a preferences file by this name |
| 880 | * does not exist, it will be created when you retrieve an |
| 881 | * editor (SharedPreferences.edit()) and then commit changes (Editor.commit()). |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 882 | * @param mode Operating mode. |
Jeff Sharkey | 8fc29cf | 2015-11-30 17:51:00 -0700 | [diff] [blame] | 883 | * |
| 884 | * @return The single {@link SharedPreferences} instance that can be used |
| 885 | * to retrieve and modify the preference values. |
| 886 | * |
Jeff Sharkey | 6a6cdaf | 2015-12-07 19:25:19 -0700 | [diff] [blame] | 887 | * @see #getSharedPreferencesPath(String) |
Jeff Sharkey | 8fc29cf | 2015-11-30 17:51:00 -0700 | [diff] [blame] | 888 | * @see #MODE_PRIVATE |
Jeff Sharkey | cf3f0a1 | 2016-03-17 19:57:58 -0600 | [diff] [blame] | 889 | * @removed |
Jeff Sharkey | 8fc29cf | 2015-11-30 17:51:00 -0700 | [diff] [blame] | 890 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 891 | public abstract SharedPreferences getSharedPreferences(File file, @PreferencesMode int mode); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 892 | |
| 893 | /** |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 894 | * Move an existing shared preferences file from the given source storage |
Jeff Sharkey | 35871f2 | 2016-01-29 17:13:29 -0700 | [diff] [blame] | 895 | * context to this context. This is typically used to migrate data between |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 896 | * storage locations after an upgrade, such as moving to device protected |
| 897 | * storage. |
Jeff Sharkey | 35871f2 | 2016-01-29 17:13:29 -0700 | [diff] [blame] | 898 | * |
| 899 | * @param sourceContext The source context which contains the existing |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 900 | * shared preferences to move. |
Jeff Sharkey | 35871f2 | 2016-01-29 17:13:29 -0700 | [diff] [blame] | 901 | * @param name The name of the shared preferences file. |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 902 | * @return {@code true} if the move was successful or if the shared |
Jeff Sharkey | 35871f2 | 2016-01-29 17:13:29 -0700 | [diff] [blame] | 903 | * preferences didn't exist in the source context, otherwise |
| 904 | * {@code false}. |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 905 | * @see #createDeviceProtectedStorageContext() |
Jeff Sharkey | 35871f2 | 2016-01-29 17:13:29 -0700 | [diff] [blame] | 906 | */ |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 907 | public abstract boolean moveSharedPreferencesFrom(Context sourceContext, String name); |
| 908 | |
Jeff Sharkey | 35871f2 | 2016-01-29 17:13:29 -0700 | [diff] [blame] | 909 | /** |
| 910 | * Delete an existing shared preferences file. |
| 911 | * |
| 912 | * @param name The name (unique in the application package) of the shared |
| 913 | * preferences file. |
| 914 | * @return {@code true} if the shared preferences file was successfully |
| 915 | * deleted; else {@code false}. |
| 916 | * @see #getSharedPreferences(String, int) |
| 917 | */ |
| 918 | public abstract boolean deleteSharedPreferences(String name); |
| 919 | |
Christopher Tate | fe2368c | 2017-05-17 15:42:35 -0700 | [diff] [blame] | 920 | /** @hide */ |
| 921 | public abstract void reloadSharedPreferences(); |
| 922 | |
Jeff Sharkey | 35871f2 | 2016-01-29 17:13:29 -0700 | [diff] [blame] | 923 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 924 | * Open a private file associated with this Context's application package |
| 925 | * for reading. |
| 926 | * |
| 927 | * @param name The name of the file to open; can not contain path |
| 928 | * separators. |
| 929 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 930 | * @return The resulting {@link FileInputStream}. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 931 | * |
| 932 | * @see #openFileOutput |
| 933 | * @see #fileList |
| 934 | * @see #deleteFile |
| 935 | * @see java.io.FileInputStream#FileInputStream(String) |
| 936 | */ |
| 937 | public abstract FileInputStream openFileInput(String name) |
| 938 | throws FileNotFoundException; |
| 939 | |
| 940 | /** |
Nick Kralevich | 1506921 | 2013-01-09 15:54:56 -0800 | [diff] [blame] | 941 | * Open a private file associated with this Context's application package |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 942 | * for writing. Creates the file if it doesn't already exist. |
| 943 | * <p> |
| 944 | * No additional permissions are required for the calling app to read or |
| 945 | * write the returned file. |
Ricardo Cervera | 90a5f98 | 2014-04-04 10:26:05 -0700 | [diff] [blame] | 946 | * |
Nick Kralevich | 1506921 | 2013-01-09 15:54:56 -0800 | [diff] [blame] | 947 | * @param name The name of the file to open; can not contain path |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 948 | * separators. |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 949 | * @param mode Operating mode. |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 950 | * @return The resulting {@link FileOutputStream}. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 951 | * @see #MODE_APPEND |
| 952 | * @see #MODE_PRIVATE |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 953 | * @see #openFileInput |
| 954 | * @see #fileList |
| 955 | * @see #deleteFile |
| 956 | * @see java.io.FileOutputStream#FileOutputStream(String) |
| 957 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 958 | public abstract FileOutputStream openFileOutput(String name, @FileMode int mode) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 959 | throws FileNotFoundException; |
| 960 | |
| 961 | /** |
| 962 | * Delete the given private file associated with this Context's |
| 963 | * application package. |
| 964 | * |
| 965 | * @param name The name of the file to delete; can not contain path |
| 966 | * separators. |
| 967 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 968 | * @return {@code true} if the file was successfully deleted; else |
| 969 | * {@code false}. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 970 | * |
| 971 | * @see #openFileInput |
| 972 | * @see #openFileOutput |
| 973 | * @see #fileList |
| 974 | * @see java.io.File#delete() |
| 975 | */ |
| 976 | public abstract boolean deleteFile(String name); |
| 977 | |
| 978 | /** |
| 979 | * Returns the absolute path on the filesystem where a file created with |
| 980 | * {@link #openFileOutput} is stored. |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 981 | * <p> |
| 982 | * The returned path may change over time if the calling app is moved to an |
| 983 | * adopted storage device, so only relative paths should be persisted. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 984 | * |
| 985 | * @param name The name of the file for which you would like to get |
| 986 | * its path. |
| 987 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 988 | * @return An absolute path to the given file. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 989 | * |
| 990 | * @see #openFileOutput |
| 991 | * @see #getFilesDir |
| 992 | * @see #getDir |
| 993 | */ |
| 994 | public abstract File getFileStreamPath(String name); |
| 995 | |
| 996 | /** |
Jeff Sharkey | 6a6cdaf | 2015-12-07 19:25:19 -0700 | [diff] [blame] | 997 | * Returns the absolute path on the filesystem where a file created with |
| 998 | * {@link #getSharedPreferences(String, int)} is stored. |
| 999 | * <p> |
| 1000 | * The returned path may change over time if the calling app is moved to an |
| 1001 | * adopted storage device, so only relative paths should be persisted. |
| 1002 | * |
| 1003 | * @param name The name of the shared preferences for which you would like |
| 1004 | * to get a path. |
| 1005 | * @return An absolute path to the given file. |
| 1006 | * @see #getSharedPreferences(String, int) |
Jeff Sharkey | cf3f0a1 | 2016-03-17 19:57:58 -0600 | [diff] [blame] | 1007 | * @removed |
Jeff Sharkey | 6a6cdaf | 2015-12-07 19:25:19 -0700 | [diff] [blame] | 1008 | */ |
| 1009 | public abstract File getSharedPreferencesPath(String name); |
| 1010 | |
| 1011 | /** |
Jeff Sharkey | 2c1ba9a | 2016-02-17 15:29:38 -0700 | [diff] [blame] | 1012 | * Returns the absolute path to the directory on the filesystem where all |
Jeff Sharkey | cf3f0a1 | 2016-03-17 19:57:58 -0600 | [diff] [blame] | 1013 | * private files belonging to this app are stored. Apps should not use this |
| 1014 | * path directly; they should instead use {@link #getFilesDir()}, |
| 1015 | * {@link #getCacheDir()}, {@link #getDir(String, int)}, or other storage |
| 1016 | * APIs on this class. |
Jeff Sharkey | 2c1ba9a | 2016-02-17 15:29:38 -0700 | [diff] [blame] | 1017 | * <p> |
| 1018 | * The returned path may change over time if the calling app is moved to an |
| 1019 | * adopted storage device, so only relative paths should be persisted. |
| 1020 | * <p> |
| 1021 | * No additional permissions are required for the calling app to read or |
| 1022 | * write files under the returned path. |
| 1023 | * |
Jeff Sharkey | cf3f0a1 | 2016-03-17 19:57:58 -0600 | [diff] [blame] | 1024 | * @see ApplicationInfo#dataDir |
Jeff Sharkey | 2c1ba9a | 2016-02-17 15:29:38 -0700 | [diff] [blame] | 1025 | */ |
| 1026 | public abstract File getDataDir(); |
| 1027 | |
| 1028 | /** |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1029 | * Returns the absolute path to the directory on the filesystem where files |
| 1030 | * created with {@link #openFileOutput} are stored. |
| 1031 | * <p> |
| 1032 | * The returned path may change over time if the calling app is moved to an |
| 1033 | * adopted storage device, so only relative paths should be persisted. |
| 1034 | * <p> |
| 1035 | * No additional permissions are required for the calling app to read or |
| 1036 | * write files under the returned path. |
Ricardo Cervera | 90a5f98 | 2014-04-04 10:26:05 -0700 | [diff] [blame] | 1037 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1038 | * @return The path of the directory holding application files. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1039 | * @see #openFileOutput |
| 1040 | * @see #getFileStreamPath |
| 1041 | * @see #getDir |
| 1042 | */ |
| 1043 | public abstract File getFilesDir(); |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 1044 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1045 | /** |
Christopher Tate | a7835b6 | 2014-07-11 17:25:57 -0700 | [diff] [blame] | 1046 | * Returns the absolute path to the directory on the filesystem similar to |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1047 | * {@link #getFilesDir()}. The difference is that files placed under this |
| 1048 | * directory will be excluded from automatic backup to remote storage. See |
Christopher Tate | a7835b6 | 2014-07-11 17:25:57 -0700 | [diff] [blame] | 1049 | * {@link android.app.backup.BackupAgent BackupAgent} for a full discussion |
| 1050 | * of the automatic backup mechanism in Android. |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1051 | * <p> |
| 1052 | * The returned path may change over time if the calling app is moved to an |
| 1053 | * adopted storage device, so only relative paths should be persisted. |
| 1054 | * <p> |
| 1055 | * No additional permissions are required for the calling app to read or |
| 1056 | * write files under the returned path. |
Christopher Tate | a7835b6 | 2014-07-11 17:25:57 -0700 | [diff] [blame] | 1057 | * |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1058 | * @return The path of the directory holding application files that will not |
| 1059 | * be automatically backed up to remote storage. |
Christopher Tate | a7835b6 | 2014-07-11 17:25:57 -0700 | [diff] [blame] | 1060 | * @see #openFileOutput |
| 1061 | * @see #getFileStreamPath |
| 1062 | * @see #getDir |
| 1063 | * @see android.app.backup.BackupAgent |
| 1064 | */ |
| 1065 | public abstract File getNoBackupFilesDir(); |
| 1066 | |
| 1067 | /** |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1068 | * Returns the absolute path to the directory on the primary shared/external |
| 1069 | * storage device where the application can place persistent files it owns. |
| 1070 | * These files are internal to the applications, and not typically visible |
| 1071 | * to the user as media. |
| 1072 | * <p> |
| 1073 | * This is like {@link #getFilesDir()} in that these files will be deleted |
| 1074 | * when the application is uninstalled, however there are some important |
| 1075 | * differences: |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 1076 | * <ul> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1077 | * <li>Shared storage may not always be available, since removable media can |
| 1078 | * be ejected by the user. Media state can be checked using |
| 1079 | * {@link Environment#getExternalStorageState(File)}. |
| 1080 | * <li>There is no security enforced with these files. For example, any |
| 1081 | * application holding |
| 1082 | * {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} can write to |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1083 | * these files. |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 1084 | * </ul> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1085 | * <p> |
| 1086 | * If a shared storage device is emulated (as determined by |
| 1087 | * {@link Environment#isExternalStorageEmulated(File)}), it's contents are |
| 1088 | * backed by a private user data partition, which means there is little |
| 1089 | * benefit to storing data here instead of the private directories returned |
| 1090 | * by {@link #getFilesDir()}, etc. |
| 1091 | * <p> |
| 1092 | * Starting in {@link android.os.Build.VERSION_CODES#KITKAT}, no permissions |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1093 | * are required to read or write to the returned path; it's always |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1094 | * accessible to the calling app. This only applies to paths generated for |
| 1095 | * package name of the calling application. To access paths belonging to |
| 1096 | * other packages, |
| 1097 | * {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} and/or |
| 1098 | * {@link android.Manifest.permission#READ_EXTERNAL_STORAGE} are required. |
| 1099 | * <p> |
| 1100 | * On devices with multiple users (as described by {@link UserManager}), |
| 1101 | * each user has their own isolated shared storage. Applications only have |
| 1102 | * access to the shared storage for the user they're running as. |
| 1103 | * <p> |
| 1104 | * The returned path may change over time if different shared storage media |
| 1105 | * is inserted, so only relative paths should be persisted. |
| 1106 | * <p> |
| 1107 | * Here is an example of typical code to manipulate a file in an |
| 1108 | * application's shared storage: |
| 1109 | * </p> |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 1110 | * {@sample development/samples/ApiDemos/src/com/example/android/apis/content/ExternalStorage.java |
| 1111 | * private_file} |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1112 | * <p> |
| 1113 | * If you supply a non-null <var>type</var> to this function, the returned |
| 1114 | * file will be a path to a sub-directory of the given type. Though these |
| 1115 | * files are not automatically scanned by the media scanner, you can |
| 1116 | * explicitly add them to the media database with |
| 1117 | * {@link android.media.MediaScannerConnection#scanFile(Context, String[], String[], android.media.MediaScannerConnection.OnScanCompletedListener) |
| 1118 | * MediaScannerConnection.scanFile}. Note that this is not the same as |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 1119 | * {@link android.os.Environment#getExternalStoragePublicDirectory |
| 1120 | * Environment.getExternalStoragePublicDirectory()}, which provides |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1121 | * directories of media shared by all applications. The directories returned |
| 1122 | * here are owned by the application, and their contents will be removed |
| 1123 | * when the application is uninstalled. Unlike |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 1124 | * {@link android.os.Environment#getExternalStoragePublicDirectory |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1125 | * Environment.getExternalStoragePublicDirectory()}, the directory returned |
| 1126 | * here will be automatically created for you. |
| 1127 | * <p> |
| 1128 | * Here is an example of typical code to manipulate a picture in an |
| 1129 | * application's shared storage and add it to the media database: |
| 1130 | * </p> |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 1131 | * {@sample development/samples/ApiDemos/src/com/example/android/apis/content/ExternalStorage.java |
| 1132 | * private_picture} |
Jeff Sharkey | 8c16579 | 2012-10-22 14:08:29 -0700 | [diff] [blame] | 1133 | * |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1134 | * @param type The type of files directory to return. May be {@code null} |
| 1135 | * for the root of the files directory or one of the following |
| 1136 | * constants for a subdirectory: |
| 1137 | * {@link android.os.Environment#DIRECTORY_MUSIC}, |
| 1138 | * {@link android.os.Environment#DIRECTORY_PODCASTS}, |
| 1139 | * {@link android.os.Environment#DIRECTORY_RINGTONES}, |
| 1140 | * {@link android.os.Environment#DIRECTORY_ALARMS}, |
| 1141 | * {@link android.os.Environment#DIRECTORY_NOTIFICATIONS}, |
| 1142 | * {@link android.os.Environment#DIRECTORY_PICTURES}, or |
| 1143 | * {@link android.os.Environment#DIRECTORY_MOVIES}. |
| 1144 | * @return the absolute path to application-specific directory. May return |
| 1145 | * {@code null} if shared storage is not currently available. |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 1146 | * @see #getFilesDir |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1147 | * @see #getExternalFilesDirs(String) |
| 1148 | * @see Environment#getExternalStorageState(File) |
| 1149 | * @see Environment#isExternalStorageEmulated(File) |
| 1150 | * @see Environment#isExternalStorageRemovable(File) |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 1151 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 1152 | @Nullable |
| 1153 | public abstract File getExternalFilesDir(@Nullable String type); |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 1154 | |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 1155 | /** |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1156 | * Returns absolute paths to application-specific directories on all |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1157 | * shared/external storage devices where the application can place |
| 1158 | * persistent files it owns. These files are internal to the application, |
| 1159 | * and not typically visible to the user as media. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1160 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1161 | * This is like {@link #getFilesDir()} in that these files will be deleted |
| 1162 | * when the application is uninstalled, however there are some important |
| 1163 | * differences: |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1164 | * <ul> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1165 | * <li>Shared storage may not always be available, since removable media can |
| 1166 | * be ejected by the user. Media state can be checked using |
| 1167 | * {@link Environment#getExternalStorageState(File)}. |
| 1168 | * <li>There is no security enforced with these files. For example, any |
| 1169 | * application holding |
| 1170 | * {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} can write to |
| 1171 | * these files. |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1172 | * </ul> |
| 1173 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1174 | * If a shared storage device is emulated (as determined by |
| 1175 | * {@link Environment#isExternalStorageEmulated(File)}), it's contents are |
| 1176 | * backed by a private user data partition, which means there is little |
| 1177 | * benefit to storing data here instead of the private directories returned |
| 1178 | * by {@link #getFilesDir()}, etc. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1179 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1180 | * Shared storage devices returned here are considered a stable part of the |
| 1181 | * device, including physical media slots under a protective cover. The |
| 1182 | * returned paths do not include transient devices, such as USB flash drives |
| 1183 | * connected to handheld devices. |
| 1184 | * <p> |
| 1185 | * An application may store data on any or all of the returned devices. For |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1186 | * example, an app may choose to store large files on the device with the |
| 1187 | * most available space, as measured by {@link StatFs}. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1188 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1189 | * No additional permissions are required for the calling app to read or |
| 1190 | * write files under the returned path. Write access outside of these paths |
| 1191 | * on secondary external storage devices is not available. |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1192 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1193 | * The returned path may change over time if different shared storage media |
| 1194 | * is inserted, so only relative paths should be persisted. |
Jeff Sharkey | 8c16579 | 2012-10-22 14:08:29 -0700 | [diff] [blame] | 1195 | * |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1196 | * @param type The type of files directory to return. May be {@code null} |
| 1197 | * for the root of the files directory or one of the following |
| 1198 | * constants for a subdirectory: |
| 1199 | * {@link android.os.Environment#DIRECTORY_MUSIC}, |
| 1200 | * {@link android.os.Environment#DIRECTORY_PODCASTS}, |
| 1201 | * {@link android.os.Environment#DIRECTORY_RINGTONES}, |
| 1202 | * {@link android.os.Environment#DIRECTORY_ALARMS}, |
| 1203 | * {@link android.os.Environment#DIRECTORY_NOTIFICATIONS}, |
| 1204 | * {@link android.os.Environment#DIRECTORY_PICTURES}, or |
| 1205 | * {@link android.os.Environment#DIRECTORY_MOVIES}. |
| 1206 | * @return the absolute paths to application-specific directories. Some |
| 1207 | * individual paths may be {@code null} if that shared storage is |
| 1208 | * not currently available. The first path returned is the same as |
| 1209 | * {@link #getExternalFilesDir(String)}. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1210 | * @see #getExternalFilesDir(String) |
Jeff Sharkey | 4ca728c | 2014-01-10 16:27:19 -0800 | [diff] [blame] | 1211 | * @see Environment#getExternalStorageState(File) |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1212 | * @see Environment#isExternalStorageEmulated(File) |
| 1213 | * @see Environment#isExternalStorageRemovable(File) |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1214 | */ |
| 1215 | public abstract File[] getExternalFilesDirs(String type); |
| 1216 | |
| 1217 | /** |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1218 | * Return the primary shared/external storage directory where this |
| 1219 | * application's OBB files (if there are any) can be found. Note if the |
| 1220 | * application does not have any OBB files, this directory may not exist. |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1221 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1222 | * This is like {@link #getFilesDir()} in that these files will be deleted |
| 1223 | * when the application is uninstalled, however there are some important |
| 1224 | * differences: |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1225 | * <ul> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1226 | * <li>Shared storage may not always be available, since removable media can |
| 1227 | * be ejected by the user. Media state can be checked using |
| 1228 | * {@link Environment#getExternalStorageState(File)}. |
| 1229 | * <li>There is no security enforced with these files. For example, any |
| 1230 | * application holding |
| 1231 | * {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} can write to |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1232 | * these files. |
| 1233 | * </ul> |
| 1234 | * <p> |
| 1235 | * Starting in {@link android.os.Build.VERSION_CODES#KITKAT}, no permissions |
Dave Friedman | cfe5088 | 2017-07-05 00:40:07 -0700 | [diff] [blame] | 1236 | * are required to read or write to the path that this method returns. |
| 1237 | * However, starting from {@link android.os.Build.VERSION_CODES#M}, |
| 1238 | * to read the OBB expansion files, you must declare the |
| 1239 | * {@link android.Manifest.permission#READ_EXTERNAL_STORAGE} permission in the app manifest and ask for |
| 1240 | * permission at runtime as follows: |
| 1241 | * </p> |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1242 | * <p> |
Dave Friedman | cfe5088 | 2017-07-05 00:40:07 -0700 | [diff] [blame] | 1243 | * {@code <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" |
| 1244 | * android:maxSdkVersion="23" />} |
| 1245 | * </p> |
| 1246 | * <p> |
| 1247 | * Starting from {@link android.os.Build.VERSION_CODES#N}, |
| 1248 | * {@link android.Manifest.permission#READ_EXTERNAL_STORAGE} |
| 1249 | * permission is not required, so don’t ask for this |
| 1250 | * permission at runtime. To handle both cases, your app must first try to read the OBB file, |
| 1251 | * and if it fails, you must request |
| 1252 | * {@link android.Manifest.permission#READ_EXTERNAL_STORAGE} permission at runtime. |
| 1253 | * </p> |
| 1254 | * |
| 1255 | * <p> |
| 1256 | * The following code snippet shows how to do this: |
| 1257 | * </p> |
| 1258 | * |
| 1259 | * <pre> |
| 1260 | * File obb = new File(obb_filename); |
| 1261 | * boolean open_failed = false; |
| 1262 | * |
| 1263 | * try { |
| 1264 | * BufferedReader br = new BufferedReader(new FileReader(obb)); |
| 1265 | * open_failed = false; |
| 1266 | * ReadObbFile(br); |
| 1267 | * } catch (IOException e) { |
| 1268 | * open_failed = true; |
| 1269 | * } |
| 1270 | * |
| 1271 | * if (open_failed) { |
| 1272 | * // request READ_EXTERNAL_STORAGE permission before reading OBB file |
| 1273 | * ReadObbFileWithPermission(); |
| 1274 | * } |
| 1275 | * </pre> |
| 1276 | * |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1277 | * On devices with multiple users (as described by {@link UserManager}), |
Jeff Sharkey | 8c16579 | 2012-10-22 14:08:29 -0700 | [diff] [blame] | 1278 | * multiple users may share the same OBB storage location. Applications |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1279 | * should ensure that multiple instances running under different users don't |
| 1280 | * interfere with each other. |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1281 | * |
| 1282 | * @return the absolute path to application-specific directory. May return |
| 1283 | * {@code null} if shared storage is not currently available. |
| 1284 | * @see #getObbDirs() |
| 1285 | * @see Environment#getExternalStorageState(File) |
| 1286 | * @see Environment#isExternalStorageEmulated(File) |
| 1287 | * @see Environment#isExternalStorageRemovable(File) |
Dianne Hackborn | 805fd7e | 2011-01-16 18:30:29 -0800 | [diff] [blame] | 1288 | */ |
| 1289 | public abstract File getObbDir(); |
| 1290 | |
| 1291 | /** |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1292 | * Returns absolute paths to application-specific directories on all |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1293 | * shared/external storage devices where the application's OBB files (if |
| 1294 | * there are any) can be found. Note if the application does not have any |
| 1295 | * OBB files, these directories may not exist. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1296 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1297 | * This is like {@link #getFilesDir()} in that these files will be deleted |
| 1298 | * when the application is uninstalled, however there are some important |
| 1299 | * differences: |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1300 | * <ul> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1301 | * <li>Shared storage may not always be available, since removable media can |
| 1302 | * be ejected by the user. Media state can be checked using |
| 1303 | * {@link Environment#getExternalStorageState(File)}. |
| 1304 | * <li>There is no security enforced with these files. For example, any |
| 1305 | * application holding |
| 1306 | * {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} can write to |
| 1307 | * these files. |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1308 | * </ul> |
| 1309 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1310 | * Shared storage devices returned here are considered a stable part of the |
| 1311 | * device, including physical media slots under a protective cover. The |
| 1312 | * returned paths do not include transient devices, such as USB flash drives |
| 1313 | * connected to handheld devices. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1314 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1315 | * An application may store data on any or all of the returned devices. For |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1316 | * example, an app may choose to store large files on the device with the |
| 1317 | * most available space, as measured by {@link StatFs}. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1318 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1319 | * No additional permissions are required for the calling app to read or |
| 1320 | * write files under the returned path. Write access outside of these paths |
| 1321 | * on secondary external storage devices is not available. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1322 | * |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1323 | * @return the absolute paths to application-specific directories. Some |
| 1324 | * individual paths may be {@code null} if that shared storage is |
| 1325 | * not currently available. The first path returned is the same as |
| 1326 | * {@link #getObbDir()} |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1327 | * @see #getObbDir() |
Jeff Sharkey | 4ca728c | 2014-01-10 16:27:19 -0800 | [diff] [blame] | 1328 | * @see Environment#getExternalStorageState(File) |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1329 | * @see Environment#isExternalStorageEmulated(File) |
| 1330 | * @see Environment#isExternalStorageRemovable(File) |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1331 | */ |
| 1332 | public abstract File[] getObbDirs(); |
| 1333 | |
| 1334 | /** |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1335 | * Returns the absolute path to the application specific cache directory on |
Jeff Sharkey | 60a82cd | 2017-04-18 18:19:16 -0600 | [diff] [blame] | 1336 | * the filesystem. |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1337 | * <p> |
Jeff Sharkey | 60a82cd | 2017-04-18 18:19:16 -0600 | [diff] [blame] | 1338 | * The system will automatically delete files in this directory as disk |
| 1339 | * space is needed elsewhere on the device. The system will always delete |
| 1340 | * older files first, as reported by {@link File#lastModified()}. If |
| 1341 | * desired, you can exert more control over how files are deleted using |
| 1342 | * {@link StorageManager#setCacheBehaviorGroup(File, boolean)} and |
| 1343 | * {@link StorageManager#setCacheBehaviorTombstone(File, boolean)}. |
| 1344 | * <p> |
| 1345 | * Apps are strongly encouraged to keep their usage of cache space below the |
| 1346 | * quota returned by |
| 1347 | * {@link StorageManager#getCacheQuotaBytes(java.util.UUID)}. If your app |
| 1348 | * goes above this quota, your cached files will be some of the first to be |
| 1349 | * deleted when additional disk space is needed. Conversely, if your app |
| 1350 | * stays under this quota, your cached files will be some of the last to be |
| 1351 | * deleted when additional disk space is needed. |
| 1352 | * <p> |
| 1353 | * Note that your cache quota will change over time depending on how |
| 1354 | * frequently the user interacts with your app, and depending on how much |
| 1355 | * system-wide disk space is used. |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1356 | * <p> |
| 1357 | * The returned path may change over time if the calling app is moved to an |
| 1358 | * adopted storage device, so only relative paths should be persisted. |
| 1359 | * <p> |
| 1360 | * Apps require no extra permissions to read or write to the returned path, |
| 1361 | * since this path lives in their private storage. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 1362 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1363 | * @return The path of the directory holding application cache files. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1364 | * @see #openFileOutput |
| 1365 | * @see #getFileStreamPath |
| 1366 | * @see #getDir |
Kevin Hufnagle | e9681e1 | 2016-09-23 16:44:03 -0700 | [diff] [blame] | 1367 | * @see #getExternalCacheDir |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1368 | */ |
| 1369 | public abstract File getCacheDir(); |
| 1370 | |
| 1371 | /** |
Jeff Sharkey | 4ed745d | 2014-07-15 20:39:15 -0700 | [diff] [blame] | 1372 | * Returns the absolute path to the application specific cache directory on |
Jeff Sharkey | 60a82cd | 2017-04-18 18:19:16 -0600 | [diff] [blame] | 1373 | * the filesystem designed for storing cached code. |
| 1374 | * <p> |
| 1375 | * The system will delete any files stored in this location both when your |
| 1376 | * specific application is upgraded, and when the entire platform is |
| 1377 | * upgraded. |
Jeff Sharkey | 4ed745d | 2014-07-15 20:39:15 -0700 | [diff] [blame] | 1378 | * <p> |
| 1379 | * This location is optimal for storing compiled or optimized code generated |
| 1380 | * by your application at runtime. |
| 1381 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1382 | * The returned path may change over time if the calling app is moved to an |
| 1383 | * adopted storage device, so only relative paths should be persisted. |
| 1384 | * <p> |
Jeff Sharkey | 4ed745d | 2014-07-15 20:39:15 -0700 | [diff] [blame] | 1385 | * Apps require no extra permissions to read or write to the returned path, |
| 1386 | * since this path lives in their private storage. |
| 1387 | * |
| 1388 | * @return The path of the directory holding application code cache files. |
| 1389 | */ |
| 1390 | public abstract File getCodeCacheDir(); |
| 1391 | |
| 1392 | /** |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1393 | * Returns absolute path to application-specific directory on the primary |
| 1394 | * shared/external storage device where the application can place cache |
| 1395 | * files it owns. These files are internal to the application, and not |
| 1396 | * typically visible to the user as media. |
| 1397 | * <p> |
| 1398 | * This is like {@link #getCacheDir()} in that these files will be deleted |
| 1399 | * when the application is uninstalled, however there are some important |
| 1400 | * differences: |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 1401 | * <ul> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1402 | * <li>The platform does not always monitor the space available in shared |
| 1403 | * storage, and thus may not automatically delete these files. Apps should |
| 1404 | * always manage the maximum space used in this location. Currently the only |
| 1405 | * time files here will be deleted by the platform is when running on |
| 1406 | * {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1} or later and |
| 1407 | * {@link Environment#isExternalStorageEmulated(File)} returns true. |
| 1408 | * <li>Shared storage may not always be available, since removable media can |
| 1409 | * be ejected by the user. Media state can be checked using |
| 1410 | * {@link Environment#getExternalStorageState(File)}. |
| 1411 | * <li>There is no security enforced with these files. For example, any |
| 1412 | * application holding |
| 1413 | * {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} can write to |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1414 | * these files. |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 1415 | * </ul> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1416 | * <p> |
| 1417 | * If a shared storage device is emulated (as determined by |
Kevin Hufnagle | e9681e1 | 2016-09-23 16:44:03 -0700 | [diff] [blame] | 1418 | * {@link Environment#isExternalStorageEmulated(File)}), its contents are |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1419 | * backed by a private user data partition, which means there is little |
| 1420 | * benefit to storing data here instead of the private directory returned by |
| 1421 | * {@link #getCacheDir()}. |
| 1422 | * <p> |
| 1423 | * Starting in {@link android.os.Build.VERSION_CODES#KITKAT}, no permissions |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1424 | * are required to read or write to the returned path; it's always |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1425 | * accessible to the calling app. This only applies to paths generated for |
| 1426 | * package name of the calling application. To access paths belonging to |
| 1427 | * other packages, |
| 1428 | * {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} and/or |
| 1429 | * {@link android.Manifest.permission#READ_EXTERNAL_STORAGE} are required. |
| 1430 | * <p> |
| 1431 | * On devices with multiple users (as described by {@link UserManager}), |
| 1432 | * each user has their own isolated shared storage. Applications only have |
| 1433 | * access to the shared storage for the user they're running as. |
| 1434 | * <p> |
| 1435 | * The returned path may change over time if different shared storage media |
| 1436 | * is inserted, so only relative paths should be persisted. |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1437 | * |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1438 | * @return the absolute path to application-specific directory. May return |
| 1439 | * {@code null} if shared storage is not currently available. |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 1440 | * @see #getCacheDir |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1441 | * @see #getExternalCacheDirs() |
| 1442 | * @see Environment#getExternalStorageState(File) |
| 1443 | * @see Environment#isExternalStorageEmulated(File) |
| 1444 | * @see Environment#isExternalStorageRemovable(File) |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 1445 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 1446 | @Nullable |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 1447 | public abstract File getExternalCacheDir(); |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 1448 | |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 1449 | /** |
Fyodor Kupolov | 6122129 | 2016-09-02 15:21:03 -0700 | [diff] [blame] | 1450 | * Returns absolute path to application-specific directory in the preloaded cache. |
| 1451 | * <p>Files stored in the cache directory can be deleted when the device runs low on storage. |
| 1452 | * There is no guarantee when these files will be deleted. |
| 1453 | * @hide |
| 1454 | */ |
| 1455 | @Nullable |
| 1456 | @SystemApi |
| 1457 | public abstract File getPreloadsFileCache(); |
| 1458 | |
| 1459 | /** |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1460 | * Returns absolute paths to application-specific directories on all |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1461 | * shared/external storage devices where the application can place cache |
| 1462 | * files it owns. These files are internal to the application, and not |
| 1463 | * typically visible to the user as media. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1464 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1465 | * This is like {@link #getCacheDir()} in that these files will be deleted |
| 1466 | * when the application is uninstalled, however there are some important |
| 1467 | * differences: |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1468 | * <ul> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1469 | * <li>The platform does not always monitor the space available in shared |
| 1470 | * storage, and thus may not automatically delete these files. Apps should |
| 1471 | * always manage the maximum space used in this location. Currently the only |
| 1472 | * time files here will be deleted by the platform is when running on |
| 1473 | * {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1} or later and |
| 1474 | * {@link Environment#isExternalStorageEmulated(File)} returns true. |
| 1475 | * <li>Shared storage may not always be available, since removable media can |
| 1476 | * be ejected by the user. Media state can be checked using |
| 1477 | * {@link Environment#getExternalStorageState(File)}. |
| 1478 | * <li>There is no security enforced with these files. For example, any |
| 1479 | * application holding |
| 1480 | * {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} can write to |
| 1481 | * these files. |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1482 | * </ul> |
| 1483 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1484 | * If a shared storage device is emulated (as determined by |
| 1485 | * {@link Environment#isExternalStorageEmulated(File)}), it's contents are |
| 1486 | * backed by a private user data partition, which means there is little |
| 1487 | * benefit to storing data here instead of the private directory returned by |
| 1488 | * {@link #getCacheDir()}. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1489 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1490 | * Shared storage devices returned here are considered a stable part of the |
| 1491 | * device, including physical media slots under a protective cover. The |
| 1492 | * returned paths do not include transient devices, such as USB flash drives |
| 1493 | * connected to handheld devices. |
| 1494 | * <p> |
| 1495 | * An application may store data on any or all of the returned devices. For |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1496 | * example, an app may choose to store large files on the device with the |
| 1497 | * most available space, as measured by {@link StatFs}. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1498 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1499 | * No additional permissions are required for the calling app to read or |
| 1500 | * write files under the returned path. Write access outside of these paths |
| 1501 | * on secondary external storage devices is not available. |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1502 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1503 | * The returned paths may change over time if different shared storage media |
| 1504 | * is inserted, so only relative paths should be persisted. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1505 | * |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1506 | * @return the absolute paths to application-specific directories. Some |
| 1507 | * individual paths may be {@code null} if that shared storage is |
| 1508 | * not currently available. The first path returned is the same as |
| 1509 | * {@link #getExternalCacheDir()}. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1510 | * @see #getExternalCacheDir() |
Jeff Sharkey | 4ca728c | 2014-01-10 16:27:19 -0800 | [diff] [blame] | 1511 | * @see Environment#getExternalStorageState(File) |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1512 | * @see Environment#isExternalStorageEmulated(File) |
| 1513 | * @see Environment#isExternalStorageRemovable(File) |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1514 | */ |
| 1515 | public abstract File[] getExternalCacheDirs(); |
| 1516 | |
| 1517 | /** |
Jeff Sharkey | 2ee3c1e | 2014-05-30 15:38:35 -0700 | [diff] [blame] | 1518 | * Returns absolute paths to application-specific directories on all |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1519 | * shared/external storage devices where the application can place media |
| 1520 | * files. These files are scanned and made available to other apps through |
Jeff Sharkey | 2ee3c1e | 2014-05-30 15:38:35 -0700 | [diff] [blame] | 1521 | * {@link MediaStore}. |
| 1522 | * <p> |
| 1523 | * This is like {@link #getExternalFilesDirs} in that these files will be |
| 1524 | * deleted when the application is uninstalled, however there are some |
| 1525 | * important differences: |
| 1526 | * <ul> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1527 | * <li>Shared storage may not always be available, since removable media can |
| 1528 | * be ejected by the user. Media state can be checked using |
| 1529 | * {@link Environment#getExternalStorageState(File)}. |
| 1530 | * <li>There is no security enforced with these files. For example, any |
| 1531 | * application holding |
| 1532 | * {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} can write to |
| 1533 | * these files. |
Jeff Sharkey | 2ee3c1e | 2014-05-30 15:38:35 -0700 | [diff] [blame] | 1534 | * </ul> |
| 1535 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1536 | * Shared storage devices returned here are considered a stable part of the |
| 1537 | * device, including physical media slots under a protective cover. The |
| 1538 | * returned paths do not include transient devices, such as USB flash drives |
| 1539 | * connected to handheld devices. |
Jeff Sharkey | 2ee3c1e | 2014-05-30 15:38:35 -0700 | [diff] [blame] | 1540 | * <p> |
| 1541 | * An application may store data on any or all of the returned devices. For |
| 1542 | * example, an app may choose to store large files on the device with the |
| 1543 | * most available space, as measured by {@link StatFs}. |
| 1544 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1545 | * No additional permissions are required for the calling app to read or |
| 1546 | * write files under the returned path. Write access outside of these paths |
| 1547 | * on secondary external storage devices is not available. |
Jeff Sharkey | 2ee3c1e | 2014-05-30 15:38:35 -0700 | [diff] [blame] | 1548 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1549 | * The returned paths may change over time if different shared storage media |
| 1550 | * is inserted, so only relative paths should be persisted. |
Jeff Sharkey | 2ee3c1e | 2014-05-30 15:38:35 -0700 | [diff] [blame] | 1551 | * |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1552 | * @return the absolute paths to application-specific directories. Some |
| 1553 | * individual paths may be {@code null} if that shared storage is |
| 1554 | * not currently available. |
Jeff Sharkey | 2ee3c1e | 2014-05-30 15:38:35 -0700 | [diff] [blame] | 1555 | * @see Environment#getExternalStorageState(File) |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1556 | * @see Environment#isExternalStorageEmulated(File) |
| 1557 | * @see Environment#isExternalStorageRemovable(File) |
Jeff Sharkey | 2ee3c1e | 2014-05-30 15:38:35 -0700 | [diff] [blame] | 1558 | */ |
| 1559 | public abstract File[] getExternalMediaDirs(); |
| 1560 | |
| 1561 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1562 | * Returns an array of strings naming the private files associated with |
| 1563 | * this Context's application package. |
| 1564 | * |
| 1565 | * @return Array of strings naming the private files. |
| 1566 | * |
| 1567 | * @see #openFileInput |
| 1568 | * @see #openFileOutput |
| 1569 | * @see #deleteFile |
| 1570 | */ |
| 1571 | public abstract String[] fileList(); |
| 1572 | |
| 1573 | /** |
| 1574 | * Retrieve, creating if needed, a new directory in which the application |
| 1575 | * can place its own custom data files. You can use the returned File |
| 1576 | * object to create and access files in this directory. Note that files |
| 1577 | * created through a File object will only be accessible by your own |
| 1578 | * application; you can only set the mode of the entire directory, not |
| 1579 | * of individual files. |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1580 | * <p> |
| 1581 | * The returned path may change over time if the calling app is moved to an |
| 1582 | * adopted storage device, so only relative paths should be persisted. |
| 1583 | * <p> |
| 1584 | * Apps require no extra permissions to read or write to the returned path, |
| 1585 | * since this path lives in their private storage. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1586 | * |
Nick Kralevich | 92091fa | 2012-12-12 16:24:31 -0800 | [diff] [blame] | 1587 | * @param name Name of the directory to retrieve. This is a directory |
Nick Kralevich | 1506921 | 2013-01-09 15:54:56 -0800 | [diff] [blame] | 1588 | * that is created as part of your application data. |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 1589 | * @param mode Operating mode. |
Nick Kralevich | 1506921 | 2013-01-09 15:54:56 -0800 | [diff] [blame] | 1590 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1591 | * @return A {@link File} object for the requested directory. The directory |
Nick Kralevich | 1506921 | 2013-01-09 15:54:56 -0800 | [diff] [blame] | 1592 | * will have been created if it does not already exist. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1593 | * |
| 1594 | * @see #openFileOutput(String, int) |
| 1595 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 1596 | public abstract File getDir(String name, @FileMode int mode); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1597 | |
| 1598 | /** |
| 1599 | * Open a new private SQLiteDatabase associated with this Context's |
Jeff Sharkey | 634dc42 | 2016-01-30 17:44:15 -0700 | [diff] [blame] | 1600 | * application package. Create the database file if it doesn't exist. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1601 | * |
| 1602 | * @param name The name (unique in the application package) of the database. |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 1603 | * @param mode Operating mode. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1604 | * @param factory An optional factory class that is called to instantiate a |
Jeff Sharkey | 634dc42 | 2016-01-30 17:44:15 -0700 | [diff] [blame] | 1605 | * cursor when query is called. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1606 | * @return The contents of a newly created database with the given name. |
Jeff Sharkey | 634dc42 | 2016-01-30 17:44:15 -0700 | [diff] [blame] | 1607 | * @throws android.database.sqlite.SQLiteException if the database file |
| 1608 | * could not be opened. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1609 | * @see #MODE_PRIVATE |
Jeff Brown | 47847f3 | 2012-03-22 19:13:11 -0700 | [diff] [blame] | 1610 | * @see #MODE_ENABLE_WRITE_AHEAD_LOGGING |
Sunny Goyal | a21e6b2 | 2015-12-02 09:51:02 -0800 | [diff] [blame] | 1611 | * @see #MODE_NO_LOCALIZED_COLLATORS |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1612 | * @see #deleteDatabase |
| 1613 | */ |
| 1614 | public abstract SQLiteDatabase openOrCreateDatabase(String name, |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 1615 | @DatabaseMode int mode, CursorFactory factory); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1616 | |
| 1617 | /** |
Vasu Nori | 74f170f | 2010-06-01 18:06:18 -0700 | [diff] [blame] | 1618 | * Open a new private SQLiteDatabase associated with this Context's |
Jeff Sharkey | 634dc42 | 2016-01-30 17:44:15 -0700 | [diff] [blame] | 1619 | * application package. Creates the database file if it doesn't exist. |
| 1620 | * <p> |
| 1621 | * Accepts input param: a concrete instance of {@link DatabaseErrorHandler} |
| 1622 | * to be used to handle corruption when sqlite reports database corruption. |
| 1623 | * </p> |
Vasu Nori | 74f170f | 2010-06-01 18:06:18 -0700 | [diff] [blame] | 1624 | * |
| 1625 | * @param name The name (unique in the application package) of the database. |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 1626 | * @param mode Operating mode. |
Vasu Nori | 74f170f | 2010-06-01 18:06:18 -0700 | [diff] [blame] | 1627 | * @param factory An optional factory class that is called to instantiate a |
Jeff Sharkey | 634dc42 | 2016-01-30 17:44:15 -0700 | [diff] [blame] | 1628 | * cursor when query is called. |
| 1629 | * @param errorHandler the {@link DatabaseErrorHandler} to be used when |
| 1630 | * sqlite reports database corruption. if null, |
| 1631 | * {@link android.database.DefaultDatabaseErrorHandler} is |
| 1632 | * assumed. |
Vasu Nori | 74f170f | 2010-06-01 18:06:18 -0700 | [diff] [blame] | 1633 | * @return The contents of a newly created database with the given name. |
Jeff Sharkey | 634dc42 | 2016-01-30 17:44:15 -0700 | [diff] [blame] | 1634 | * @throws android.database.sqlite.SQLiteException if the database file |
| 1635 | * could not be opened. |
Vasu Nori | 74f170f | 2010-06-01 18:06:18 -0700 | [diff] [blame] | 1636 | * @see #MODE_PRIVATE |
Jeff Brown | 47847f3 | 2012-03-22 19:13:11 -0700 | [diff] [blame] | 1637 | * @see #MODE_ENABLE_WRITE_AHEAD_LOGGING |
Sunny Goyal | a21e6b2 | 2015-12-02 09:51:02 -0800 | [diff] [blame] | 1638 | * @see #MODE_NO_LOCALIZED_COLLATORS |
Vasu Nori | 74f170f | 2010-06-01 18:06:18 -0700 | [diff] [blame] | 1639 | * @see #deleteDatabase |
| 1640 | */ |
| 1641 | public abstract SQLiteDatabase openOrCreateDatabase(String name, |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 1642 | @DatabaseMode int mode, CursorFactory factory, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 1643 | @Nullable DatabaseErrorHandler errorHandler); |
Vasu Nori | 74f170f | 2010-06-01 18:06:18 -0700 | [diff] [blame] | 1644 | |
| 1645 | /** |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 1646 | * Move an existing database file from the given source storage context to |
| 1647 | * this context. This is typically used to migrate data between storage |
| 1648 | * locations after an upgrade, such as migrating to device protected |
| 1649 | * storage. |
Jeff Sharkey | d21cad1 | 2016-05-20 11:30:07 -0600 | [diff] [blame] | 1650 | * <p> |
| 1651 | * The database must be closed before being moved. |
Jeff Sharkey | 35871f2 | 2016-01-29 17:13:29 -0700 | [diff] [blame] | 1652 | * |
| 1653 | * @param sourceContext The source context which contains the existing |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 1654 | * database to move. |
Jeff Sharkey | 35871f2 | 2016-01-29 17:13:29 -0700 | [diff] [blame] | 1655 | * @param name The name of the database file. |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 1656 | * @return {@code true} if the move was successful or if the database didn't |
| 1657 | * exist in the source context, otherwise {@code false}. |
| 1658 | * @see #createDeviceProtectedStorageContext() |
Jeff Sharkey | 35871f2 | 2016-01-29 17:13:29 -0700 | [diff] [blame] | 1659 | */ |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 1660 | public abstract boolean moveDatabaseFrom(Context sourceContext, String name); |
| 1661 | |
Jeff Sharkey | 35871f2 | 2016-01-29 17:13:29 -0700 | [diff] [blame] | 1662 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1663 | * Delete an existing private SQLiteDatabase associated with this Context's |
| 1664 | * application package. |
| 1665 | * |
| 1666 | * @param name The name (unique in the application package) of the |
| 1667 | * database. |
| 1668 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1669 | * @return {@code true} if the database was successfully deleted; else {@code false}. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1670 | * |
| 1671 | * @see #openOrCreateDatabase |
| 1672 | */ |
| 1673 | public abstract boolean deleteDatabase(String name); |
| 1674 | |
| 1675 | /** |
| 1676 | * Returns the absolute path on the filesystem where a database created with |
| 1677 | * {@link #openOrCreateDatabase} is stored. |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1678 | * <p> |
| 1679 | * The returned path may change over time if the calling app is moved to an |
| 1680 | * adopted storage device, so only relative paths should be persisted. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1681 | * |
| 1682 | * @param name The name of the database for which you would like to get |
| 1683 | * its path. |
| 1684 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1685 | * @return An absolute path to the given database. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1686 | * |
| 1687 | * @see #openOrCreateDatabase |
| 1688 | */ |
| 1689 | public abstract File getDatabasePath(String name); |
| 1690 | |
| 1691 | /** |
| 1692 | * Returns an array of strings naming the private databases associated with |
| 1693 | * this Context's application package. |
| 1694 | * |
| 1695 | * @return Array of strings naming the private databases. |
| 1696 | * |
| 1697 | * @see #openOrCreateDatabase |
| 1698 | * @see #deleteDatabase |
| 1699 | */ |
| 1700 | public abstract String[] databaseList(); |
| 1701 | |
| 1702 | /** |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 1703 | * @deprecated Use {@link android.app.WallpaperManager#getDrawable |
Dianne Hackborn | 8cc6a50 | 2009-08-05 21:29:42 -0700 | [diff] [blame] | 1704 | * WallpaperManager.get()} instead. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1705 | */ |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame] | 1706 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1707 | public abstract Drawable getWallpaper(); |
| 1708 | |
| 1709 | /** |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 1710 | * @deprecated Use {@link android.app.WallpaperManager#peekDrawable |
Dianne Hackborn | 8cc6a50 | 2009-08-05 21:29:42 -0700 | [diff] [blame] | 1711 | * WallpaperManager.peek()} instead. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1712 | */ |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame] | 1713 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1714 | public abstract Drawable peekWallpaper(); |
| 1715 | |
| 1716 | /** |
Dianne Hackborn | 8cc6a50 | 2009-08-05 21:29:42 -0700 | [diff] [blame] | 1717 | * @deprecated Use {@link android.app.WallpaperManager#getDesiredMinimumWidth() |
| 1718 | * WallpaperManager.getDesiredMinimumWidth()} instead. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1719 | */ |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame] | 1720 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1721 | public abstract int getWallpaperDesiredMinimumWidth(); |
| 1722 | |
| 1723 | /** |
Dianne Hackborn | 8cc6a50 | 2009-08-05 21:29:42 -0700 | [diff] [blame] | 1724 | * @deprecated Use {@link android.app.WallpaperManager#getDesiredMinimumHeight() |
| 1725 | * WallpaperManager.getDesiredMinimumHeight()} instead. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1726 | */ |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame] | 1727 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1728 | public abstract int getWallpaperDesiredMinimumHeight(); |
| 1729 | |
| 1730 | /** |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 1731 | * @deprecated Use {@link android.app.WallpaperManager#setBitmap(Bitmap) |
Dianne Hackborn | 8cc6a50 | 2009-08-05 21:29:42 -0700 | [diff] [blame] | 1732 | * WallpaperManager.set()} instead. |
Nicolas Falliere | 9530e3a | 2012-06-18 17:21:06 -0700 | [diff] [blame] | 1733 | * <p>This method requires the caller to hold the permission |
| 1734 | * {@link android.Manifest.permission#SET_WALLPAPER}. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1735 | */ |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame] | 1736 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1737 | public abstract void setWallpaper(Bitmap bitmap) throws IOException; |
| 1738 | |
| 1739 | /** |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 1740 | * @deprecated Use {@link android.app.WallpaperManager#setStream(InputStream) |
Dianne Hackborn | 8cc6a50 | 2009-08-05 21:29:42 -0700 | [diff] [blame] | 1741 | * WallpaperManager.set()} instead. |
Nicolas Falliere | 9530e3a | 2012-06-18 17:21:06 -0700 | [diff] [blame] | 1742 | * <p>This method requires the caller to hold the permission |
| 1743 | * {@link android.Manifest.permission#SET_WALLPAPER}. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1744 | */ |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame] | 1745 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1746 | public abstract void setWallpaper(InputStream data) throws IOException; |
| 1747 | |
| 1748 | /** |
Dianne Hackborn | 8cc6a50 | 2009-08-05 21:29:42 -0700 | [diff] [blame] | 1749 | * @deprecated Use {@link android.app.WallpaperManager#clear |
| 1750 | * WallpaperManager.clear()} instead. |
Nicolas Falliere | 9530e3a | 2012-06-18 17:21:06 -0700 | [diff] [blame] | 1751 | * <p>This method requires the caller to hold the permission |
| 1752 | * {@link android.Manifest.permission#SET_WALLPAPER}. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1753 | */ |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame] | 1754 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1755 | public abstract void clearWallpaper() throws IOException; |
| 1756 | |
| 1757 | /** |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1758 | * Same as {@link #startActivity(Intent, Bundle)} with no options |
| 1759 | * specified. |
| 1760 | * |
| 1761 | * @param intent The description of the activity to start. |
| 1762 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1763 | * @throws ActivityNotFoundException |
Svet Ganov | 1ed0e55 | 2015-06-11 01:15:43 -0700 | [diff] [blame] | 1764 | *` |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1765 | * @see #startActivity(Intent, Bundle) |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1766 | * @see PackageManager#resolveActivity |
| 1767 | */ |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 1768 | public abstract void startActivity(@RequiresPermission Intent intent); |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1769 | |
| 1770 | /** |
Dianne Hackborn | 8832c18 | 2012-09-17 17:20:24 -0700 | [diff] [blame] | 1771 | * Version of {@link #startActivity(Intent)} that allows you to specify the |
| 1772 | * user the activity will be started for. This is not available to applications |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 1773 | * that are not pre-installed on the system image. |
Amith Yamasani | 8264408 | 2012-08-03 13:09:11 -0700 | [diff] [blame] | 1774 | * @param intent The description of the activity to start. |
Dianne Hackborn | 79af1dd | 2012-08-16 16:42:52 -0700 | [diff] [blame] | 1775 | * @param user The UserHandle of the user to start this activity for. |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1776 | * @throws ActivityNotFoundException |
Amith Yamasani | 8264408 | 2012-08-03 13:09:11 -0700 | [diff] [blame] | 1777 | * @hide |
| 1778 | */ |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 1779 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS_FULL) |
Philip P. Moltmann | 4e615e6 | 2018-08-28 14:57:49 -0700 | [diff] [blame] | 1780 | @SystemApi |
Adrian Roos | ebc927c | 2019-02-28 16:21:18 +0100 | [diff] [blame] | 1781 | public void startActivityAsUser(@RequiresPermission @NonNull Intent intent, |
| 1782 | @NonNull UserHandle user) { |
Amith Yamasani | 8264408 | 2012-08-03 13:09:11 -0700 | [diff] [blame] | 1783 | throw new RuntimeException("Not implemented. Must override in a subclass."); |
| 1784 | } |
| 1785 | |
| 1786 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1787 | * Launch a new activity. You will not receive any information about when |
| 1788 | * the activity exits. |
| 1789 | * |
| 1790 | * <p>Note that if this method is being called from outside of an |
| 1791 | * {@link android.app.Activity} Context, then the Intent must include |
| 1792 | * the {@link Intent#FLAG_ACTIVITY_NEW_TASK} launch flag. This is because, |
| 1793 | * without being started from an existing Activity, there is no existing |
| 1794 | * task in which to place the new activity and thus it needs to be placed |
| 1795 | * in its own separate task. |
| 1796 | * |
| 1797 | * <p>This method throws {@link ActivityNotFoundException} |
| 1798 | * if there was no Activity found to run the given Intent. |
| 1799 | * |
| 1800 | * @param intent The description of the activity to start. |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1801 | * @param options Additional options for how the Activity should be started. |
Dianne Hackborn | 7a2195c | 2012-03-19 17:38:00 -0700 | [diff] [blame] | 1802 | * May be null if there are no options. See {@link android.app.ActivityOptions} |
| 1803 | * for how to build the Bundle supplied here; there are no supported definitions |
| 1804 | * for building it manually. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1805 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1806 | * @throws ActivityNotFoundException |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1807 | * |
Scott Main | 60dd520 | 2012-06-23 00:01:22 -0700 | [diff] [blame] | 1808 | * @see #startActivity(Intent) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1809 | * @see PackageManager#resolveActivity |
| 1810 | */ |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 1811 | public abstract void startActivity(@RequiresPermission Intent intent, |
| 1812 | @Nullable Bundle options); |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1813 | |
| 1814 | /** |
Dianne Hackborn | 8832c18 | 2012-09-17 17:20:24 -0700 | [diff] [blame] | 1815 | * Version of {@link #startActivity(Intent, Bundle)} that allows you to specify the |
| 1816 | * user the activity will be started for. This is not available to applications |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 1817 | * that are not pre-installed on the system image. |
Amith Yamasani | 258848d | 2012-08-10 17:06:33 -0700 | [diff] [blame] | 1818 | * @param intent The description of the activity to start. |
| 1819 | * @param options Additional options for how the Activity should be started. |
| 1820 | * May be null if there are no options. See {@link android.app.ActivityOptions} |
| 1821 | * for how to build the Bundle supplied here; there are no supported definitions |
| 1822 | * for building it manually. |
Dianne Hackborn | 221ea89 | 2013-08-04 16:50:16 -0700 | [diff] [blame] | 1823 | * @param userId The UserHandle of the user to start this activity for. |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1824 | * @throws ActivityNotFoundException |
Amith Yamasani | 258848d | 2012-08-10 17:06:33 -0700 | [diff] [blame] | 1825 | * @hide |
| 1826 | */ |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 1827 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS_FULL) |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 1828 | @UnsupportedAppUsage |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 1829 | public void startActivityAsUser(@RequiresPermission Intent intent, @Nullable Bundle options, |
| 1830 | UserHandle userId) { |
Amith Yamasani | 258848d | 2012-08-10 17:06:33 -0700 | [diff] [blame] | 1831 | throw new RuntimeException("Not implemented. Must override in a subclass."); |
| 1832 | } |
| 1833 | |
| 1834 | /** |
Clara Bayarri | d5bf3ed | 2015-03-27 17:32:45 +0000 | [diff] [blame] | 1835 | * Version of {@link #startActivity(Intent, Bundle)} that returns a result to the caller. This |
| 1836 | * is only supported for Views and Fragments. |
| 1837 | * @param who The identifier for the calling element that will receive the result. |
| 1838 | * @param intent The intent to start. |
| 1839 | * @param requestCode The code that will be returned with onActivityResult() identifying this |
| 1840 | * request. |
| 1841 | * @param options Additional options for how the Activity should be started. |
| 1842 | * May be null if there are no options. See {@link android.app.ActivityOptions} |
| 1843 | * for how to build the Bundle supplied here; there are no supported definitions |
| 1844 | * for building it manually. |
| 1845 | * @hide |
| 1846 | */ |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 1847 | @UnsupportedAppUsage |
Clara Bayarri | d5bf3ed | 2015-03-27 17:32:45 +0000 | [diff] [blame] | 1848 | public void startActivityForResult( |
| 1849 | @NonNull String who, Intent intent, int requestCode, @Nullable Bundle options) { |
| 1850 | throw new RuntimeException("This method is only implemented for Activity-based Contexts. " |
| 1851 | + "Check canStartActivityForResult() before calling."); |
| 1852 | } |
| 1853 | |
| 1854 | /** |
| 1855 | * Identifies whether this Context instance will be able to process calls to |
| 1856 | * {@link #startActivityForResult(String, Intent, int, Bundle)}. |
| 1857 | * @hide |
| 1858 | */ |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 1859 | @UnsupportedAppUsage |
Clara Bayarri | d5bf3ed | 2015-03-27 17:32:45 +0000 | [diff] [blame] | 1860 | public boolean canStartActivityForResult() { |
| 1861 | return false; |
| 1862 | } |
| 1863 | |
| 1864 | /** |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1865 | * Same as {@link #startActivities(Intent[], Bundle)} with no options |
| 1866 | * specified. |
| 1867 | * |
| 1868 | * @param intents An array of Intents to be started. |
| 1869 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1870 | * @throws ActivityNotFoundException |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1871 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1872 | * @see #startActivities(Intent[], Bundle) |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1873 | * @see PackageManager#resolveActivity |
| 1874 | */ |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 1875 | public abstract void startActivities(@RequiresPermission Intent[] intents); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1876 | |
| 1877 | /** |
Dianne Hackborn | 621e17d | 2010-11-22 15:59:56 -0800 | [diff] [blame] | 1878 | * Launch multiple new activities. This is generally the same as calling |
| 1879 | * {@link #startActivity(Intent)} for the first Intent in the array, |
| 1880 | * that activity during its creation calling {@link #startActivity(Intent)} |
| 1881 | * for the second entry, etc. Note that unlike that approach, generally |
| 1882 | * none of the activities except the last in the array will be created |
| 1883 | * at this point, but rather will be created when the user first visits |
| 1884 | * them (due to pressing back from the activity on top). |
| 1885 | * |
| 1886 | * <p>This method throws {@link ActivityNotFoundException} |
| 1887 | * if there was no Activity found for <em>any</em> given Intent. In this |
| 1888 | * case the state of the activity stack is undefined (some Intents in the |
| 1889 | * list may be on it, some not), so you probably want to avoid such situations. |
| 1890 | * |
| 1891 | * @param intents An array of Intents to be started. |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1892 | * @param options Additional options for how the Activity should be started. |
Elliot Waite | 54de774 | 2017-01-11 15:30:35 -0800 | [diff] [blame] | 1893 | * See {@link android.content.Context#startActivity(Intent, Bundle)} |
Dianne Hackborn | 7a2195c | 2012-03-19 17:38:00 -0700 | [diff] [blame] | 1894 | * Context.startActivity(Intent, Bundle)} for more details. |
Dianne Hackborn | 621e17d | 2010-11-22 15:59:56 -0800 | [diff] [blame] | 1895 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1896 | * @throws ActivityNotFoundException |
Dianne Hackborn | 621e17d | 2010-11-22 15:59:56 -0800 | [diff] [blame] | 1897 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1898 | * @see #startActivities(Intent[]) |
Dianne Hackborn | 621e17d | 2010-11-22 15:59:56 -0800 | [diff] [blame] | 1899 | * @see PackageManager#resolveActivity |
| 1900 | */ |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 1901 | public abstract void startActivities(@RequiresPermission Intent[] intents, Bundle options); |
Dianne Hackborn | 621e17d | 2010-11-22 15:59:56 -0800 | [diff] [blame] | 1902 | |
| 1903 | /** |
Amith Yamasani | ea7e915 | 2012-09-24 16:11:18 -0700 | [diff] [blame] | 1904 | * @hide |
| 1905 | * Launch multiple new activities. This is generally the same as calling |
| 1906 | * {@link #startActivity(Intent)} for the first Intent in the array, |
| 1907 | * that activity during its creation calling {@link #startActivity(Intent)} |
| 1908 | * for the second entry, etc. Note that unlike that approach, generally |
| 1909 | * none of the activities except the last in the array will be created |
| 1910 | * at this point, but rather will be created when the user first visits |
| 1911 | * them (due to pressing back from the activity on top). |
| 1912 | * |
| 1913 | * <p>This method throws {@link ActivityNotFoundException} |
| 1914 | * if there was no Activity found for <em>any</em> given Intent. In this |
| 1915 | * case the state of the activity stack is undefined (some Intents in the |
| 1916 | * list may be on it, some not), so you probably want to avoid such situations. |
| 1917 | * |
| 1918 | * @param intents An array of Intents to be started. |
| 1919 | * @param options Additional options for how the Activity should be started. |
| 1920 | * @param userHandle The user for whom to launch the activities |
Elliot Waite | 54de774 | 2017-01-11 15:30:35 -0800 | [diff] [blame] | 1921 | * See {@link android.content.Context#startActivity(Intent, Bundle)} |
Amith Yamasani | ea7e915 | 2012-09-24 16:11:18 -0700 | [diff] [blame] | 1922 | * Context.startActivity(Intent, Bundle)} for more details. |
| 1923 | * |
Selim Cinek | 7fa385a | 2018-01-24 08:35:28 -0800 | [diff] [blame] | 1924 | * @return The corresponding flag {@link ActivityManager#START_CANCELED}, |
| 1925 | * {@link ActivityManager#START_SUCCESS} etc. indicating whether the launch was |
| 1926 | * successful. |
| 1927 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1928 | * @throws ActivityNotFoundException |
Amith Yamasani | ea7e915 | 2012-09-24 16:11:18 -0700 | [diff] [blame] | 1929 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1930 | * @see #startActivities(Intent[]) |
Amith Yamasani | ea7e915 | 2012-09-24 16:11:18 -0700 | [diff] [blame] | 1931 | * @see PackageManager#resolveActivity |
| 1932 | */ |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 1933 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS_FULL) |
Selim Cinek | 7fa385a | 2018-01-24 08:35:28 -0800 | [diff] [blame] | 1934 | public int startActivitiesAsUser(Intent[] intents, Bundle options, UserHandle userHandle) { |
Amith Yamasani | ea7e915 | 2012-09-24 16:11:18 -0700 | [diff] [blame] | 1935 | throw new RuntimeException("Not implemented. Must override in a subclass."); |
| 1936 | } |
| 1937 | |
| 1938 | /** |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1939 | * Same as {@link #startIntentSender(IntentSender, Intent, int, int, int, Bundle)} |
| 1940 | * with no options specified. |
| 1941 | * |
| 1942 | * @param intent The IntentSender to launch. |
| 1943 | * @param fillInIntent If non-null, this will be provided as the |
| 1944 | * intent parameter to {@link IntentSender#sendIntent}. |
| 1945 | * @param flagsMask Intent flags in the original IntentSender that you |
| 1946 | * would like to change. |
| 1947 | * @param flagsValues Desired values for any bits set in |
| 1948 | * <var>flagsMask</var> |
| 1949 | * @param extraFlags Always set to 0. |
| 1950 | * |
| 1951 | * @see #startActivity(Intent) |
| 1952 | * @see #startIntentSender(IntentSender, Intent, int, int, int, Bundle) |
| 1953 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 1954 | public abstract void startIntentSender(IntentSender intent, @Nullable Intent fillInIntent, |
| 1955 | @Intent.MutableFlags int flagsMask, @Intent.MutableFlags int flagsValues, |
| 1956 | int extraFlags) throws IntentSender.SendIntentException; |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1957 | |
| 1958 | /** |
| 1959 | * Like {@link #startActivity(Intent, Bundle)}, but taking a IntentSender |
Dianne Hackborn | fa82f22 | 2009-09-17 15:14:12 -0700 | [diff] [blame] | 1960 | * to start. If the IntentSender is for an activity, that activity will be started |
Dianne Hackborn | ae22c05 | 2009-09-17 18:46:22 -0700 | [diff] [blame] | 1961 | * as if you had called the regular {@link #startActivity(Intent)} |
Dianne Hackborn | fa82f22 | 2009-09-17 15:14:12 -0700 | [diff] [blame] | 1962 | * here; otherwise, its associated action will be executed (such as |
| 1963 | * sending a broadcast) as if you had called |
| 1964 | * {@link IntentSender#sendIntent IntentSender.sendIntent} on it. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 1965 | * |
Dianne Hackborn | fa82f22 | 2009-09-17 15:14:12 -0700 | [diff] [blame] | 1966 | * @param intent The IntentSender to launch. |
| 1967 | * @param fillInIntent If non-null, this will be provided as the |
| 1968 | * intent parameter to {@link IntentSender#sendIntent}. |
| 1969 | * @param flagsMask Intent flags in the original IntentSender that you |
| 1970 | * would like to change. |
| 1971 | * @param flagsValues Desired values for any bits set in |
| 1972 | * <var>flagsMask</var> |
| 1973 | * @param extraFlags Always set to 0. |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1974 | * @param options Additional options for how the Activity should be started. |
Elliot Waite | 54de774 | 2017-01-11 15:30:35 -0800 | [diff] [blame] | 1975 | * See {@link android.content.Context#startActivity(Intent, Bundle)} |
Dianne Hackborn | 7a2195c | 2012-03-19 17:38:00 -0700 | [diff] [blame] | 1976 | * Context.startActivity(Intent, Bundle)} for more details. If options |
| 1977 | * have also been supplied by the IntentSender, options given here will |
| 1978 | * override any that conflict with those given by the IntentSender. |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1979 | * |
| 1980 | * @see #startActivity(Intent, Bundle) |
| 1981 | * @see #startIntentSender(IntentSender, Intent, int, int, int) |
Dianne Hackborn | fa82f22 | 2009-09-17 15:14:12 -0700 | [diff] [blame] | 1982 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 1983 | public abstract void startIntentSender(IntentSender intent, @Nullable Intent fillInIntent, |
| 1984 | @Intent.MutableFlags int flagsMask, @Intent.MutableFlags int flagsValues, |
| 1985 | int extraFlags, @Nullable Bundle options) throws IntentSender.SendIntentException; |
Dianne Hackborn | fa82f22 | 2009-09-17 15:14:12 -0700 | [diff] [blame] | 1986 | |
| 1987 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1988 | * Broadcast the given intent to all interested BroadcastReceivers. This |
| 1989 | * call is asynchronous; it returns immediately, and you will continue |
| 1990 | * executing while the receivers are run. No results are propagated from |
| 1991 | * receivers and receivers can not abort the broadcast. If you want |
| 1992 | * to allow receivers to propagate results or abort the broadcast, you must |
| 1993 | * send an ordered broadcast using |
| 1994 | * {@link #sendOrderedBroadcast(Intent, String)}. |
| 1995 | * |
| 1996 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 1997 | * |
| 1998 | * @param intent The Intent to broadcast; all receivers matching this |
| 1999 | * Intent will receive the broadcast. |
| 2000 | * |
| 2001 | * @see android.content.BroadcastReceiver |
| 2002 | * @see #registerReceiver |
| 2003 | * @see #sendBroadcast(Intent, String) |
| 2004 | * @see #sendOrderedBroadcast(Intent, String) |
| 2005 | * @see #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle) |
| 2006 | */ |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 2007 | public abstract void sendBroadcast(@RequiresPermission Intent intent); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2008 | |
| 2009 | /** |
| 2010 | * Broadcast the given intent to all interested BroadcastReceivers, allowing |
| 2011 | * an optional required permission to be enforced. This |
| 2012 | * call is asynchronous; it returns immediately, and you will continue |
| 2013 | * executing while the receivers are run. No results are propagated from |
| 2014 | * receivers and receivers can not abort the broadcast. If you want |
| 2015 | * to allow receivers to propagate results or abort the broadcast, you must |
| 2016 | * send an ordered broadcast using |
| 2017 | * {@link #sendOrderedBroadcast(Intent, String)}. |
| 2018 | * |
| 2019 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 2020 | * |
| 2021 | * @param intent The Intent to broadcast; all receivers matching this |
| 2022 | * Intent will receive the broadcast. |
Brad Fitzpatrick | 26b71be | 2010-12-07 14:52:58 -0800 | [diff] [blame] | 2023 | * @param receiverPermission (optional) String naming a permission that |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2024 | * a receiver must hold in order to receive your broadcast. |
| 2025 | * If null, no permission is required. |
| 2026 | * |
| 2027 | * @see android.content.BroadcastReceiver |
| 2028 | * @see #registerReceiver |
| 2029 | * @see #sendBroadcast(Intent) |
| 2030 | * @see #sendOrderedBroadcast(Intent, String) |
| 2031 | * @see #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle) |
| 2032 | */ |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 2033 | public abstract void sendBroadcast(@RequiresPermission Intent intent, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2034 | @Nullable String receiverPermission); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2035 | |
Fyodor Kupolov | d4fd8c7 | 2015-07-13 19:19:25 -0700 | [diff] [blame] | 2036 | |
| 2037 | /** |
| 2038 | * Broadcast the given intent to all interested BroadcastReceivers, allowing |
| 2039 | * an array of required permissions to be enforced. This call is asynchronous; it returns |
| 2040 | * immediately, and you will continue executing while the receivers are run. No results are |
| 2041 | * propagated from receivers and receivers can not abort the broadcast. If you want to allow |
| 2042 | * receivers to propagate results or abort the broadcast, you must send an ordered broadcast |
| 2043 | * using {@link #sendOrderedBroadcast(Intent, String)}. |
| 2044 | * |
| 2045 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 2046 | * |
| 2047 | * @param intent The Intent to broadcast; all receivers matching this |
| 2048 | * Intent will receive the broadcast. |
| 2049 | * @param receiverPermissions Array of names of permissions that a receiver must hold |
| 2050 | * in order to receive your broadcast. |
| 2051 | * If null or empty, no permissions are required. |
| 2052 | * |
| 2053 | * @see android.content.BroadcastReceiver |
| 2054 | * @see #registerReceiver |
| 2055 | * @see #sendBroadcast(Intent) |
| 2056 | * @see #sendOrderedBroadcast(Intent, String) |
| 2057 | * @see #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle) |
| 2058 | * @hide |
| 2059 | */ |
| 2060 | public abstract void sendBroadcastMultiplePermissions(Intent intent, |
| 2061 | String[] receiverPermissions); |
| 2062 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2063 | /** |
Dianne Hackborn | a750a63 | 2015-06-16 17:18:23 -0700 | [diff] [blame] | 2064 | * Broadcast the given intent to all interested BroadcastReceivers, allowing |
Tyler Gunn | f955e56 | 2018-04-26 14:43:31 -0700 | [diff] [blame] | 2065 | * an array of required permissions to be enforced. This call is asynchronous; it returns |
| 2066 | * immediately, and you will continue executing while the receivers are run. No results are |
| 2067 | * propagated from receivers and receivers can not abort the broadcast. If you want to allow |
| 2068 | * receivers to propagate results or abort the broadcast, you must send an ordered broadcast |
| 2069 | * using {@link #sendOrderedBroadcast(Intent, String)}. |
| 2070 | * |
| 2071 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 2072 | * |
| 2073 | * @param intent The Intent to broadcast; all receivers matching this |
| 2074 | * Intent will receive the broadcast. |
| 2075 | * @param user The user to send the broadcast to. |
| 2076 | * @param receiverPermissions Array of names of permissions that a receiver must hold |
| 2077 | * in order to receive your broadcast. |
| 2078 | * If null or empty, no permissions are required. |
| 2079 | * |
| 2080 | * @see android.content.BroadcastReceiver |
| 2081 | * @see #registerReceiver |
| 2082 | * @see #sendBroadcast(Intent) |
| 2083 | * @see #sendOrderedBroadcast(Intent, String) |
| 2084 | * @see #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle) |
| 2085 | * @hide |
| 2086 | */ |
| 2087 | public abstract void sendBroadcastAsUserMultiplePermissions(Intent intent, UserHandle user, |
| 2088 | String[] receiverPermissions); |
| 2089 | |
| 2090 | /** |
| 2091 | * Broadcast the given intent to all interested BroadcastReceivers, allowing |
Dianne Hackborn | a750a63 | 2015-06-16 17:18:23 -0700 | [diff] [blame] | 2092 | * an optional required permission to be enforced. This |
| 2093 | * call is asynchronous; it returns immediately, and you will continue |
| 2094 | * executing while the receivers are run. No results are propagated from |
| 2095 | * receivers and receivers can not abort the broadcast. If you want |
| 2096 | * to allow receivers to propagate results or abort the broadcast, you must |
| 2097 | * send an ordered broadcast using |
| 2098 | * {@link #sendOrderedBroadcast(Intent, String)}. |
| 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 permission that |
| 2105 | * a receiver must hold in order to receive your broadcast. |
| 2106 | * If null, no permission is required. |
| 2107 | * @param options (optional) Additional sending options, generated from a |
| 2108 | * {@link android.app.BroadcastOptions}. |
| 2109 | * |
| 2110 | * @see android.content.BroadcastReceiver |
| 2111 | * @see #registerReceiver |
| 2112 | * @see #sendBroadcast(Intent) |
| 2113 | * @see #sendOrderedBroadcast(Intent, String) |
| 2114 | * @see #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle) |
| 2115 | * @hide |
| 2116 | */ |
| 2117 | @SystemApi |
| 2118 | public abstract void sendBroadcast(Intent intent, |
| 2119 | @Nullable String receiverPermission, |
| 2120 | @Nullable Bundle options); |
| 2121 | |
| 2122 | /** |
Dianne Hackborn | f51f612 | 2013-02-04 18:23:34 -0800 | [diff] [blame] | 2123 | * Like {@link #sendBroadcast(Intent, String)}, but also allows specification |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2124 | * of an associated app op as per {@link android.app.AppOpsManager}. |
Dianne Hackborn | f51f612 | 2013-02-04 18:23:34 -0800 | [diff] [blame] | 2125 | * @hide |
| 2126 | */ |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 2127 | @UnsupportedAppUsage |
Dianne Hackborn | f51f612 | 2013-02-04 18:23:34 -0800 | [diff] [blame] | 2128 | public abstract void sendBroadcast(Intent intent, |
| 2129 | String receiverPermission, int appOp); |
| 2130 | |
| 2131 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2132 | * Broadcast the given intent to all interested BroadcastReceivers, delivering |
| 2133 | * them one at a time to allow more preferred receivers to consume the |
| 2134 | * broadcast before it is delivered to less preferred receivers. This |
| 2135 | * call is asynchronous; it returns immediately, and you will continue |
| 2136 | * executing while the receivers are run. |
| 2137 | * |
| 2138 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 2139 | * |
| 2140 | * @param intent The Intent to broadcast; all receivers matching this |
| 2141 | * Intent will receive the broadcast. |
| 2142 | * @param receiverPermission (optional) String naming a permissions that |
| 2143 | * a receiver must hold in order to receive your broadcast. |
| 2144 | * If null, no permission is required. |
| 2145 | * |
| 2146 | * @see android.content.BroadcastReceiver |
| 2147 | * @see #registerReceiver |
| 2148 | * @see #sendBroadcast(Intent) |
| 2149 | * @see #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle) |
| 2150 | */ |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 2151 | public abstract void sendOrderedBroadcast(@RequiresPermission Intent intent, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2152 | @Nullable String receiverPermission); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2153 | |
| 2154 | /** |
| 2155 | * Version of {@link #sendBroadcast(Intent)} that allows you to |
| 2156 | * receive data back from the broadcast. This is accomplished by |
| 2157 | * supplying your own BroadcastReceiver when calling, which will be |
| 2158 | * treated as a final receiver at the end of the broadcast -- its |
| 2159 | * {@link BroadcastReceiver#onReceive} method will be called with |
Dianne Hackborn | efa199f | 2009-09-19 12:03:15 -0700 | [diff] [blame] | 2160 | * the result values collected from the other receivers. The broadcast will |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2161 | * be serialized in the same way as calling |
| 2162 | * {@link #sendOrderedBroadcast(Intent, String)}. |
| 2163 | * |
| 2164 | * <p>Like {@link #sendBroadcast(Intent)}, this method is |
| 2165 | * asynchronous; it will return before |
| 2166 | * resultReceiver.onReceive() is called. |
| 2167 | * |
| 2168 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 2169 | * |
| 2170 | * @param intent The Intent to broadcast; all receivers matching this |
| 2171 | * Intent will receive the broadcast. |
| 2172 | * @param receiverPermission String naming a permissions that |
| 2173 | * a receiver must hold in order to receive your broadcast. |
| 2174 | * If null, no permission is required. |
| 2175 | * @param resultReceiver Your own BroadcastReceiver to treat as the final |
| 2176 | * receiver of the broadcast. |
| 2177 | * @param scheduler A custom Handler with which to schedule the |
| 2178 | * resultReceiver callback; if null it will be |
| 2179 | * scheduled in the Context's main thread. |
| 2180 | * @param initialCode An initial value for the result code. Often |
| 2181 | * Activity.RESULT_OK. |
| 2182 | * @param initialData An initial value for the result data. Often |
| 2183 | * null. |
| 2184 | * @param initialExtras An initial value for the result extras. Often |
| 2185 | * null. |
| 2186 | * |
| 2187 | * @see #sendBroadcast(Intent) |
| 2188 | * @see #sendBroadcast(Intent, String) |
| 2189 | * @see #sendOrderedBroadcast(Intent, String) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2190 | * @see android.content.BroadcastReceiver |
| 2191 | * @see #registerReceiver |
| 2192 | * @see android.app.Activity#RESULT_OK |
| 2193 | */ |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 2194 | public abstract void sendOrderedBroadcast(@RequiresPermission @NonNull Intent intent, |
Dianne Hackborn | a750a63 | 2015-06-16 17:18:23 -0700 | [diff] [blame] | 2195 | @Nullable String receiverPermission, @Nullable BroadcastReceiver resultReceiver, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2196 | @Nullable Handler scheduler, int initialCode, @Nullable String initialData, |
| 2197 | @Nullable Bundle initialExtras); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2198 | |
| 2199 | /** |
Dianne Hackborn | a750a63 | 2015-06-16 17:18:23 -0700 | [diff] [blame] | 2200 | * Version of {@link #sendBroadcast(Intent)} that allows you to |
| 2201 | * receive data back from the broadcast. This is accomplished by |
| 2202 | * supplying your own BroadcastReceiver when calling, which will be |
| 2203 | * treated as a final receiver at the end of the broadcast -- its |
| 2204 | * {@link BroadcastReceiver#onReceive} method will be called with |
| 2205 | * the result values collected from the other receivers. The broadcast will |
| 2206 | * be serialized in the same way as calling |
| 2207 | * {@link #sendOrderedBroadcast(Intent, String)}. |
| 2208 | * |
| 2209 | * <p>Like {@link #sendBroadcast(Intent)}, this method is |
| 2210 | * asynchronous; it will return before |
| 2211 | * resultReceiver.onReceive() is called. |
| 2212 | * |
| 2213 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 2214 | * |
| 2215 | * |
| 2216 | * @param intent The Intent to broadcast; all receivers matching this |
| 2217 | * Intent will receive the broadcast. |
| 2218 | * @param receiverPermission String naming a permissions that |
| 2219 | * a receiver must hold in order to receive your broadcast. |
| 2220 | * If null, no permission is required. |
| 2221 | * @param options (optional) Additional sending options, generated from a |
| 2222 | * {@link android.app.BroadcastOptions}. |
| 2223 | * @param resultReceiver Your own BroadcastReceiver to treat as the final |
| 2224 | * receiver of the broadcast. |
| 2225 | * @param scheduler A custom Handler with which to schedule the |
| 2226 | * resultReceiver callback; if null it will be |
| 2227 | * scheduled in the Context's main thread. |
| 2228 | * @param initialCode An initial value for the result code. Often |
| 2229 | * Activity.RESULT_OK. |
| 2230 | * @param initialData An initial value for the result data. Often |
| 2231 | * null. |
| 2232 | * @param initialExtras An initial value for the result extras. Often |
| 2233 | * null. |
| 2234 | * @see #sendBroadcast(Intent) |
| 2235 | * @see #sendBroadcast(Intent, String) |
| 2236 | * @see #sendOrderedBroadcast(Intent, String) |
| 2237 | * @see android.content.BroadcastReceiver |
| 2238 | * @see #registerReceiver |
| 2239 | * @see android.app.Activity#RESULT_OK |
| 2240 | * @hide |
| 2241 | */ |
| 2242 | @SystemApi |
| 2243 | public abstract void sendOrderedBroadcast(@NonNull Intent intent, |
| 2244 | @Nullable String receiverPermission, @Nullable Bundle options, |
| 2245 | @Nullable BroadcastReceiver resultReceiver, @Nullable Handler scheduler, |
| 2246 | int initialCode, @Nullable String initialData, @Nullable Bundle initialExtras); |
| 2247 | |
| 2248 | /** |
Dianne Hackborn | f51f612 | 2013-02-04 18:23:34 -0800 | [diff] [blame] | 2249 | * Like {@link #sendOrderedBroadcast(Intent, String, BroadcastReceiver, android.os.Handler, |
| 2250 | * int, String, android.os.Bundle)}, but also allows specification |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2251 | * of an associated app op as per {@link android.app.AppOpsManager}. |
Dianne Hackborn | f51f612 | 2013-02-04 18:23:34 -0800 | [diff] [blame] | 2252 | * @hide |
| 2253 | */ |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 2254 | @UnsupportedAppUsage |
Dianne Hackborn | f51f612 | 2013-02-04 18:23:34 -0800 | [diff] [blame] | 2255 | public abstract void sendOrderedBroadcast(Intent intent, |
| 2256 | String receiverPermission, int appOp, BroadcastReceiver resultReceiver, |
| 2257 | Handler scheduler, int initialCode, String initialData, |
| 2258 | Bundle initialExtras); |
| 2259 | |
| 2260 | /** |
Dianne Hackborn | 8832c18 | 2012-09-17 17:20:24 -0700 | [diff] [blame] | 2261 | * Version of {@link #sendBroadcast(Intent)} that allows you to specify the |
| 2262 | * user the broadcast will be sent to. This is not available to applications |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2263 | * that are not pre-installed on the system image. |
Dianne Hackborn | 7d19e02 | 2012-08-07 19:12:33 -0700 | [diff] [blame] | 2264 | * @param intent The intent to broadcast |
Dianne Hackborn | 79af1dd | 2012-08-16 16:42:52 -0700 | [diff] [blame] | 2265 | * @param user UserHandle to send the intent to. |
Dianne Hackborn | 7d19e02 | 2012-08-07 19:12:33 -0700 | [diff] [blame] | 2266 | * @see #sendBroadcast(Intent) |
| 2267 | */ |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2268 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 2269 | public abstract void sendBroadcastAsUser(@RequiresPermission Intent intent, |
| 2270 | UserHandle user); |
Dianne Hackborn | 7d19e02 | 2012-08-07 19:12:33 -0700 | [diff] [blame] | 2271 | |
| 2272 | /** |
Dianne Hackborn | 8832c18 | 2012-09-17 17:20:24 -0700 | [diff] [blame] | 2273 | * Version of {@link #sendBroadcast(Intent, String)} that allows you to specify the |
| 2274 | * user the broadcast will be sent to. This is not available to applications |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2275 | * that are not pre-installed on the system image. |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2276 | * |
| 2277 | * @param intent The Intent to broadcast; all receivers matching this |
| 2278 | * Intent will receive the broadcast. |
| 2279 | * @param user UserHandle to send the intent to. |
| 2280 | * @param receiverPermission (optional) String naming a permission that |
| 2281 | * a receiver must hold in order to receive your broadcast. |
| 2282 | * If null, no permission is required. |
| 2283 | * |
| 2284 | * @see #sendBroadcast(Intent, String) |
| 2285 | */ |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2286 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 2287 | public abstract void sendBroadcastAsUser(@RequiresPermission Intent intent, |
| 2288 | UserHandle user, @Nullable String receiverPermission); |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2289 | |
Chad Brubaker | 52c8edc | 2016-07-25 14:30:26 -0700 | [diff] [blame] | 2290 | /** |
| 2291 | * Version of {@link #sendBroadcast(Intent, String, Bundle)} that allows you to specify the |
| 2292 | * user the broadcast will be sent to. This is not available to applications |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2293 | * that are not pre-installed on the system image. |
Chad Brubaker | 52c8edc | 2016-07-25 14:30:26 -0700 | [diff] [blame] | 2294 | * |
| 2295 | * @param intent The Intent to broadcast; all receivers matching this |
| 2296 | * Intent will receive the broadcast. |
| 2297 | * @param user UserHandle to send the intent to. |
| 2298 | * @param receiverPermission (optional) String naming a permission that |
| 2299 | * a receiver must hold in order to receive your broadcast. |
| 2300 | * If null, no permission is required. |
| 2301 | * @param options (optional) Additional sending options, generated from a |
| 2302 | * {@link android.app.BroadcastOptions}. |
| 2303 | * |
| 2304 | * @see #sendBroadcast(Intent, String, Bundle) |
| 2305 | * @hide |
| 2306 | */ |
| 2307 | @SystemApi |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2308 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) |
Chad Brubaker | 52c8edc | 2016-07-25 14:30:26 -0700 | [diff] [blame] | 2309 | public abstract void sendBroadcastAsUser(@RequiresPermission Intent intent, |
| 2310 | UserHandle user, @Nullable String receiverPermission, @Nullable Bundle options); |
Svet Ganov | 16a1689 | 2015-04-16 10:32:04 -0700 | [diff] [blame] | 2311 | |
| 2312 | /** |
| 2313 | * Version of {@link #sendBroadcast(Intent, String)} that allows you to specify the |
| 2314 | * user the broadcast will be sent to. This is not available to applications |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2315 | * that are not pre-installed on the system image. |
Svet Ganov | 16a1689 | 2015-04-16 10:32:04 -0700 | [diff] [blame] | 2316 | * |
| 2317 | * @param intent The Intent to broadcast; all receivers matching this |
| 2318 | * Intent will receive the broadcast. |
| 2319 | * @param user UserHandle to send the intent to. |
| 2320 | * @param receiverPermission (optional) String naming a permission that |
| 2321 | * a receiver must hold in order to receive your broadcast. |
| 2322 | * If null, no permission is required. |
| 2323 | * @param appOp The app op associated with the broadcast. |
| 2324 | * |
| 2325 | * @see #sendBroadcast(Intent, String) |
| 2326 | * |
| 2327 | * @hide |
| 2328 | */ |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2329 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 2330 | @UnsupportedAppUsage |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 2331 | public abstract void sendBroadcastAsUser(@RequiresPermission Intent intent, |
| 2332 | UserHandle user, @Nullable String receiverPermission, int appOp); |
Svet Ganov | 16a1689 | 2015-04-16 10:32:04 -0700 | [diff] [blame] | 2333 | |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2334 | /** |
Dianne Hackborn | 8832c18 | 2012-09-17 17:20:24 -0700 | [diff] [blame] | 2335 | * Version of |
| 2336 | * {@link #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle)} |
| 2337 | * that allows you to specify the |
| 2338 | * user the broadcast will be sent to. This is not available to applications |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2339 | * that are not pre-installed on the system image. |
Dianne Hackborn | 7d19e02 | 2012-08-07 19:12:33 -0700 | [diff] [blame] | 2340 | * |
| 2341 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 2342 | * |
| 2343 | * @param intent The Intent to broadcast; all receivers matching this |
| 2344 | * Intent will receive the broadcast. |
Dianne Hackborn | 79af1dd | 2012-08-16 16:42:52 -0700 | [diff] [blame] | 2345 | * @param user UserHandle to send the intent to. |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2346 | * @param receiverPermission String naming a permissions that |
| 2347 | * a receiver must hold in order to receive your broadcast. |
| 2348 | * If null, no permission is required. |
Dianne Hackborn | 7d19e02 | 2012-08-07 19:12:33 -0700 | [diff] [blame] | 2349 | * @param resultReceiver Your own BroadcastReceiver to treat as the final |
| 2350 | * receiver of the broadcast. |
| 2351 | * @param scheduler A custom Handler with which to schedule the |
| 2352 | * resultReceiver callback; if null it will be |
| 2353 | * scheduled in the Context's main thread. |
| 2354 | * @param initialCode An initial value for the result code. Often |
| 2355 | * Activity.RESULT_OK. |
| 2356 | * @param initialData An initial value for the result data. Often |
| 2357 | * null. |
| 2358 | * @param initialExtras An initial value for the result extras. Often |
| 2359 | * null. |
| 2360 | * |
| 2361 | * @see #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle) |
| 2362 | */ |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2363 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 2364 | public abstract void sendOrderedBroadcastAsUser(@RequiresPermission Intent intent, |
| 2365 | UserHandle user, @Nullable String receiverPermission, BroadcastReceiver resultReceiver, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2366 | @Nullable Handler scheduler, int initialCode, @Nullable String initialData, |
| 2367 | @Nullable Bundle initialExtras); |
Dianne Hackborn | 7d19e02 | 2012-08-07 19:12:33 -0700 | [diff] [blame] | 2368 | |
| 2369 | /** |
Amith Yamasani | 3cf7572 | 2014-05-16 12:37:29 -0700 | [diff] [blame] | 2370 | * Similar to above but takes an appOp as well, to enforce restrictions. |
| 2371 | * @see #sendOrderedBroadcastAsUser(Intent, UserHandle, String, |
| 2372 | * BroadcastReceiver, Handler, int, String, Bundle) |
| 2373 | * @hide |
| 2374 | */ |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2375 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 2376 | @UnsupportedAppUsage |
Amith Yamasani | 3cf7572 | 2014-05-16 12:37:29 -0700 | [diff] [blame] | 2377 | public abstract void sendOrderedBroadcastAsUser(Intent intent, UserHandle user, |
| 2378 | @Nullable String receiverPermission, int appOp, BroadcastReceiver resultReceiver, |
| 2379 | @Nullable Handler scheduler, int initialCode, @Nullable String initialData, |
| 2380 | @Nullable Bundle initialExtras); |
| 2381 | |
| 2382 | /** |
Dianne Hackborn | fd854ee | 2015-07-13 18:00:37 -0700 | [diff] [blame] | 2383 | * Similar to above but takes an appOp as well, to enforce restrictions, and an options Bundle. |
| 2384 | * @see #sendOrderedBroadcastAsUser(Intent, UserHandle, String, |
| 2385 | * BroadcastReceiver, Handler, int, String, Bundle) |
| 2386 | * @hide |
| 2387 | */ |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2388 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 2389 | @UnsupportedAppUsage |
Dianne Hackborn | fd854ee | 2015-07-13 18:00:37 -0700 | [diff] [blame] | 2390 | public abstract void sendOrderedBroadcastAsUser(Intent intent, UserHandle user, |
| 2391 | @Nullable String receiverPermission, int appOp, @Nullable Bundle options, |
| 2392 | BroadcastReceiver resultReceiver, @Nullable Handler scheduler, int initialCode, |
| 2393 | @Nullable String initialData, @Nullable Bundle initialExtras); |
| 2394 | |
| 2395 | /** |
Jordan Liu | a32e6fc | 2019-10-29 10:33:55 -0700 | [diff] [blame] | 2396 | * Version of |
| 2397 | * {@link #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, |
| 2398 | * Bundle)} that allows you to specify the App Op to enforce restrictions on which receivers |
| 2399 | * the broadcast will be sent to. |
| 2400 | * |
| 2401 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 2402 | * |
| 2403 | * @param intent The Intent to broadcast; all receivers matching this |
| 2404 | * Intent will receive the broadcast. |
| 2405 | * @param receiverPermission String naming a permissions that |
| 2406 | * a receiver must hold in order to receive your broadcast. |
| 2407 | * If null, no permission is required. |
| 2408 | * @param receiverAppOp The app op associated with the broadcast. If null, no appOp is |
| 2409 | * required. If both receiverAppOp and receiverPermission are non-null, |
| 2410 | * a receiver must have both of them to |
| 2411 | * receive the broadcast |
| 2412 | * @param resultReceiver Your own BroadcastReceiver to treat as the final |
| 2413 | * receiver of the broadcast. |
| 2414 | * @param scheduler A custom Handler with which to schedule the |
| 2415 | * resultReceiver callback; if null it will be |
| 2416 | * scheduled in the Context's main thread. |
| 2417 | * @param initialCode An initial value for the result code. Often |
| 2418 | * Activity.RESULT_OK. |
| 2419 | * @param initialData An initial value for the result data. Often |
| 2420 | * null. |
| 2421 | * @param initialExtras An initial value for the result extras. Often |
| 2422 | * null. |
| 2423 | * |
| 2424 | * @see #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle) |
| 2425 | */ |
| 2426 | public void sendOrderedBroadcast(@RequiresPermission @NonNull Intent intent, |
| 2427 | @Nullable String receiverPermission, @Nullable String receiverAppOp, |
| 2428 | @Nullable BroadcastReceiver resultReceiver, @Nullable Handler scheduler, |
| 2429 | int initialCode, @Nullable String initialData, @Nullable Bundle initialExtras) { |
| 2430 | throw new RuntimeException("Not implemented. Must override in a subclass."); |
| 2431 | } |
| 2432 | |
| 2433 | /** |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2434 | * <p>Perform a {@link #sendBroadcast(Intent)} that is "sticky," meaning the |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2435 | * Intent you are sending stays around after the broadcast is complete, |
| 2436 | * so that others can quickly retrieve that data through the return |
| 2437 | * value of {@link #registerReceiver(BroadcastReceiver, IntentFilter)}. In |
| 2438 | * all other ways, this behaves the same as |
| 2439 | * {@link #sendBroadcast(Intent)}. |
| 2440 | * |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2441 | * @deprecated Sticky broadcasts should not be used. They provide no security (anyone |
| 2442 | * can access them), no protection (anyone can modify them), and many other problems. |
| 2443 | * The recommended pattern is to use a non-sticky broadcast to report that <em>something</em> |
| 2444 | * has changed, with another mechanism for apps to retrieve the current value whenever |
| 2445 | * desired. |
| 2446 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2447 | * @param intent The Intent to broadcast; all receivers matching this |
| 2448 | * Intent will receive the broadcast, and the Intent will be held to |
| 2449 | * be re-broadcast to future receivers. |
| 2450 | * |
| 2451 | * @see #sendBroadcast(Intent) |
Dianne Hackborn | efa199f | 2009-09-19 12:03:15 -0700 | [diff] [blame] | 2452 | * @see #sendStickyOrderedBroadcast(Intent, BroadcastReceiver, Handler, int, String, Bundle) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2453 | */ |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2454 | @Deprecated |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 2455 | @RequiresPermission(android.Manifest.permission.BROADCAST_STICKY) |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 2456 | public abstract void sendStickyBroadcast(@RequiresPermission Intent intent); |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 2457 | |
Dianne Hackborn | efa199f | 2009-09-19 12:03:15 -0700 | [diff] [blame] | 2458 | /** |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2459 | * <p>Version of {@link #sendStickyBroadcast} that allows you to |
Dianne Hackborn | efa199f | 2009-09-19 12:03:15 -0700 | [diff] [blame] | 2460 | * receive data back from the broadcast. This is accomplished by |
| 2461 | * supplying your own BroadcastReceiver when calling, which will be |
| 2462 | * treated as a final receiver at the end of the broadcast -- its |
| 2463 | * {@link BroadcastReceiver#onReceive} method will be called with |
| 2464 | * the result values collected from the other receivers. The broadcast will |
| 2465 | * be serialized in the same way as calling |
| 2466 | * {@link #sendOrderedBroadcast(Intent, String)}. |
| 2467 | * |
| 2468 | * <p>Like {@link #sendBroadcast(Intent)}, this method is |
| 2469 | * asynchronous; it will return before |
| 2470 | * resultReceiver.onReceive() is called. Note that the sticky data |
| 2471 | * stored is only the data you initially supply to the broadcast, not |
| 2472 | * the result of any changes made by the receivers. |
| 2473 | * |
| 2474 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 2475 | * |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2476 | * @deprecated Sticky broadcasts should not be used. They provide no security (anyone |
| 2477 | * can access them), no protection (anyone can modify them), and many other problems. |
| 2478 | * The recommended pattern is to use a non-sticky broadcast to report that <em>something</em> |
| 2479 | * has changed, with another mechanism for apps to retrieve the current value whenever |
| 2480 | * desired. |
| 2481 | * |
Dianne Hackborn | efa199f | 2009-09-19 12:03:15 -0700 | [diff] [blame] | 2482 | * @param intent The Intent to broadcast; all receivers matching this |
| 2483 | * Intent will receive the broadcast. |
| 2484 | * @param resultReceiver Your own BroadcastReceiver to treat as the final |
| 2485 | * receiver of the broadcast. |
| 2486 | * @param scheduler A custom Handler with which to schedule the |
| 2487 | * resultReceiver callback; if null it will be |
| 2488 | * scheduled in the Context's main thread. |
| 2489 | * @param initialCode An initial value for the result code. Often |
| 2490 | * Activity.RESULT_OK. |
| 2491 | * @param initialData An initial value for the result data. Often |
| 2492 | * null. |
| 2493 | * @param initialExtras An initial value for the result extras. Often |
| 2494 | * null. |
| 2495 | * |
| 2496 | * @see #sendBroadcast(Intent) |
| 2497 | * @see #sendBroadcast(Intent, String) |
| 2498 | * @see #sendOrderedBroadcast(Intent, String) |
| 2499 | * @see #sendStickyBroadcast(Intent) |
| 2500 | * @see android.content.BroadcastReceiver |
| 2501 | * @see #registerReceiver |
| 2502 | * @see android.app.Activity#RESULT_OK |
| 2503 | */ |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2504 | @Deprecated |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 2505 | @RequiresPermission(android.Manifest.permission.BROADCAST_STICKY) |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 2506 | public abstract void sendStickyOrderedBroadcast(@RequiresPermission Intent intent, |
Dianne Hackborn | efa199f | 2009-09-19 12:03:15 -0700 | [diff] [blame] | 2507 | BroadcastReceiver resultReceiver, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2508 | @Nullable Handler scheduler, int initialCode, @Nullable String initialData, |
| 2509 | @Nullable Bundle initialExtras); |
Dianne Hackborn | efa199f | 2009-09-19 12:03:15 -0700 | [diff] [blame] | 2510 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2511 | /** |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2512 | * <p>Remove the data previously sent with {@link #sendStickyBroadcast}, |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2513 | * so that it is as if the sticky broadcast had never happened. |
| 2514 | * |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2515 | * @deprecated Sticky broadcasts should not be used. They provide no security (anyone |
| 2516 | * can access them), no protection (anyone can modify them), and many other problems. |
| 2517 | * The recommended pattern is to use a non-sticky broadcast to report that <em>something</em> |
| 2518 | * has changed, with another mechanism for apps to retrieve the current value whenever |
| 2519 | * desired. |
| 2520 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2521 | * @param intent The Intent that was previously broadcast. |
| 2522 | * |
| 2523 | * @see #sendStickyBroadcast |
| 2524 | */ |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2525 | @Deprecated |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 2526 | @RequiresPermission(android.Manifest.permission.BROADCAST_STICKY) |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 2527 | public abstract void removeStickyBroadcast(@RequiresPermission Intent intent); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2528 | |
| 2529 | /** |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2530 | * <p>Version of {@link #sendStickyBroadcast(Intent)} that allows you to specify the |
Dianne Hackborn | 8832c18 | 2012-09-17 17:20:24 -0700 | [diff] [blame] | 2531 | * user the broadcast will be sent to. This is not available to applications |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2532 | * that are not pre-installed on the system image. |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2533 | * |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2534 | * @deprecated Sticky broadcasts should not be used. They provide no security (anyone |
| 2535 | * can access them), no protection (anyone can modify them), and many other problems. |
| 2536 | * The recommended pattern is to use a non-sticky broadcast to report that <em>something</em> |
| 2537 | * has changed, with another mechanism for apps to retrieve the current value whenever |
| 2538 | * desired. |
| 2539 | * |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2540 | * @param intent The Intent to broadcast; all receivers matching this |
| 2541 | * Intent will receive the broadcast, and the Intent will be held to |
| 2542 | * be re-broadcast to future receivers. |
| 2543 | * @param user UserHandle to send the intent to. |
| 2544 | * |
| 2545 | * @see #sendBroadcast(Intent) |
| 2546 | */ |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2547 | @Deprecated |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2548 | @RequiresPermission(allOf = { |
| 2549 | android.Manifest.permission.INTERACT_ACROSS_USERS, |
| 2550 | android.Manifest.permission.BROADCAST_STICKY |
| 2551 | }) |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 2552 | public abstract void sendStickyBroadcastAsUser(@RequiresPermission Intent intent, |
| 2553 | UserHandle user); |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2554 | |
| 2555 | /** |
Dianne Hackborn | e0e413e | 2015-12-09 17:22:26 -0800 | [diff] [blame] | 2556 | * @hide |
| 2557 | * This is just here for sending CONNECTIVITY_ACTION. |
| 2558 | */ |
| 2559 | @Deprecated |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2560 | @RequiresPermission(allOf = { |
| 2561 | android.Manifest.permission.INTERACT_ACROSS_USERS, |
| 2562 | android.Manifest.permission.BROADCAST_STICKY |
| 2563 | }) |
Dianne Hackborn | e0e413e | 2015-12-09 17:22:26 -0800 | [diff] [blame] | 2564 | public abstract void sendStickyBroadcastAsUser(@RequiresPermission Intent intent, |
| 2565 | UserHandle user, Bundle options); |
| 2566 | |
| 2567 | /** |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2568 | * <p>Version of |
Dianne Hackborn | 8832c18 | 2012-09-17 17:20:24 -0700 | [diff] [blame] | 2569 | * {@link #sendStickyOrderedBroadcast(Intent, BroadcastReceiver, Handler, int, String, Bundle)} |
| 2570 | * that allows you to specify the |
| 2571 | * user the broadcast will be sent to. This is not available to applications |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2572 | * that are not pre-installed on the system image. |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2573 | * |
| 2574 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 2575 | * |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2576 | * @deprecated Sticky broadcasts should not be used. They provide no security (anyone |
| 2577 | * can access them), no protection (anyone can modify them), and many other problems. |
| 2578 | * The recommended pattern is to use a non-sticky broadcast to report that <em>something</em> |
| 2579 | * has changed, with another mechanism for apps to retrieve the current value whenever |
| 2580 | * desired. |
| 2581 | * |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2582 | * @param intent The Intent to broadcast; all receivers matching this |
| 2583 | * Intent will receive the broadcast. |
| 2584 | * @param user UserHandle to send the intent to. |
| 2585 | * @param resultReceiver Your own BroadcastReceiver to treat as the final |
| 2586 | * receiver of the broadcast. |
| 2587 | * @param scheduler A custom Handler with which to schedule the |
| 2588 | * resultReceiver callback; if null it will be |
| 2589 | * scheduled in the Context's main thread. |
| 2590 | * @param initialCode An initial value for the result code. Often |
| 2591 | * Activity.RESULT_OK. |
| 2592 | * @param initialData An initial value for the result data. Often |
| 2593 | * null. |
| 2594 | * @param initialExtras An initial value for the result extras. Often |
| 2595 | * null. |
| 2596 | * |
| 2597 | * @see #sendStickyOrderedBroadcast(Intent, BroadcastReceiver, Handler, int, String, Bundle) |
| 2598 | */ |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2599 | @Deprecated |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2600 | @RequiresPermission(allOf = { |
| 2601 | android.Manifest.permission.INTERACT_ACROSS_USERS, |
| 2602 | android.Manifest.permission.BROADCAST_STICKY |
| 2603 | }) |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 2604 | public abstract void sendStickyOrderedBroadcastAsUser(@RequiresPermission Intent intent, |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2605 | UserHandle user, BroadcastReceiver resultReceiver, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2606 | @Nullable Handler scheduler, int initialCode, @Nullable String initialData, |
| 2607 | @Nullable Bundle initialExtras); |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2608 | |
| 2609 | /** |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2610 | * <p>Version of {@link #removeStickyBroadcast(Intent)} that allows you to specify the |
Dianne Hackborn | 8832c18 | 2012-09-17 17:20:24 -0700 | [diff] [blame] | 2611 | * user the broadcast will be sent to. This is not available to applications |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2612 | * that are not pre-installed on the system image. |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2613 | * |
| 2614 | * <p>You must hold the {@link android.Manifest.permission#BROADCAST_STICKY} |
| 2615 | * permission in order to use this API. If you do not hold that |
| 2616 | * permission, {@link SecurityException} will be thrown. |
| 2617 | * |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2618 | * @deprecated Sticky broadcasts should not be used. They provide no security (anyone |
| 2619 | * can access them), no protection (anyone can modify them), and many other problems. |
| 2620 | * The recommended pattern is to use a non-sticky broadcast to report that <em>something</em> |
| 2621 | * has changed, with another mechanism for apps to retrieve the current value whenever |
| 2622 | * desired. |
| 2623 | * |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2624 | * @param intent The Intent that was previously broadcast. |
| 2625 | * @param user UserHandle to remove the sticky broadcast from. |
| 2626 | * |
| 2627 | * @see #sendStickyBroadcastAsUser |
| 2628 | */ |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2629 | @Deprecated |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2630 | @RequiresPermission(allOf = { |
| 2631 | android.Manifest.permission.INTERACT_ACROSS_USERS, |
| 2632 | android.Manifest.permission.BROADCAST_STICKY |
| 2633 | }) |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 2634 | public abstract void removeStickyBroadcastAsUser(@RequiresPermission Intent intent, |
| 2635 | UserHandle user); |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2636 | |
| 2637 | /** |
Chris Tate | a34df8a2 | 2009-04-02 23:15:58 -0700 | [diff] [blame] | 2638 | * Register a BroadcastReceiver to be run in the main activity thread. The |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2639 | * <var>receiver</var> will be called with any broadcast Intent that |
| 2640 | * matches <var>filter</var>, in the main application thread. |
| 2641 | * |
| 2642 | * <p>The system may broadcast Intents that are "sticky" -- these stay |
Kweku Adams | 86f39a4 | 2016-11-16 12:50:38 -0800 | [diff] [blame] | 2643 | * around after the broadcast has finished, to be sent to any later |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2644 | * registrations. If your IntentFilter matches one of these sticky |
| 2645 | * Intents, that Intent will be returned by this function |
| 2646 | * <strong>and</strong> sent to your <var>receiver</var> as if it had just |
| 2647 | * been broadcast. |
| 2648 | * |
| 2649 | * <p>There may be multiple sticky Intents that match <var>filter</var>, |
| 2650 | * in which case each of these will be sent to <var>receiver</var>. In |
| 2651 | * this case, only one of these can be returned directly by the function; |
| 2652 | * which of these that is returned is arbitrarily decided by the system. |
| 2653 | * |
| 2654 | * <p>If you know the Intent your are registering for is sticky, you can |
| 2655 | * supply null for your <var>receiver</var>. In this case, no receiver is |
| 2656 | * registered -- the function simply returns the sticky Intent that |
| 2657 | * matches <var>filter</var>. In the case of multiple matches, the same |
| 2658 | * rules as described above apply. |
| 2659 | * |
| 2660 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 2661 | * |
Dianne Hackborn | 6c418d5 | 2011-06-29 14:05:33 -0700 | [diff] [blame] | 2662 | * <p>As of {@link android.os.Build.VERSION_CODES#ICE_CREAM_SANDWICH}, receivers |
| 2663 | * registered with this method will correctly respect the |
| 2664 | * {@link Intent#setPackage(String)} specified for an Intent being broadcast. |
| 2665 | * Prior to that, it would be ignored and delivered to all matching registered |
| 2666 | * receivers. Be careful if using this for security.</p> |
| 2667 | * |
Chris Tate | a34df8a2 | 2009-04-02 23:15:58 -0700 | [diff] [blame] | 2668 | * <p class="note">Note: this method <em>cannot be called from a |
| 2669 | * {@link BroadcastReceiver} component;</em> that is, from a BroadcastReceiver |
| 2670 | * that is declared in an application's manifest. It is okay, however, to call |
| 2671 | * this method from another BroadcastReceiver that has itself been registered |
| 2672 | * at run time with {@link #registerReceiver}, since the lifetime of such a |
| 2673 | * registered BroadcastReceiver is tied to the object that registered it.</p> |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2674 | * |
| 2675 | * @param receiver The BroadcastReceiver to handle the broadcast. |
| 2676 | * @param filter Selects the Intent broadcasts to be received. |
| 2677 | * |
| 2678 | * @return The first sticky intent found that matches <var>filter</var>, |
| 2679 | * or null if there are none. |
| 2680 | * |
| 2681 | * @see #registerReceiver(BroadcastReceiver, IntentFilter, String, Handler) |
| 2682 | * @see #sendBroadcast |
| 2683 | * @see #unregisterReceiver |
| 2684 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2685 | @Nullable |
| 2686 | public abstract Intent registerReceiver(@Nullable BroadcastReceiver receiver, |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2687 | IntentFilter filter); |
| 2688 | |
| 2689 | /** |
Chad Brubaker | 816c83b | 2017-03-02 10:27:59 -0800 | [diff] [blame] | 2690 | * Register to receive intent broadcasts, with the receiver optionally being |
| 2691 | * exposed to Instant Apps. See |
| 2692 | * {@link #registerReceiver(BroadcastReceiver, IntentFilter)} for more |
| 2693 | * information. By default Instant Apps cannot interact with receivers in other |
| 2694 | * applications, this allows you to expose a receiver that Instant Apps can |
| 2695 | * interact with. |
| 2696 | * |
| 2697 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 2698 | * |
| 2699 | * <p>As of {@link android.os.Build.VERSION_CODES#ICE_CREAM_SANDWICH}, receivers |
| 2700 | * registered with this method will correctly respect the |
| 2701 | * {@link Intent#setPackage(String)} specified for an Intent being broadcast. |
| 2702 | * Prior to that, it would be ignored and delivered to all matching registered |
| 2703 | * receivers. Be careful if using this for security.</p> |
| 2704 | * |
| 2705 | * @param receiver The BroadcastReceiver to handle the broadcast. |
| 2706 | * @param filter Selects the Intent broadcasts to be received. |
Chad Brubaker | 6d6015f | 2017-04-18 11:25:16 -0700 | [diff] [blame] | 2707 | * @param flags Additional options for the receiver. May be 0 or |
| 2708 | * {@link #RECEIVER_VISIBLE_TO_INSTANT_APPS}. |
Chad Brubaker | 816c83b | 2017-03-02 10:27:59 -0800 | [diff] [blame] | 2709 | * |
| 2710 | * @return The first sticky intent found that matches <var>filter</var>, |
| 2711 | * or null if there are none. |
| 2712 | * |
| 2713 | * @see #registerReceiver(BroadcastReceiver, IntentFilter) |
| 2714 | * @see #sendBroadcast |
| 2715 | * @see #unregisterReceiver |
| 2716 | */ |
| 2717 | @Nullable |
| 2718 | public abstract Intent registerReceiver(@Nullable BroadcastReceiver receiver, |
| 2719 | IntentFilter filter, |
Chad Brubaker | 6d6015f | 2017-04-18 11:25:16 -0700 | [diff] [blame] | 2720 | @RegisterReceiverFlags int flags); |
Chad Brubaker | 816c83b | 2017-03-02 10:27:59 -0800 | [diff] [blame] | 2721 | |
| 2722 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2723 | * Register to receive intent broadcasts, to run in the context of |
| 2724 | * <var>scheduler</var>. See |
| 2725 | * {@link #registerReceiver(BroadcastReceiver, IntentFilter)} for more |
| 2726 | * information. This allows you to enforce permissions on who can |
| 2727 | * broadcast intents to your receiver, or have the receiver run in |
| 2728 | * a different thread than the main application thread. |
| 2729 | * |
| 2730 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 2731 | * |
Dianne Hackborn | 6c418d5 | 2011-06-29 14:05:33 -0700 | [diff] [blame] | 2732 | * <p>As of {@link android.os.Build.VERSION_CODES#ICE_CREAM_SANDWICH}, receivers |
| 2733 | * registered with this method will correctly respect the |
| 2734 | * {@link Intent#setPackage(String)} specified for an Intent being broadcast. |
| 2735 | * Prior to that, it would be ignored and delivered to all matching registered |
| 2736 | * receivers. Be careful if using this for security.</p> |
| 2737 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2738 | * @param receiver The BroadcastReceiver to handle the broadcast. |
| 2739 | * @param filter Selects the Intent broadcasts to be received. |
| 2740 | * @param broadcastPermission String naming a permissions that a |
| 2741 | * broadcaster must hold in order to send an Intent to you. If null, |
| 2742 | * no permission is required. |
| 2743 | * @param scheduler Handler identifying the thread that will receive |
| 2744 | * the Intent. If null, the main thread of the process will be used. |
| 2745 | * |
| 2746 | * @return The first sticky intent found that matches <var>filter</var>, |
| 2747 | * or null if there are none. |
| 2748 | * |
| 2749 | * @see #registerReceiver(BroadcastReceiver, IntentFilter) |
| 2750 | * @see #sendBroadcast |
| 2751 | * @see #unregisterReceiver |
| 2752 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2753 | @Nullable |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2754 | public abstract Intent registerReceiver(BroadcastReceiver receiver, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2755 | IntentFilter filter, @Nullable String broadcastPermission, |
| 2756 | @Nullable Handler scheduler); |
Dianne Hackborn | 20e8098 | 2012-08-31 19:00:44 -0700 | [diff] [blame] | 2757 | |
| 2758 | /** |
Chad Brubaker | 6d6015f | 2017-04-18 11:25:16 -0700 | [diff] [blame] | 2759 | * Register to receive intent broadcasts, to run in the context of |
| 2760 | * <var>scheduler</var>. See |
| 2761 | * {@link #registerReceiver(BroadcastReceiver, IntentFilter, int)} and |
Chad Brubaker | 816c83b | 2017-03-02 10:27:59 -0800 | [diff] [blame] | 2762 | * {@link #registerReceiver(BroadcastReceiver, IntentFilter, String, Handler)} |
| 2763 | * for more information. |
| 2764 | * |
| 2765 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 2766 | * |
| 2767 | * <p>As of {@link android.os.Build.VERSION_CODES#ICE_CREAM_SANDWICH}, receivers |
| 2768 | * registered with this method will correctly respect the |
| 2769 | * {@link Intent#setPackage(String)} specified for an Intent being broadcast. |
| 2770 | * Prior to that, it would be ignored and delivered to all matching registered |
| 2771 | * receivers. Be careful if using this for security.</p> |
| 2772 | * |
| 2773 | * @param receiver The BroadcastReceiver to handle the broadcast. |
| 2774 | * @param filter Selects the Intent broadcasts to be received. |
| 2775 | * @param broadcastPermission String naming a permissions that a |
| 2776 | * broadcaster must hold in order to send an Intent to you. If null, |
| 2777 | * no permission is required. |
| 2778 | * @param scheduler Handler identifying the thread that will receive |
| 2779 | * the Intent. If null, the main thread of the process will be used. |
Chad Brubaker | 6d6015f | 2017-04-18 11:25:16 -0700 | [diff] [blame] | 2780 | * @param flags Additional options for the receiver. May be 0 or |
| 2781 | * {@link #RECEIVER_VISIBLE_TO_INSTANT_APPS}. |
Chad Brubaker | 816c83b | 2017-03-02 10:27:59 -0800 | [diff] [blame] | 2782 | * |
| 2783 | * @return The first sticky intent found that matches <var>filter</var>, |
| 2784 | * or null if there are none. |
| 2785 | * |
Chad Brubaker | 6d6015f | 2017-04-18 11:25:16 -0700 | [diff] [blame] | 2786 | * @see #registerReceiver(BroadcastReceiver, IntentFilter, int) |
Chad Brubaker | 816c83b | 2017-03-02 10:27:59 -0800 | [diff] [blame] | 2787 | * @see #registerReceiver(BroadcastReceiver, IntentFilter, String, Handler) |
| 2788 | * @see #sendBroadcast |
| 2789 | * @see #unregisterReceiver |
| 2790 | */ |
| 2791 | @Nullable |
| 2792 | public abstract Intent registerReceiver(BroadcastReceiver receiver, |
| 2793 | IntentFilter filter, @Nullable String broadcastPermission, |
Chad Brubaker | 6d6015f | 2017-04-18 11:25:16 -0700 | [diff] [blame] | 2794 | @Nullable Handler scheduler, @RegisterReceiverFlags int flags); |
Chad Brubaker | 816c83b | 2017-03-02 10:27:59 -0800 | [diff] [blame] | 2795 | |
| 2796 | /** |
Dianne Hackborn | 20e8098 | 2012-08-31 19:00:44 -0700 | [diff] [blame] | 2797 | * @hide |
| 2798 | * Same as {@link #registerReceiver(BroadcastReceiver, IntentFilter, String, Handler) |
| 2799 | * but for a specific user. This receiver will receiver broadcasts that |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2800 | * are sent to the requested user. |
Dianne Hackborn | 20e8098 | 2012-08-31 19:00:44 -0700 | [diff] [blame] | 2801 | * |
| 2802 | * @param receiver The BroadcastReceiver to handle the broadcast. |
| 2803 | * @param user UserHandle to send the intent to. |
| 2804 | * @param filter Selects the Intent broadcasts to be received. |
| 2805 | * @param broadcastPermission String naming a permissions that a |
| 2806 | * broadcaster must hold in order to send an Intent to you. If null, |
| 2807 | * no permission is required. |
| 2808 | * @param scheduler Handler identifying the thread that will receive |
| 2809 | * the Intent. If null, the main thread of the process will be used. |
| 2810 | * |
| 2811 | * @return The first sticky intent found that matches <var>filter</var>, |
| 2812 | * or null if there are none. |
| 2813 | * |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 2814 | * @see #registerReceiver(BroadcastReceiver, IntentFilter, String, Handler) |
Dianne Hackborn | 20e8098 | 2012-08-31 19:00:44 -0700 | [diff] [blame] | 2815 | * @see #sendBroadcast |
| 2816 | * @see #unregisterReceiver |
| 2817 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2818 | @Nullable |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2819 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS_FULL) |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 2820 | @UnsupportedAppUsage |
Dianne Hackborn | 20e8098 | 2012-08-31 19:00:44 -0700 | [diff] [blame] | 2821 | public abstract Intent registerReceiverAsUser(BroadcastReceiver receiver, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2822 | UserHandle user, IntentFilter filter, @Nullable String broadcastPermission, |
| 2823 | @Nullable Handler scheduler); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2824 | |
| 2825 | /** |
| 2826 | * Unregister a previously registered BroadcastReceiver. <em>All</em> |
| 2827 | * filters that have been registered for this BroadcastReceiver will be |
| 2828 | * removed. |
| 2829 | * |
| 2830 | * @param receiver The BroadcastReceiver to unregister. |
| 2831 | * |
| 2832 | * @see #registerReceiver |
| 2833 | */ |
| 2834 | public abstract void unregisterReceiver(BroadcastReceiver receiver); |
| 2835 | |
| 2836 | /** |
| 2837 | * Request that a given application service be started. The Intent |
Hans Boehm | fb9f6ac | 2016-05-05 13:09:28 -0700 | [diff] [blame] | 2838 | * should either contain the complete class name of a specific service |
| 2839 | * implementation to start, or a specific package name to target. If the |
| 2840 | * Intent is less specified, it logs a warning about this. In this case any of the |
| 2841 | * multiple matching services may be used. If this service |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2842 | * is not already running, it will be instantiated and started (creating a |
| 2843 | * process for it if needed); if it is running then it remains running. |
| 2844 | * |
| 2845 | * <p>Every call to this method will result in a corresponding call to |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 2846 | * the target service's {@link android.app.Service#onStartCommand} method, |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2847 | * with the <var>intent</var> given here. This provides a convenient way |
| 2848 | * to submit jobs to a service without having to bind and call on to its |
| 2849 | * interface. |
| 2850 | * |
| 2851 | * <p>Using startService() overrides the default service lifetime that is |
| 2852 | * managed by {@link #bindService}: it requires the service to remain |
| 2853 | * running until {@link #stopService} is called, regardless of whether |
| 2854 | * any clients are connected to it. Note that calls to startService() |
Hans Boehm | fb9f6ac | 2016-05-05 13:09:28 -0700 | [diff] [blame] | 2855 | * do not nest: no matter how many times you call startService(), |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2856 | * a single call to {@link #stopService} will stop it. |
| 2857 | * |
| 2858 | * <p>The system attempts to keep running services around as much as |
| 2859 | * possible. The only time they should be stopped is if the current |
| 2860 | * foreground application is using so many resources that the service needs |
| 2861 | * to be killed. If any errors happen in the service's process, it will |
| 2862 | * automatically be restarted. |
| 2863 | * |
| 2864 | * <p>This function will throw {@link SecurityException} if you do not |
| 2865 | * have permission to start the given service. |
| 2866 | * |
Chris Craik | 1e35352 | 2016-04-18 10:20:50 -0700 | [diff] [blame] | 2867 | * <p class="note"><strong>Note:</strong> Each call to startService() |
| 2868 | * results in significant work done by the system to manage service |
| 2869 | * lifecycle surrounding the processing of the intent, which can take |
| 2870 | * multiple milliseconds of CPU time. Due to this cost, startService() |
| 2871 | * should not be used for frequent intent delivery to a service, and only |
| 2872 | * for scheduling significant work. Use {@link #bindService bound services} |
| 2873 | * for high frequency calls. |
| 2874 | * </p> |
| 2875 | * |
Mark Lu | 94ebbe0 | 2016-12-13 16:29:51 -0800 | [diff] [blame] | 2876 | * @param service Identifies the service to be started. The Intent must be |
| 2877 | * fully explicit (supplying a component name). Additional values |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2878 | * may be included in the Intent extras to supply arguments along with |
| 2879 | * this specific start call. |
| 2880 | * |
| 2881 | * @return If the service is being started or is already running, the |
| 2882 | * {@link ComponentName} of the actual service that was started is |
| 2883 | * returned; else if the service does not exist null is returned. |
| 2884 | * |
Christopher Tate | 08992ac | 2017-03-21 11:37:06 -0700 | [diff] [blame] | 2885 | * @throws SecurityException If the caller does not have permission to access the service |
Dianne Hackborn | 85e3564 | 2017-01-12 15:10:57 -0800 | [diff] [blame] | 2886 | * or the service can not be found. |
| 2887 | * @throws IllegalStateException If the application is in a state where the service |
| 2888 | * can not be started (such as not in the foreground in a state when services are allowed). |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2889 | * |
| 2890 | * @see #stopService |
| 2891 | * @see #bindService |
| 2892 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2893 | @Nullable |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2894 | public abstract ComponentName startService(Intent service); |
| 2895 | |
| 2896 | /** |
Christopher Tate | 08992ac | 2017-03-21 11:37:06 -0700 | [diff] [blame] | 2897 | * Similar to {@link #startService(Intent)}, but with an implicit promise that the |
Neil Fuller | fe6ec56 | 2017-03-16 18:29:36 +0000 | [diff] [blame] | 2898 | * Service will call {@link android.app.Service#startForeground(int, android.app.Notification) |
| 2899 | * startForeground(int, android.app.Notification)} once it begins running. The service is given |
Christopher Tate | 08992ac | 2017-03-21 11:37:06 -0700 | [diff] [blame] | 2900 | * an amount of time comparable to the ANR interval to do this, otherwise the system |
| 2901 | * will automatically stop the service and declare the app ANR. |
| 2902 | * |
| 2903 | * <p>Unlike the ordinary {@link #startService(Intent)}, this method can be used |
| 2904 | * at any time, regardless of whether the app hosting the service is in a foreground |
| 2905 | * state. |
| 2906 | * |
| 2907 | * @param service Identifies the service to be started. The Intent must be |
| 2908 | * fully explicit (supplying a component name). Additional values |
| 2909 | * may be included in the Intent extras to supply arguments along with |
| 2910 | * this specific start call. |
| 2911 | * |
| 2912 | * @return If the service is being started or is already running, the |
| 2913 | * {@link ComponentName} of the actual service that was started is |
| 2914 | * returned; else if the service does not exist null is returned. |
| 2915 | * |
| 2916 | * @throws SecurityException If the caller does not have permission to access the service |
| 2917 | * or the service can not be found. |
| 2918 | * |
| 2919 | * @see #stopService |
Neil Fuller | fe6ec56 | 2017-03-16 18:29:36 +0000 | [diff] [blame] | 2920 | * @see android.app.Service#startForeground(int, android.app.Notification) |
Christopher Tate | 08992ac | 2017-03-21 11:37:06 -0700 | [diff] [blame] | 2921 | */ |
| 2922 | @Nullable |
| 2923 | public abstract ComponentName startForegroundService(Intent service); |
| 2924 | |
| 2925 | /** |
| 2926 | * @hide like {@link #startForegroundService(Intent)} but for a specific user. |
| 2927 | */ |
| 2928 | @Nullable |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2929 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) |
Christopher Tate | 08992ac | 2017-03-21 11:37:06 -0700 | [diff] [blame] | 2930 | public abstract ComponentName startForegroundServiceAsUser(Intent service, UserHandle user); |
| 2931 | |
| 2932 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2933 | * Request that a given application service be stopped. If the service is |
| 2934 | * not running, nothing happens. Otherwise it is stopped. Note that calls |
| 2935 | * to startService() are not counted -- this stops the service no matter |
| 2936 | * how many times it was started. |
| 2937 | * |
| 2938 | * <p>Note that if a stopped service still has {@link ServiceConnection} |
| 2939 | * objects bound to it with the {@link #BIND_AUTO_CREATE} set, it will |
| 2940 | * not be destroyed until all of these bindings are removed. See |
| 2941 | * the {@link android.app.Service} documentation for more details on a |
| 2942 | * service's lifecycle. |
| 2943 | * |
| 2944 | * <p>This function will throw {@link SecurityException} if you do not |
| 2945 | * have permission to stop the given service. |
| 2946 | * |
Dianne Hackborn | 221ea89 | 2013-08-04 16:50:16 -0700 | [diff] [blame] | 2947 | * @param service Description of the service to be stopped. The Intent must be either |
| 2948 | * fully explicit (supplying a component name) or specify a specific package |
kopriva | 219f7dc | 2018-10-09 13:42:28 -0700 | [diff] [blame] | 2949 | * name it is targeted to. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2950 | * |
| 2951 | * @return If there is a service matching the given Intent that is already |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 2952 | * running, then it is stopped and {@code true} is returned; else {@code false} is returned. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2953 | * |
Christopher Tate | 08992ac | 2017-03-21 11:37:06 -0700 | [diff] [blame] | 2954 | * @throws SecurityException If the caller does not have permission to access the service |
Dianne Hackborn | 85e3564 | 2017-01-12 15:10:57 -0800 | [diff] [blame] | 2955 | * or the service can not be found. |
| 2956 | * @throws IllegalStateException If the application is in a state where the service |
| 2957 | * can not be started (such as not in the foreground in a state when services are allowed). |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2958 | * |
| 2959 | * @see #startService |
| 2960 | */ |
| 2961 | public abstract boolean stopService(Intent service); |
| 2962 | |
| 2963 | /** |
Dianne Hackborn | 7767eac | 2012-08-23 18:25:40 -0700 | [diff] [blame] | 2964 | * @hide like {@link #startService(Intent)} but for a specific user. |
| 2965 | */ |
Christopher Tate | 42a386b | 2016-11-07 12:21:21 -0800 | [diff] [blame] | 2966 | @Nullable |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2967 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 2968 | @UnsupportedAppUsage |
Dianne Hackborn | 7767eac | 2012-08-23 18:25:40 -0700 | [diff] [blame] | 2969 | public abstract ComponentName startServiceAsUser(Intent service, UserHandle user); |
| 2970 | |
| 2971 | /** |
| 2972 | * @hide like {@link #stopService(Intent)} but for a specific user. |
| 2973 | */ |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2974 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) |
Dianne Hackborn | 7767eac | 2012-08-23 18:25:40 -0700 | [diff] [blame] | 2975 | public abstract boolean stopServiceAsUser(Intent service, UserHandle user); |
RoboErik | 01fe661 | 2014-02-13 14:19:04 -0800 | [diff] [blame] | 2976 | |
Dianne Hackborn | 7767eac | 2012-08-23 18:25:40 -0700 | [diff] [blame] | 2977 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2978 | * Connect to an application service, creating it if needed. This defines |
| 2979 | * a dependency between your application and the service. The given |
Ken Wakasa | f76a50c | 2012-03-09 19:56:35 +0900 | [diff] [blame] | 2980 | * <var>conn</var> will receive the service object when it is created and be |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2981 | * told if it dies and restarts. The service will be considered required |
| 2982 | * by the system only for as long as the calling context exists. For |
| 2983 | * example, if this Context is an Activity that is stopped, the service will |
| 2984 | * not be required to continue running until the Activity is resumed. |
| 2985 | * |
Christopher Tate | 5d73b6d | 2017-10-06 16:15:34 -0700 | [diff] [blame] | 2986 | * <p>If the service does not support binding, it may return {@code null} from |
| 2987 | * its {@link android.app.Service#onBind(Intent) onBind()} method. If it does, then |
| 2988 | * the ServiceConnection's |
| 2989 | * {@link ServiceConnection#onNullBinding(ComponentName) onNullBinding()} method |
| 2990 | * will be invoked instead of |
| 2991 | * {@link ServiceConnection#onServiceConnected(ComponentName, IBinder) onServiceConnected()}. |
| 2992 | * |
| 2993 | * <p>This method will throw {@link SecurityException} if the calling app does not |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2994 | * have permission to bind to the given service. |
| 2995 | * |
Christopher Tate | 5d73b6d | 2017-10-06 16:15:34 -0700 | [diff] [blame] | 2996 | * <p class="note">Note: this method <em>cannot be called from a |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2997 | * {@link BroadcastReceiver} component</em>. A pattern you can use to |
Ken Wakasa | f76a50c | 2012-03-09 19:56:35 +0900 | [diff] [blame] | 2998 | * communicate from a BroadcastReceiver to a Service is to call |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2999 | * {@link #startService} with the arguments containing the command to be |
| 3000 | * sent, with the service calling its |
| 3001 | * {@link android.app.Service#stopSelf(int)} method when done executing |
| 3002 | * that command. See the API demo App/Service/Service Start Arguments |
| 3003 | * Controller for an illustration of this. It is okay, however, to use |
Ken Wakasa | f76a50c | 2012-03-09 19:56:35 +0900 | [diff] [blame] | 3004 | * this method from a BroadcastReceiver that has been registered with |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3005 | * {@link #registerReceiver}, since the lifetime of this BroadcastReceiver |
| 3006 | * is tied to another object (the one that registered it).</p> |
| 3007 | * |
Mark Lu | 94ebbe0 | 2016-12-13 16:29:51 -0800 | [diff] [blame] | 3008 | * @param service Identifies the service to connect to. The Intent must |
| 3009 | * specify an explicit component name. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3010 | * @param conn Receives information as the service is started and stopped. |
Christopher Tate | 79b3317 | 2012-06-18 14:54:21 -0700 | [diff] [blame] | 3011 | * This must be a valid ServiceConnection object; it must not be null. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3012 | * @param flags Operation options for the binding. May be 0, |
Dianne Hackborn | c68c913 | 2011-07-29 01:25:18 -0700 | [diff] [blame] | 3013 | * {@link #BIND_AUTO_CREATE}, {@link #BIND_DEBUG_UNBIND}, |
| 3014 | * {@link #BIND_NOT_FOREGROUND}, {@link #BIND_ABOVE_CLIENT}, |
Dianne Hackborn | 27b4d94 | 2018-11-12 15:01:40 -0800 | [diff] [blame] | 3015 | * {@link #BIND_ALLOW_OOM_MANAGEMENT}, {@link #BIND_WAIVE_PRIORITY}. |
| 3016 | * {@link #BIND_IMPORTANT}, or |
| 3017 | * {@link #BIND_ADJUST_WITH_ACTIVITY}. |
Kevin Hufnagle | 34acbc9b | 2017-06-29 15:58:48 -0700 | [diff] [blame] | 3018 | * @return {@code true} if the system is in the process of bringing up a |
| 3019 | * service that your client has permission to bind to; {@code false} |
| 3020 | * if the system couldn't find the service or if your client doesn't |
| 3021 | * have permission to bind to it. If this value is {@code true}, you |
| 3022 | * should later call {@link #unbindService} to release the |
| 3023 | * connection. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3024 | * |
Christopher Tate | 08992ac | 2017-03-21 11:37:06 -0700 | [diff] [blame] | 3025 | * @throws SecurityException If the caller does not have permission to access the service |
Dianne Hackborn | 85e3564 | 2017-01-12 15:10:57 -0800 | [diff] [blame] | 3026 | * or the service can not be found. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3027 | * |
| 3028 | * @see #unbindService |
| 3029 | * @see #startService |
| 3030 | * @see #BIND_AUTO_CREATE |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3031 | * @see #BIND_DEBUG_UNBIND |
| 3032 | * @see #BIND_NOT_FOREGROUND |
Dianne Hackborn | 27b4d94 | 2018-11-12 15:01:40 -0800 | [diff] [blame] | 3033 | * @see #BIND_ABOVE_CLIENT |
| 3034 | * @see #BIND_ALLOW_OOM_MANAGEMENT |
| 3035 | * @see #BIND_WAIVE_PRIORITY |
| 3036 | * @see #BIND_IMPORTANT |
| 3037 | * @see #BIND_ADJUST_WITH_ACTIVITY |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3038 | */ |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 3039 | public abstract boolean bindService(@RequiresPermission Intent service, |
| 3040 | @NonNull ServiceConnection conn, @BindServiceFlags int flags); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3041 | |
| 3042 | /** |
Bo Liu | 58a5766 | 2019-03-06 20:21:45 +0000 | [diff] [blame] | 3043 | * Same as {@link #bindService(Intent, ServiceConnection, int)} with executor to control |
| 3044 | * ServiceConnection callbacks. |
| 3045 | * @param executor Callbacks on ServiceConnection will be called on executor. Must use same |
| 3046 | * instance for the same instance of ServiceConnection. |
| 3047 | */ |
| 3048 | public boolean bindService(@RequiresPermission @NonNull Intent service, |
| 3049 | @BindServiceFlags int flags, @NonNull @CallbackExecutor Executor executor, |
| 3050 | @NonNull ServiceConnection conn) { |
| 3051 | throw new RuntimeException("Not implemented. Must override in a subclass."); |
| 3052 | } |
| 3053 | |
| 3054 | /** |
Dianne Hackborn | 27b4d94 | 2018-11-12 15:01:40 -0800 | [diff] [blame] | 3055 | * Variation of {@link #bindService} that, in the specific case of isolated |
| 3056 | * services, allows the caller to generate multiple instances of a service |
Dianne Hackborn | cc67f96 | 2019-04-29 16:32:44 -0700 | [diff] [blame] | 3057 | * from a single component declaration. In other words, you can use this to bind |
| 3058 | * to a service that has specified {@link android.R.attr#isolatedProcess} and, in |
| 3059 | * addition to the existing behavior of running in an isolated process, you can |
| 3060 | * also through the arguments here have the system bring up multiple concurrent |
| 3061 | * processes hosting their own instances of that service. The <var>instanceName</var> |
| 3062 | * you provide here identifies the different instances, and you can use |
| 3063 | * {@link #updateServiceGroup(ServiceConnection, int, int)} to tell the system how it |
| 3064 | * should manage each of these instances. |
Dianne Hackborn | 27b4d94 | 2018-11-12 15:01:40 -0800 | [diff] [blame] | 3065 | * |
| 3066 | * @param service Identifies the service to connect to. The Intent must |
| 3067 | * specify an explicit component name. |
Dianne Hackborn | 27b4d94 | 2018-11-12 15:01:40 -0800 | [diff] [blame] | 3068 | * @param flags Operation options for the binding as per {@link #bindService}. |
| 3069 | * @param instanceName Unique identifier for the service instance. Each unique |
Robert Sesek | e3a5bc6 | 2019-04-22 17:43:03 -0400 | [diff] [blame] | 3070 | * name here will result in a different service instance being created. Identifiers |
| 3071 | * must only contain ASCII letters, digits, underscores, and periods. |
Dianne Hackborn | 27b4d94 | 2018-11-12 15:01:40 -0800 | [diff] [blame] | 3072 | * @return Returns success of binding as per {@link #bindService}. |
Bo Liu | 58a5766 | 2019-03-06 20:21:45 +0000 | [diff] [blame] | 3073 | * @param executor Callbacks on ServiceConnection will be called on executor. |
| 3074 | * Must use same instance for the same instance of ServiceConnection. |
| 3075 | * @param conn Receives information as the service is started and stopped. |
| 3076 | * This must be a valid ServiceConnection object; it must not be null. |
Dianne Hackborn | 27b4d94 | 2018-11-12 15:01:40 -0800 | [diff] [blame] | 3077 | * |
| 3078 | * @throws SecurityException If the caller does not have permission to access the service |
Robert Sesek | e3a5bc6 | 2019-04-22 17:43:03 -0400 | [diff] [blame] | 3079 | * @throws IllegalArgumentException If the instanceName is invalid. |
Dianne Hackborn | 27b4d94 | 2018-11-12 15:01:40 -0800 | [diff] [blame] | 3080 | * |
| 3081 | * @see #bindService |
Dianne Hackborn | cc67f96 | 2019-04-29 16:32:44 -0700 | [diff] [blame] | 3082 | * @see #updateServiceGroup |
| 3083 | * @see android.R.attr#isolatedProcess |
Dianne Hackborn | 27b4d94 | 2018-11-12 15:01:40 -0800 | [diff] [blame] | 3084 | */ |
Adrian Roos | ebc927c | 2019-02-28 16:21:18 +0100 | [diff] [blame] | 3085 | public boolean bindIsolatedService(@RequiresPermission @NonNull Intent service, |
Bo Liu | 58a5766 | 2019-03-06 20:21:45 +0000 | [diff] [blame] | 3086 | @BindServiceFlags int flags, @NonNull String instanceName, |
| 3087 | @NonNull @CallbackExecutor Executor executor, @NonNull ServiceConnection conn) { |
Adrian Roos | fe6aeaf | 2019-01-22 16:58:56 +0100 | [diff] [blame] | 3088 | throw new RuntimeException("Not implemented. Must override in a subclass."); |
| 3089 | } |
Dianne Hackborn | 27b4d94 | 2018-11-12 15:01:40 -0800 | [diff] [blame] | 3090 | |
| 3091 | /** |
Dianne Hackborn | 7d19e02 | 2012-08-07 19:12:33 -0700 | [diff] [blame] | 3092 | * Same as {@link #bindService(Intent, ServiceConnection, int)}, but with an explicit userHandle |
Amith Yamasani | 37ce3a8 | 2012-02-06 12:04:42 -0800 | [diff] [blame] | 3093 | * argument for use by system server and other multi-user aware code. |
| 3094 | * @hide |
| 3095 | */ |
Amith Yamasani | c85029f | 2014-09-11 16:47:17 -0700 | [diff] [blame] | 3096 | @SystemApi |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 3097 | @SuppressWarnings("unused") |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 3098 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 3099 | public boolean bindServiceAsUser(@RequiresPermission Intent service, ServiceConnection conn, |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 3100 | int flags, UserHandle user) { |
Amith Yamasani | 37ce3a8 | 2012-02-06 12:04:42 -0800 | [diff] [blame] | 3101 | throw new RuntimeException("Not implemented. Must override in a subclass."); |
| 3102 | } |
| 3103 | |
| 3104 | /** |
Dianne Hackborn | 27b4d94 | 2018-11-12 15:01:40 -0800 | [diff] [blame] | 3105 | * Same as {@link #bindServiceAsUser(Intent, ServiceConnection, int, UserHandle)}, but with an |
Adrian Roos | 691546e | 2016-02-09 10:13:41 -0800 | [diff] [blame] | 3106 | * explicit non-null Handler to run the ServiceConnection callbacks on. |
| 3107 | * |
| 3108 | * @hide |
| 3109 | */ |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 3110 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) |
Mathew Inwood | 7bcc174 | 2019-07-04 11:39:42 +0100 | [diff] [blame] | 3111 | @UnsupportedAppUsage(trackingBug = 136728678) |
Adrian Roos | 691546e | 2016-02-09 10:13:41 -0800 | [diff] [blame] | 3112 | public boolean bindServiceAsUser(Intent service, ServiceConnection conn, int flags, |
| 3113 | Handler handler, UserHandle user) { |
| 3114 | throw new RuntimeException("Not implemented. Must override in a subclass."); |
| 3115 | } |
| 3116 | |
| 3117 | /** |
Dianne Hackborn | a631d56 | 2018-11-20 15:58:15 -0800 | [diff] [blame] | 3118 | * For a service previously bound with {@link #bindService} or a related method, change |
| 3119 | * how the system manages that service's process in relation to other processes. This |
| 3120 | * doesn't modify the original bind flags that were passed in when binding, but adjusts |
| 3121 | * how the process will be managed in some cases based on those flags. Currently only |
| 3122 | * works on isolated processes (will be ignored for non-isolated processes). |
| 3123 | * |
Dianne Hackborn | 2f55e5a | 2018-11-30 16:31:31 -0800 | [diff] [blame] | 3124 | * <p>Note that this call does not take immediate effect, but will be applied the next |
| 3125 | * time the impacted process is adjusted for some other reason. Typically you would |
| 3126 | * call this before then calling a new {@link #bindIsolatedService} on the service |
| 3127 | * of interest, with that binding causing the process to be shuffled accordingly.</p> |
| 3128 | * |
Dianne Hackborn | a631d56 | 2018-11-20 15:58:15 -0800 | [diff] [blame] | 3129 | * @param conn The connection interface previously supplied to bindService(). This |
| 3130 | * parameter must not be null. |
| 3131 | * @param group A group to put this connection's process in. Upon calling here, this |
| 3132 | * will override any previous group that was set for that process. The group |
| 3133 | * tells the system about processes that are logically grouped together, so |
| 3134 | * should be managed as one unit of importance (such as when being considered |
| 3135 | * a recently used app). All processes in the same app with the same group |
| 3136 | * are considered to be related. Supplying 0 reverts to the default behavior |
| 3137 | * of not grouping. |
| 3138 | * @param importance Additional importance of the processes within a group. Upon calling |
Dianne Hackborn | cc67f96 | 2019-04-29 16:32:44 -0700 | [diff] [blame] | 3139 | * here, this will override any previous importance that was set for that |
| 3140 | * process. The most important process is 0, and higher values are |
| 3141 | * successively less important. You can view this as describing how |
| 3142 | * to order the processes in an array, with the processes at the end of |
| 3143 | * the array being the least important. This value has no meaning besides |
| 3144 | * indicating how processes should be ordered in that array one after the |
| 3145 | * other. This provides a way to fine-tune the system's process killing, |
| 3146 | * guiding it to kill processes at the end of the array first. |
| 3147 | * |
| 3148 | * @see #bindIsolatedService |
Dianne Hackborn | a631d56 | 2018-11-20 15:58:15 -0800 | [diff] [blame] | 3149 | */ |
Adrian Roos | fe6aeaf | 2019-01-22 16:58:56 +0100 | [diff] [blame] | 3150 | public void updateServiceGroup(@NonNull ServiceConnection conn, int group, |
| 3151 | int importance) { |
| 3152 | throw new RuntimeException("Not implemented. Must override in a subclass."); |
| 3153 | } |
Dianne Hackborn | a631d56 | 2018-11-20 15:58:15 -0800 | [diff] [blame] | 3154 | |
| 3155 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3156 | * Disconnect from an application service. You will no longer receive |
| 3157 | * calls as the service is restarted, and the service is now allowed to |
| 3158 | * stop at any time. |
| 3159 | * |
| 3160 | * @param conn The connection interface previously supplied to |
Christopher Tate | 79b3317 | 2012-06-18 14:54:21 -0700 | [diff] [blame] | 3161 | * bindService(). This parameter must not be null. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3162 | * |
| 3163 | * @see #bindService |
| 3164 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3165 | public abstract void unbindService(@NonNull ServiceConnection conn); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3166 | |
| 3167 | /** |
| 3168 | * Start executing an {@link android.app.Instrumentation} class. The given |
| 3169 | * Instrumentation component will be run by killing its target application |
| 3170 | * (if currently running), starting the target process, instantiating the |
| 3171 | * instrumentation component, and then letting it drive the application. |
| 3172 | * |
| 3173 | * <p>This function is not synchronous -- it returns as soon as the |
| 3174 | * instrumentation has started and while it is running. |
| 3175 | * |
| 3176 | * <p>Instrumentation is normally only allowed to run against a package |
| 3177 | * that is either unsigned or signed with a signature that the |
| 3178 | * the instrumentation package is also signed with (ensuring the target |
| 3179 | * trusts the instrumentation). |
| 3180 | * |
| 3181 | * @param className Name of the Instrumentation component to be run. |
| 3182 | * @param profileFile Optional path to write profiling data as the |
| 3183 | * instrumentation runs, or null for no profiling. |
| 3184 | * @param arguments Additional optional arguments to pass to the |
| 3185 | * instrumentation, or null. |
| 3186 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 3187 | * @return {@code true} if the instrumentation was successfully started, |
| 3188 | * else {@code false} if it could not be found. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3189 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3190 | public abstract boolean startInstrumentation(@NonNull ComponentName className, |
| 3191 | @Nullable String profileFile, @Nullable Bundle arguments); |
| 3192 | |
| 3193 | /** @hide */ |
Jeff Sharkey | 5db9a91 | 2017-12-08 17:32:32 -0700 | [diff] [blame] | 3194 | @StringDef(suffix = { "_SERVICE" }, value = { |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3195 | POWER_SERVICE, |
| 3196 | WINDOW_SERVICE, |
| 3197 | LAYOUT_INFLATER_SERVICE, |
| 3198 | ACCOUNT_SERVICE, |
| 3199 | ACTIVITY_SERVICE, |
| 3200 | ALARM_SERVICE, |
| 3201 | NOTIFICATION_SERVICE, |
| 3202 | ACCESSIBILITY_SERVICE, |
| 3203 | CAPTIONING_SERVICE, |
| 3204 | KEYGUARD_SERVICE, |
| 3205 | LOCATION_SERVICE, |
| 3206 | //@hide: COUNTRY_DETECTOR, |
| 3207 | SEARCH_SERVICE, |
| 3208 | SENSOR_SERVICE, |
Chad Brubaker | 90f391f | 2018-10-19 10:26:19 -0700 | [diff] [blame] | 3209 | SENSOR_PRIVACY_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3210 | STORAGE_SERVICE, |
Jeff Sharkey | e8cece9 | 2017-01-04 11:33:33 -0700 | [diff] [blame] | 3211 | STORAGE_STATS_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3212 | WALLPAPER_SERVICE, |
Neil Fuller | fe6ec56 | 2017-03-16 18:29:36 +0000 | [diff] [blame] | 3213 | TIME_ZONE_RULES_MANAGER_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3214 | VIBRATOR_SERVICE, |
| 3215 | //@hide: STATUS_BAR_SERVICE, |
| 3216 | CONNECTIVITY_SERVICE, |
Chalard Jean | 8c141bd | 2018-12-04 20:20:56 +0900 | [diff] [blame] | 3217 | //@hide: IP_MEMORY_STORE_SERVICE, |
Nathan Harold | 330e108 | 2017-01-12 18:38:57 -0800 | [diff] [blame] | 3218 | IPSEC_SERVICE, |
Benedict Wong | 99a4841 | 2018-11-09 14:45:34 -0800 | [diff] [blame] | 3219 | TEST_NETWORK_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3220 | //@hide: UPDATE_LOCK_SERVICE, |
| 3221 | //@hide: NETWORKMANAGEMENT_SERVICE, |
Zoltan Szatmary-Ban | 9c5dfa5 | 2015-02-23 17:20:20 +0000 | [diff] [blame] | 3222 | NETWORK_STATS_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3223 | //@hide: NETWORK_POLICY_SERVICE, |
| 3224 | WIFI_SERVICE, |
Etan Cohen | 0413327 | 2016-10-26 11:22:06 -0700 | [diff] [blame] | 3225 | WIFI_AWARE_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3226 | WIFI_P2P_SERVICE, |
Vinit Deshapnde | 011e1b3 | 2014-05-07 21:09:11 -0700 | [diff] [blame] | 3227 | WIFI_SCANNING_SERVICE, |
Robert Quattlebaum | 87a7104 | 2017-05-15 15:45:20 -0700 | [diff] [blame] | 3228 | //@hide: LOWPAN_SERVICE, |
Tor Norbye | bf44ce2 | 2015-02-12 11:47:32 -0800 | [diff] [blame] | 3229 | //@hide: WIFI_RTT_SERVICE, |
Lorenzo Colitti | bd8a374 | 2014-05-22 11:51:27 -0700 | [diff] [blame] | 3230 | //@hide: ETHERNET_SERVICE, |
Etan Cohen | 46efb48 | 2017-12-07 13:50:57 -0800 | [diff] [blame] | 3231 | WIFI_RTT_RANGING_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3232 | NSD_SERVICE, |
| 3233 | AUDIO_SERVICE, |
Jim Miller | ce7eb6d | 2015-04-03 19:29:13 -0700 | [diff] [blame] | 3234 | FINGERPRINT_SERVICE, |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 3235 | //@hide: FACE_SERVICE, |
Kevin Chyn | 05c2150 | 2018-09-18 13:07:19 -0700 | [diff] [blame] | 3236 | BIOMETRIC_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3237 | MEDIA_ROUTER_SERVICE, |
| 3238 | TELEPHONY_SERVICE, |
Tor Norbye | bf44ce2 | 2015-02-12 11:47:32 -0800 | [diff] [blame] | 3239 | TELEPHONY_SUBSCRIPTION_SERVICE, |
Jonathan Basseri | 9a1c9b6 | 2015-02-25 13:01:52 -0800 | [diff] [blame] | 3240 | CARRIER_CONFIG_SERVICE, |
hyunhae.lee | 75fdafa | 2019-07-19 22:08:41 +0900 | [diff] [blame] | 3241 | EUICC_SERVICE, |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 3242 | TELECOM_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3243 | CLIPBOARD_SERVICE, |
| 3244 | INPUT_METHOD_SERVICE, |
| 3245 | TEXT_SERVICES_MANAGER_SERVICE, |
Abodunrinwa Toki | 3de110b | 2017-05-04 16:29:04 +0100 | [diff] [blame] | 3246 | TEXT_CLASSIFICATION_SERVICE, |
Svetoslav | 976e8bd | 2014-07-16 15:12:03 -0700 | [diff] [blame] | 3247 | APPWIDGET_SERVICE, |
Tor Norbye | bf44ce2 | 2015-02-12 11:47:32 -0800 | [diff] [blame] | 3248 | //@hide: VOICE_INTERACTION_MANAGER_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3249 | //@hide: BACKUP_SERVICE, |
Richard Uhler | b29f145 | 2018-09-12 16:38:15 +0100 | [diff] [blame] | 3250 | ROLLBACK_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3251 | DROPBOX_SERVICE, |
Dianne Hackborn | 1958e5e | 2015-06-12 18:11:41 -0700 | [diff] [blame] | 3252 | //@hide: DEVICE_IDLE_CONTROLLER, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3253 | DEVICE_POLICY_SERVICE, |
| 3254 | UI_MODE_SERVICE, |
| 3255 | DOWNLOAD_SERVICE, |
| 3256 | NFC_SERVICE, |
| 3257 | BLUETOOTH_SERVICE, |
| 3258 | //@hide: SIP_SERVICE, |
| 3259 | USB_SERVICE, |
Amith Yamasani | 4f58263 | 2014-02-19 14:31:52 -0800 | [diff] [blame] | 3260 | LAUNCHER_APPS_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3261 | //@hide: SERIAL_SERVICE, |
Tor Norbye | bf44ce2 | 2015-02-12 11:47:32 -0800 | [diff] [blame] | 3262 | //@hide: HDMI_CONTROL_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3263 | INPUT_SERVICE, |
| 3264 | DISPLAY_SERVICE, |
Christine Franks | 39b0311 | 2018-07-03 14:46:07 -0700 | [diff] [blame] | 3265 | //@hide COLOR_DISPLAY_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3266 | USER_SERVICE, |
Tor Norbye | bf44ce2 | 2015-02-12 11:47:32 -0800 | [diff] [blame] | 3267 | RESTRICTIONS_SERVICE, |
| 3268 | APP_OPS_SERVICE, |
Hai Zhang | b777668 | 2018-09-25 15:10:57 -0700 | [diff] [blame] | 3269 | ROLE_SERVICE, |
Hai Zhang | a4959e5 | 2019-03-06 12:21:07 -0800 | [diff] [blame] | 3270 | //@hide ROLE_CONTROLLER_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3271 | CAMERA_SERVICE, |
atrost | 8266ae3 | 2019-08-15 16:53:01 +0100 | [diff] [blame] | 3272 | //@hide: PLATFORM_COMPAT_SERVICE, |
atrost | ff948d8 | 2019-10-10 19:27:31 +0100 | [diff] [blame] | 3273 | //@hide: PLATFORM_COMPAT_NATIVE_SERVICE, |
RoboErik | 01fe661 | 2014-02-13 14:19:04 -0800 | [diff] [blame] | 3274 | PRINT_SERVICE, |
Tor Norbye | bf44ce2 | 2015-02-12 11:47:32 -0800 | [diff] [blame] | 3275 | CONSUMER_IR_SERVICE, |
| 3276 | //@hide: TRUST_SERVICE, |
| 3277 | TV_INPUT_SERVICE, |
| 3278 | //@hide: NETWORK_SCORE_SERVICE, |
| 3279 | USAGE_STATS_SERVICE, |
RoboErik | 01fe661 | 2014-02-13 14:19:04 -0800 | [diff] [blame] | 3280 | MEDIA_SESSION_SERVICE, |
Todd Poynor | e35872d | 2013-12-10 11:57:21 -0800 | [diff] [blame] | 3281 | BATTERY_SERVICE, |
Christopher Tate | 7060b04 | 2014-06-09 19:50:00 -0700 | [diff] [blame] | 3282 | JOB_SCHEDULER_SERVICE, |
Tor Norbye | bf44ce2 | 2015-02-12 11:47:32 -0800 | [diff] [blame] | 3283 | //@hide: PERSISTENT_DATA_BLOCK_SERVICE, |
Andrew Scull | 3b8b46f | 2017-02-13 18:12:15 +0000 | [diff] [blame] | 3284 | //@hide: OEM_LOCK_SERVICE, |
Michael Wright | 446e019 | 2014-12-22 09:38:43 -0800 | [diff] [blame] | 3285 | MEDIA_PROJECTION_SERVICE, |
Mike Lockwood | 67f8e8b | 2014-12-01 13:54:59 -0800 | [diff] [blame] | 3286 | MIDI_SERVICE, |
Eric Laurent | 2035ac8 | 2015-03-05 15:18:44 -0800 | [diff] [blame] | 3287 | RADIO_SERVICE, |
Polina Bondarenko | 965ecbb | 2015-11-13 15:34:28 +0100 | [diff] [blame] | 3288 | HARDWARE_PROPERTIES_SERVICE, |
Arunesh Mishra | a772e5f | 2016-01-25 10:33:11 -0800 | [diff] [blame] | 3289 | //@hide: SOUND_TRIGGER_SERVICE, |
Makoto Onuki | 6f7362d9 | 2016-03-04 13:39:41 -0800 | [diff] [blame] | 3290 | SHORTCUT_SERVICE, |
Peng Xu | 9ff7d22 | 2016-02-11 13:02:05 -0800 | [diff] [blame] | 3291 | //@hide: CONTEXTHUB_SERVICE, |
Joe Onorato | 1754d74 | 2016-11-21 17:51:35 -0800 | [diff] [blame] | 3292 | SYSTEM_HEALTH_SERVICE, |
Tor Norbye | 8246c07 | 2017-07-07 10:21:09 -0700 | [diff] [blame] | 3293 | //@hide: INCIDENT_SERVICE, |
Joe Onorato | e21ab7e | 2018-12-18 15:00:25 -0800 | [diff] [blame] | 3294 | //@hide: INCIDENT_COMPANION_SERVICE, |
Bookatz | 9472641 | 2017-08-31 09:26:15 -0700 | [diff] [blame] | 3295 | //@hide: STATS_COMPANION_SERVICE, |
Tony Mak | 9240c7f | 2017-12-29 11:02:02 +0000 | [diff] [blame] | 3296 | COMPANION_DEVICE_SERVICE, |
Tao Bao | 07342dc | 2017-01-24 15:08:21 -0800 | [diff] [blame] | 3297 | CROSS_PROFILE_APPS_SERVICE, |
| 3298 | //@hide: SYSTEM_UPDATE_SERVICE, |
Neil Fuller | feeee68 | 2018-05-30 14:35:24 +0100 | [diff] [blame] | 3299 | //@hide: TIME_DETECTOR_SERVICE, |
Philip P. Moltmann | 039678e | 2018-09-18 13:04:38 -0700 | [diff] [blame] | 3300 | PERMISSION_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3301 | }) |
| 3302 | @Retention(RetentionPolicy.SOURCE) |
| 3303 | public @interface ServiceName {} |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3304 | |
| 3305 | /** |
| 3306 | * Return the handle to a system-level service by name. The class of the |
| 3307 | * returned object varies by the requested name. Currently available names |
| 3308 | * are: |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3309 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3310 | * <dl> |
| 3311 | * <dt> {@link #WINDOW_SERVICE} ("window") |
| 3312 | * <dd> The top-level window manager in which you can place custom |
| 3313 | * windows. The returned object is a {@link android.view.WindowManager}. |
| 3314 | * <dt> {@link #LAYOUT_INFLATER_SERVICE} ("layout_inflater") |
| 3315 | * <dd> A {@link android.view.LayoutInflater} for inflating layout resources |
| 3316 | * in this context. |
| 3317 | * <dt> {@link #ACTIVITY_SERVICE} ("activity") |
| 3318 | * <dd> A {@link android.app.ActivityManager} for interacting with the |
| 3319 | * global activity state of the system. |
| 3320 | * <dt> {@link #POWER_SERVICE} ("power") |
| 3321 | * <dd> A {@link android.os.PowerManager} for controlling power |
| 3322 | * management. |
| 3323 | * <dt> {@link #ALARM_SERVICE} ("alarm") |
| 3324 | * <dd> A {@link android.app.AlarmManager} for receiving intents at the |
| 3325 | * time of your choosing. |
| 3326 | * <dt> {@link #NOTIFICATION_SERVICE} ("notification") |
| 3327 | * <dd> A {@link android.app.NotificationManager} for informing the user |
| 3328 | * of background events. |
| 3329 | * <dt> {@link #KEYGUARD_SERVICE} ("keyguard") |
| 3330 | * <dd> A {@link android.app.KeyguardManager} for controlling keyguard. |
| 3331 | * <dt> {@link #LOCATION_SERVICE} ("location") |
| 3332 | * <dd> A {@link android.location.LocationManager} for controlling location |
| 3333 | * (e.g., GPS) updates. |
| 3334 | * <dt> {@link #SEARCH_SERVICE} ("search") |
| 3335 | * <dd> A {@link android.app.SearchManager} for handling search. |
| 3336 | * <dt> {@link #VIBRATOR_SERVICE} ("vibrator") |
| 3337 | * <dd> A {@link android.os.Vibrator} for interacting with the vibrator |
| 3338 | * hardware. |
| 3339 | * <dt> {@link #CONNECTIVITY_SERVICE} ("connection") |
| 3340 | * <dd> A {@link android.net.ConnectivityManager ConnectivityManager} for |
| 3341 | * handling management of network connections. |
Nathan Harold | d999d22 | 2017-09-11 19:53:33 -0700 | [diff] [blame] | 3342 | * <dt> {@link #IPSEC_SERVICE} ("ipsec") |
| 3343 | * <dd> A {@link android.net.IpSecManager IpSecManager} for managing IPSec on |
| 3344 | * sockets and networks. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3345 | * <dt> {@link #WIFI_SERVICE} ("wifi") |
Paul Stewart | 0e164b1 | 2016-08-08 10:20:13 -0700 | [diff] [blame] | 3346 | * <dd> A {@link android.net.wifi.WifiManager WifiManager} for management of Wi-Fi |
| 3347 | * connectivity. On releases before NYC, it should only be obtained from an application |
| 3348 | * context, and not from any other derived context to avoid memory leaks within the calling |
| 3349 | * process. |
Etan Cohen | 6a4b323 | 2017-01-09 21:47:32 -0800 | [diff] [blame] | 3350 | * <dt> {@link #WIFI_AWARE_SERVICE} ("wifiaware") |
| 3351 | * <dd> A {@link android.net.wifi.aware.WifiAwareManager WifiAwareManager} for management of |
| 3352 | * Wi-Fi Aware discovery and connectivity. |
Vinit Deshapnde | 011e1b3 | 2014-05-07 21:09:11 -0700 | [diff] [blame] | 3353 | * <dt> {@link #WIFI_P2P_SERVICE} ("wifip2p") |
| 3354 | * <dd> A {@link android.net.wifi.p2p.WifiP2pManager WifiP2pManager} for management of |
| 3355 | * Wi-Fi Direct connectivity. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3356 | * <dt> {@link #INPUT_METHOD_SERVICE} ("input_method") |
| 3357 | * <dd> An {@link android.view.inputmethod.InputMethodManager InputMethodManager} |
| 3358 | * for management of input methods. |
Tobias Haamel | 5333288 | 2010-02-18 16:15:43 -0800 | [diff] [blame] | 3359 | * <dt> {@link #UI_MODE_SERVICE} ("uimode") |
| 3360 | * <dd> An {@link android.app.UiModeManager} for controlling UI modes. |
Steve Howard | 7083c42 | 2010-07-28 16:01:23 -0700 | [diff] [blame] | 3361 | * <dt> {@link #DOWNLOAD_SERVICE} ("download") |
Steve Howard | d58429f | 2010-09-27 16:32:39 -0700 | [diff] [blame] | 3362 | * <dd> A {@link android.app.DownloadManager} for requesting HTTP downloads |
Todd Poynor | e35872d | 2013-12-10 11:57:21 -0800 | [diff] [blame] | 3363 | * <dt> {@link #BATTERY_SERVICE} ("batterymanager") |
Todd Poynor | 99f7e12 | 2014-04-15 16:03:42 -0700 | [diff] [blame] | 3364 | * <dd> A {@link android.os.BatteryManager} for managing battery state |
Christopher Tate | 7060b04 | 2014-06-09 19:50:00 -0700 | [diff] [blame] | 3365 | * <dt> {@link #JOB_SCHEDULER_SERVICE} ("taskmanager") |
| 3366 | * <dd> A {@link android.app.job.JobScheduler} for managing scheduled tasks |
Zoltan Szatmary-Ban | 9c5dfa5 | 2015-02-23 17:20:20 +0000 | [diff] [blame] | 3367 | * <dt> {@link #NETWORK_STATS_SERVICE} ("netstats") |
| 3368 | * <dd> A {@link android.app.usage.NetworkStatsManager NetworkStatsManager} for querying network |
| 3369 | * usage statistics. |
Polina Bondarenko | 8333c73 | 2016-03-09 18:08:42 +0100 | [diff] [blame] | 3370 | * <dt> {@link #HARDWARE_PROPERTIES_SERVICE} ("hardware_properties") |
Polina Bondarenko | 965ecbb | 2015-11-13 15:34:28 +0100 | [diff] [blame] | 3371 | * <dd> A {@link android.os.HardwarePropertiesManager} for accessing hardware properties. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3372 | * </dl> |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3373 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3374 | * <p>Note: System services obtained via this API may be closely associated with |
| 3375 | * the Context in which they are obtained from. In general, do not share the |
| 3376 | * service objects between various different contexts (Activities, Applications, |
| 3377 | * Services, Providers, etc.) |
| 3378 | * |
Svet Ganov | 8f90bcc | 2017-12-22 23:29:24 -0800 | [diff] [blame] | 3379 | * <p>Note: Instant apps, for which {@link PackageManager#isInstantApp()} returns true, |
| 3380 | * don't have access to the following system services: {@link #DEVICE_POLICY_SERVICE}, |
Donald Chai | ee4c91c | 2018-09-19 14:42:41 -0700 | [diff] [blame] | 3381 | * {@link #FINGERPRINT_SERVICE}, {@link #KEYGUARD_SERVICE}, {@link #SHORTCUT_SERVICE}, |
| 3382 | * {@link #USB_SERVICE}, {@link #WALLPAPER_SERVICE}, {@link #WIFI_P2P_SERVICE}, |
| 3383 | * {@link #WIFI_SERVICE}, {@link #WIFI_AWARE_SERVICE}. For these services this method will |
| 3384 | * return <code>null</code>. Generally, if you are running as an instant app you should always |
Felipe Leme | 4685b86 | 2019-03-06 10:32:33 -0800 | [diff] [blame] | 3385 | * check whether the result of this method is {@code null}. |
| 3386 | * |
| 3387 | * <p>Note: When implementing this method, keep in mind that new services can be added on newer |
| 3388 | * Android releases, so if you're looking for just the explicit names mentioned above, make sure |
| 3389 | * to return {@code null} when you don't recognize the name — if you throw a |
| 3390 | * {@link RuntimeException} exception instead, you're app might break on new Android releases. |
Svet Ganov | 8f90bcc | 2017-12-22 23:29:24 -0800 | [diff] [blame] | 3391 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3392 | * @param name The name of the desired service. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3393 | * |
Felipe Leme | 4685b86 | 2019-03-06 10:32:33 -0800 | [diff] [blame] | 3394 | * @return The service or {@code null} if the name does not exist. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3395 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3396 | * @see #WINDOW_SERVICE |
| 3397 | * @see android.view.WindowManager |
| 3398 | * @see #LAYOUT_INFLATER_SERVICE |
| 3399 | * @see android.view.LayoutInflater |
| 3400 | * @see #ACTIVITY_SERVICE |
| 3401 | * @see android.app.ActivityManager |
| 3402 | * @see #POWER_SERVICE |
| 3403 | * @see android.os.PowerManager |
| 3404 | * @see #ALARM_SERVICE |
| 3405 | * @see android.app.AlarmManager |
| 3406 | * @see #NOTIFICATION_SERVICE |
| 3407 | * @see android.app.NotificationManager |
| 3408 | * @see #KEYGUARD_SERVICE |
| 3409 | * @see android.app.KeyguardManager |
| 3410 | * @see #LOCATION_SERVICE |
| 3411 | * @see android.location.LocationManager |
| 3412 | * @see #SEARCH_SERVICE |
| 3413 | * @see android.app.SearchManager |
| 3414 | * @see #SENSOR_SERVICE |
| 3415 | * @see android.hardware.SensorManager |
San Mehat | c9d8175 | 2010-02-01 10:23:27 -0800 | [diff] [blame] | 3416 | * @see #STORAGE_SERVICE |
San Mehat | b104340 | 2010-02-05 08:26:50 -0800 | [diff] [blame] | 3417 | * @see android.os.storage.StorageManager |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3418 | * @see #VIBRATOR_SERVICE |
| 3419 | * @see android.os.Vibrator |
| 3420 | * @see #CONNECTIVITY_SERVICE |
| 3421 | * @see android.net.ConnectivityManager |
| 3422 | * @see #WIFI_SERVICE |
| 3423 | * @see android.net.wifi.WifiManager |
| 3424 | * @see #AUDIO_SERVICE |
| 3425 | * @see android.media.AudioManager |
Dianne Hackborn | b58b8f8 | 2012-06-11 15:08:39 -0700 | [diff] [blame] | 3426 | * @see #MEDIA_ROUTER_SERVICE |
| 3427 | * @see android.media.MediaRouter |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3428 | * @see #TELEPHONY_SERVICE |
| 3429 | * @see android.telephony.TelephonyManager |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 3430 | * @see #TELEPHONY_SUBSCRIPTION_SERVICE |
| 3431 | * @see android.telephony.SubscriptionManager |
Jonathan Basseri | 9a1c9b6 | 2015-02-25 13:01:52 -0800 | [diff] [blame] | 3432 | * @see #CARRIER_CONFIG_SERVICE |
| 3433 | * @see android.telephony.CarrierConfigManager |
hyunhae.lee | 75fdafa | 2019-07-19 22:08:41 +0900 | [diff] [blame] | 3434 | * @see #EUICC_SERVICE |
| 3435 | * @see android.telephony.euicc.EuiccManager |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3436 | * @see #INPUT_METHOD_SERVICE |
| 3437 | * @see android.view.inputmethod.InputMethodManager |
Tobias Haamel | 5333288 | 2010-02-18 16:15:43 -0800 | [diff] [blame] | 3438 | * @see #UI_MODE_SERVICE |
| 3439 | * @see android.app.UiModeManager |
Steve Howard | 7083c42 | 2010-07-28 16:01:23 -0700 | [diff] [blame] | 3440 | * @see #DOWNLOAD_SERVICE |
Steve Howard | d58429f | 2010-09-27 16:32:39 -0700 | [diff] [blame] | 3441 | * @see android.app.DownloadManager |
Todd Poynor | e35872d | 2013-12-10 11:57:21 -0800 | [diff] [blame] | 3442 | * @see #BATTERY_SERVICE |
| 3443 | * @see android.os.BatteryManager |
Christopher Tate | 7060b04 | 2014-06-09 19:50:00 -0700 | [diff] [blame] | 3444 | * @see #JOB_SCHEDULER_SERVICE |
| 3445 | * @see android.app.job.JobScheduler |
Zoltan Szatmary-Ban | 9c5dfa5 | 2015-02-23 17:20:20 +0000 | [diff] [blame] | 3446 | * @see #NETWORK_STATS_SERVICE |
| 3447 | * @see android.app.usage.NetworkStatsManager |
Polina Bondarenko | 965ecbb | 2015-11-13 15:34:28 +0100 | [diff] [blame] | 3448 | * @see android.os.HardwarePropertiesManager |
| 3449 | * @see #HARDWARE_PROPERTIES_SERVICE |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3450 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 3451 | public abstract @Nullable Object getSystemService(@ServiceName @NonNull String name); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3452 | |
| 3453 | /** |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 3454 | * Return the handle to a system-level service by class. |
| 3455 | * <p> |
| 3456 | * Currently available classes are: |
| 3457 | * {@link android.view.WindowManager}, {@link android.view.LayoutInflater}, |
| 3458 | * {@link android.app.ActivityManager}, {@link android.os.PowerManager}, |
| 3459 | * {@link android.app.AlarmManager}, {@link android.app.NotificationManager}, |
| 3460 | * {@link android.app.KeyguardManager}, {@link android.location.LocationManager}, |
| 3461 | * {@link android.app.SearchManager}, {@link android.os.Vibrator}, |
| 3462 | * {@link android.net.ConnectivityManager}, |
| 3463 | * {@link android.net.wifi.WifiManager}, |
| 3464 | * {@link android.media.AudioManager}, {@link android.media.MediaRouter}, |
| 3465 | * {@link android.telephony.TelephonyManager}, {@link android.telephony.SubscriptionManager}, |
| 3466 | * {@link android.view.inputmethod.InputMethodManager}, |
| 3467 | * {@link android.app.UiModeManager}, {@link android.app.DownloadManager}, |
Zoltan Szatmary-Ban | 9c5dfa5 | 2015-02-23 17:20:20 +0000 | [diff] [blame] | 3468 | * {@link android.os.BatteryManager}, {@link android.app.job.JobScheduler}, |
| 3469 | * {@link android.app.usage.NetworkStatsManager}. |
Felipe Leme | 4685b86 | 2019-03-06 10:32:33 -0800 | [diff] [blame] | 3470 | * </p> |
| 3471 | * |
| 3472 | * <p> |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 3473 | * Note: System services obtained via this API may be closely associated with |
| 3474 | * the Context in which they are obtained from. In general, do not share the |
| 3475 | * service objects between various different contexts (Activities, Applications, |
| 3476 | * Services, Providers, etc.) |
| 3477 | * </p> |
| 3478 | * |
Svet Ganov | 8f90bcc | 2017-12-22 23:29:24 -0800 | [diff] [blame] | 3479 | * <p>Note: Instant apps, for which {@link PackageManager#isInstantApp()} returns true, |
| 3480 | * don't have access to the following system services: {@link #DEVICE_POLICY_SERVICE}, |
Donald Chai | ee4c91c | 2018-09-19 14:42:41 -0700 | [diff] [blame] | 3481 | * {@link #FINGERPRINT_SERVICE}, {@link #KEYGUARD_SERVICE}, {@link #SHORTCUT_SERVICE}, |
| 3482 | * {@link #USB_SERVICE}, {@link #WALLPAPER_SERVICE}, {@link #WIFI_P2P_SERVICE}, |
| 3483 | * {@link #WIFI_SERVICE}, {@link #WIFI_AWARE_SERVICE}. For these services this method will |
Felipe Leme | 4685b86 | 2019-03-06 10:32:33 -0800 | [diff] [blame] | 3484 | * return {@code null}. Generally, if you are running as an instant app you should always |
| 3485 | * check whether the result of this method is {@code null}. |
| 3486 | * </p> |
Svet Ganov | 8f90bcc | 2017-12-22 23:29:24 -0800 | [diff] [blame] | 3487 | * |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 3488 | * @param serviceClass The class of the desired service. |
Felipe Leme | 4685b86 | 2019-03-06 10:32:33 -0800 | [diff] [blame] | 3489 | * @return The service or {@code null} if the class is not a supported system service. Note: |
| 3490 | * <b>never</b> throw a {@link RuntimeException} if the name is not supported. |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 3491 | */ |
| 3492 | @SuppressWarnings("unchecked") |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 3493 | public final @Nullable <T> T getSystemService(@NonNull Class<T> serviceClass) { |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 3494 | // Because subclasses may override getSystemService(String) we cannot |
| 3495 | // perform a lookup by class alone. We must first map the class to its |
| 3496 | // service name then invoke the string-based method. |
| 3497 | String serviceName = getSystemServiceName(serviceClass); |
| 3498 | return serviceName != null ? (T)getSystemService(serviceName) : null; |
| 3499 | } |
| 3500 | |
| 3501 | /** |
| 3502 | * Gets the name of the system-level service that is represented by the specified class. |
| 3503 | * |
| 3504 | * @param serviceClass The class of the desired service. |
| 3505 | * @return The service name or null if the class is not a supported system service. |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 3506 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 3507 | public abstract @Nullable String getSystemServiceName(@NonNull Class<?> serviceClass); |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 3508 | |
| 3509 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3510 | * Use with {@link #getSystemService(String)} to retrieve a |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3511 | * {@link android.os.PowerManager} for controlling power management, |
| 3512 | * including "wake locks," which let you keep the device on while |
| 3513 | * you're running long tasks. |
| 3514 | */ |
| 3515 | public static final String POWER_SERVICE = "power"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3516 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3517 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3518 | * Use with {@link #getSystemService(String)} to retrieve a |
Tao Bao | e8a403d | 2015-12-31 07:44:55 -0800 | [diff] [blame] | 3519 | * {@link android.os.RecoverySystem} for accessing the recovery system |
| 3520 | * service. |
| 3521 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3522 | * @see #getSystemService(String) |
Tao Bao | e8a403d | 2015-12-31 07:44:55 -0800 | [diff] [blame] | 3523 | * @hide |
| 3524 | */ |
| 3525 | public static final String RECOVERY_SERVICE = "recovery"; |
| 3526 | |
| 3527 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3528 | * Use with {@link #getSystemService(String)} to retrieve a |
Tao Bao | 07342dc | 2017-01-24 15:08:21 -0800 | [diff] [blame] | 3529 | * {@link android.os.SystemUpdateManager} for accessing the system update |
| 3530 | * manager service. |
| 3531 | * |
| 3532 | * @see #getSystemService(String) |
| 3533 | * @hide |
| 3534 | */ |
| 3535 | @SystemApi |
| 3536 | public static final String SYSTEM_UPDATE_SERVICE = "system_update"; |
| 3537 | |
| 3538 | /** |
| 3539 | * Use with {@link #getSystemService(String)} to retrieve a |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3540 | * {@link android.view.WindowManager} for accessing the system's window |
| 3541 | * manager. |
| 3542 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3543 | * @see #getSystemService(String) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3544 | * @see android.view.WindowManager |
| 3545 | */ |
| 3546 | public static final String WINDOW_SERVICE = "window"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3547 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3548 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3549 | * Use with {@link #getSystemService(String)} to retrieve a |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3550 | * {@link android.view.LayoutInflater} for inflating layout resources in this |
| 3551 | * context. |
| 3552 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3553 | * @see #getSystemService(String) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3554 | * @see android.view.LayoutInflater |
| 3555 | */ |
| 3556 | public static final String LAYOUT_INFLATER_SERVICE = "layout_inflater"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3557 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3558 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3559 | * Use with {@link #getSystemService(String)} to retrieve a |
Fred Quintana | 6030734 | 2009-03-24 22:48:12 -0700 | [diff] [blame] | 3560 | * {@link android.accounts.AccountManager} for receiving intents at a |
| 3561 | * time of your choosing. |
Fred Quintana | 6030734 | 2009-03-24 22:48:12 -0700 | [diff] [blame] | 3562 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3563 | * @see #getSystemService(String) |
Fred Quintana | 6030734 | 2009-03-24 22:48:12 -0700 | [diff] [blame] | 3564 | * @see android.accounts.AccountManager |
| 3565 | */ |
| 3566 | public static final String ACCOUNT_SERVICE = "account"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3567 | |
Fred Quintana | 6030734 | 2009-03-24 22:48:12 -0700 | [diff] [blame] | 3568 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3569 | * Use with {@link #getSystemService(String)} to retrieve a |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3570 | * {@link android.app.ActivityManager} for interacting with the global |
| 3571 | * system state. |
| 3572 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3573 | * @see #getSystemService(String) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3574 | * @see android.app.ActivityManager |
| 3575 | */ |
| 3576 | public static final String ACTIVITY_SERVICE = "activity"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3577 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3578 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3579 | * Use with {@link #getSystemService(String)} to retrieve a |
Wale Ogunwale | 65ebd95 | 2018-04-25 15:41:44 -0700 | [diff] [blame] | 3580 | * {@link android.app.ActivityTaskManager} for interacting with the global system state. |
| 3581 | * |
| 3582 | * @see #getSystemService(String) |
| 3583 | * @see android.app.ActivityTaskManager |
| 3584 | * @hide |
| 3585 | */ |
| 3586 | public static final String ACTIVITY_TASK_SERVICE = "activity_task"; |
| 3587 | |
| 3588 | /** |
| 3589 | * Use with {@link #getSystemService(String)} to retrieve a |
Wale Ogunwale | 6d50dcc | 2018-07-21 23:00:40 -0700 | [diff] [blame] | 3590 | * {@link android.app.UriGrantsManager} for interacting with the global system state. |
| 3591 | * |
| 3592 | * @see #getSystemService(String) |
| 3593 | * @see android.app.UriGrantsManager |
| 3594 | * @hide |
| 3595 | */ |
| 3596 | public static final String URI_GRANTS_SERVICE = "uri_grants"; |
| 3597 | |
| 3598 | /** |
| 3599 | * Use with {@link #getSystemService(String)} to retrieve a |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3600 | * {@link android.app.AlarmManager} for receiving intents at a |
| 3601 | * time of your choosing. |
| 3602 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3603 | * @see #getSystemService(String) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3604 | * @see android.app.AlarmManager |
| 3605 | */ |
| 3606 | public static final String ALARM_SERVICE = "alarm"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3607 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3608 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3609 | * Use with {@link #getSystemService(String)} to retrieve a |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3610 | * {@link android.app.NotificationManager} for informing the user of |
| 3611 | * background events. |
| 3612 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3613 | * @see #getSystemService(String) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3614 | * @see android.app.NotificationManager |
| 3615 | */ |
| 3616 | public static final String NOTIFICATION_SERVICE = "notification"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3617 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3618 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3619 | * Use with {@link #getSystemService(String)} to retrieve a |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 3620 | * {@link android.view.accessibility.AccessibilityManager} for giving the user |
| 3621 | * feedback for UI events through the registered event listeners. |
| 3622 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3623 | * @see #getSystemService(String) |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 3624 | * @see android.view.accessibility.AccessibilityManager |
| 3625 | */ |
| 3626 | public static final String ACCESSIBILITY_SERVICE = "accessibility"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3627 | |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 3628 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3629 | * Use with {@link #getSystemService(String)} to retrieve a |
Alan Viverette | 69ce69b | 2013-08-29 12:23:48 -0700 | [diff] [blame] | 3630 | * {@link android.view.accessibility.CaptioningManager} for obtaining |
| 3631 | * captioning properties and listening for changes in captioning |
| 3632 | * preferences. |
| 3633 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3634 | * @see #getSystemService(String) |
Alan Viverette | 69ce69b | 2013-08-29 12:23:48 -0700 | [diff] [blame] | 3635 | * @see android.view.accessibility.CaptioningManager |
| 3636 | */ |
| 3637 | public static final String CAPTIONING_SERVICE = "captioning"; |
| 3638 | |
| 3639 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3640 | * Use with {@link #getSystemService(String)} to retrieve a |
kopriva | 5495dbb | 2018-09-13 14:18:34 -0700 | [diff] [blame] | 3641 | * {@link android.app.KeyguardManager} for controlling keyguard. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3642 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3643 | * @see #getSystemService(String) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3644 | * @see android.app.KeyguardManager |
| 3645 | */ |
| 3646 | public static final String KEYGUARD_SERVICE = "keyguard"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3647 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3648 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3649 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3650 | * android.location.LocationManager} for controlling location |
| 3651 | * updates. |
| 3652 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3653 | * @see #getSystemService(String) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3654 | * @see android.location.LocationManager |
| 3655 | */ |
| 3656 | public static final String LOCATION_SERVICE = "location"; |
Bai Tao | a58a875 | 2010-07-13 15:32:16 +0800 | [diff] [blame] | 3657 | |
| 3658 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3659 | * Use with {@link #getSystemService(String)} to retrieve a |
Bai Tao | a58a875 | 2010-07-13 15:32:16 +0800 | [diff] [blame] | 3660 | * {@link android.location.CountryDetector} for detecting the country that |
| 3661 | * the user is in. |
| 3662 | * |
| 3663 | * @hide |
| 3664 | */ |
Mathew Inwood | 8c854f8 | 2018-09-14 12:35:36 +0100 | [diff] [blame] | 3665 | @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023) |
Bai Tao | a58a875 | 2010-07-13 15:32:16 +0800 | [diff] [blame] | 3666 | public static final String COUNTRY_DETECTOR = "country_detector"; |
| 3667 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3668 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3669 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3670 | * android.app.SearchManager} for handling searches. |
| 3671 | * |
Erik Wolsheimer | ac5cecd | 2017-12-05 13:11:50 -0800 | [diff] [blame] | 3672 | * <p> |
| 3673 | * {@link Configuration#UI_MODE_TYPE_WATCH} does not support |
| 3674 | * {@link android.app.SearchManager}. |
| 3675 | * |
| 3676 | * @see #getSystemService |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3677 | * @see android.app.SearchManager |
| 3678 | */ |
| 3679 | public static final String SEARCH_SERVICE = "search"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3680 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3681 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3682 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3683 | * android.hardware.SensorManager} for accessing sensors. |
| 3684 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3685 | * @see #getSystemService(String) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3686 | * @see android.hardware.SensorManager |
| 3687 | */ |
| 3688 | public static final String SENSOR_SERVICE = "sensor"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3689 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3690 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3691 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Chad Brubaker | 90f391f | 2018-10-19 10:26:19 -0700 | [diff] [blame] | 3692 | * android.hardware.SensorPrivacyManager} for accessing sensor privacy |
| 3693 | * functions. |
| 3694 | * |
| 3695 | * @see #getSystemService(String) |
| 3696 | * @see android.hardware.SensorPrivacyManager |
| 3697 | * |
| 3698 | * @hide |
| 3699 | */ |
| 3700 | public static final String SENSOR_PRIVACY_SERVICE = "sensor_privacy"; |
| 3701 | |
| 3702 | /** |
| 3703 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Kenny Root | 02c8730 | 2010-07-01 08:10:18 -0700 | [diff] [blame] | 3704 | * android.os.storage.StorageManager} for accessing system storage |
San Mehat | c9d8175 | 2010-02-01 10:23:27 -0800 | [diff] [blame] | 3705 | * functions. |
| 3706 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3707 | * @see #getSystemService(String) |
San Mehat | b104340 | 2010-02-05 08:26:50 -0800 | [diff] [blame] | 3708 | * @see android.os.storage.StorageManager |
San Mehat | c9d8175 | 2010-02-01 10:23:27 -0800 | [diff] [blame] | 3709 | */ |
| 3710 | public static final String STORAGE_SERVICE = "storage"; |
| 3711 | |
| 3712 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3713 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Jeff Sharkey | e8cece9 | 2017-01-04 11:33:33 -0700 | [diff] [blame] | 3714 | * android.app.usage.StorageStatsManager} for accessing system storage |
| 3715 | * statistics. |
| 3716 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3717 | * @see #getSystemService(String) |
Jeff Sharkey | e8cece9 | 2017-01-04 11:33:33 -0700 | [diff] [blame] | 3718 | * @see android.app.usage.StorageStatsManager |
| 3719 | */ |
| 3720 | public static final String STORAGE_STATS_SERVICE = "storagestats"; |
| 3721 | |
| 3722 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3723 | * Use with {@link #getSystemService(String)} to retrieve a |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3724 | * com.android.server.WallpaperService for accessing wallpapers. |
| 3725 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3726 | * @see #getSystemService(String) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3727 | */ |
| 3728 | public static final String WALLPAPER_SERVICE = "wallpaper"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3729 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3730 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3731 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3732 | * android.os.Vibrator} for interacting with the vibration hardware. |
| 3733 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3734 | * @see #getSystemService(String) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3735 | * @see android.os.Vibrator |
| 3736 | */ |
| 3737 | public static final String VIBRATOR_SERVICE = "vibrator"; |
Robert Greenwalt | 9e696c2 | 2010-04-01 14:45:18 -0700 | [diff] [blame] | 3738 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3739 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3740 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3741 | * android.app.StatusBarManager} for interacting with the status bar. |
| 3742 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3743 | * @see #getSystemService(String) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3744 | * @see android.app.StatusBarManager |
Evan Laird | edd016f | 2019-01-23 18:36:29 -0500 | [diff] [blame] | 3745 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3746 | * @hide |
| 3747 | */ |
Evan Laird | edd016f | 2019-01-23 18:36:29 -0500 | [diff] [blame] | 3748 | @SystemApi |
Evan Laird | 418ba8f | 2019-04-17 15:55:21 -0400 | [diff] [blame] | 3749 | @TestApi |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3750 | public static final String STATUS_BAR_SERVICE = "statusbar"; |
| 3751 | |
| 3752 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3753 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3754 | * android.net.ConnectivityManager} for handling management of |
| 3755 | * network connections. |
| 3756 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3757 | * @see #getSystemService(String) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3758 | * @see android.net.ConnectivityManager |
| 3759 | */ |
| 3760 | public static final String CONNECTIVITY_SERVICE = "connectivity"; |
| 3761 | |
| 3762 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3763 | * Use with {@link #getSystemService(String)} to retrieve a |
Remi NGUYEN VAN | 3193598 | 2019-01-28 11:40:08 +0900 | [diff] [blame] | 3764 | * {@link android.net.INetd} for communicating with the network stack |
| 3765 | * @hide |
| 3766 | * @see #getSystemService(String) |
| 3767 | * @hide |
| 3768 | */ |
| 3769 | @SystemApi |
| 3770 | public static final String NETD_SERVICE = "netd"; |
| 3771 | |
| 3772 | /** |
Remi NGUYEN VAN | 310da6f | 2019-02-14 18:04:20 +0900 | [diff] [blame] | 3773 | * Use with {@link android.os.ServiceManager.getService()} to retrieve a |
| 3774 | * {@link NetworkStackClient} IBinder for communicating with the network stack |
Remi NGUYEN VAN | c094a54 | 2018-12-07 16:52:24 +0900 | [diff] [blame] | 3775 | * @hide |
Remi NGUYEN VAN | 310da6f | 2019-02-14 18:04:20 +0900 | [diff] [blame] | 3776 | * @see NetworkStackClient |
Remi NGUYEN VAN | c094a54 | 2018-12-07 16:52:24 +0900 | [diff] [blame] | 3777 | */ |
| 3778 | public static final String NETWORK_STACK_SERVICE = "network_stack"; |
| 3779 | |
| 3780 | /** |
| 3781 | * Use with {@link #getSystemService(String)} to retrieve a |
Nathan Harold | 330e108 | 2017-01-12 18:38:57 -0800 | [diff] [blame] | 3782 | * {@link android.net.IpSecManager} for encrypting Sockets or Networks with |
| 3783 | * IPSec. |
| 3784 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3785 | * @see #getSystemService(String) |
Nathan Harold | 330e108 | 2017-01-12 18:38:57 -0800 | [diff] [blame] | 3786 | */ |
| 3787 | public static final String IPSEC_SERVICE = "ipsec"; |
| 3788 | |
| 3789 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3790 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Benedict Wong | 99a4841 | 2018-11-09 14:45:34 -0800 | [diff] [blame] | 3791 | * android.net.TestNetworkManager} for building TUNs and limited-use Networks |
| 3792 | * |
| 3793 | * @see #getSystemService(String) |
| 3794 | * @hide |
| 3795 | */ |
| 3796 | @TestApi public static final String TEST_NETWORK_SERVICE = "test_network"; |
| 3797 | |
| 3798 | /** |
| 3799 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Christopher Tate | 8662cab5 | 2012-02-23 14:59:36 -0800 | [diff] [blame] | 3800 | * android.os.IUpdateLock} for managing runtime sequences that |
| 3801 | * must not be interrupted by headless OTA application or similar. |
| 3802 | * |
| 3803 | * @hide |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3804 | * @see #getSystemService(String) |
Christopher Tate | 8662cab5 | 2012-02-23 14:59:36 -0800 | [diff] [blame] | 3805 | * @see android.os.UpdateLock |
| 3806 | */ |
| 3807 | public static final String UPDATE_LOCK_SERVICE = "updatelock"; |
| 3808 | |
| 3809 | /** |
Dianne Hackborn | 35f72be | 2013-09-16 10:57:39 -0700 | [diff] [blame] | 3810 | * Constant for the internal network management service, not really a Context service. |
Dianne Hackborn | 0a6a80f | 2013-09-16 15:20:27 -0700 | [diff] [blame] | 3811 | * @hide |
San Mehat | d1df8ac | 2010-01-26 06:17:26 -0800 | [diff] [blame] | 3812 | */ |
| 3813 | public static final String NETWORKMANAGEMENT_SERVICE = "network_management"; |
| 3814 | |
Zoltan Szatmary-Ban | 9c5dfa5 | 2015-02-23 17:20:20 +0000 | [diff] [blame] | 3815 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3816 | * Use with {@link #getSystemService(String)} to retrieve a |
Jason Monk | 8f5f7ff | 2017-10-17 14:12:42 -0400 | [diff] [blame] | 3817 | * {@link com.android.server.slice.SliceManagerService} for managing slices. |
| 3818 | * @hide |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3819 | * @see #getSystemService(String) |
Jason Monk | 8f5f7ff | 2017-10-17 14:12:42 -0400 | [diff] [blame] | 3820 | */ |
| 3821 | public static final String SLICE_SERVICE = "slice"; |
| 3822 | |
| 3823 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3824 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Zoltan Szatmary-Ban | 9c5dfa5 | 2015-02-23 17:20:20 +0000 | [diff] [blame] | 3825 | * android.app.usage.NetworkStatsManager} for querying network usage stats. |
| 3826 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3827 | * @see #getSystemService(String) |
Zoltan Szatmary-Ban | 9c5dfa5 | 2015-02-23 17:20:20 +0000 | [diff] [blame] | 3828 | * @see android.app.usage.NetworkStatsManager |
| 3829 | */ |
Jeff Sharkey | 7527990 | 2011-05-24 18:39:45 -0700 | [diff] [blame] | 3830 | public static final String NETWORK_STATS_SERVICE = "netstats"; |
| 3831 | /** {@hide} */ |
Jeff Sharkey | eedcb95 | 2011-05-17 14:55:15 -0700 | [diff] [blame] | 3832 | public static final String NETWORK_POLICY_SERVICE = "netpolicy"; |
Ricky Wai | 1a6e667 | 2017-10-27 14:46:01 +0100 | [diff] [blame] | 3833 | /** {@hide} */ |
| 3834 | public static final String NETWORK_WATCHLIST_SERVICE = "network_watchlist"; |
Jeff Sharkey | eedcb95 | 2011-05-17 14:55:15 -0700 | [diff] [blame] | 3835 | |
San Mehat | d1df8ac | 2010-01-26 06:17:26 -0800 | [diff] [blame] | 3836 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3837 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3838 | * android.net.wifi.WifiManager} for handling management of |
| 3839 | * Wi-Fi access. |
| 3840 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3841 | * @see #getSystemService(String) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3842 | * @see android.net.wifi.WifiManager |
| 3843 | */ |
| 3844 | public static final String WIFI_SERVICE = "wifi"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3845 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3846 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3847 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
repo sync | 55bc5f3 | 2011-06-24 14:23:07 -0700 | [diff] [blame] | 3848 | * android.net.wifi.p2p.WifiP2pManager} for handling management of |
Irfan Sheriff | 651cdfc | 2011-09-07 00:31:20 -0700 | [diff] [blame] | 3849 | * Wi-Fi peer-to-peer connections. |
repo sync | 55bc5f3 | 2011-06-24 14:23:07 -0700 | [diff] [blame] | 3850 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3851 | * @see #getSystemService(String) |
repo sync | 55bc5f3 | 2011-06-24 14:23:07 -0700 | [diff] [blame] | 3852 | * @see android.net.wifi.p2p.WifiP2pManager |
repo sync | 55bc5f3 | 2011-06-24 14:23:07 -0700 | [diff] [blame] | 3853 | */ |
| 3854 | public static final String WIFI_P2P_SERVICE = "wifip2p"; |
| 3855 | |
| 3856 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3857 | * Use with {@link #getSystemService(String)} to retrieve a |
Etan Cohen | 0413327 | 2016-10-26 11:22:06 -0700 | [diff] [blame] | 3858 | * {@link android.net.wifi.aware.WifiAwareManager} for handling management of |
| 3859 | * Wi-Fi Aware. |
Etan Cohen | 20d329b | 2015-09-29 13:49:02 -0700 | [diff] [blame] | 3860 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3861 | * @see #getSystemService(String) |
Etan Cohen | 0413327 | 2016-10-26 11:22:06 -0700 | [diff] [blame] | 3862 | * @see android.net.wifi.aware.WifiAwareManager |
Etan Cohen | 20d329b | 2015-09-29 13:49:02 -0700 | [diff] [blame] | 3863 | */ |
Etan Cohen | 0413327 | 2016-10-26 11:22:06 -0700 | [diff] [blame] | 3864 | public static final String WIFI_AWARE_SERVICE = "wifiaware"; |
Etan Cohen | 20d329b | 2015-09-29 13:49:02 -0700 | [diff] [blame] | 3865 | |
| 3866 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3867 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Vinit Deshapnde | 011e1b3 | 2014-05-07 21:09:11 -0700 | [diff] [blame] | 3868 | * android.net.wifi.WifiScanner} for scanning the wifi universe |
| 3869 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3870 | * @see #getSystemService(String) |
Vinit Deshapnde | 011e1b3 | 2014-05-07 21:09:11 -0700 | [diff] [blame] | 3871 | * @see android.net.wifi.WifiScanner |
| 3872 | * @hide |
| 3873 | */ |
Wei Wang | 35d552f | 2014-07-08 21:37:01 -0700 | [diff] [blame] | 3874 | @SystemApi |
Vinit Deshapnde | 011e1b3 | 2014-05-07 21:09:11 -0700 | [diff] [blame] | 3875 | public static final String WIFI_SCANNING_SERVICE = "wifiscanner"; |
| 3876 | |
| 3877 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3878 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Vinit Deshpande | 7686c06 | 2014-06-30 15:25:01 -0700 | [diff] [blame] | 3879 | * android.net.wifi.RttManager} for ranging devices with wifi |
| 3880 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3881 | * @see #getSystemService(String) |
Vinit Deshpande | 7686c06 | 2014-06-30 15:25:01 -0700 | [diff] [blame] | 3882 | * @see android.net.wifi.RttManager |
| 3883 | * @hide |
| 3884 | */ |
| 3885 | @SystemApi |
Etan Cohen | d0acccd | 2018-01-31 08:36:33 -0800 | [diff] [blame] | 3886 | @Deprecated |
Vinit Deshpande | 7686c06 | 2014-06-30 15:25:01 -0700 | [diff] [blame] | 3887 | public static final String WIFI_RTT_SERVICE = "rttmanager"; |
| 3888 | |
| 3889 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3890 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Etan Cohen | f4062a9 | 2019-04-11 07:00:42 -0700 | [diff] [blame] | 3891 | * android.net.wifi.rtt.WifiRttManager} for ranging devices with wifi. |
Etan Cohen | 17ba472 | 2017-08-21 10:52:17 -0700 | [diff] [blame] | 3892 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3893 | * @see #getSystemService(String) |
Etan Cohen | 17ba472 | 2017-08-21 10:52:17 -0700 | [diff] [blame] | 3894 | * @see android.net.wifi.rtt.WifiRttManager |
Etan Cohen | 17ba472 | 2017-08-21 10:52:17 -0700 | [diff] [blame] | 3895 | */ |
Etan Cohen | 091d777 | 2018-01-04 17:47:37 -0800 | [diff] [blame] | 3896 | public static final String WIFI_RTT_RANGING_SERVICE = "wifirtt"; |
Etan Cohen | 17ba472 | 2017-08-21 10:52:17 -0700 | [diff] [blame] | 3897 | |
| 3898 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3899 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Robert Quattlebaum | 87a7104 | 2017-05-15 15:45:20 -0700 | [diff] [blame] | 3900 | * android.net.lowpan.LowpanManager} for handling management of |
| 3901 | * LoWPAN access. |
| 3902 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3903 | * @see #getSystemService(String) |
Robert Quattlebaum | 87a7104 | 2017-05-15 15:45:20 -0700 | [diff] [blame] | 3904 | * @see android.net.lowpan.LowpanManager |
| 3905 | * |
| 3906 | * @hide |
| 3907 | */ |
| 3908 | public static final String LOWPAN_SERVICE = "lowpan"; |
| 3909 | |
| 3910 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3911 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Dianne Hackborn | fee756f | 2014-07-16 17:31:10 -0700 | [diff] [blame] | 3912 | * android.net.EthernetManager} for handling management of |
Lorenzo Colitti | f9ff2c9 | 2014-05-21 16:32:11 -0700 | [diff] [blame] | 3913 | * Ethernet access. |
| 3914 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3915 | * @see #getSystemService(String) |
Dianne Hackborn | fee756f | 2014-07-16 17:31:10 -0700 | [diff] [blame] | 3916 | * @see android.net.EthernetManager |
Lorenzo Colitti | f9ff2c9 | 2014-05-21 16:32:11 -0700 | [diff] [blame] | 3917 | * |
| 3918 | * @hide |
| 3919 | */ |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 3920 | @UnsupportedAppUsage |
Lorenzo Colitti | f9ff2c9 | 2014-05-21 16:32:11 -0700 | [diff] [blame] | 3921 | public static final String ETHERNET_SERVICE = "ethernet"; |
| 3922 | |
| 3923 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3924 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Irfan Sheriff | 60309fc | 2012-04-24 14:52:37 -0700 | [diff] [blame] | 3925 | * android.net.nsd.NsdManager} for handling management of network service |
Irfan Sheriff | 7d024d3 | 2012-03-22 17:01:39 -0700 | [diff] [blame] | 3926 | * discovery |
| 3927 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3928 | * @see #getSystemService(String) |
Irfan Sheriff | 60309fc | 2012-04-24 14:52:37 -0700 | [diff] [blame] | 3929 | * @see android.net.nsd.NsdManager |
Irfan Sheriff | 7d024d3 | 2012-03-22 17:01:39 -0700 | [diff] [blame] | 3930 | */ |
| 3931 | public static final String NSD_SERVICE = "servicediscovery"; |
| 3932 | |
Irfan Sheriff | 7d024d3 | 2012-03-22 17:01:39 -0700 | [diff] [blame] | 3933 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3934 | * Use with {@link #getSystemService(String)} to retrieve a |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3935 | * {@link android.media.AudioManager} for handling management of volume, |
| 3936 | * ringer modes and audio routing. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3937 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3938 | * @see #getSystemService(String) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3939 | * @see android.media.AudioManager |
| 3940 | */ |
| 3941 | public static final String AUDIO_SERVICE = "audio"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3942 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3943 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3944 | * Use with {@link #getSystemService(String)} to retrieve a |
Jim Miller | ce7eb6d | 2015-04-03 19:29:13 -0700 | [diff] [blame] | 3945 | * {@link android.hardware.fingerprint.FingerprintManager} for handling management |
Jim Miller | 08fa40c | 2014-04-29 18:18:47 -0700 | [diff] [blame] | 3946 | * of fingerprints. |
| 3947 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3948 | * @see #getSystemService(String) |
Jim Miller | ce7eb6d | 2015-04-03 19:29:13 -0700 | [diff] [blame] | 3949 | * @see android.hardware.fingerprint.FingerprintManager |
Jim Miller | 08fa40c | 2014-04-29 18:18:47 -0700 | [diff] [blame] | 3950 | */ |
| 3951 | public static final String FINGERPRINT_SERVICE = "fingerprint"; |
| 3952 | |
| 3953 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3954 | * Use with {@link #getSystemService(String)} to retrieve a |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 3955 | * {@link android.hardware.face.FaceManager} for handling management |
| 3956 | * of face authentication. |
| 3957 | * |
| 3958 | * @hide |
| 3959 | * @see #getSystemService |
| 3960 | * @see android.hardware.face.FaceManager |
| 3961 | */ |
| 3962 | public static final String FACE_SERVICE = "face"; |
| 3963 | |
| 3964 | /** |
Kevin Chyn | 05c2150 | 2018-09-18 13:07:19 -0700 | [diff] [blame] | 3965 | * Use with {@link #getSystemService(String)} to retrieve a |
Kevin Chyn | 51676d2 | 2018-11-05 18:00:43 -0800 | [diff] [blame] | 3966 | * {@link android.hardware.iris.IrisManager} for handling management |
| 3967 | * of iris authentication. |
| 3968 | * |
| 3969 | * @hide |
| 3970 | * @see #getSystemService |
| 3971 | * @see android.hardware.iris.IrisManager |
| 3972 | */ |
| 3973 | public static final String IRIS_SERVICE = "iris"; |
| 3974 | |
| 3975 | /** |
| 3976 | * Use with {@link #getSystemService(String)} to retrieve a |
Kevin Chyn | 05c2150 | 2018-09-18 13:07:19 -0700 | [diff] [blame] | 3977 | * {@link android.hardware.biometrics.BiometricManager} for handling management |
| 3978 | * of face authentication. |
| 3979 | * |
| 3980 | * @see #getSystemService |
| 3981 | * @see android.hardware.biometrics.BiometricManager |
| 3982 | */ |
| 3983 | public static final String BIOMETRIC_SERVICE = "biometric"; |
| 3984 | |
| 3985 | /** |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 3986 | * Use with {@link #getSystemService} to retrieve a |
Dianne Hackborn | b58b8f8 | 2012-06-11 15:08:39 -0700 | [diff] [blame] | 3987 | * {@link android.media.MediaRouter} for controlling and managing |
| 3988 | * routing of media. |
| 3989 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3990 | * @see #getSystemService(String) |
Dianne Hackborn | b58b8f8 | 2012-06-11 15:08:39 -0700 | [diff] [blame] | 3991 | * @see android.media.MediaRouter |
| 3992 | */ |
| 3993 | public static final String MEDIA_ROUTER_SERVICE = "media_router"; |
| 3994 | |
| 3995 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3996 | * Use with {@link #getSystemService(String)} to retrieve a |
RoboErik | 42ea7ee | 2014-05-16 16:27:35 -0700 | [diff] [blame] | 3997 | * {@link android.media.session.MediaSessionManager} for managing media Sessions. |
RoboErik | 01fe661 | 2014-02-13 14:19:04 -0800 | [diff] [blame] | 3998 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3999 | * @see #getSystemService(String) |
RoboErik | 42ea7ee | 2014-05-16 16:27:35 -0700 | [diff] [blame] | 4000 | * @see android.media.session.MediaSessionManager |
RoboErik | 01fe661 | 2014-02-13 14:19:04 -0800 | [diff] [blame] | 4001 | */ |
| 4002 | public static final String MEDIA_SESSION_SERVICE = "media_session"; |
| 4003 | |
| 4004 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4005 | * Use with {@link #getSystemService(String)} to retrieve a |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4006 | * {@link android.telephony.TelephonyManager} for handling management the |
| 4007 | * telephony features of the device. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 4008 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4009 | * @see #getSystemService(String) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4010 | * @see android.telephony.TelephonyManager |
| 4011 | */ |
| 4012 | public static final String TELEPHONY_SERVICE = "phone"; |
| 4013 | |
| 4014 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4015 | * Use with {@link #getSystemService(String)} to retrieve a |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 4016 | * {@link android.telephony.SubscriptionManager} for handling management the |
| 4017 | * telephony subscriptions of the device. |
| 4018 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4019 | * @see #getSystemService(String) |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 4020 | * @see android.telephony.SubscriptionManager |
| 4021 | */ |
| 4022 | public static final String TELEPHONY_SUBSCRIPTION_SERVICE = "telephony_subscription_service"; |
| 4023 | |
| 4024 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4025 | * Use with {@link #getSystemService(String)} to retrieve a |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 4026 | * {@link android.telecom.TelecomManager} to manage telecom-related features |
Yorke Lee | b4ce143 | 2014-06-09 13:53:23 -0700 | [diff] [blame] | 4027 | * of the device. |
| 4028 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4029 | * @see #getSystemService(String) |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 4030 | * @see android.telecom.TelecomManager |
Yorke Lee | b4ce143 | 2014-06-09 13:53:23 -0700 | [diff] [blame] | 4031 | */ |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 4032 | public static final String TELECOM_SERVICE = "telecom"; |
Yorke Lee | b4ce143 | 2014-06-09 13:53:23 -0700 | [diff] [blame] | 4033 | |
| 4034 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4035 | * Use with {@link #getSystemService(String)} to retrieve a |
Jonathan Basseri | 9a1c9b6 | 2015-02-25 13:01:52 -0800 | [diff] [blame] | 4036 | * {@link android.telephony.CarrierConfigManager} for reading carrier configuration values. |
| 4037 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4038 | * @see #getSystemService(String) |
Jonathan Basseri | 9a1c9b6 | 2015-02-25 13:01:52 -0800 | [diff] [blame] | 4039 | * @see android.telephony.CarrierConfigManager |
| 4040 | */ |
| 4041 | public static final String CARRIER_CONFIG_SERVICE = "carrier_config"; |
| 4042 | |
| 4043 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4044 | * Use with {@link #getSystemService(String)} to retrieve a |
Jeff Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 4045 | * {@link android.telephony.euicc.EuiccManager} to manage the device eUICC (embedded SIM). |
| 4046 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4047 | * @see #getSystemService(String) |
Jeff Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 4048 | * @see android.telephony.euicc.EuiccManager |
Jeff Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 4049 | */ |
Holly Jiuyu Sun | 4f73b9c | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 4050 | public static final String EUICC_SERVICE = "euicc"; |
Jeff Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 4051 | |
| 4052 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4053 | * Use with {@link #getSystemService(String)} to retrieve a |
Holly Jiuyu Sun | 5c11024 | 2017-12-21 18:44:59 -0800 | [diff] [blame] | 4054 | * {@link android.telephony.euicc.EuiccCardManager} to access the device eUICC (embedded SIM). |
| 4055 | * |
| 4056 | * @see #getSystemService(String) |
| 4057 | * @see android.telephony.euicc.EuiccCardManager |
Holly Jiuyu Sun | 5c11024 | 2017-12-21 18:44:59 -0800 | [diff] [blame] | 4058 | * @hide |
| 4059 | */ |
Holly Jiuyu Sun | 4f73b9c | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 4060 | @SystemApi |
| 4061 | public static final String EUICC_CARD_SERVICE = "euicc_card"; |
Holly Jiuyu Sun | 5c11024 | 2017-12-21 18:44:59 -0800 | [diff] [blame] | 4062 | |
| 4063 | /** |
| 4064 | * Use with {@link #getSystemService(String)} to retrieve a |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 4065 | * {@link android.content.ClipboardManager} for accessing and modifying |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4066 | * the contents of the global clipboard. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 4067 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4068 | * @see #getSystemService(String) |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 4069 | * @see android.content.ClipboardManager |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4070 | */ |
| 4071 | public static final String CLIPBOARD_SERVICE = "clipboard"; |
| 4072 | |
| 4073 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4074 | * Use with {@link #getSystemService(String)} to retrieve a |
Abodunrinwa Toki | f001fef | 2017-01-04 23:51:42 +0000 | [diff] [blame] | 4075 | * {@link TextClassificationManager} for text classification services. |
Abodunrinwa Toki | 8158af5 | 2016-11-23 20:41:09 +0000 | [diff] [blame] | 4076 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4077 | * @see #getSystemService(String) |
Abodunrinwa Toki | f001fef | 2017-01-04 23:51:42 +0000 | [diff] [blame] | 4078 | * @see TextClassificationManager |
Abodunrinwa Toki | 8158af5 | 2016-11-23 20:41:09 +0000 | [diff] [blame] | 4079 | */ |
| 4080 | public static final String TEXT_CLASSIFICATION_SERVICE = "textclassification"; |
| 4081 | |
| 4082 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4083 | * Use with {@link #getSystemService(String)} to retrieve a |
Alex Salo | 5f5b5f4 | 2019-02-27 10:49:00 -0800 | [diff] [blame] | 4084 | * {@link com.android.server.attention.AttentionManagerService} for attention services. |
| 4085 | * |
| 4086 | * @see #getSystemService(String) |
| 4087 | * @see android.server.attention.AttentionManagerService |
| 4088 | * @hide |
| 4089 | */ |
| 4090 | public static final String ATTENTION_SERVICE = "attention"; |
| 4091 | |
| 4092 | /** |
| 4093 | * Use with {@link #getSystemService(String)} to retrieve a |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4094 | * {@link android.view.inputmethod.InputMethodManager} for accessing input |
| 4095 | * methods. |
| 4096 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4097 | * @see #getSystemService(String) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4098 | */ |
| 4099 | public static final String INPUT_METHOD_SERVICE = "input_method"; |
| 4100 | |
| 4101 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4102 | * Use with {@link #getSystemService(String)} to retrieve a |
satok | 988323c | 2011-06-22 16:38:13 +0900 | [diff] [blame] | 4103 | * {@link android.view.textservice.TextServicesManager} for accessing |
| 4104 | * text services. |
| 4105 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4106 | * @see #getSystemService(String) |
satok | 988323c | 2011-06-22 16:38:13 +0900 | [diff] [blame] | 4107 | */ |
| 4108 | public static final String TEXT_SERVICES_MANAGER_SERVICE = "textservices"; |
| 4109 | |
| 4110 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4111 | * Use with {@link #getSystemService(String)} to retrieve a |
Dan Egnor | e38d58b | 2009-12-30 19:29:03 -0800 | [diff] [blame] | 4112 | * {@link android.appwidget.AppWidgetManager} for accessing AppWidgets. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4113 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4114 | * @see #getSystemService(String) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4115 | */ |
The Android Open Source Project | c39a6e0 | 2009-03-11 12:11:56 -0700 | [diff] [blame] | 4116 | public static final String APPWIDGET_SERVICE = "appwidget"; |
Dan Egnor | 9524027 | 2009-10-27 18:23:39 -0700 | [diff] [blame] | 4117 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4118 | /** |
Dianne Hackborn | 91097de | 2014-04-04 18:02:06 -0700 | [diff] [blame] | 4119 | * Official published name of the (internal) voice interaction manager service. |
| 4120 | * |
| 4121 | * @hide |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4122 | * @see #getSystemService(String) |
Dianne Hackborn | 91097de | 2014-04-04 18:02:06 -0700 | [diff] [blame] | 4123 | */ |
| 4124 | public static final String VOICE_INTERACTION_MANAGER_SERVICE = "voiceinteraction"; |
| 4125 | |
| 4126 | /** |
Felipe Leme | 640f30a | 2017-03-06 15:44:06 -0800 | [diff] [blame] | 4127 | * Official published name of the (internal) autofill service. |
Felipe Leme | 5381aa4 | 2016-10-13 09:02:32 -0700 | [diff] [blame] | 4128 | * |
| 4129 | * @hide |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4130 | * @see #getSystemService(String) |
Felipe Leme | 5381aa4 | 2016-10-13 09:02:32 -0700 | [diff] [blame] | 4131 | */ |
Felipe Leme | 640f30a | 2017-03-06 15:44:06 -0800 | [diff] [blame] | 4132 | public static final String AUTOFILL_MANAGER_SERVICE = "autofill"; |
Felipe Leme | 5381aa4 | 2016-10-13 09:02:32 -0700 | [diff] [blame] | 4133 | |
| 4134 | /** |
Felipe Leme | 749b889 | 2018-12-03 16:30:30 -0800 | [diff] [blame] | 4135 | * Official published name of the content capture service. |
Felipe Leme | e348dc3 | 2018-11-05 12:35:29 -0800 | [diff] [blame] | 4136 | * |
| 4137 | * @hide |
| 4138 | * @see #getSystemService(String) |
| 4139 | */ |
Felipe Leme | a7e4ca6 | 2019-05-23 13:32:40 -0700 | [diff] [blame] | 4140 | @TestApi |
Felipe Leme | 749b889 | 2018-12-03 16:30:30 -0800 | [diff] [blame] | 4141 | public static final String CONTENT_CAPTURE_MANAGER_SERVICE = "content_capture"; |
Felipe Leme | e348dc3 | 2018-11-05 12:35:29 -0800 | [diff] [blame] | 4142 | |
| 4143 | /** |
Winson Chung | 3fb0f25 | 2019-01-08 17:41:55 -0800 | [diff] [blame] | 4144 | * Used for getting content selections and classifications for task snapshots. |
| 4145 | * |
| 4146 | * @hide |
| 4147 | * @see #getSystemService(String) |
| 4148 | */ |
| 4149 | @SystemApi |
| 4150 | public static final String CONTENT_SUGGESTIONS_SERVICE = "content_suggestions"; |
| 4151 | |
| 4152 | /** |
Sunny Goyal | 54e9134 | 2018-11-14 11:59:02 -0800 | [diff] [blame] | 4153 | * Official published name of the app prediction service. |
| 4154 | * |
| 4155 | * @hide |
| 4156 | * @see #getSystemService(String) |
| 4157 | */ |
| 4158 | @SystemApi |
| 4159 | public static final String APP_PREDICTION_SERVICE = "app_prediction"; |
| 4160 | |
| 4161 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4162 | * Use with {@link #getSystemService(String)} to access the |
Arunesh Mishra | a772e5f | 2016-01-25 10:33:11 -0800 | [diff] [blame] | 4163 | * {@link com.android.server.voiceinteraction.SoundTriggerService}. |
| 4164 | * |
| 4165 | * @hide |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4166 | * @see #getSystemService(String) |
Arunesh Mishra | a772e5f | 2016-01-25 10:33:11 -0800 | [diff] [blame] | 4167 | */ |
| 4168 | public static final String SOUND_TRIGGER_SERVICE = "soundtrigger"; |
| 4169 | |
Philip P. Moltmann | 039678e | 2018-09-18 13:04:38 -0700 | [diff] [blame] | 4170 | /** |
| 4171 | * Official published name of the (internal) permission service. |
| 4172 | * |
| 4173 | * @see #getSystemService(String) |
| 4174 | * @hide |
| 4175 | */ |
Winson | f27394e | 2019-06-07 14:44:40 -0700 | [diff] [blame] | 4176 | @TestApi |
Philip P. Moltmann | 039678e | 2018-09-18 13:04:38 -0700 | [diff] [blame] | 4177 | @SystemApi |
| 4178 | public static final String PERMISSION_SERVICE = "permission"; |
Arunesh Mishra | a772e5f | 2016-01-25 10:33:11 -0800 | [diff] [blame] | 4179 | |
| 4180 | /** |
Philip P. Moltmann | bc054d8 | 2018-12-21 09:41:58 -0800 | [diff] [blame] | 4181 | * Official published name of the (internal) permission controller service. |
| 4182 | * |
| 4183 | * @see #getSystemService(String) |
| 4184 | * @hide |
| 4185 | */ |
| 4186 | public static final String PERMISSION_CONTROLLER_SERVICE = "permission_controller"; |
| 4187 | |
| 4188 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4189 | * Use with {@link #getSystemService(String)} to retrieve an |
Christopher Tate | 4528186 | 2010-03-05 15:46:30 -0800 | [diff] [blame] | 4190 | * {@link android.app.backup.IBackupManager IBackupManager} for communicating |
Christopher Tate | 487529a | 2009-04-29 14:03:25 -0700 | [diff] [blame] | 4191 | * with the backup mechanism. |
Dianne Hackborn | 7f20543 | 2009-07-28 00:13:47 -0700 | [diff] [blame] | 4192 | * @hide |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 4193 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4194 | * @see #getSystemService(String) |
Christopher Tate | 487529a | 2009-04-29 14:03:25 -0700 | [diff] [blame] | 4195 | */ |
Christopher Tate | d5cf722 | 2014-07-29 16:53:09 -0700 | [diff] [blame] | 4196 | @SystemApi |
Christopher Tate | 487529a | 2009-04-29 14:03:25 -0700 | [diff] [blame] | 4197 | public static final String BACKUP_SERVICE = "backup"; |
Dan Egnor | 9524027 | 2009-10-27 18:23:39 -0700 | [diff] [blame] | 4198 | |
| 4199 | /** |
Richard Uhler | b29f145 | 2018-09-12 16:38:15 +0100 | [diff] [blame] | 4200 | * Use with {@link #getSystemService(String)} to retrieve an |
| 4201 | * {@link android.content.rollback.RollbackManager} for communicating |
| 4202 | * with the rollback manager |
| 4203 | * |
| 4204 | * @see #getSystemService(String) |
Richard Uhler | c739c8c | 2018-12-12 11:03:34 +0000 | [diff] [blame] | 4205 | * @hide |
Richard Uhler | b29f145 | 2018-09-12 16:38:15 +0100 | [diff] [blame] | 4206 | */ |
Richard Uhler | 8a97745 | 2019-03-08 13:27:17 +0000 | [diff] [blame] | 4207 | @SystemApi @TestApi |
Richard Uhler | b29f145 | 2018-09-12 16:38:15 +0100 | [diff] [blame] | 4208 | public static final String ROLLBACK_SERVICE = "rollback"; |
| 4209 | |
| 4210 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4211 | * Use with {@link #getSystemService(String)} to retrieve a |
Dan Egnor | 1337b01 | 2010-01-04 11:01:44 -0800 | [diff] [blame] | 4212 | * {@link android.os.DropBoxManager} instance for recording |
Dan Egnor | 9524027 | 2009-10-27 18:23:39 -0700 | [diff] [blame] | 4213 | * diagnostic logs. |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4214 | * @see #getSystemService(String) |
Dan Egnor | 9524027 | 2009-10-27 18:23:39 -0700 | [diff] [blame] | 4215 | */ |
| 4216 | public static final String DROPBOX_SERVICE = "dropbox"; |
| 4217 | |
Christopher Tate | 487529a | 2009-04-29 14:03:25 -0700 | [diff] [blame] | 4218 | /** |
Philip P. Moltmann | f80809f | 2018-04-04 11:20:44 -0700 | [diff] [blame] | 4219 | * System service name for the DeviceIdleManager. |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4220 | * @see #getSystemService(String) |
Dianne Hackborn | 1958e5e | 2015-06-12 18:11:41 -0700 | [diff] [blame] | 4221 | * @hide |
| 4222 | */ |
| 4223 | public static final String DEVICE_IDLE_CONTROLLER = "deviceidle"; |
| 4224 | |
| 4225 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4226 | * Use with {@link #getSystemService(String)} to retrieve a |
Dianne Hackborn | 87bba1e | 2010-02-26 17:25:54 -0800 | [diff] [blame] | 4227 | * {@link android.app.admin.DevicePolicyManager} for working with global |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 4228 | * device policy management. |
| 4229 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4230 | * @see #getSystemService(String) |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 4231 | */ |
| 4232 | public static final String DEVICE_POLICY_SERVICE = "device_policy"; |
| 4233 | |
| 4234 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4235 | * Use with {@link #getSystemService(String)} to retrieve a |
Tobias Haamel | 5333288 | 2010-02-18 16:15:43 -0800 | [diff] [blame] | 4236 | * {@link android.app.UiModeManager} for controlling UI modes. |
| 4237 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4238 | * @see #getSystemService(String) |
Tobias Haamel | 5333288 | 2010-02-18 16:15:43 -0800 | [diff] [blame] | 4239 | */ |
| 4240 | public static final String UI_MODE_SERVICE = "uimode"; |
| 4241 | |
| 4242 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4243 | * Use with {@link #getSystemService(String)} to retrieve a |
Steve Howard | d58429f | 2010-09-27 16:32:39 -0700 | [diff] [blame] | 4244 | * {@link android.app.DownloadManager} for requesting HTTP downloads. |
Steve Howard | a270936 | 2010-07-02 17:12:48 -0700 | [diff] [blame] | 4245 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4246 | * @see #getSystemService(String) |
Steve Howard | a270936 | 2010-07-02 17:12:48 -0700 | [diff] [blame] | 4247 | */ |
| 4248 | public static final String DOWNLOAD_SERVICE = "download"; |
| 4249 | |
| 4250 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4251 | * Use with {@link #getSystemService(String)} to retrieve a |
Todd Poynor | e35872d | 2013-12-10 11:57:21 -0800 | [diff] [blame] | 4252 | * {@link android.os.BatteryManager} for managing battery state. |
| 4253 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4254 | * @see #getSystemService(String) |
Todd Poynor | e35872d | 2013-12-10 11:57:21 -0800 | [diff] [blame] | 4255 | */ |
| 4256 | public static final String BATTERY_SERVICE = "batterymanager"; |
| 4257 | |
| 4258 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4259 | * Use with {@link #getSystemService(String)} to retrieve a |
Nick Pelly | 50b4d8f | 2010-12-07 22:40:28 -0800 | [diff] [blame] | 4260 | * {@link android.nfc.NfcManager} for using NFC. |
| 4261 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4262 | * @see #getSystemService(String) |
Nick Pelly | 50b4d8f | 2010-12-07 22:40:28 -0800 | [diff] [blame] | 4263 | */ |
| 4264 | public static final String NFC_SERVICE = "nfc"; |
| 4265 | |
| 4266 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4267 | * Use with {@link #getSystemService(String)} to retrieve a |
Florian Salbrechter | 084da9b | 2015-03-25 11:00:55 +0000 | [diff] [blame] | 4268 | * {@link android.bluetooth.BluetoothManager} for using Bluetooth. |
Jaikumar Ganesh | 1abb1cb | 2012-01-25 16:14:50 -0800 | [diff] [blame] | 4269 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4270 | * @see #getSystemService(String) |
Jaikumar Ganesh | 1abb1cb | 2012-01-25 16:14:50 -0800 | [diff] [blame] | 4271 | */ |
| 4272 | public static final String BLUETOOTH_SERVICE = "bluetooth"; |
| 4273 | |
| 4274 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4275 | * Use with {@link #getSystemService(String)} to retrieve a |
Chung-yih Wang | 2d94231 | 2010-08-05 12:17:37 +0800 | [diff] [blame] | 4276 | * {@link android.net.sip.SipManager} for accessing the SIP related service. |
| 4277 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4278 | * @see #getSystemService(String) |
Chung-yih Wang | 2d94231 | 2010-08-05 12:17:37 +0800 | [diff] [blame] | 4279 | */ |
| 4280 | /** @hide */ |
| 4281 | public static final String SIP_SERVICE = "sip"; |
| 4282 | |
| 4283 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4284 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Mike Lockwood | c4308f0 | 2011-03-01 08:04:54 -0800 | [diff] [blame] | 4285 | * android.hardware.usb.UsbManager} for access to USB devices (as a USB host) |
Mike Lockwood | e7d511e | 2010-12-30 13:39:37 -0500 | [diff] [blame] | 4286 | * and for controlling this device's behavior as a USB device. |
| 4287 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4288 | * @see #getSystemService(String) |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 4289 | * @see android.hardware.usb.UsbManager |
Mike Lockwood | e7d511e | 2010-12-30 13:39:37 -0500 | [diff] [blame] | 4290 | */ |
| 4291 | public static final String USB_SERVICE = "usb"; |
| 4292 | |
| 4293 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4294 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Kenny Root | f74bfde | 2018-01-18 15:42:48 -0800 | [diff] [blame] | 4295 | * Use with {@link #getSystemService} to retrieve a {@link |
| 4296 | * android.debug.AdbManager} for access to ADB debug functions. |
| 4297 | * |
| 4298 | * @see #getSystemService(String) |
| 4299 | * @see android.debug.AdbManager |
| 4300 | * |
| 4301 | * @hide |
| 4302 | */ |
| 4303 | public static final String ADB_SERVICE = "adb"; |
| 4304 | |
| 4305 | /** |
| 4306 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Mike Lockwood | b01e8bf | 2011-08-29 20:11:07 -0400 | [diff] [blame] | 4307 | * android.hardware.SerialManager} for access to serial ports. |
| 4308 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4309 | * @see #getSystemService(String) |
Dianne Hackborn | 35f72be | 2013-09-16 10:57:39 -0700 | [diff] [blame] | 4310 | * @see android.hardware.SerialManager |
Mike Lockwood | b01e8bf | 2011-08-29 20:11:07 -0400 | [diff] [blame] | 4311 | * |
| 4312 | * @hide |
| 4313 | */ |
| 4314 | public static final String SERIAL_SERVICE = "serial"; |
| 4315 | |
| 4316 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4317 | * Use with {@link #getSystemService(String)} to retrieve a |
Jinsuk Kim | 91120c5 | 2014-05-08 17:12:51 +0900 | [diff] [blame] | 4318 | * {@link android.hardware.hdmi.HdmiControlManager} for controlling and managing |
| 4319 | * HDMI-CEC protocol. |
| 4320 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4321 | * @see #getSystemService(String) |
Jinsuk Kim | 91120c5 | 2014-05-08 17:12:51 +0900 | [diff] [blame] | 4322 | * @see android.hardware.hdmi.HdmiControlManager |
Jinsuk Kim | 66d1eb2 | 2014-06-06 16:12:18 +0900 | [diff] [blame] | 4323 | * @hide |
Jinsuk Kim | 91120c5 | 2014-05-08 17:12:51 +0900 | [diff] [blame] | 4324 | */ |
Jinsuk Kim | 66d1eb2 | 2014-06-06 16:12:18 +0900 | [diff] [blame] | 4325 | @SystemApi |
Jinsuk Kim | 91120c5 | 2014-05-08 17:12:51 +0900 | [diff] [blame] | 4326 | public static final String HDMI_CONTROL_SERVICE = "hdmi_control"; |
Jinsuk Kim | fbcd503 | 2014-03-21 16:25:13 +0900 | [diff] [blame] | 4327 | |
| 4328 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4329 | * Use with {@link #getSystemService(String)} to retrieve a |
Jeff Brown | 9df6e7a | 2012-04-05 11:49:26 -0700 | [diff] [blame] | 4330 | * {@link android.hardware.input.InputManager} for interacting with input devices. |
| 4331 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4332 | * @see #getSystemService(String) |
Jeff Brown | 9df6e7a | 2012-04-05 11:49:26 -0700 | [diff] [blame] | 4333 | * @see android.hardware.input.InputManager |
| 4334 | */ |
| 4335 | public static final String INPUT_SERVICE = "input"; |
| 4336 | |
| 4337 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4338 | * Use with {@link #getSystemService(String)} to retrieve a |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 4339 | * {@link android.hardware.display.DisplayManager} for interacting with display devices. |
| 4340 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4341 | * @see #getSystemService(String) |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 4342 | * @see android.hardware.display.DisplayManager |
| 4343 | */ |
| 4344 | public static final String DISPLAY_SERVICE = "display"; |
| 4345 | |
| 4346 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4347 | * Use with {@link #getSystemService(String)} to retrieve a |
Christine Franks | 39b0311 | 2018-07-03 14:46:07 -0700 | [diff] [blame] | 4348 | * {@link android.hardware.display.ColorDisplayManager} for controlling color transforms. |
| 4349 | * |
| 4350 | * @see #getSystemService(String) |
| 4351 | * @see android.hardware.display.ColorDisplayManager |
| 4352 | * @hide |
| 4353 | */ |
| 4354 | public static final String COLOR_DISPLAY_SERVICE = "color_display"; |
| 4355 | |
| 4356 | /** |
| 4357 | * Use with {@link #getSystemService(String)} to retrieve a |
Amith Yamasani | 258848d | 2012-08-10 17:06:33 -0700 | [diff] [blame] | 4358 | * {@link android.os.UserManager} for managing users on devices that support multiple users. |
| 4359 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4360 | * @see #getSystemService(String) |
Amith Yamasani | 258848d | 2012-08-10 17:06:33 -0700 | [diff] [blame] | 4361 | * @see android.os.UserManager |
| 4362 | */ |
| 4363 | public static final String USER_SERVICE = "user"; |
| 4364 | |
| 4365 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4366 | * Use with {@link #getSystemService(String)} to retrieve a |
Amith Yamasani | 4f58263 | 2014-02-19 14:31:52 -0800 | [diff] [blame] | 4367 | * {@link android.content.pm.LauncherApps} for querying and monitoring launchable apps across |
| 4368 | * profiles of a user. |
| 4369 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4370 | * @see #getSystemService(String) |
Amith Yamasani | 4f58263 | 2014-02-19 14:31:52 -0800 | [diff] [blame] | 4371 | * @see android.content.pm.LauncherApps |
| 4372 | */ |
| 4373 | public static final String LAUNCHER_APPS_SERVICE = "launcherapps"; |
| 4374 | |
| 4375 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4376 | * Use with {@link #getSystemService(String)} to retrieve a |
Amith Yamasani | f20d640 | 2014-05-24 15:34:37 -0700 | [diff] [blame] | 4377 | * {@link android.content.RestrictionsManager} for retrieving application restrictions |
| 4378 | * and requesting permissions for restricted operations. |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4379 | * @see #getSystemService(String) |
Amith Yamasani | f20d640 | 2014-05-24 15:34:37 -0700 | [diff] [blame] | 4380 | * @see android.content.RestrictionsManager |
| 4381 | */ |
| 4382 | public static final String RESTRICTIONS_SERVICE = "restrictions"; |
| 4383 | |
| 4384 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4385 | * Use with {@link #getSystemService(String)} to retrieve a |
Dianne Hackborn | a06de0f | 2012-12-11 16:34:47 -0800 | [diff] [blame] | 4386 | * {@link android.app.AppOpsManager} for tracking application operations |
| 4387 | * on the device. |
| 4388 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4389 | * @see #getSystemService(String) |
Dianne Hackborn | a06de0f | 2012-12-11 16:34:47 -0800 | [diff] [blame] | 4390 | * @see android.app.AppOpsManager |
Dianne Hackborn | a06de0f | 2012-12-11 16:34:47 -0800 | [diff] [blame] | 4391 | */ |
| 4392 | public static final String APP_OPS_SERVICE = "appops"; |
| 4393 | |
| 4394 | /** |
Hai Zhang | b777668 | 2018-09-25 15:10:57 -0700 | [diff] [blame] | 4395 | * Use with {@link #getSystemService(String)} to retrieve a {@link android.app.role.RoleManager} |
| 4396 | * for managing roles. |
| 4397 | * |
| 4398 | * @see #getSystemService(String) |
| 4399 | * @see android.app.role.RoleManager |
| 4400 | */ |
| 4401 | public static final String ROLE_SERVICE = "role"; |
| 4402 | |
| 4403 | /** |
Hai Zhang | a4959e5 | 2019-03-06 12:21:07 -0800 | [diff] [blame] | 4404 | * Official published name of the (internal) role controller service. |
| 4405 | * |
| 4406 | * @see #getSystemService(String) |
| 4407 | * @see android.app.role.RoleControllerService |
| 4408 | * |
| 4409 | * @hide |
| 4410 | */ |
| 4411 | public static final String ROLE_CONTROLLER_SERVICE = "role_controller"; |
| 4412 | |
| 4413 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4414 | * Use with {@link #getSystemService(String)} to retrieve a |
Eino-Ville Talvala | 2f1a2e4 | 2013-07-25 17:12:05 -0700 | [diff] [blame] | 4415 | * {@link android.hardware.camera2.CameraManager} for interacting with |
Eino-Ville Talvala | b267554 | 2012-12-12 13:29:45 -0800 | [diff] [blame] | 4416 | * camera devices. |
| 4417 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4418 | * @see #getSystemService(String) |
Dianne Hackborn | 221ea89 | 2013-08-04 16:50:16 -0700 | [diff] [blame] | 4419 | * @see android.hardware.camera2.CameraManager |
Eino-Ville Talvala | b267554 | 2012-12-12 13:29:45 -0800 | [diff] [blame] | 4420 | */ |
| 4421 | public static final String CAMERA_SERVICE = "camera"; |
| 4422 | |
| 4423 | /** |
Svetoslav Ganov | 4b9a4d1 | 2013-06-11 15:20:06 -0700 | [diff] [blame] | 4424 | * {@link android.print.PrintManager} for printing and managing |
Jeff Brown | 511cd35 | 2013-08-23 17:43:37 -0700 | [diff] [blame] | 4425 | * printers and print tasks. |
Svetoslav Ganov | 4b9a4d1 | 2013-06-11 15:20:06 -0700 | [diff] [blame] | 4426 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4427 | * @see #getSystemService(String) |
Svetoslav Ganov | 4b9a4d1 | 2013-06-11 15:20:06 -0700 | [diff] [blame] | 4428 | * @see android.print.PrintManager |
| 4429 | */ |
| 4430 | public static final String PRINT_SERVICE = "print"; |
| 4431 | |
| 4432 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4433 | * Use with {@link #getSystemService(String)} to retrieve a |
Eugene Susla | 6ed45d8 | 2017-01-22 13:52:51 -0800 | [diff] [blame] | 4434 | * {@link android.companion.CompanionDeviceManager} for managing companion devices |
| 4435 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4436 | * @see #getSystemService(String) |
Eugene Susla | 6ed45d8 | 2017-01-22 13:52:51 -0800 | [diff] [blame] | 4437 | * @see android.companion.CompanionDeviceManager |
| 4438 | */ |
Eugene Susla | d7355cc | 2017-04-20 11:14:45 -0700 | [diff] [blame] | 4439 | public static final String COMPANION_DEVICE_SERVICE = "companiondevice"; |
Eugene Susla | 6ed45d8 | 2017-01-22 13:52:51 -0800 | [diff] [blame] | 4440 | |
| 4441 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4442 | * Use with {@link #getSystemService(String)} to retrieve a |
Erik Gilling | 51e95df | 2013-06-26 11:06:51 -0700 | [diff] [blame] | 4443 | * {@link android.hardware.ConsumerIrManager} for transmitting infrared |
| 4444 | * signals from the device. |
| 4445 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4446 | * @see #getSystemService(String) |
Erik Gilling | 51e95df | 2013-06-26 11:06:51 -0700 | [diff] [blame] | 4447 | * @see android.hardware.ConsumerIrManager |
| 4448 | */ |
| 4449 | public static final String CONSUMER_IR_SERVICE = "consumer_ir"; |
| 4450 | |
| 4451 | /** |
Adrian Roos | 82142c2 | 2014-03-27 14:56:59 +0100 | [diff] [blame] | 4452 | * {@link android.app.trust.TrustManager} for managing trust agents. |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4453 | * @see #getSystemService(String) |
Adrian Roos | 82142c2 | 2014-03-27 14:56:59 +0100 | [diff] [blame] | 4454 | * @see android.app.trust.TrustManager |
| 4455 | * @hide |
| 4456 | */ |
| 4457 | public static final String TRUST_SERVICE = "trust"; |
| 4458 | |
| 4459 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4460 | * Use with {@link #getSystemService(String)} to retrieve a |
Jae Seo | d5cc4a2 | 2014-05-30 16:57:43 -0700 | [diff] [blame] | 4461 | * {@link android.media.tv.TvInputManager} for interacting with TV inputs |
| 4462 | * on the device. |
Jae Seo | 3957091 | 2014-02-20 18:23:25 -0800 | [diff] [blame] | 4463 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4464 | * @see #getSystemService(String) |
Jae Seo | d5cc4a2 | 2014-05-30 16:57:43 -0700 | [diff] [blame] | 4465 | * @see android.media.tv.TvInputManager |
Jae Seo | 3957091 | 2014-02-20 18:23:25 -0800 | [diff] [blame] | 4466 | */ |
| 4467 | public static final String TV_INPUT_SERVICE = "tv_input"; |
| 4468 | |
| 4469 | /** |
Jeff Davidson | b51e0a6 | 2014-04-09 12:38:15 -0700 | [diff] [blame] | 4470 | * {@link android.net.NetworkScoreManager} for managing network scoring. |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4471 | * @see #getSystemService(String) |
Jeff Davidson | b51e0a6 | 2014-04-09 12:38:15 -0700 | [diff] [blame] | 4472 | * @see android.net.NetworkScoreManager |
| 4473 | * @hide |
| 4474 | */ |
Jeff Davidson | 5ad2079 | 2014-07-21 13:55:42 -0700 | [diff] [blame] | 4475 | @SystemApi |
Jeff Davidson | b51e0a6 | 2014-04-09 12:38:15 -0700 | [diff] [blame] | 4476 | public static final String NETWORK_SCORE_SERVICE = "network_score"; |
| 4477 | |
| 4478 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4479 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Adam Lesinski | aa60767 | 2014-11-24 11:27:50 -0800 | [diff] [blame] | 4480 | * android.app.usage.UsageStatsManager} for querying device usage stats. |
Dianne Hackborn | e22b3b1 | 2014-05-07 18:06:44 -0700 | [diff] [blame] | 4481 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4482 | * @see #getSystemService(String) |
Dianne Hackborn | ff17024 | 2014-11-19 10:59:01 -0800 | [diff] [blame] | 4483 | * @see android.app.usage.UsageStatsManager |
Dianne Hackborn | e22b3b1 | 2014-05-07 18:06:44 -0700 | [diff] [blame] | 4484 | */ |
| 4485 | public static final String USAGE_STATS_SERVICE = "usagestats"; |
| 4486 | |
| 4487 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4488 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Christopher Tate | 7060b04 | 2014-06-09 19:50:00 -0700 | [diff] [blame] | 4489 | * android.app.job.JobScheduler} instance for managing occasional |
Christopher Tate | fa380e9 | 2014-05-19 13:46:29 -0700 | [diff] [blame] | 4490 | * background tasks. |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4491 | * @see #getSystemService(String) |
Christopher Tate | 7060b04 | 2014-06-09 19:50:00 -0700 | [diff] [blame] | 4492 | * @see android.app.job.JobScheduler |
Christopher Tate | fa380e9 | 2014-05-19 13:46:29 -0700 | [diff] [blame] | 4493 | */ |
Christopher Tate | 7060b04 | 2014-06-09 19:50:00 -0700 | [diff] [blame] | 4494 | public static final String JOB_SCHEDULER_SERVICE = "jobscheduler"; |
Christopher Tate | fa380e9 | 2014-05-19 13:46:29 -0700 | [diff] [blame] | 4495 | |
| 4496 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4497 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Andres Morales | 33df937 | 2014-09-26 17:08:59 -0700 | [diff] [blame] | 4498 | * android.service.persistentdata.PersistentDataBlockManager} instance |
| 4499 | * for interacting with a storage device that lives across factory resets. |
| 4500 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4501 | * @see #getSystemService(String) |
Andres Morales | 68d4acd | 2014-07-01 19:40:41 -0700 | [diff] [blame] | 4502 | * @see android.service.persistentdata.PersistentDataBlockManager |
| 4503 | * @hide |
| 4504 | */ |
Andres Morales | 33df937 | 2014-09-26 17:08:59 -0700 | [diff] [blame] | 4505 | @SystemApi |
Andres Morales | 68d4acd | 2014-07-01 19:40:41 -0700 | [diff] [blame] | 4506 | public static final String PERSISTENT_DATA_BLOCK_SERVICE = "persistent_data_block"; |
| 4507 | |
| 4508 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4509 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Andrew Scull | 3b8b46f | 2017-02-13 18:12:15 +0000 | [diff] [blame] | 4510 | * android.service.oemlock.OemLockManager} instance for managing the OEM lock. |
| 4511 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4512 | * @see #getSystemService(String) |
Andrew Scull | 3b8b46f | 2017-02-13 18:12:15 +0000 | [diff] [blame] | 4513 | * @see android.service.oemlock.OemLockManager |
| 4514 | * @hide |
| 4515 | */ |
| 4516 | @SystemApi |
| 4517 | public static final String OEM_LOCK_SERVICE = "oem_lock"; |
| 4518 | |
| 4519 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4520 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Michael Wright | c39d47a | 2014-07-08 18:07:36 -0700 | [diff] [blame] | 4521 | * android.media.projection.MediaProjectionManager} instance for managing |
| 4522 | * media projection sessions. |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4523 | * @see #getSystemService(String) |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 4524 | * @see android.media.projection.MediaProjectionManager |
Michael Wright | c39d47a | 2014-07-08 18:07:36 -0700 | [diff] [blame] | 4525 | */ |
| 4526 | public static final String MEDIA_PROJECTION_SERVICE = "media_projection"; |
| 4527 | |
| 4528 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4529 | * Use with {@link #getSystemService(String)} to retrieve a |
Mike Lockwood | b673770 | 2015-02-20 08:28:47 -0800 | [diff] [blame] | 4530 | * {@link android.media.midi.MidiManager} for accessing the MIDI service. |
Mike Lockwood | 67f8e8b | 2014-12-01 13:54:59 -0800 | [diff] [blame] | 4531 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4532 | * @see #getSystemService(String) |
Mike Lockwood | 67f8e8b | 2014-12-01 13:54:59 -0800 | [diff] [blame] | 4533 | */ |
| 4534 | public static final String MIDI_SERVICE = "midi"; |
| 4535 | |
Eric Laurent | 2035ac8 | 2015-03-05 15:18:44 -0800 | [diff] [blame] | 4536 | |
| 4537 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4538 | * Use with {@link #getSystemService(String)} to retrieve a |
Eric Laurent | 2035ac8 | 2015-03-05 15:18:44 -0800 | [diff] [blame] | 4539 | * {@link android.hardware.radio.RadioManager} for accessing the broadcast radio service. |
| 4540 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4541 | * @see #getSystemService(String) |
Eric Laurent | 2035ac8 | 2015-03-05 15:18:44 -0800 | [diff] [blame] | 4542 | * @hide |
| 4543 | */ |
Tomasz Wasilczyk | 9110df7 | 2017-06-22 07:57:20 -0700 | [diff] [blame] | 4544 | public static final String RADIO_SERVICE = "broadcastradio"; |
Eric Laurent | 2035ac8 | 2015-03-05 15:18:44 -0800 | [diff] [blame] | 4545 | |
Paul McLean | a33be21 | 2015-02-20 07:52:45 -0800 | [diff] [blame] | 4546 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4547 | * Use with {@link #getSystemService(String)} to retrieve a |
Polina Bondarenko | 965ecbb | 2015-11-13 15:34:28 +0100 | [diff] [blame] | 4548 | * {@link android.os.HardwarePropertiesManager} for accessing the hardware properties service. |
| 4549 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4550 | * @see #getSystemService(String) |
Polina Bondarenko | 965ecbb | 2015-11-13 15:34:28 +0100 | [diff] [blame] | 4551 | */ |
Polina Bondarenko | 8333c73 | 2016-03-09 18:08:42 +0100 | [diff] [blame] | 4552 | public static final String HARDWARE_PROPERTIES_SERVICE = "hardware_properties"; |
Polina Bondarenko | 965ecbb | 2015-11-13 15:34:28 +0100 | [diff] [blame] | 4553 | |
| 4554 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4555 | * Use with {@link #getSystemService(String)} to retrieve a |
Wei Wang | bad7c20 | 2018-11-01 11:57:39 -0700 | [diff] [blame] | 4556 | * {@link android.os.ThermalService} for accessing the thermal service. |
| 4557 | * |
| 4558 | * @see #getSystemService(String) |
| 4559 | * @hide |
| 4560 | */ |
| 4561 | public static final String THERMAL_SERVICE = "thermalservice"; |
| 4562 | |
| 4563 | /** |
| 4564 | * Use with {@link #getSystemService(String)} to retrieve a |
Makoto Onuki | b5a012f | 2016-06-21 11:13:53 -0700 | [diff] [blame] | 4565 | * {@link android.content.pm.ShortcutManager} for accessing the launcher shortcut service. |
Makoto Onuki | 6f7362d9 | 2016-03-04 13:39:41 -0800 | [diff] [blame] | 4566 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4567 | * @see #getSystemService(String) |
Makoto Onuki | 6f7362d9 | 2016-03-04 13:39:41 -0800 | [diff] [blame] | 4568 | * @see android.content.pm.ShortcutManager |
| 4569 | */ |
| 4570 | public static final String SHORTCUT_SERVICE = "shortcut"; |
| 4571 | |
| 4572 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4573 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Peng Xu | 9ff7d22 | 2016-02-11 13:02:05 -0800 | [diff] [blame] | 4574 | * android.hardware.location.ContextHubManager} for accessing context hubs. |
| 4575 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4576 | * @see #getSystemService(String) |
Peng Xu | 9ff7d22 | 2016-02-11 13:02:05 -0800 | [diff] [blame] | 4577 | * @see android.hardware.location.ContextHubManager |
| 4578 | * |
| 4579 | * @hide |
| 4580 | */ |
| 4581 | @SystemApi |
| 4582 | public static final String CONTEXTHUB_SERVICE = "contexthub"; |
| 4583 | |
| 4584 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4585 | * Use with {@link #getSystemService(String)} to retrieve a |
Joe Onorato | 713fec8 | 2016-03-04 10:34:02 -0800 | [diff] [blame] | 4586 | * {@link android.os.health.SystemHealthManager} for accessing system health (battery, power, |
| 4587 | * memory, etc) metrics. |
| 4588 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4589 | * @see #getSystemService(String) |
Joe Onorato | 713fec8 | 2016-03-04 10:34:02 -0800 | [diff] [blame] | 4590 | */ |
| 4591 | public static final String SYSTEM_HEALTH_SERVICE = "systemhealth"; |
| 4592 | |
| 4593 | /** |
Amith Yamasani | d04aaa3 | 2016-06-13 12:09:36 -0700 | [diff] [blame] | 4594 | * Gatekeeper Service. |
| 4595 | * @hide |
| 4596 | */ |
| 4597 | public static final String GATEKEEPER_SERVICE = "android.service.gatekeeper.IGateKeeperService"; |
| 4598 | |
| 4599 | /** |
Svet Ganov | 37e4327 | 2016-09-09 16:01:32 -0700 | [diff] [blame] | 4600 | * Service defining the policy for access to device identifiers. |
| 4601 | * @hide |
| 4602 | */ |
| 4603 | public static final String DEVICE_IDENTIFIERS_SERVICE = "device_identifiers"; |
| 4604 | |
| 4605 | /** |
Joe Onorato | 1754d74 | 2016-11-21 17:51:35 -0800 | [diff] [blame] | 4606 | * Service to report a system health "incident" |
| 4607 | * @hide |
| 4608 | */ |
| 4609 | public static final String INCIDENT_SERVICE = "incident"; |
| 4610 | |
| 4611 | /** |
Joe Onorato | e21ab7e | 2018-12-18 15:00:25 -0800 | [diff] [blame] | 4612 | * Service to assist incidentd and dumpstated in reporting status to the user |
| 4613 | * and in confirming authorization to take an incident report or bugreport |
| 4614 | * @hide |
| 4615 | */ |
| 4616 | public static final String INCIDENT_COMPANION_SERVICE = "incidentcompanion"; |
| 4617 | |
| 4618 | /** |
Bookatz | 9472641 | 2017-08-31 09:26:15 -0700 | [diff] [blame] | 4619 | * Service to assist statsd in obtaining general stats. |
| 4620 | * @hide |
| 4621 | */ |
| 4622 | public static final String STATS_COMPANION_SERVICE = "statscompanion"; |
| 4623 | |
| 4624 | /** |
Bookatz | c697797 | 2018-01-16 16:55:05 -0800 | [diff] [blame] | 4625 | * Use with {@link #getSystemService(String)} to retrieve an {@link android.app.StatsManager}. |
David Chen | adaf8b3 | 2017-11-03 15:42:08 -0700 | [diff] [blame] | 4626 | * @hide |
| 4627 | */ |
| 4628 | @SystemApi |
| 4629 | public static final String STATS_MANAGER = "stats"; |
| 4630 | |
| 4631 | /** |
atrost | 8266ae3 | 2019-08-15 16:53:01 +0100 | [diff] [blame] | 4632 | * Use with {@link android.os.ServiceManager.getService()} to retrieve a |
| 4633 | * {@link IPlatformCompat} IBinder for communicating with the platform compat service. |
| 4634 | * @hide |
| 4635 | */ |
| 4636 | public static final String PLATFORM_COMPAT_SERVICE = "platform_compat"; |
| 4637 | |
| 4638 | /** |
atrost | ff948d8 | 2019-10-10 19:27:31 +0100 | [diff] [blame] | 4639 | * Use with {@link android.os.ServiceManager.getService()} to retrieve a |
| 4640 | * {@link IPlatformCompatNative} IBinder for native code communicating with the platform compat |
| 4641 | * service. |
| 4642 | * @hide |
| 4643 | */ |
| 4644 | public static final String PLATFORM_COMPAT_NATIVE_SERVICE = "platform_compat_native"; |
| 4645 | |
| 4646 | /** |
Nandana Dutt | d11850c | 2018-12-12 17:26:57 +0000 | [diff] [blame] | 4647 | * Service to capture a bugreport. |
| 4648 | * @see #getSystemService(String) |
| 4649 | * @see android.os.BugreportManager |
| 4650 | * @hide |
| 4651 | */ |
Nandana Dutt | d7e8d5a | 2019-04-11 17:27:45 +0100 | [diff] [blame] | 4652 | @SystemApi @TestApi |
Nandana Dutt | d11850c | 2018-12-12 17:26:57 +0000 | [diff] [blame] | 4653 | public static final String BUGREPORT_SERVICE = "bugreport"; |
| 4654 | |
| 4655 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4656 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
MÃ¥rten Kongstad | eabc9e9 | 2015-12-15 16:40:23 +0100 | [diff] [blame] | 4657 | * android.content.om.OverlayManager} for managing overlay packages. |
| 4658 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4659 | * @see #getSystemService(String) |
MÃ¥rten Kongstad | eabc9e9 | 2015-12-15 16:40:23 +0100 | [diff] [blame] | 4660 | * @see android.content.om.OverlayManager |
| 4661 | * @hide |
| 4662 | */ |
| 4663 | public static final String OVERLAY_SERVICE = "overlay"; |
| 4664 | |
| 4665 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4666 | * Use with {@link #getSystemService(String)} to retrieve a |
MÃ¥rten Kongstad | 06a1ac8 | 2018-09-20 13:09:47 +0200 | [diff] [blame] | 4667 | * {android.os.IIdmap2} for managing idmap files (used by overlay |
| 4668 | * packages). |
| 4669 | * |
| 4670 | * @see #getSystemService(String) |
| 4671 | * @hide |
| 4672 | */ |
| 4673 | public static final String IDMAP_SERVICE = "idmap"; |
| 4674 | |
| 4675 | /** |
| 4676 | * Use with {@link #getSystemService(String)} to retrieve a |
Zak Cohen | 56345f4 | 2017-01-26 13:54:28 -0800 | [diff] [blame] | 4677 | * {@link VrManager} for accessing the VR service. |
| 4678 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4679 | * @see #getSystemService(String) |
Zak Cohen | 56345f4 | 2017-01-26 13:54:28 -0800 | [diff] [blame] | 4680 | * @hide |
| 4681 | */ |
| 4682 | @SystemApi |
| 4683 | public static final String VR_SERVICE = "vrmanager"; |
| 4684 | |
| 4685 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4686 | * Use with {@link #getSystemService(String)} to retrieve an |
Neil Fuller | fe6ec56 | 2017-03-16 18:29:36 +0000 | [diff] [blame] | 4687 | * {@link android.app.timezone.ITimeZoneRulesManager}. |
| 4688 | * @hide |
| 4689 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4690 | * @see #getSystemService(String) |
Neil Fuller | fe6ec56 | 2017-03-16 18:29:36 +0000 | [diff] [blame] | 4691 | */ |
| 4692 | public static final String TIME_ZONE_RULES_MANAGER_SERVICE = "timezone"; |
| 4693 | |
| 4694 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4695 | * Use with {@link #getSystemService(String)} to retrieve a |
Tony Mak | b0d2262 | 2018-01-18 12:49:49 +0000 | [diff] [blame] | 4696 | * {@link android.content.pm.CrossProfileApps} for cross profile operations. |
Tony Mak | 1b708e6 | 2017-10-12 10:59:11 +0100 | [diff] [blame] | 4697 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4698 | * @see #getSystemService(String) |
Tony Mak | 1b708e6 | 2017-10-12 10:59:11 +0100 | [diff] [blame] | 4699 | */ |
| 4700 | public static final String CROSS_PROFILE_APPS_SERVICE = "crossprofileapps"; |
| 4701 | |
| 4702 | /** |
Ruchi Kandoi | 6149b0f | 2018-01-03 16:14:57 -0800 | [diff] [blame] | 4703 | * Use with {@link #getSystemService} to retrieve a |
| 4704 | * {@link android.se.omapi.ISecureElementService} |
| 4705 | * for accessing the SecureElementService. |
| 4706 | * |
| 4707 | * @hide |
| 4708 | */ |
| 4709 | @SystemApi |
| 4710 | public static final String SECURE_ELEMENT_SERVICE = "secure_element"; |
| 4711 | |
| 4712 | /** |
Neil Fuller | feeee68 | 2018-05-30 14:35:24 +0100 | [diff] [blame] | 4713 | * Use with {@link #getSystemService(String)} to retrieve an |
| 4714 | * {@link android.app.timedetector.ITimeDetectorService}. |
| 4715 | * @hide |
| 4716 | * |
| 4717 | * @see #getSystemService(String) |
| 4718 | */ |
| 4719 | public static final String TIME_DETECTOR_SERVICE = "time_detector"; |
| 4720 | |
| 4721 | /** |
Makoto Onuki | df7e481 | 2018-09-24 14:31:25 -0700 | [diff] [blame] | 4722 | * Binder service name for {@link AppBindingService}. |
| 4723 | * @hide |
| 4724 | */ |
| 4725 | public static final String APP_BINDING_SERVICE = "app_binding"; |
| 4726 | |
| 4727 | /** |
Sahin Caliskan | 9458ebc | 2018-10-31 13:23:29 -0700 | [diff] [blame] | 4728 | * Use with {@link #getSystemService(String)} to retrieve an |
James.cf Lin | 2bc9cd4 | 2019-11-04 20:23:36 +0800 | [diff] [blame] | 4729 | * {@link android.telephony.ims.ImsManager}. |
| 4730 | * @hide |
| 4731 | */ |
| 4732 | public static final String TELEPHONY_IMS_SERVICE = "telephony_ims"; |
| 4733 | |
| 4734 | /** |
| 4735 | * Use with {@link #getSystemService(String)} to retrieve an |
Brad Ebinger | d1cb346 | 2019-06-20 14:20:01 -0700 | [diff] [blame] | 4736 | * {@link android.telephony.ims.RcsMessageManager}. |
Sahin Caliskan | 9458ebc | 2018-10-31 13:23:29 -0700 | [diff] [blame] | 4737 | * @hide |
| 4738 | */ |
Brad Ebinger | d1cb346 | 2019-06-20 14:20:01 -0700 | [diff] [blame] | 4739 | public static final String TELEPHONY_RCS_MESSAGE_SERVICE = "ircsmessage"; |
Sahin Caliskan | 9458ebc | 2018-10-31 13:23:29 -0700 | [diff] [blame] | 4740 | |
Howard Chen | 0a94764 | 2019-01-07 14:10:44 +0800 | [diff] [blame] | 4741 | /** |
| 4742 | * Use with {@link #getSystemService(String)} to retrieve an |
Po-Chien Hsueh | 4e908c2 | 2019-03-07 11:57:17 +0800 | [diff] [blame] | 4743 | * {@link android.os.image.DynamicSystemManager}. |
Howard Chen | 0a94764 | 2019-01-07 14:10:44 +0800 | [diff] [blame] | 4744 | * @hide |
| 4745 | */ |
Po-Chien Hsueh | 4e908c2 | 2019-03-07 11:57:17 +0800 | [diff] [blame] | 4746 | public static final String DYNAMIC_SYSTEM_SERVICE = "dynamic_system"; |
Howard Chen | 0a94764 | 2019-01-07 14:10:44 +0800 | [diff] [blame] | 4747 | |
Sahin Caliskan | 9458ebc | 2018-10-31 13:23:29 -0700 | [diff] [blame] | 4748 | /** |
Chen Xu | 1f1c25e | 2019-09-15 18:28:21 -0700 | [diff] [blame] | 4749 | * Use with {@link #getSystemService(String)} to retrieve an |
| 4750 | * {@link android.os.telephony.TelephonyRegistryManager}. |
| 4751 | * @hide |
| 4752 | */ |
| 4753 | @SystemApi |
| 4754 | public static final String TELEPHONY_REGISTRY_SERVICE = "telephony_registry"; |
| 4755 | |
| 4756 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4757 | * Determine whether the given permission is allowed for a particular |
| 4758 | * process and user ID running in the system. |
| 4759 | * |
| 4760 | * @param permission The name of the permission being checked. |
| 4761 | * @param pid The process ID being checked against. Must be > 0. |
| 4762 | * @param uid The user ID being checked against. A uid of 0 is the root |
| 4763 | * user, which will pass every permission check. |
| 4764 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 4765 | * @return {@link PackageManager#PERMISSION_GRANTED} if the given |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4766 | * pid/uid is allowed that permission, or |
| 4767 | * {@link PackageManager#PERMISSION_DENIED} if it is not. |
| 4768 | * |
| 4769 | * @see PackageManager#checkPermission(String, String) |
| 4770 | * @see #checkCallingPermission |
| 4771 | */ |
Tor Norbye | 1c2bf03 | 2015-03-02 10:57:08 -0800 | [diff] [blame] | 4772 | @CheckResult(suggest="#enforcePermission(String,int,int,String)") |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 4773 | @PackageManager.PermissionResult |
| 4774 | public abstract int checkPermission(@NonNull String permission, int pid, int uid); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4775 | |
Dianne Hackborn | ff17024 | 2014-11-19 10:59:01 -0800 | [diff] [blame] | 4776 | /** @hide */ |
| 4777 | @PackageManager.PermissionResult |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 4778 | @UnsupportedAppUsage |
Dianne Hackborn | ff17024 | 2014-11-19 10:59:01 -0800 | [diff] [blame] | 4779 | public abstract int checkPermission(@NonNull String permission, int pid, int uid, |
| 4780 | IBinder callerToken); |
| 4781 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4782 | /** |
| 4783 | * Determine whether the calling process of an IPC you are handling has been |
| 4784 | * granted a particular permission. This is basically the same as calling |
| 4785 | * {@link #checkPermission(String, int, int)} with the pid and uid returned |
| 4786 | * by {@link android.os.Binder#getCallingPid} and |
| 4787 | * {@link android.os.Binder#getCallingUid}. One important difference |
| 4788 | * is that if you are not currently processing an IPC, this function |
| 4789 | * will always fail. This is done to protect against accidentally |
| 4790 | * leaking permissions; you can use {@link #checkCallingOrSelfPermission} |
| 4791 | * to avoid this protection. |
| 4792 | * |
| 4793 | * @param permission The name of the permission being checked. |
| 4794 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 4795 | * @return {@link PackageManager#PERMISSION_GRANTED} if the calling |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4796 | * pid/uid is allowed that permission, or |
| 4797 | * {@link PackageManager#PERMISSION_DENIED} if it is not. |
| 4798 | * |
| 4799 | * @see PackageManager#checkPermission(String, String) |
| 4800 | * @see #checkPermission |
| 4801 | * @see #checkCallingOrSelfPermission |
| 4802 | */ |
Tor Norbye | 1c2bf03 | 2015-03-02 10:57:08 -0800 | [diff] [blame] | 4803 | @CheckResult(suggest="#enforceCallingPermission(String,String)") |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 4804 | @PackageManager.PermissionResult |
| 4805 | public abstract int checkCallingPermission(@NonNull String permission); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4806 | |
| 4807 | /** |
| 4808 | * Determine whether the calling process of an IPC <em>or you</em> have been |
| 4809 | * granted a particular permission. This is the same as |
| 4810 | * {@link #checkCallingPermission}, except it grants your own permissions |
| 4811 | * if you are not currently processing an IPC. Use with care! |
| 4812 | * |
| 4813 | * @param permission The name of the permission being checked. |
| 4814 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 4815 | * @return {@link PackageManager#PERMISSION_GRANTED} if the calling |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4816 | * pid/uid is allowed that permission, or |
| 4817 | * {@link PackageManager#PERMISSION_DENIED} if it is not. |
| 4818 | * |
| 4819 | * @see PackageManager#checkPermission(String, String) |
| 4820 | * @see #checkPermission |
| 4821 | * @see #checkCallingPermission |
| 4822 | */ |
Tor Norbye | 1c2bf03 | 2015-03-02 10:57:08 -0800 | [diff] [blame] | 4823 | @CheckResult(suggest="#enforceCallingOrSelfPermission(String,String)") |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 4824 | @PackageManager.PermissionResult |
| 4825 | public abstract int checkCallingOrSelfPermission(@NonNull String permission); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4826 | |
| 4827 | /** |
Svetoslav | c6d1c34 | 2015-02-26 14:44:43 -0800 | [diff] [blame] | 4828 | * Determine whether <em>you</em> have been granted a particular permission. |
| 4829 | * |
| 4830 | * @param permission The name of the permission being checked. |
| 4831 | * |
| 4832 | * @return {@link PackageManager#PERMISSION_GRANTED} if you have the |
| 4833 | * permission, or {@link PackageManager#PERMISSION_DENIED} if not. |
| 4834 | * |
| 4835 | * @see PackageManager#checkPermission(String, String) |
| 4836 | * @see #checkCallingPermission(String) |
| 4837 | */ |
| 4838 | @PackageManager.PermissionResult |
| 4839 | public abstract int checkSelfPermission(@NonNull String permission); |
| 4840 | |
| 4841 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4842 | * If the given permission is not allowed for a particular process |
| 4843 | * and user ID running in the system, throw a {@link SecurityException}. |
| 4844 | * |
| 4845 | * @param permission The name of the permission being checked. |
| 4846 | * @param pid The process ID being checked against. Must be > 0. |
| 4847 | * @param uid The user ID being checked against. A uid of 0 is the root |
| 4848 | * user, which will pass every permission check. |
| 4849 | * @param message A message to include in the exception if it is thrown. |
| 4850 | * |
| 4851 | * @see #checkPermission(String, int, int) |
| 4852 | */ |
| 4853 | public abstract void enforcePermission( |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 4854 | @NonNull String permission, int pid, int uid, @Nullable String message); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4855 | |
| 4856 | /** |
| 4857 | * If the calling process of an IPC you are handling has not been |
| 4858 | * granted a particular permission, throw a {@link |
| 4859 | * SecurityException}. This is basically the same as calling |
| 4860 | * {@link #enforcePermission(String, int, int, String)} with the |
| 4861 | * pid and uid returned by {@link android.os.Binder#getCallingPid} |
| 4862 | * and {@link android.os.Binder#getCallingUid}. One important |
| 4863 | * difference is that if you are not currently processing an IPC, |
| 4864 | * this function will always throw the SecurityException. This is |
| 4865 | * done to protect against accidentally leaking permissions; you |
| 4866 | * can use {@link #enforceCallingOrSelfPermission} to avoid this |
| 4867 | * protection. |
| 4868 | * |
| 4869 | * @param permission The name of the permission being checked. |
| 4870 | * @param message A message to include in the exception if it is thrown. |
| 4871 | * |
| 4872 | * @see #checkCallingPermission(String) |
| 4873 | */ |
| 4874 | public abstract void enforceCallingPermission( |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 4875 | @NonNull String permission, @Nullable String message); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4876 | |
| 4877 | /** |
| 4878 | * If neither you nor the calling process of an IPC you are |
| 4879 | * handling has been granted a particular permission, throw a |
| 4880 | * {@link SecurityException}. This is the same as {@link |
| 4881 | * #enforceCallingPermission}, except it grants your own |
| 4882 | * permissions if you are not currently processing an IPC. Use |
| 4883 | * with care! |
| 4884 | * |
| 4885 | * @param permission The name of the permission being checked. |
| 4886 | * @param message A message to include in the exception if it is thrown. |
| 4887 | * |
| 4888 | * @see #checkCallingOrSelfPermission(String) |
| 4889 | */ |
| 4890 | public abstract void enforceCallingOrSelfPermission( |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 4891 | @NonNull String permission, @Nullable String message); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4892 | |
| 4893 | /** |
| 4894 | * Grant permission to access a specific Uri to another package, regardless |
| 4895 | * of whether that package has general permission to access the Uri's |
| 4896 | * content provider. This can be used to grant specific, temporary |
| 4897 | * permissions, typically in response to user interaction (such as the |
| 4898 | * user opening an attachment that you would like someone else to |
| 4899 | * display). |
| 4900 | * |
| 4901 | * <p>Normally you should use {@link Intent#FLAG_GRANT_READ_URI_PERMISSION |
| 4902 | * Intent.FLAG_GRANT_READ_URI_PERMISSION} or |
| 4903 | * {@link Intent#FLAG_GRANT_WRITE_URI_PERMISSION |
| 4904 | * Intent.FLAG_GRANT_WRITE_URI_PERMISSION} with the Intent being used to |
| 4905 | * start an activity instead of this function directly. If you use this |
| 4906 | * function directly, you should be sure to call |
| 4907 | * {@link #revokeUriPermission} when the target should no longer be allowed |
| 4908 | * to access it. |
| 4909 | * |
| 4910 | * <p>To succeed, the content provider owning the Uri must have set the |
| 4911 | * {@link android.R.styleable#AndroidManifestProvider_grantUriPermissions |
| 4912 | * grantUriPermissions} attribute in its manifest or included the |
| 4913 | * {@link android.R.styleable#AndroidManifestGrantUriPermission |
| 4914 | * <grant-uri-permissions>} tag. |
| 4915 | * |
| 4916 | * @param toPackage The package you would like to allow to access the Uri. |
| 4917 | * @param uri The Uri you would like to grant access to. |
Jeff Sharkey | 6503bd8 | 2017-04-19 23:24:18 -0600 | [diff] [blame] | 4918 | * @param modeFlags The desired access modes. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4919 | * |
| 4920 | * @see #revokeUriPermission |
| 4921 | */ |
| 4922 | public abstract void grantUriPermission(String toPackage, Uri uri, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 4923 | @Intent.GrantUriMode int modeFlags); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4924 | |
| 4925 | /** |
| 4926 | * Remove all permissions to access a particular content provider Uri |
Dianne Hackborn | a47223f | 2017-03-30 13:49:13 -0700 | [diff] [blame] | 4927 | * that were previously added with {@link #grantUriPermission} or <em>any other</em> mechanism. |
| 4928 | * The given Uri will match all previously granted Uris that are the same or a |
Jeff Sharkey | 328ebf2 | 2013-03-21 18:09:39 -0700 | [diff] [blame] | 4929 | * sub-path of the given Uri. That is, revoking "content://foo/target" will |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4930 | * revoke both "content://foo/target" and "content://foo/target/sub", but not |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 4931 | * "content://foo". It will not remove any prefix grants that exist at a |
| 4932 | * higher level. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4933 | * |
Dianne Hackborn | 955d8d6 | 2014-10-07 20:17:19 -0700 | [diff] [blame] | 4934 | * <p>Prior to {@link android.os.Build.VERSION_CODES#LOLLIPOP}, if you did not have |
Dianne Hackborn | 192679a | 2014-09-10 14:28:48 -0700 | [diff] [blame] | 4935 | * regular permission access to a Uri, but had received access to it through |
| 4936 | * a specific Uri permission grant, you could not revoke that grant with this |
| 4937 | * function and a {@link SecurityException} would be thrown. As of |
Dianne Hackborn | a47223f | 2017-03-30 13:49:13 -0700 | [diff] [blame] | 4938 | * {@link android.os.Build.VERSION_CODES#LOLLIPOP}, this function will not throw a security |
| 4939 | * exception, but will remove whatever permission grants to the Uri had been given to the app |
Dianne Hackborn | 192679a | 2014-09-10 14:28:48 -0700 | [diff] [blame] | 4940 | * (or none).</p> |
| 4941 | * |
Dianne Hackborn | a47223f | 2017-03-30 13:49:13 -0700 | [diff] [blame] | 4942 | * <p>Unlike {@link #revokeUriPermission(String, Uri, int)}, this method impacts all permission |
| 4943 | * grants matching the given Uri, for any package they had been granted to, through any |
| 4944 | * mechanism this had happened (such as indirectly through the clipboard, activity launch, |
| 4945 | * service start, etc). That means this can be potentially dangerous to use, as it can |
| 4946 | * revoke grants that another app could be strongly expecting to stick around.</p> |
| 4947 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4948 | * @param uri The Uri you would like to revoke access to. |
Jeff Sharkey | 6503bd8 | 2017-04-19 23:24:18 -0600 | [diff] [blame] | 4949 | * @param modeFlags The access modes to revoke. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4950 | * |
| 4951 | * @see #grantUriPermission |
| 4952 | */ |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 4953 | public abstract void revokeUriPermission(Uri uri, @Intent.AccessUriMode int modeFlags); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4954 | |
| 4955 | /** |
Dianne Hackborn | a47223f | 2017-03-30 13:49:13 -0700 | [diff] [blame] | 4956 | * Remove permissions to access a particular content provider Uri |
| 4957 | * that were previously added with {@link #grantUriPermission} for a specific target |
| 4958 | * package. The given Uri will match all previously granted Uris that are the same or a |
| 4959 | * sub-path of the given Uri. That is, revoking "content://foo/target" will |
| 4960 | * revoke both "content://foo/target" and "content://foo/target/sub", but not |
| 4961 | * "content://foo". It will not remove any prefix grants that exist at a |
| 4962 | * higher level. |
| 4963 | * |
| 4964 | * <p>Unlike {@link #revokeUriPermission(Uri, int)}, this method will <em>only</em> |
| 4965 | * revoke permissions that had been explicitly granted through {@link #grantUriPermission} |
| 4966 | * and only for the package specified. Any matching grants that have happened through |
| 4967 | * other mechanisms (clipboard, activity launching, service starting, etc) will not be |
| 4968 | * removed.</p> |
| 4969 | * |
| 4970 | * @param toPackage The package you had previously granted access to. |
| 4971 | * @param uri The Uri you would like to revoke access to. |
Jeff Sharkey | 6503bd8 | 2017-04-19 23:24:18 -0600 | [diff] [blame] | 4972 | * @param modeFlags The access modes to revoke. |
Dianne Hackborn | a47223f | 2017-03-30 13:49:13 -0700 | [diff] [blame] | 4973 | * |
| 4974 | * @see #grantUriPermission |
| 4975 | */ |
| 4976 | public abstract void revokeUriPermission(String toPackage, Uri uri, |
| 4977 | @Intent.AccessUriMode int modeFlags); |
| 4978 | |
| 4979 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4980 | * Determine whether a particular process and user ID has been granted |
| 4981 | * permission to access a specific URI. This only checks for permissions |
| 4982 | * that have been explicitly granted -- if the given process/uid has |
| 4983 | * more general access to the URI's content provider then this check will |
| 4984 | * always fail. |
| 4985 | * |
| 4986 | * @param uri The uri that is being checked. |
| 4987 | * @param pid The process ID being checked against. Must be > 0. |
| 4988 | * @param uid The user ID being checked against. A uid of 0 is the root |
| 4989 | * user, which will pass every permission check. |
Jeff Sharkey | 6503bd8 | 2017-04-19 23:24:18 -0600 | [diff] [blame] | 4990 | * @param modeFlags The access modes to check. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4991 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 4992 | * @return {@link PackageManager#PERMISSION_GRANTED} if the given |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4993 | * pid/uid is allowed to access that uri, or |
| 4994 | * {@link PackageManager#PERMISSION_DENIED} if it is not. |
| 4995 | * |
| 4996 | * @see #checkCallingUriPermission |
| 4997 | */ |
Tor Norbye | 1c2bf03 | 2015-03-02 10:57:08 -0800 | [diff] [blame] | 4998 | @CheckResult(suggest="#enforceUriPermission(Uri,int,int,String)") |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 4999 | @PackageManager.PermissionResult |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 5000 | public abstract int checkUriPermission(Uri uri, int pid, int uid, |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 5001 | @Intent.AccessUriMode int modeFlags); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5002 | |
Dianne Hackborn | ff17024 | 2014-11-19 10:59:01 -0800 | [diff] [blame] | 5003 | /** @hide */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 5004 | @PackageManager.PermissionResult |
Dianne Hackborn | ff17024 | 2014-11-19 10:59:01 -0800 | [diff] [blame] | 5005 | public abstract int checkUriPermission(Uri uri, int pid, int uid, |
| 5006 | @Intent.AccessUriMode int modeFlags, IBinder callerToken); |
| 5007 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5008 | /** |
| 5009 | * Determine whether the calling process and user ID has been |
| 5010 | * granted permission to access a specific URI. This is basically |
| 5011 | * the same as calling {@link #checkUriPermission(Uri, int, int, |
| 5012 | * int)} with the pid and uid returned by {@link |
| 5013 | * android.os.Binder#getCallingPid} and {@link |
| 5014 | * android.os.Binder#getCallingUid}. One important difference is |
| 5015 | * that if you are not currently processing an IPC, this function |
| 5016 | * will always fail. |
| 5017 | * |
| 5018 | * @param uri The uri that is being checked. |
Jeff Sharkey | 6503bd8 | 2017-04-19 23:24:18 -0600 | [diff] [blame] | 5019 | * @param modeFlags The access modes to check. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5020 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 5021 | * @return {@link PackageManager#PERMISSION_GRANTED} if the caller |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5022 | * is allowed to access that uri, or |
| 5023 | * {@link PackageManager#PERMISSION_DENIED} if it is not. |
| 5024 | * |
| 5025 | * @see #checkUriPermission(Uri, int, int, int) |
| 5026 | */ |
Tor Norbye | 1c2bf03 | 2015-03-02 10:57:08 -0800 | [diff] [blame] | 5027 | @CheckResult(suggest="#enforceCallingUriPermission(Uri,int,String)") |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 5028 | @PackageManager.PermissionResult |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 5029 | public abstract int checkCallingUriPermission(Uri uri, @Intent.AccessUriMode int modeFlags); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5030 | |
| 5031 | /** |
| 5032 | * Determine whether the calling process of an IPC <em>or you</em> has been granted |
| 5033 | * permission to access a specific URI. This is the same as |
| 5034 | * {@link #checkCallingUriPermission}, except it grants your own permissions |
| 5035 | * if you are not currently processing an IPC. Use with care! |
| 5036 | * |
| 5037 | * @param uri The uri that is being checked. |
Jeff Sharkey | 6503bd8 | 2017-04-19 23:24:18 -0600 | [diff] [blame] | 5038 | * @param modeFlags The access modes to check. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5039 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 5040 | * @return {@link PackageManager#PERMISSION_GRANTED} if the caller |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5041 | * is allowed to access that uri, or |
| 5042 | * {@link PackageManager#PERMISSION_DENIED} if it is not. |
| 5043 | * |
| 5044 | * @see #checkCallingUriPermission |
| 5045 | */ |
Tor Norbye | 1c2bf03 | 2015-03-02 10:57:08 -0800 | [diff] [blame] | 5046 | @CheckResult(suggest="#enforceCallingOrSelfUriPermission(Uri,int,String)") |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 5047 | @PackageManager.PermissionResult |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 5048 | public abstract int checkCallingOrSelfUriPermission(Uri uri, |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 5049 | @Intent.AccessUriMode int modeFlags); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5050 | |
| 5051 | /** |
| 5052 | * Check both a Uri and normal permission. This allows you to perform |
| 5053 | * both {@link #checkPermission} and {@link #checkUriPermission} in one |
| 5054 | * call. |
| 5055 | * |
| 5056 | * @param uri The Uri whose permission is to be checked, or null to not |
| 5057 | * do this check. |
| 5058 | * @param readPermission The permission that provides overall read access, |
| 5059 | * or null to not do this check. |
| 5060 | * @param writePermission The permission that provides overall write |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 5061 | * access, or null to not do this check. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5062 | * @param pid The process ID being checked against. Must be > 0. |
| 5063 | * @param uid The user ID being checked against. A uid of 0 is the root |
| 5064 | * user, which will pass every permission check. |
Jeff Sharkey | 6503bd8 | 2017-04-19 23:24:18 -0600 | [diff] [blame] | 5065 | * @param modeFlags The access modes to check. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5066 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 5067 | * @return {@link PackageManager#PERMISSION_GRANTED} if the caller |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5068 | * is allowed to access that uri or holds one of the given permissions, or |
| 5069 | * {@link PackageManager#PERMISSION_DENIED} if it is not. |
| 5070 | */ |
Tor Norbye | 1c2bf03 | 2015-03-02 10:57:08 -0800 | [diff] [blame] | 5071 | @CheckResult(suggest="#enforceUriPermission(Uri,String,String,int,int,int,String)") |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 5072 | @PackageManager.PermissionResult |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 5073 | public abstract int checkUriPermission(@Nullable Uri uri, @Nullable String readPermission, |
| 5074 | @Nullable String writePermission, int pid, int uid, |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 5075 | @Intent.AccessUriMode int modeFlags); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5076 | |
| 5077 | /** |
| 5078 | * If a particular process and user ID has not been granted |
| 5079 | * permission to access a specific URI, throw {@link |
| 5080 | * SecurityException}. This only checks for permissions that have |
| 5081 | * been explicitly granted -- if the given process/uid has more |
| 5082 | * general access to the URI's content provider then this check |
| 5083 | * will always fail. |
| 5084 | * |
| 5085 | * @param uri The uri that is being checked. |
| 5086 | * @param pid The process ID being checked against. Must be > 0. |
| 5087 | * @param uid The user ID being checked against. A uid of 0 is the root |
| 5088 | * user, which will pass every permission check. |
Jeff Sharkey | 6503bd8 | 2017-04-19 23:24:18 -0600 | [diff] [blame] | 5089 | * @param modeFlags The access modes to enforce. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5090 | * @param message A message to include in the exception if it is thrown. |
| 5091 | * |
| 5092 | * @see #checkUriPermission(Uri, int, int, int) |
| 5093 | */ |
| 5094 | public abstract void enforceUriPermission( |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 5095 | Uri uri, int pid, int uid, @Intent.AccessUriMode int modeFlags, String message); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5096 | |
| 5097 | /** |
| 5098 | * If the calling process and user ID has not been granted |
| 5099 | * permission to access a specific URI, throw {@link |
| 5100 | * SecurityException}. This is basically the same as calling |
| 5101 | * {@link #enforceUriPermission(Uri, int, int, int, String)} with |
| 5102 | * the pid and uid returned by {@link |
| 5103 | * android.os.Binder#getCallingPid} and {@link |
| 5104 | * android.os.Binder#getCallingUid}. One important difference is |
| 5105 | * that if you are not currently processing an IPC, this function |
| 5106 | * will always throw a SecurityException. |
| 5107 | * |
| 5108 | * @param uri The uri that is being checked. |
Jeff Sharkey | 6503bd8 | 2017-04-19 23:24:18 -0600 | [diff] [blame] | 5109 | * @param modeFlags The access modes to enforce. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5110 | * @param message A message to include in the exception if it is thrown. |
| 5111 | * |
| 5112 | * @see #checkCallingUriPermission(Uri, int) |
| 5113 | */ |
| 5114 | public abstract void enforceCallingUriPermission( |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 5115 | Uri uri, @Intent.AccessUriMode int modeFlags, String message); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5116 | |
| 5117 | /** |
| 5118 | * If the calling process of an IPC <em>or you</em> has not been |
| 5119 | * granted permission to access a specific URI, throw {@link |
| 5120 | * SecurityException}. This is the same as {@link |
| 5121 | * #enforceCallingUriPermission}, except it grants your own |
| 5122 | * permissions if you are not currently processing an IPC. Use |
| 5123 | * with care! |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 5124 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5125 | * @param uri The uri that is being checked. |
Jeff Sharkey | 6503bd8 | 2017-04-19 23:24:18 -0600 | [diff] [blame] | 5126 | * @param modeFlags The access modes to enforce. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5127 | * @param message A message to include in the exception if it is thrown. |
| 5128 | * |
| 5129 | * @see #checkCallingOrSelfUriPermission(Uri, int) |
| 5130 | */ |
| 5131 | public abstract void enforceCallingOrSelfUriPermission( |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 5132 | Uri uri, @Intent.AccessUriMode int modeFlags, String message); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5133 | |
| 5134 | /** |
| 5135 | * Enforce both a Uri and normal permission. This allows you to perform |
| 5136 | * both {@link #enforcePermission} and {@link #enforceUriPermission} in one |
| 5137 | * call. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 5138 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5139 | * @param uri The Uri whose permission is to be checked, or null to not |
| 5140 | * do this check. |
| 5141 | * @param readPermission The permission that provides overall read access, |
| 5142 | * or null to not do this check. |
| 5143 | * @param writePermission The permission that provides overall write |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 5144 | * access, or null to not do this check. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5145 | * @param pid The process ID being checked against. Must be > 0. |
| 5146 | * @param uid The user ID being checked against. A uid of 0 is the root |
| 5147 | * user, which will pass every permission check. |
Jeff Sharkey | 6503bd8 | 2017-04-19 23:24:18 -0600 | [diff] [blame] | 5148 | * @param modeFlags The access modes to enforce. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5149 | * @param message A message to include in the exception if it is thrown. |
| 5150 | * |
| 5151 | * @see #checkUriPermission(Uri, String, String, int, int, int) |
| 5152 | */ |
| 5153 | public abstract void enforceUriPermission( |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 5154 | @Nullable Uri uri, @Nullable String readPermission, |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 5155 | @Nullable String writePermission, int pid, int uid, @Intent.AccessUriMode int modeFlags, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 5156 | @Nullable String message); |
| 5157 | |
| 5158 | /** @hide */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 5159 | @IntDef(flag = true, prefix = { "CONTEXT_" }, value = { |
| 5160 | CONTEXT_INCLUDE_CODE, |
| 5161 | CONTEXT_IGNORE_SECURITY, |
| 5162 | CONTEXT_RESTRICTED, |
| 5163 | CONTEXT_DEVICE_PROTECTED_STORAGE, |
| 5164 | CONTEXT_CREDENTIAL_PROTECTED_STORAGE, |
| 5165 | CONTEXT_REGISTER_PACKAGE, |
| 5166 | }) |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 5167 | @Retention(RetentionPolicy.SOURCE) |
| 5168 | public @interface CreatePackageOptions {} |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5169 | |
| 5170 | /** |
| 5171 | * Flag for use with {@link #createPackageContext}: include the application |
| 5172 | * code with the context. This means loading code into the caller's |
| 5173 | * process, so that {@link #getClassLoader()} can be used to instantiate |
| 5174 | * the application's classes. Setting this flags imposes security |
| 5175 | * restrictions on what application context you can access; if the |
| 5176 | * requested application can not be safely loaded into your process, |
| 5177 | * java.lang.SecurityException will be thrown. If this flag is not set, |
| 5178 | * there will be no restrictions on the packages that can be loaded, |
| 5179 | * but {@link #getClassLoader} will always return the default system |
| 5180 | * class loader. |
| 5181 | */ |
| 5182 | public static final int CONTEXT_INCLUDE_CODE = 0x00000001; |
| 5183 | |
| 5184 | /** |
| 5185 | * Flag for use with {@link #createPackageContext}: ignore any security |
| 5186 | * restrictions on the Context being requested, allowing it to always |
| 5187 | * be loaded. For use with {@link #CONTEXT_INCLUDE_CODE} to allow code |
| 5188 | * to be loaded into a process even when it isn't safe to do so. Use |
| 5189 | * with extreme care! |
| 5190 | */ |
| 5191 | public static final int CONTEXT_IGNORE_SECURITY = 0x00000002; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 5192 | |
Romain Guy | 870e09f | 2009-07-06 16:35:25 -0700 | [diff] [blame] | 5193 | /** |
| 5194 | * Flag for use with {@link #createPackageContext}: a restricted context may |
| 5195 | * disable specific features. For instance, a View associated with a restricted |
| 5196 | * context would ignore particular XML attributes. |
| 5197 | */ |
| 5198 | public static final int CONTEXT_RESTRICTED = 0x00000004; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5199 | |
| 5200 | /** |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 5201 | * Flag for use with {@link #createPackageContext}: point all file APIs at |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 5202 | * device-protected storage. |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 5203 | * |
| 5204 | * @hide |
| 5205 | */ |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 5206 | public static final int CONTEXT_DEVICE_PROTECTED_STORAGE = 0x00000008; |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 5207 | |
| 5208 | /** |
| 5209 | * Flag for use with {@link #createPackageContext}: point all file APIs at |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 5210 | * credential-protected storage. |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 5211 | * |
| 5212 | * @hide |
| 5213 | */ |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 5214 | public static final int CONTEXT_CREDENTIAL_PROTECTED_STORAGE = 0x00000010; |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 5215 | |
| 5216 | /** |
Dianne Hackborn | fee756f | 2014-07-16 17:31:10 -0700 | [diff] [blame] | 5217 | * @hide Used to indicate we should tell the activity manager about the process |
| 5218 | * loading this code. |
| 5219 | */ |
| 5220 | public static final int CONTEXT_REGISTER_PACKAGE = 0x40000000; |
| 5221 | |
| 5222 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5223 | * Return a new Context object for the given application name. This |
| 5224 | * Context is the same as what the named application gets when it is |
| 5225 | * launched, containing the same resources and class loader. Each call to |
| 5226 | * this method returns a new instance of a Context object; Context objects |
| 5227 | * are not shared, however they share common state (Resources, ClassLoader, |
| 5228 | * etc) so the Context instance itself is fairly lightweight. |
| 5229 | * |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 5230 | * <p>Throws {@link android.content.pm.PackageManager.NameNotFoundException} if there is no |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5231 | * application with the given package name. |
| 5232 | * |
| 5233 | * <p>Throws {@link java.lang.SecurityException} if the Context requested |
| 5234 | * can not be loaded into the caller's process for security reasons (see |
| 5235 | * {@link #CONTEXT_INCLUDE_CODE} for more information}. |
| 5236 | * |
| 5237 | * @param packageName Name of the application's package. |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 5238 | * @param flags Option flags. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5239 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 5240 | * @return A {@link Context} for the application. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5241 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 5242 | * @throws SecurityException |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5243 | * @throws PackageManager.NameNotFoundException if there is no application with |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 5244 | * the given package name. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5245 | */ |
| 5246 | public abstract Context createPackageContext(String packageName, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 5247 | @CreatePackageOptions int flags) throws PackageManager.NameNotFoundException; |
Romain Guy | 870e09f | 2009-07-06 16:35:25 -0700 | [diff] [blame] | 5248 | |
| 5249 | /** |
Jeff Sharkey | 6d51571 | 2012-09-20 16:06:08 -0700 | [diff] [blame] | 5250 | * Similar to {@link #createPackageContext(String, int)}, but with a |
| 5251 | * different {@link UserHandle}. For example, {@link #getContentResolver()} |
| 5252 | * will open any {@link Uri} as the given user. |
| 5253 | * |
| 5254 | * @hide |
| 5255 | */ |
Patrick Baumann | ef4c407 | 2018-02-01 08:54:05 -0800 | [diff] [blame] | 5256 | @SystemApi |
Jeff Sharkey | ec5f7d1 | 2018-08-08 09:15:04 -0600 | [diff] [blame] | 5257 | @TestApi |
Patrick Baumann | ef4c407 | 2018-02-01 08:54:05 -0800 | [diff] [blame] | 5258 | public Context createPackageContextAsUser( |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 5259 | String packageName, @CreatePackageOptions int flags, UserHandle user) |
Patrick Baumann | ef4c407 | 2018-02-01 08:54:05 -0800 | [diff] [blame] | 5260 | throws PackageManager.NameNotFoundException { |
| 5261 | if (Build.IS_ENG) { |
| 5262 | throw new IllegalStateException("createPackageContextAsUser not overridden!"); |
| 5263 | } |
| 5264 | return this; |
| 5265 | } |
Jeff Sharkey | 6d51571 | 2012-09-20 16:06:08 -0700 | [diff] [blame] | 5266 | |
| 5267 | /** |
Svetoslav | 976e8bd | 2014-07-16 15:12:03 -0700 | [diff] [blame] | 5268 | * Creates a context given an {@link android.content.pm.ApplicationInfo}. |
| 5269 | * |
| 5270 | * @hide |
| 5271 | */ |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 5272 | @UnsupportedAppUsage |
Svetoslav | 976e8bd | 2014-07-16 15:12:03 -0700 | [diff] [blame] | 5273 | public abstract Context createApplicationContext(ApplicationInfo application, |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 5274 | @CreatePackageOptions int flags) throws PackageManager.NameNotFoundException; |
Svetoslav | 976e8bd | 2014-07-16 15:12:03 -0700 | [diff] [blame] | 5275 | |
| 5276 | /** |
Adam Lesinski | 4e86281 | 2016-11-21 16:02:24 -0800 | [diff] [blame] | 5277 | * Return a new Context object for the given split name. The new Context has a ClassLoader and |
| 5278 | * Resources object that can access the split's and all of its dependencies' code/resources. |
| 5279 | * Each call to this method returns a new instance of a Context object; |
| 5280 | * Context objects are not shared, however common state (ClassLoader, other Resources for |
| 5281 | * the same split) may be so the Context itself can be fairly lightweight. |
| 5282 | * |
| 5283 | * @param splitName The name of the split to include, as declared in the split's |
| 5284 | * <code>AndroidManifest.xml</code>. |
| 5285 | * @return A {@link Context} with the given split's code and/or resources loaded. |
| 5286 | */ |
| 5287 | public abstract Context createContextForSplit(String splitName) |
| 5288 | throws PackageManager.NameNotFoundException; |
| 5289 | |
| 5290 | /** |
Jeff Sharkey | ad357d1 | 2018-02-02 13:25:31 -0700 | [diff] [blame] | 5291 | * Get the user associated with this context |
Jim Miller | a75a883 | 2013-02-07 16:53:32 -0800 | [diff] [blame] | 5292 | * @hide |
| 5293 | */ |
Jeff Sharkey | a73b8fd | 2016-01-06 17:02:08 -0700 | [diff] [blame] | 5294 | @TestApi |
Jeff Sharkey | ad357d1 | 2018-02-02 13:25:31 -0700 | [diff] [blame] | 5295 | public UserHandle getUser() { |
| 5296 | return android.os.Process.myUserHandle(); |
| 5297 | } |
| 5298 | |
| 5299 | /** |
| 5300 | * Get the user associated with this context |
| 5301 | * @hide |
| 5302 | */ |
Artur Satayev | 5a52585 | 2019-10-31 15:15:50 +0000 | [diff] [blame^] | 5303 | @UnsupportedAppUsage |
Jeff Sharkey | ad357d1 | 2018-02-02 13:25:31 -0700 | [diff] [blame] | 5304 | @TestApi |
| 5305 | public @UserIdInt int getUserId() { |
| 5306 | return android.os.UserHandle.myUserId(); |
| 5307 | } |
Jim Miller | a75a883 | 2013-02-07 16:53:32 -0800 | [diff] [blame] | 5308 | |
| 5309 | /** |
Dianne Hackborn | 756220b | 2012-08-14 16:45:30 -0700 | [diff] [blame] | 5310 | * Return a new Context object for the current Context but whose resources |
| 5311 | * are adjusted to match the given Configuration. Each call to this method |
Jeff Brown | a492c3a | 2012-08-23 19:48:44 -0700 | [diff] [blame] | 5312 | * returns a new instance of a Context object; Context objects are not |
Dianne Hackborn | 756220b | 2012-08-14 16:45:30 -0700 | [diff] [blame] | 5313 | * shared, however common state (ClassLoader, other Resources for the |
| 5314 | * same configuration) may be so the Context itself can be fairly lightweight. |
| 5315 | * |
| 5316 | * @param overrideConfiguration A {@link Configuration} specifying what |
| 5317 | * values to modify in the base Configuration of the original Context's |
| 5318 | * resources. If the base configuration changes (such as due to an |
| 5319 | * orientation change), the resources of this context will also change except |
| 5320 | * for those that have been explicitly overridden with a value here. |
| 5321 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 5322 | * @return A {@link Context} with the given configuration override. |
Dianne Hackborn | 756220b | 2012-08-14 16:45:30 -0700 | [diff] [blame] | 5323 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 5324 | public abstract Context createConfigurationContext( |
| 5325 | @NonNull Configuration overrideConfiguration); |
Dianne Hackborn | 756220b | 2012-08-14 16:45:30 -0700 | [diff] [blame] | 5326 | |
| 5327 | /** |
Jeff Brown | a492c3a | 2012-08-23 19:48:44 -0700 | [diff] [blame] | 5328 | * Return a new Context object for the current Context but whose resources |
| 5329 | * are adjusted to match the metrics of the given Display. Each call to this method |
| 5330 | * returns a new instance of a Context object; Context objects are not |
| 5331 | * shared, however common state (ClassLoader, other Resources for the |
| 5332 | * same configuration) may be so the Context itself can be fairly lightweight. |
| 5333 | * |
| 5334 | * The returned display Context provides a {@link WindowManager} |
| 5335 | * (see {@link #getSystemService(String)}) that is configured to show windows |
| 5336 | * on the given display. The WindowManager's {@link WindowManager#getDefaultDisplay} |
| 5337 | * method can be used to retrieve the Display from the returned Context. |
| 5338 | * |
| 5339 | * @param display A {@link Display} object specifying the display |
| 5340 | * for whose metrics the Context's resources should be tailored and upon which |
| 5341 | * new windows should be shown. |
| 5342 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 5343 | * @return A {@link Context} for the display. |
Jeff Brown | a492c3a | 2012-08-23 19:48:44 -0700 | [diff] [blame] | 5344 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 5345 | public abstract Context createDisplayContext(@NonNull Display display); |
Jeff Brown | a492c3a | 2012-08-23 19:48:44 -0700 | [diff] [blame] | 5346 | |
| 5347 | /** |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 5348 | * Return a new Context object for the current Context but whose storage |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 5349 | * APIs are backed by device-protected storage. |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 5350 | * <p> |
Jeff Sharkey | cf3f0a1 | 2016-03-17 19:57:58 -0600 | [diff] [blame] | 5351 | * On devices with direct boot, data stored in this location is encrypted |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 5352 | * with a key tied to the physical device, and it can be accessed |
| 5353 | * immediately after the device has booted successfully, both |
| 5354 | * <em>before and after</em> the user has authenticated with their |
| 5355 | * credentials (such as a lock pattern or PIN). |
| 5356 | * <p> |
| 5357 | * Because device-protected data is available without user authentication, |
| 5358 | * you should carefully limit the data you store using this Context. For |
| 5359 | * example, storing sensitive authentication tokens or passwords in the |
| 5360 | * device-protected area is strongly discouraged. |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 5361 | * <p> |
Jeff Sharkey | 3ea44a5 | 2016-01-09 15:19:56 -0700 | [diff] [blame] | 5362 | * If the underlying device does not have the ability to store |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 5363 | * device-protected and credential-protected data using different keys, then |
| 5364 | * both storage areas will become available at the same time. They remain as |
| 5365 | * two distinct storage locations on disk, and only the window of |
| 5366 | * availability changes. |
Jeff Sharkey | 3ea44a5 | 2016-01-09 15:19:56 -0700 | [diff] [blame] | 5367 | * <p> |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 5368 | * Each call to this method returns a new instance of a Context object; |
| 5369 | * Context objects are not shared, however common state (ClassLoader, other |
| 5370 | * Resources for the same configuration) may be so the Context itself can be |
| 5371 | * fairly lightweight. |
| 5372 | * |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 5373 | * @see #isDeviceProtectedStorage() |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 5374 | */ |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 5375 | public abstract Context createDeviceProtectedStorageContext(); |
| 5376 | |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 5377 | /** |
| 5378 | * Return a new Context object for the current Context but whose storage |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 5379 | * APIs are backed by credential-protected storage. This is the default |
| 5380 | * storage area for apps unless |
| 5381 | * {@link android.R.attr#defaultToDeviceProtectedStorage} was requested. |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 5382 | * <p> |
Jeff Sharkey | cf3f0a1 | 2016-03-17 19:57:58 -0600 | [diff] [blame] | 5383 | * On devices with direct boot, data stored in this location is encrypted |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 5384 | * with a key tied to user credentials, which can be accessed |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 5385 | * <em>only after</em> the user has entered their credentials (such as a |
| 5386 | * lock pattern or PIN). |
| 5387 | * <p> |
Jeff Sharkey | 3ea44a5 | 2016-01-09 15:19:56 -0700 | [diff] [blame] | 5388 | * If the underlying device does not have the ability to store |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 5389 | * device-protected and credential-protected data using different keys, then |
| 5390 | * both storage areas will become available at the same time. They remain as |
| 5391 | * two distinct storage locations on disk, and only the window of |
| 5392 | * availability changes. |
Jeff Sharkey | 3ea44a5 | 2016-01-09 15:19:56 -0700 | [diff] [blame] | 5393 | * <p> |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 5394 | * Each call to this method returns a new instance of a Context object; |
| 5395 | * Context objects are not shared, however common state (ClassLoader, other |
| 5396 | * Resources for the same configuration) may be so the Context itself can be |
| 5397 | * fairly lightweight. |
| 5398 | * |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 5399 | * @see #isCredentialProtectedStorage() |
Jeff Sharkey | e13529a | 2015-12-09 14:15:27 -0700 | [diff] [blame] | 5400 | * @hide |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 5401 | */ |
Jeff Sharkey | e13529a | 2015-12-09 14:15:27 -0700 | [diff] [blame] | 5402 | @SystemApi |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 5403 | public abstract Context createCredentialProtectedStorageContext(); |
| 5404 | |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 5405 | /** |
Craig Mautner | 48d0d18 | 2013-06-11 07:53:06 -0700 | [diff] [blame] | 5406 | * Gets the display adjustments holder for this context. This information |
| 5407 | * is provided on a per-application or activity basis and is used to simulate lower density |
| 5408 | * display metrics for legacy applications and restricted screen sizes. |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 5409 | * |
Jeff Brown | a492c3a | 2012-08-23 19:48:44 -0700 | [diff] [blame] | 5410 | * @param displayId The display id for which to get compatibility info. |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 5411 | * @return The compatibility info holder, or null if not required by the application. |
| 5412 | * @hide |
| 5413 | */ |
Craig Mautner | 48d0d18 | 2013-06-11 07:53:06 -0700 | [diff] [blame] | 5414 | public abstract DisplayAdjustments getDisplayAdjustments(int displayId); |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 5415 | |
| 5416 | /** |
Wale Ogunwale | 691af68 | 2019-02-11 03:09:10 -0800 | [diff] [blame] | 5417 | * @return Returns the {@link Display} object this context is associated with. |
Adam Lesinski | 4ece3d6 | 2016-06-16 18:05:41 -0700 | [diff] [blame] | 5418 | * @hide |
| 5419 | */ |
Artur Satayev | 5a52585 | 2019-10-31 15:15:50 +0000 | [diff] [blame^] | 5420 | @UnsupportedAppUsage |
Wale Ogunwale | 691af68 | 2019-02-11 03:09:10 -0800 | [diff] [blame] | 5421 | @TestApi |
Adam Lesinski | 4ece3d6 | 2016-06-16 18:05:41 -0700 | [diff] [blame] | 5422 | public abstract Display getDisplay(); |
| 5423 | |
| 5424 | /** |
Yohei Yukawa | 5281b6b | 2018-10-15 07:38:25 +0800 | [diff] [blame] | 5425 | * Gets the display ID. |
| 5426 | * |
| 5427 | * @return display ID associated with this {@link Context}. |
| 5428 | * @hide |
| 5429 | */ |
wilsonshih | 5db7b39 | 2019-02-20 23:08:45 +0800 | [diff] [blame] | 5430 | @TestApi |
Yohei Yukawa | 5281b6b | 2018-10-15 07:38:25 +0800 | [diff] [blame] | 5431 | public abstract int getDisplayId(); |
| 5432 | |
| 5433 | /** |
Andrii Kulian | b047b8b | 2017-02-08 18:38:26 -0800 | [diff] [blame] | 5434 | * @hide |
| 5435 | */ |
| 5436 | public abstract void updateDisplay(int displayId); |
| 5437 | |
| 5438 | /** |
Romain Guy | 870e09f | 2009-07-06 16:35:25 -0700 | [diff] [blame] | 5439 | * Indicates whether this Context is restricted. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 5440 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 5441 | * @return {@code true} if this Context is restricted, {@code false} otherwise. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 5442 | * |
Romain Guy | 870e09f | 2009-07-06 16:35:25 -0700 | [diff] [blame] | 5443 | * @see #CONTEXT_RESTRICTED |
| 5444 | */ |
| 5445 | public boolean isRestricted() { |
| 5446 | return false; |
| 5447 | } |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 5448 | |
| 5449 | /** |
| 5450 | * Indicates if the storage APIs of this Context are backed by |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 5451 | * device-protected storage. |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 5452 | * |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 5453 | * @see #createDeviceProtectedStorageContext() |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 5454 | */ |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 5455 | public abstract boolean isDeviceProtectedStorage(); |
| 5456 | |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 5457 | /** |
| 5458 | * Indicates if the storage APIs of this Context are backed by |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 5459 | * credential-protected storage. |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 5460 | * |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 5461 | * @see #createCredentialProtectedStorageContext() |
Jeff Sharkey | e13529a | 2015-12-09 14:15:27 -0700 | [diff] [blame] | 5462 | * @hide |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 5463 | */ |
Jeff Sharkey | e13529a | 2015-12-09 14:15:27 -0700 | [diff] [blame] | 5464 | @SystemApi |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 5465 | public abstract boolean isCredentialProtectedStorage(); |
| 5466 | |
Tony Mak | 46aabe5 | 2016-11-14 12:53:06 +0000 | [diff] [blame] | 5467 | /** |
Seigo Nonaka | 6d6cd68 | 2017-06-22 08:22:18 -0700 | [diff] [blame] | 5468 | * Returns true if the context can load unsafe resources, e.g. fonts. |
| 5469 | * @hide |
| 5470 | */ |
| 5471 | public abstract boolean canLoadUnsafeResources(); |
| 5472 | |
| 5473 | /** |
Tony Mak | 46aabe5 | 2016-11-14 12:53:06 +0000 | [diff] [blame] | 5474 | * @hide |
| 5475 | */ |
| 5476 | public IBinder getActivityToken() { |
| 5477 | throw new RuntimeException("Not implemented. Must override in a subclass."); |
| 5478 | } |
| 5479 | |
| 5480 | /** |
| 5481 | * @hide |
| 5482 | */ |
| 5483 | @Nullable |
| 5484 | public IServiceConnection getServiceDispatcher(ServiceConnection conn, Handler handler, |
| 5485 | int flags) { |
| 5486 | throw new RuntimeException("Not implemented. Must override in a subclass."); |
| 5487 | } |
| 5488 | |
| 5489 | /** |
| 5490 | * @hide |
| 5491 | */ |
| 5492 | public IApplicationThread getIApplicationThread() { |
| 5493 | throw new RuntimeException("Not implemented. Must override in a subclass."); |
| 5494 | } |
Tony Mak | bf9928d | 2016-12-22 11:02:45 +0000 | [diff] [blame] | 5495 | |
| 5496 | /** |
| 5497 | * @hide |
| 5498 | */ |
| 5499 | public Handler getMainThreadHandler() { |
| 5500 | throw new RuntimeException("Not implemented. Must override in a subclass."); |
| 5501 | } |
Adam Lesinski | a82b626 | 2017-03-21 16:56:17 -0700 | [diff] [blame] | 5502 | |
| 5503 | /** |
Felipe Leme | bb567ae | 2017-10-04 09:56:21 -0700 | [diff] [blame] | 5504 | * @hide |
| 5505 | */ |
| 5506 | public AutofillClient getAutofillClient() { |
| 5507 | return null; |
| 5508 | } |
| 5509 | |
| 5510 | /** |
| 5511 | * @hide |
| 5512 | */ |
Svet Ganov | 47b37aa | 2018-02-16 00:11:39 -0800 | [diff] [blame] | 5513 | public void setAutofillClient(@SuppressWarnings("unused") AutofillClient client) { |
Felipe Leme | bb567ae | 2017-10-04 09:56:21 -0700 | [diff] [blame] | 5514 | } |
| 5515 | |
| 5516 | /** |
Svetoslav Ganov | 24c9045 | 2017-12-27 15:17:14 -0800 | [diff] [blame] | 5517 | * @hide |
| 5518 | */ |
Felipe Leme | cbf7f26 | 2019-04-17 13:57:59 -0700 | [diff] [blame] | 5519 | @Nullable |
| 5520 | public ContentCaptureClient getContentCaptureClient() { |
| 5521 | return null; |
| 5522 | } |
| 5523 | |
| 5524 | /** |
| 5525 | * @hide |
| 5526 | */ |
Felipe Leme | a4f39cd | 2019-02-19 15:08:59 -0800 | [diff] [blame] | 5527 | public final boolean isAutofillCompatibilityEnabled() { |
| 5528 | final AutofillOptions options = getAutofillOptions(); |
| 5529 | return options != null && options.compatModeEnabled; |
| 5530 | } |
| 5531 | |
| 5532 | /** |
| 5533 | * @hide |
| 5534 | */ |
| 5535 | @Nullable |
| 5536 | public AutofillOptions getAutofillOptions() { |
| 5537 | return null; |
Svetoslav Ganov | 24c9045 | 2017-12-27 15:17:14 -0800 | [diff] [blame] | 5538 | } |
| 5539 | |
| 5540 | /** |
| 5541 | * @hide |
| 5542 | */ |
Svet Ganov | 47b37aa | 2018-02-16 00:11:39 -0800 | [diff] [blame] | 5543 | @TestApi |
Felipe Leme | a4f39cd | 2019-02-19 15:08:59 -0800 | [diff] [blame] | 5544 | public void setAutofillOptions(@SuppressWarnings("unused") @Nullable AutofillOptions options) { |
Svetoslav Ganov | 24c9045 | 2017-12-27 15:17:14 -0800 | [diff] [blame] | 5545 | } |
| 5546 | |
| 5547 | /** |
Felipe Leme | 326f15a | 2019-02-19 09:42:24 -0800 | [diff] [blame] | 5548 | * Gets the Content Capture options for this context, or {@code null} if it's not whitelisted. |
Felipe Leme | ecb08be | 2018-11-27 15:48:47 -0800 | [diff] [blame] | 5549 | * |
| 5550 | * @hide |
| 5551 | */ |
Felipe Leme | 326f15a | 2019-02-19 09:42:24 -0800 | [diff] [blame] | 5552 | @Nullable |
| 5553 | public ContentCaptureOptions getContentCaptureOptions() { |
| 5554 | return null; |
Felipe Leme | ecb08be | 2018-11-27 15:48:47 -0800 | [diff] [blame] | 5555 | } |
| 5556 | |
| 5557 | /** |
| 5558 | * @hide |
| 5559 | */ |
Felipe Leme | 326f15a | 2019-02-19 09:42:24 -0800 | [diff] [blame] | 5560 | @TestApi |
| 5561 | public void setContentCaptureOptions( |
| 5562 | @SuppressWarnings("unused") @Nullable ContentCaptureOptions options) { |
Felipe Leme | ecb08be | 2018-11-27 15:48:47 -0800 | [diff] [blame] | 5563 | } |
| 5564 | |
| 5565 | /** |
Adam Lesinski | a82b626 | 2017-03-21 16:56:17 -0700 | [diff] [blame] | 5566 | * Throws an exception if the Context is using system resources, |
| 5567 | * which are non-runtime-overlay-themable and may show inconsistent UI. |
| 5568 | * @hide |
| 5569 | */ |
| 5570 | public void assertRuntimeOverlayThemable() { |
| 5571 | // Resources.getSystem() is a singleton and the only Resources not managed by |
| 5572 | // ResourcesManager; therefore Resources.getSystem() is not themable. |
| 5573 | if (getResources() == Resources.getSystem()) { |
| 5574 | throw new IllegalArgumentException("Non-UI context used to display UI; " |
| 5575 | + "get a UI context from ActivityThread#getSystemUiContext()"); |
| 5576 | } |
| 5577 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5578 | } |